Skip to content

Commit a3385b4

Browse files
committed
make mark_calibration_bad robust to duplicated calibration triggers, more agnostic to non-numeric calibration IDs
1 parent be1d361 commit a3385b4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

mne_bids_pipeline/steps/preprocessing/_05b_sync_eyelink.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ def _mark_calibration_as_bad(raw):
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(".* Recalibration (start|end) \\| (.*)", 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,11 @@ 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 - skipping"))
5456
elif calib_status == "start" and cur_idx is not None:
5557
raise ValueError(f"Annotation {annot["description"]} could not be assigned membership")
58+
last_status = calib_status
5659

5760
return raw
5861

0 commit comments

Comments
 (0)