Skip to content

Commit

Permalink
Merge branch 'master' into numpy-2-0
Browse files Browse the repository at this point in the history
  • Loading branch information
zm711 authored Nov 25, 2024
2 parents 9a1962b + 685fd3d commit 7449082
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ A project with similar aims but for neuroimaging file formats is `NiBabel`_.
Code status
-----------

.. image:: https://img.shields.io/pypi/v/neo.svg
:target: https://pypi.python.org/pypi/neo
:alt: PyPI Release Version
.. image:: https://github.com/NeuralEnsemble/python-neo/actions/workflows/core-test.yml/badge.svg?event=push&branch=master
:target: https://github.com/NeuralEnsemble/python-neo/actions?query=event%3Apush+branch%3Amaster
:alt: Core Test Status (Github Actions)
.. image:: https://github.com/NeuralEnsemble/python-neo/actions/workflows/io-test.yml/badge.svg?event=push&branch=master
.. image:: https://github.com/NeuralEnsemble/python-neo/actions/workflows/io-test_trigger.yml/badge.svg?event=push&branch=master
:target: https://github.com/NeuralEnsemble/python-neo/actions?query=event%3Apush+branch%3Amaster
:alt: IO Test Status (Github Actions)
.. image:: https://coveralls.io/repos/NeuralEnsemble/python-neo/badge.png
Expand Down
18 changes: 18 additions & 0 deletions neo/rawio/openephysbinaryrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import os
import json
from pathlib import Path
from warnings import warn

import numpy as np

Expand Down Expand Up @@ -570,6 +571,15 @@ def explore_folder(dirname, experiment_names=None):
stream_name = node_name + "#" + oe_stream_name
else:
stream_name = oe_stream_name

# skip streams if folder is on oebin, but doesn't exist
if not (recording_folder / "continuous" / info["folder_name"]).is_dir():
warn(
f"For {recording_folder} the folder continuous/{info['folder_name']} is missing. "
f"Skipping {stream_name} continuous stream."
)
continue

raw_filename = recording_folder / "continuous" / info["folder_name"] / "continuous.dat"

# Updates for OpenEphys v0.6:
Expand Down Expand Up @@ -604,6 +614,14 @@ def explore_folder(dirname, experiment_names=None):
else:
stream_name = oe_stream_name

# skip streams if folder is on oebin, but doesn't exist
if not (recording_folder / "events" / info["folder_name"]).is_dir():
warn(
f"For {recording_folder} the folder events/{info['folder_name']} is missing. "
f"Skipping {stream_name} event stream."
)
continue

event_stream = info.copy()
for name in _possible_event_stream_names:
npy_filename = root / "events" / info["folder_name"] / f"{name}.npy"
Expand Down
9 changes: 9 additions & 0 deletions neo/test/rawiotest/test_openephysbinaryrawio.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class TestOpenEphysBinaryRawIO(BaseTestRawIO, unittest.TestCase):
"openephysbinary/v0.5.x_two_nodes",
"openephysbinary/v0.6.x_neuropixels_multiexp_multistream",
"openephysbinary/v0.6.x_neuropixels_with_sync",
"openephysbinary/v0.6.x_neuropixels_missing_folders",
]

def test_sync(self):
Expand Down Expand Up @@ -48,6 +49,14 @@ def test_no_sync(self):
)
rawio_no_sync.parse_header()

def test_missing_folders(self):
# missing folders should raise an error
with self.assertWarns(UserWarning):
rawio = OpenEphysBinaryRawIO(
self.get_local_path("openephysbinary/v0.6.x_neuropixels_missing_folders"), load_sync_channel=False
)
rawio.parse_header()


if __name__ == "__main__":
unittest.main()

0 comments on commit 7449082

Please sign in to comment.