Skip to content

Commit

Permalink
Do not write offset_to_uV and gain_to_uV in Electrodes (#803)
Browse files Browse the repository at this point in the history
Co-authored-by: Cody Baker <[email protected]>
  • Loading branch information
h-mayorquin and CodyCBakerPhD authored Apr 3, 2024
1 parent 1ee13dc commit 468157b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions src/neuroconv/tools/spikeinterface/spikeinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion src/neuroconv/tools/testing/data_interface_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion tests/test_on_data/test_gin_ecephys/test_raw_recordings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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:
Expand Down

0 comments on commit 468157b

Please sign in to comment.