From 54ab1d92036441d5ec510391164f232eec56385a Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Thu, 16 Jan 2025 13:25:41 -0600 Subject: [PATCH 1/2] add test --- .../openephys/openephysbinarydatainterface.py | 7 +++++++ .../ecephys/test_recording_interfaces.py | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/neuroconv/datainterfaces/ecephys/openephys/openephysbinarydatainterface.py b/src/neuroconv/datainterfaces/ecephys/openephys/openephysbinarydatainterface.py index ef67fde40..a684e5e90 100644 --- a/src/neuroconv/datainterfaces/ecephys/openephys/openephysbinarydatainterface.py +++ b/src/neuroconv/datainterfaces/ecephys/openephys/openephysbinarydatainterface.py @@ -86,6 +86,13 @@ def __init__( if stub_test: self.subset_channels = [0, 1] + # Check if the recording has ADC channels + 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 diff --git a/tests/test_on_data/ecephys/test_recording_interfaces.py b/tests/test_on_data/ecephys/test_recording_interfaces.py index 8978efa93..4248fe5b3 100644 --- a/tests/test_on_data/ecephys/test_recording_interfaces.py +++ b/tests/test_on_data/ecephys/test_recording_interfaces.py @@ -541,6 +541,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")) From 38167e7c32fd8e9a4fa9670d217ff0e2845d3a1f Mon Sep 17 00:00:00 2001 From: Heberto Mayorquin Date: Fri, 7 Feb 2025 19:10:34 -0600 Subject: [PATCH 2/2] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e4463175..06a5a34ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) ## Features * Use the latest version of ndx-pose for `DeepLabCutInterface` and `LightningPoseDataInterface` [PR #1128](https://github.com/catalystneuro/neuroconv/pull/1128)