Skip to content

Commit

Permalink
convert and interface have consistent metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
h-mayorquin committed Dec 5, 2024
1 parent 683ba39 commit 25e6486
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,16 @@ def __init__(
stream_kind = self._signals_info_dict["stream_kind"] # ap or lf
stream_kind_caps = stream_kind.upper()
device = self._signals_info_dict["device"].capitalize() # imec0, imec1, etc.
self.es_key = f"ElectricalSeries{stream_kind_caps}{device}"

electrical_series_name = f"ElectricalSeries{stream_kind_caps}"

# Add imec{probe_index} to the electrical series name when there are multiple probes
# or undefined, `typeImEnabled` is present in the meta of all the production probes
self.probes_enabled_in_run = int(self.meta.get("typeImEnabled", 0))
if self.probes_enabled_in_run != 1:
electrical_series_name += f"{device}"

self.es_key = electrical_series_name

# Set electrodes properties
add_recording_extractor_properties(self.recording_extractor)
Expand Down
12 changes: 6 additions & 6 deletions tests/test_on_data/ecephys/spikeglx_single_probe_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
"device": "NIDQBoard"
}
],
"ElectricalSeriesAPImec0": {
"name": "ElectricalSeriesAPImec0",
"description": "Acquisition traces for the ElectricalSeriesAPImec0."
"ElectricalSeriesAP": {
"name": "ElectricalSeriesAP",
"description": "Acquisition traces for the ElectricalSeriesAP."
},
"Electrodes": [
{
Expand All @@ -51,9 +51,9 @@
"name": "ElectricalSeriesNIDQ",
"description": "Raw acquisition traces from the NIDQ (.nidq.bin) channels."
},
"ElectricalSeriesLFImec0": {
"name": "ElectricalSeriesLFImec0",
"description": "Acquisition traces for the ElectricalSeriesLFImec0."
"ElectricalSeriesLF": {
"name": "ElectricalSeriesLF",
"description": "Acquisition traces for the ElectricalSeriesLF."
}
}
}
12 changes: 6 additions & 6 deletions tests/test_on_data/ecephys/test_spikeglx_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def assertNWBFileStructure(self, nwbfile_path: FilePath, expected_session_start_

assert nwbfile.session_start_time.replace(tzinfo=None) == expected_session_start_time

assert "ElectricalSeriesAPImec0" in nwbfile.acquisition
assert "ElectricalSeriesLFImec0" in nwbfile.acquisition
assert "ElectricalSeriesAP" in nwbfile.acquisition
assert "ElectricalSeriesLF" in nwbfile.acquisition
assert "ElectricalSeriesNIDQ" in nwbfile.acquisition
assert len(nwbfile.acquisition) == 3

Expand Down Expand Up @@ -194,7 +194,7 @@ def test_electrode_table_writing(tmp_path):
np.testing.assert_array_equal(saved_channel_names, expected_channel_names_nidq)

# Test AP
electrical_series = nwbfile.acquisition["ElectricalSeriesAPImec0"]
electrical_series = nwbfile.acquisition["ElectricalSeriesAP"]
ap_electrodes_table_region = electrical_series.electrodes
region_indices = ap_electrodes_table_region.data
recording_extractor = converter.data_interface_objects["imec0.ap"].recording_extractor
Expand All @@ -204,7 +204,7 @@ def test_electrode_table_writing(tmp_path):
np.testing.assert_array_equal(saved_channel_names, expected_channel_names_ap)

# Test LF
electrical_series = nwbfile.acquisition["ElectricalSeriesLFImec0"]
electrical_series = nwbfile.acquisition["ElectricalSeriesLF"]
lf_electrodes_table_region = electrical_series.electrodes
region_indices = lf_electrodes_table_region.data
recording_extractor = converter.data_interface_objects["imec0.lf"].recording_extractor
Expand All @@ -223,15 +223,15 @@ def test_electrode_table_writing(tmp_path):
# Test round trip with spikeinterface
recording_extractor_ap = NwbRecordingExtractor(
file_path=nwbfile_path,
electrical_series_name="ElectricalSeriesAPImec0",
electrical_series_name="ElectricalSeriesAP",
)

channel_ids = recording_extractor_ap.get_channel_ids()
np.testing.assert_array_equal(channel_ids, expected_channel_names_ap)

recording_extractor_lf = NwbRecordingExtractor(
file_path=nwbfile_path,
electrical_series_name="ElectricalSeriesLFImec0",
electrical_series_name="ElectricalSeriesLF",
)

channel_ids = recording_extractor_lf.get_channel_ids()
Expand Down

0 comments on commit 25e6486

Please sign in to comment.