diff --git a/CHANGELOG.md b/CHANGELOG.md index c4ac56b6e..7335da40a 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) * `DatasetIOConfiguration` now recommends `chunk_shape = (len(candidate_dataset),)` for datasets with compound dtypes, as used by hdmf >= 3.14.6. diff --git a/src/neuroconv/datainterfaces/ecephys/openephys/openephysbinarydatainterface.py b/src/neuroconv/datainterfaces/ecephys/openephys/openephysbinarydatainterface.py index cb8cc3342..79df61e4a 100644 --- a/src/neuroconv/datainterfaces/ecephys/openephys/openephysbinarydatainterface.py +++ b/src/neuroconv/datainterfaces/ecephys/openephys/openephysbinarydatainterface.py @@ -108,6 +108,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 967e9e19b..6745269c5 100644 --- a/tests/test_on_data/ecephys/test_recording_interfaces.py +++ b/tests/test_on_data/ecephys/test_recording_interfaces.py @@ -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"))