Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not convert non-neural channels to ElectricalSeries on OpenEphysBinaryRecordingInterface #1179

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

## Bug Fixes
* `run_conversion` does not longer trigger append mode an index error when `nwbfile_path` points to a faulty file [PR #1180](https://github.com/catalystneuro/neuroconv/pull/1180)
* `OpenEphysBinaryRecordingInterface` no longer stores analog data as an `ElectricalSeries` [PR #1179](https://github.com/catalystneuro/neuroconv/pull/1179)
* `DatasetIOConfiguration` now recommends `chunk_shape = (len(candidate_dataset),)` for datasets with compound dtypes,
as used by hdmf >= 3.14.6.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ def __init__(
if stub_test:
self.subset_channels = [0, 1]

# Check if the recording has ADC channels
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the data from Kind Lab, they have AUX (AUX1, AUX2, AUX3), not ADC, for the accelerometer signals.
Should we go the other way around? --> checking that the channel_id contains CH, and only if it contains CH we add that as ElectricalSeries.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great suggestion. Let me debug against that data. Could you talk to them to see if we can see use some of their data in our gin tests? I can then stub some of that .

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, but I just checked and your data is legacy, right? This PR is for the binary format where the channels are only ADC:

https://open-ephys.github.io/gui-docs/User-Manual/Recording-data/Open-Ephys-format.html
https://open-ephys.github.io/gui-docs/User-Manual/Recording-data/Binary-format.html

Your data might need another PR altogether.

recording = self.recording_extractor
channel_ids = recording.get_channel_ids()
neural_channels = [id for id in channel_ids if "ADC" not in id]
if len(neural_channels) < len(channel_ids):
self.recording_extractor = recording.select_channels(channel_ids=neural_channels)

def get_metadata(self) -> dict:
from ._openephys_utils import _get_session_start_time

Expand Down
20 changes: 20 additions & 0 deletions tests/test_on_data/ecephys/test_recording_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,26 @@ def check_extracted_metadata(self, metadata: dict):
assert metadata["NWBFile"]["session_start_time"] == datetime(2022, 5, 3, 10, 52, 24)


class TestOpenEphysBinaryRecordingInterfaceNonNeuralDatExcluded(RecordingExtractorInterfaceTestMixin):
"""Test that non-neural channels are not written as ElectricalSeries"""

data_interface_cls = OpenEphysBinaryRecordingInterface
interface_kwargs = dict(
folder_path=str(ECEPHY_DATA_PATH / "openephysbinary" / "neural_and_non_neural_data_mixed"),
stream_name="Rhythm_FPGA-100.0",
)
save_directory = OUTPUT_PATH

def test_non_neural_channels_not_added(self, setup_interface):
interface, test_name = setup_interface
nwbfile = interface.create_nwbfile()

written_channels = nwbfile.acquisition["ElectricalSeries"].electrodes["channel_name"].data
# Note the absence of "ADC1" and "ADC2"
assert all("ADC" not in channel for channel in written_channels)
assert np.array_equal(written_channels, np.asarray(["CH1", "CH2", "CH3", "CH4"]))


class TestOpenEphysLegacyRecordingInterface(RecordingExtractorInterfaceTestMixin):
data_interface_cls = OpenEphysLegacyRecordingInterface
interface_kwargs = dict(folder_path=str(ECEPHY_DATA_PATH / "openephys" / "OpenEphys_SampleData_1"))
Expand Down
Loading