Skip to content

Commit a7f191c

Browse files
committed
Merge branch 'master' into add_annotations_to_intan
2 parents 38536af + 5c54fd9 commit a7f191c

File tree

4 files changed

+42
-15
lines changed

4 files changed

+42
-15
lines changed

.github/workflows/core-test.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,32 @@ jobs:
2626
matrix:
2727
os: ["ubuntu-latest", "windows-latest"]
2828
# "macos-latest",
29-
python-version: ['3.8', '3.9', '3.10', '3.11']
30-
numpy-version: ['1.20.3', '1.21.6', '1.22.4', '1.23.5', '1.24.1', '1.25.1']
29+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
30+
numpy-version: ['1.20.3', '1.21.6', '1.22.4', '1.23.5', '1.24.1', '1.25.1', '1.26.4']
3131
exclude:
3232
- python-version: '3.8'
3333
numpy-version: '1.25.1'
34+
- python-version: '3.8'
35+
numpy-version: '1.26.4'
3436
- python-version: '3.10'
3537
numpy-version: '1.20.3'
3638
- python-version: '3.11'
3739
numpy-version: '1.20.3'
3840
- python-version: '3.11'
3941
numpy-version: '1.21.6'
42+
- python-version: '3.12'
43+
numpy-version: '1.20.3'
44+
# python 3.12 only works on latest numpy
45+
- python-version: '3.12'
46+
numpy-version: '1.21.6'
47+
- python-version: '3.12'
48+
numpy-version: '1.22.4'
49+
- python-version: '3.12'
50+
numpy-version: '1.23.5'
51+
- python-version: '3.12'
52+
numpy-version: '1.24.1'
53+
- python-version: '3.12'
54+
numpy-version: '1.25.1'
4055
steps:
4156
- name: Set up Python ${{ matrix.python-version }}
4257
uses: actions/setup-python@v4

.github/workflows/io-test.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ concurrency: # Cancel previous workflows on the same pull request
1313

1414
jobs:
1515
build-and-test:
16-
name: Test on (${{ inputs.os }})
16+
name: Test on (${{ inputs.os }}) (${{ matrix.python-version}})
1717
runs-on: ${{ inputs.os }}
1818
strategy:
1919
fail-fast: true
2020
matrix:
21-
python-version: ['3.9', ]
21+
python-version: ['3.9', '3.11']
2222
defaults:
2323
# by default run in bash mode (required for conda usage)
2424
run:
@@ -75,6 +75,7 @@ jobs:
7575
if: steps.cache-conda-env.outputs.cache-hit != 'true'
7676
run: |
7777
conda env update --name neo-test-env --file environment_testing.yml --prune
78+
conda install python=${{ matrix.python-version }}
7879
7980
- name: Configure git
8081
run: |

environment_testing.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ name: neo-test-env
22
channels:
33
- conda-forge
44
dependencies:
5-
- python=3.9
65
- datalad
76
- pip

neo/rawio/intanrawio.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
"""
2121

2222
from pathlib import Path
23-
import os
24-
from collections import OrderedDict
2523
from packaging.version import Version
2624
import warnings
2725

@@ -44,8 +42,12 @@ class IntanRawIO(BaseRawIO):
4442
Parameters
4543
----------
4644
filename: str, default: ''
47-
name of the 'rhd' or 'rhs' data/header file
48-
45+
name of the 'rhd' or 'rhs' data/header file
46+
ignore_integrity_checks: bool, default: False
47+
If True, data that violates integrity assumptions will be loaded. At the moment the only integrity
48+
check we perform is that timestamps are continuous. Setting this to True will ignore this check and set
49+
the attribute `discontinuous_timestamps` to True if the timestamps are not continous. This attribute can be checked
50+
after parsing the header to see if the timestamps are continuous or not.
4951
Notes
5052
-----
5153
* The Intan reader can handle two file formats 'rhd' and 'rhs'. It will automatically
@@ -99,10 +101,13 @@ class IntanRawIO(BaseRawIO):
99101
extensions = ["rhd", "rhs", "dat"]
100102
rawmode = "one-file"
101103

102-
def __init__(self, filename=""):
104+
def __init__(self, filename="", ignore_integrity_checks=False):
103105

104106
BaseRawIO.__init__(self)
105107
self.filename = filename
108+
self.ignore_integrity_checks = ignore_integrity_checks
109+
self.discontinuous_timestamps = False
110+
106111

107112
def _source_name(self):
108113
return self.filename
@@ -202,11 +207,18 @@ def _parse_header(self):
202207
elif self.file_format == "one-file-per-channel":
203208
time_stream_index = max(self._raw_data.keys())
204209
timestamp = self._raw_data[time_stream_index][0]
205-
206-
if not np.all(np.diff(timestamp) == 1):
207-
raise NeoReadWriteError(
208-
f"Timestamp have gaps, this could be due to a corrupted file or an inappropriate file merge"
209-
)
210+
211+
discontinuous_timestamps = np.diff(timestamp) != 1
212+
timestamps_are_not_contiguous = np.any(discontinuous_timestamps)
213+
if timestamps_are_not_contiguous:
214+
self.discontinuous_timestamps = True
215+
if not self.ignore_integrity_checks:
216+
error_msg = (
217+
"Timestamps are not continuous, this could be due to a corrupted file or an inappropriate file merge. "
218+
"Initialize the reader with `ignore_integrity_checks=True` to ignore this error and open the file. \n"
219+
f"Timestamps around discontinuities: {timestamp[discontinuous_timestamps]}"
220+
)
221+
raise NeoReadWriteError(error_msg)
210222

211223
# signals
212224
signal_channels = []

0 commit comments

Comments
 (0)