Skip to content

Commit 207e1e8

Browse files
committed
Add ignore_timestamps_errors flag
1 parent ae7cee1 commit 207e1e8

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

neo/rawio/openephysrawio.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import os
1212
import re
13-
import warnings
1413

1514
import numpy as np
1615

@@ -69,9 +68,10 @@ class OpenEphysRawIO(BaseRawIO):
6968
extensions = ['continuous', 'openephys', 'spikes', 'events', 'xml']
7069
rawmode = 'one-dir'
7170

72-
def __init__(self, dirname=''):
71+
def __init__(self, dirname='', ignore_timestamps_errors=False):
7372
BaseRawIO.__init__(self)
7473
self.dirname = dirname
74+
self._ignore_timestamps_errors = ignore_timestamps_errors
7575

7676
def _source_name(self):
7777
return self.dirname
@@ -116,8 +116,8 @@ def _parse_header(self):
116116

117117
# check for continuity (no gaps)
118118
diff = np.diff(data_chan['timestamp'])
119-
if not np.all(diff == RECORD_SIZE):
120-
warnings.warn(
119+
if not np.all(diff == RECORD_SIZE) and not self._ignore_timestamps_errors:
120+
raise Exception(
121121
'Not continuous timestamps for {}. ' \
122122
'Maybe because recording was paused/stopped.'.format(continuous_filename)
123123
)

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.assertWarns(UserWarning):
23+
with self.assertRaises(Exception):
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)