diff --git a/CHANGELOG.md b/CHANGELOG.md index 718ba5640..c59c118d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ * Keyword argument `field_name` of the `DatasetIOConfiguration.from_neurodata_object` method has been renamed to `dataset_name` to be more consistent with its usage. This only affects direct initialization of the model; usage via the `BackendConfiguration` constructor and its associated helper functions in `neuroconv.tools.nwb_helpers` is unaffected. [PR #767](https://github.com/catalystneuro/neuroconv/pull/767) * Manual construction of a `DatasetIOConfiguration` now requires the field `dataset_name`, and will be validated to match the final path of `location_in_file`. Usage via the automated constructors is unchanged. [PR #767](https://github.com/catalystneuro/neuroconv/pull/767) * Enhance `get_schema_from_method_signature` to extract descriptions from the method docval. [PR #771](https://github.com/catalystneuro/neuroconv/pull/771) - +* Avoid writing `channel_to_uV` and `offset_to_uV` in `add_electrodes` [PR #803](https://github.com/catalystneuro/neuroconv/pull/803) # v0.4.7 (February 21, 2024) diff --git a/src/neuroconv/tools/spikeinterface/spikeinterface.py b/src/neuroconv/tools/spikeinterface/spikeinterface.py index 735b21c5b..0dc6041ba 100644 --- a/src/neuroconv/tools/spikeinterface/spikeinterface.py +++ b/src/neuroconv/tools/spikeinterface/spikeinterface.py @@ -175,7 +175,12 @@ def add_electrode_groups(recording: BaseRecording, nwbfile: pynwb.NWBFile, metad nwbfile.create_electrode_group(**electrode_group_kwargs) -def add_electrodes(recording: BaseRecording, nwbfile: pynwb.NWBFile, metadata: dict = None, exclude: tuple = ()): +def add_electrodes( + recording: BaseRecording, + nwbfile: pynwb.NWBFile, + metadata: dict = None, + exclude: tuple = (), +): """ Add channels from recording object as electrodes to nwbfile object. @@ -237,7 +242,7 @@ def add_electrodes(recording: BaseRecording, nwbfile: pynwb.NWBFile, metadata: d data_to_add = defaultdict(dict) recorder_properties = recording.get_property_keys() - excluded_properties = list(exclude) + ["contact_vector"] + excluded_properties = list(exclude) + ["offset_to_uV", "gain_to_uV", "contact_vector"] properties_to_extract = [property for property in recorder_properties if property not in excluded_properties] for property in properties_to_extract: diff --git a/src/neuroconv/tools/testing/data_interface_mixins.py b/src/neuroconv/tools/testing/data_interface_mixins.py index b252b0011..bde8898cf 100644 --- a/src/neuroconv/tools/testing/data_interface_mixins.py +++ b/src/neuroconv/tools/testing/data_interface_mixins.py @@ -290,7 +290,9 @@ def check_read_nwb(self, nwbfile_path: str): # Spikeinterface behavior is to load the electrode table channel_name property as a channel_id self.nwb_recording = NwbRecordingExtractor( - file_path=nwbfile_path, electrical_series_name=electrical_series_name + file_path=nwbfile_path, + electrical_series_name=electrical_series_name, + use_pynwb=True, ) # Set channel_ids right for comparison diff --git a/tests/test_on_data/test_gin_ecephys/test_raw_recordings.py b/tests/test_on_data/test_gin_ecephys/test_raw_recordings.py index 0738fa3c2..4e8183227 100644 --- a/tests/test_on_data/test_gin_ecephys/test_raw_recordings.py +++ b/tests/test_on_data/test_gin_ecephys/test_raw_recordings.py @@ -236,6 +236,17 @@ class TestConverter(NWBConverter): converter.run_conversion(nwbfile_path=nwbfile_path, overwrite=True, metadata=metadata) recording = converter.data_interface_objects["TestRecording"].recording_extractor + # Read NWB file + from pynwb import NWBHDF5IO + + with NWBHDF5IO(path=nwbfile_path, mode="r") as io: + nwbfile = io.read() + electrodes = nwbfile.electrodes + electrodes_columns = electrodes.colnames + + assert "offset_to_uV" not in electrodes_columns + assert "grain_to_uV" not in electrodes_columns + es_key = converter.data_interface_objects["TestRecording"].es_key electrical_series_name = metadata["Ecephys"][es_key]["name"] if es_key else None if not isinstance(recording, BaseRecording): @@ -244,7 +255,9 @@ class TestConverter(NWBConverter): # NWBRecordingExtractor on spikeinterface does not yet support loading data written from multiple segment. if recording.get_num_segments() == 1: # Spikeinterface behavior is to load the electrode table channel_name property as a channel_id - nwb_recording = NwbRecordingExtractor(file_path=nwbfile_path, electrical_series_name=electrical_series_name) + nwb_recording = NwbRecordingExtractor( + file_path=nwbfile_path, electrical_series_name=electrical_series_name, use_pynwb=True + ) if "channel_name" in recording.get_property_keys(): renamed_channel_ids = recording.get_property("channel_name") else: