@@ -824,7 +824,7 @@ def shift_time_events(events, ids, tshift, sfreq):
824
824
825
825
826
826
def make_fixed_length_events (raw , id = 1 , start = 0 , stop = None , duration = 1. ,
827
- first_samp = True ):
827
+ first_samp = True , overlap = 0. ):
828
828
"""Make a set of events separated by a fixed duration.
829
829
830
830
Parameters
@@ -846,6 +846,10 @@ def make_fixed_length_events(raw, id=1, start=0, stop=None, duration=1.,
846
846
returned events will be combined with event times that already
847
847
have ``raw.first_samp`` added to them, e.g. event times that come
848
848
from :func:`mne.find_events`.
849
+ overlap : float
850
+ The overlap between events. Must be ``0 <= overlap < duration``.
851
+
852
+ .. versionadded:: 0.18
849
853
850
854
Returns
851
855
-------
@@ -856,6 +860,11 @@ def make_fixed_length_events(raw, id=1, start=0, stop=None, duration=1.,
856
860
_validate_type (raw , BaseRaw , "raw" )
857
861
_validate_type (id , int , "id" )
858
862
_validate_type (duration , "numeric" , "duration" )
863
+ _validate_type (overlap , "numeric" , "overlap" )
864
+ duration , overlap = float (duration ), float (overlap )
865
+ if not 0 <= overlap < duration :
866
+ raise ValueError ('overlap must be >=0 but < duration (%s), got %s'
867
+ % (duration , overlap ))
859
868
860
869
start = raw .time_as_index (start , use_rounding = True )[0 ]
861
870
if stop is not None :
@@ -870,7 +879,8 @@ def make_fixed_length_events(raw, id=1, start=0, stop=None, duration=1.,
870
879
# Make sure we don't go out the end of the file:
871
880
stop -= int (np .round (raw .info ['sfreq' ] * duration ))
872
881
# This should be inclusive due to how we generally use start and stop...
873
- ts = np .arange (start , stop + 1 , raw .info ['sfreq' ] * duration ).astype (int )
882
+ ts = np .arange (start , stop + 1 ,
883
+ raw .info ['sfreq' ] * (duration - overlap )).astype (int )
874
884
n_events = len (ts )
875
885
if n_events == 0 :
876
886
raise ValueError ('No events produced, check the values of start, '
0 commit comments