Skip to content

Commit ac9d769

Browse files
Merge pull request #1213 from alejoe91/oe-legacy-ts-fix
Add `ignore_timestamps_errors` argument to OpenEphysRawIO
2 parents 3bf53cc + a1ab9ec commit ac9d769

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

neo/rawio/openephysrawio.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ class OpenEphysRawIO(BaseRawIO):
6868
extensions = ['continuous', 'openephys', 'spikes', 'events', 'xml']
6969
rawmode = 'one-dir'
7070

71-
def __init__(self, dirname=''):
71+
def __init__(self, dirname='', ignore_timestamps_errors=False):
7272
BaseRawIO.__init__(self)
7373
self.dirname = dirname
74+
self._ignore_timestamps_errors = ignore_timestamps_errors
7475

7576
def _source_name(self):
7677
return self.dirname
@@ -115,9 +116,11 @@ def _parse_header(self):
115116

116117
# check for continuity (no gaps)
117118
diff = np.diff(data_chan['timestamp'])
118-
assert np.all(diff == RECORD_SIZE), \
119-
'Not continuous timestamps for {}. ' \
120-
'Maybe because recording was paused/stopped.'.format(continuous_filename)
119+
if not np.all(diff == RECORD_SIZE) and not self._ignore_timestamps_errors:
120+
raise ValueError(
121+
'Not continuous timestamps for {}. ' \
122+
'Maybe because recording was paused/stopped.'.format(continuous_filename)
123+
)
121124

122125
if seg_index == 0:
123126
# add in channel list

neo/test/rawiotest/test_openephysrawio.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ def test_raise_error_if_discontinuous_files(self):
2020
# It must raise an error
2121
reader = OpenEphysRawIO(dirname=self.get_local_path(
2222
'openephys/OpenEphys_SampleData_2_(multiple_starts)'))
23-
with self.assertRaises(Exception):
23+
with self.assertRaises(ValueError):
2424
reader.parse_header()
25+
# if ignore_timestamps_errors=True, no exception is raised
26+
reader = OpenEphysRawIO(dirname=self.get_local_path(
27+
'openephys/OpenEphys_SampleData_2_(multiple_starts)'),
28+
ignore_timestamps_errors=True)
29+
reader.parse_header()
30+
2531

2632
def test_raise_error_if_strange_timestamps(self):
2733
# In this dataset CH32 have strange timestamps

0 commit comments

Comments
 (0)