@@ -35,14 +35,14 @@ def _check_HEOG_ET_vars(cfg):
3535
3636 return heog_ch , et_ch , bipolar
3737
38- def _mark_calibration_as_bad (raw ):
38+ def _mark_calibration_as_bad (raw , cfg ):
3939 # marks recalibration beginnings and ends as one bad segment
4040 cur_idx = None
4141 cur_start_time = 0.
42+ last_status = None
4243 for annot in raw .annotations :
43- calib_match = re .match (".* Recalibration (start|end) \\ | ( \\ d*)" , annot ["description" ])
44+ calib_match = re .match (cfg . sync_calibration_string , annot ["description" ])
4445 if not calib_match : continue
45-
4646 calib_status , calib_idx = calib_match .group (1 ), calib_match .group (2 )
4747 if calib_idx == cur_idx and calib_status == "end" :
4848 duration = annot ["onset" ] - cur_start_time
@@ -51,8 +51,12 @@ def _mark_calibration_as_bad(raw):
5151 elif calib_status == "start" and cur_idx is None :
5252 cur_idx = calib_idx
5353 cur_start_time = annot ["onset" ]
54+ elif calib_status == last_status :
55+ logger .info (** gen_log_kwargs (message = f"Encountered apparent duplicate calibration event ({ calib_status } , { calib_idx } ) - skipping" ))
5456 elif calib_status == "start" and cur_idx is not None :
55- raise ValueError (f"Annotation { annot ["description" ]} could not be assigned membership" )
57+ raise ValueError (f"Annotation { annot ["description" ]} could not be assigned membership"
58+ f"" )
59+ last_status = calib_status
5660
5761 return raw
5862
@@ -246,7 +250,7 @@ def sync_eyelink(
246250 # create bipolar HEOG
247251 raw = mne .set_bipolar_reference (raw , * cfg .sync_heog_ch , ch_name = heog_ch , drop_refs = False )
248252 raw .filter (l_freq = cfg .sync_heog_highpass , h_freq = cfg .sync_heog_lowpass , picks = heog_ch ) # get rid of drift and high freq noise
249- _mark_calibration_as_bad (raw )
253+ _mark_calibration_as_bad (raw , cfg )
250254 # extract HEOG and ET as arrays
251255 heog_array = raw .get_data (picks = [heog_ch ], reject_by_annotation = "omit" )
252256 et_array = raw .get_data (picks = et_ch , reject_by_annotation = "omit" )
@@ -344,6 +348,7 @@ def get_config(
344348 sync_heog_highpass = config .sync_heog_highpass ,
345349 sync_heog_lowpass = config .sync_heog_lowpass ,
346350 sync_plot_samps = config .sync_plot_samps ,
351+ sync_calibration_string = config .sync_calibration_string ,
347352 processing = "filt" if config .regress_artifact is None else "regress" ,
348353 _raw_split_size = config ._raw_split_size ,
349354
0 commit comments