Преглед на файлове

Feat: Add a new parameter to control crop length

dk преди 8 месеца
родител
ревизия
5d069724c0
променени са 1 файла, в които са добавени 4 реда и са изтрити 2 реда
  1. 4 2
      backend/dataloaders/neo.py

+ 4 - 2
backend/dataloaders/neo.py

@@ -77,10 +77,12 @@ def reref(raw, method='average'):
         raise ValueError(f'Rereference method unacceptable, got {str(method)}, expect "monopolar" or "average" or "bipolar"')
 
 
-def preprocessing(raw, reref_method='monopolar'):
+def preprocessing(raw, reref_method='monopolar', keeptimes=None):
     # cut by the first and last annotations
     annotation_onset, annotation_offset = raw.annotations.onset[0], raw.annotations.onset[-1]
-    tmin, tmax = max(annotation_onset - 5., raw.times[0]), min(annotation_offset + 5, raw.times[-1])
+    if keeptimes is None:
+        keeptimes = 10.
+    tmin, tmax = max(annotation_onset - keeptimes, raw.times[0]), min(annotation_offset + keeptimes, raw.times[-1])
     # rebuilt the raw
     # MNE的crop函数会导致annotation错乱,只能重建raw object
     new_annotations = mne.Annotations(onset=raw.annotations.onset - tmin,