@@ -2742,8 +2742,9 @@ def mrgann(ann_file1, ann_file2, out_file_name='merged_ann.atr',
27422742 'combine' which simply combines the two files along every attribute;
27432743 duplicates will be preserved. The other options are 'replace1' which
27442744 replaces attributes of the first annotation file with attributes of
2745- the second for the desired time range and 'replace2' which does the
2746- same thing except switched (first file replaces second).
2745+ the second for the desired time range, 'replace2' which does the
2746+ same thing except switched (first file replaces second), and 'delete'
2747+ which deletes all of the annotations in the desired time range.
27472748 chan1 : int, optional
27482749 Sets the value of `chan` for the first annotation file. The default is
27492750 -1 which means to keep it the same.
@@ -2851,7 +2852,7 @@ def mrgann(ann_file1, ann_file2, out_file_name='merged_ann.atr',
28512852 if verbose :
28522853 print (f'Start sample: { start_sample } , end sample: { end_sample } ' )
28532854
2854- if merge_method == 'combine' :
2855+ if ( merge_method == 'combine' ) or ( merge_method == 'delete' ) :
28552856 if verbose :
28562857 print ('Combining the two files together' )
28572858 # The sample should never be empty but others can (though they
@@ -2861,8 +2862,12 @@ def mrgann(ann_file1, ann_file2, out_file_name='merged_ann.atr',
28612862 sort_indices = np .argsort (both_sample )
28622863 both_sample = np .sort (both_sample )
28632864 # Find where to filter the array
2864- sample_range = ((both_sample >= start_sample ) &
2865- (both_sample <= end_sample ))
2865+ if merge_method == 'combine' :
2866+ sample_range = ((both_sample >= start_sample ) &
2867+ (both_sample <= end_sample ))
2868+ if merge_method == 'delete' :
2869+ sample_range = ((both_sample < start_sample ) |
2870+ (both_sample > end_sample ))
28662871 index_range = np .where (sample_range )[0 ]
28672872 both_sample = both_sample [sample_range ]
28682873 # Combine both annotation attributes
0 commit comments