Skip to content

Commit

Permalink
Merge pull request #2637 from alejoe91/nwb-req
Browse files Browse the repository at this point in the history
Add extra_requirements for nwb extractors
  • Loading branch information
alejoe91 authored Mar 28, 2024
2 parents 9704a8f + ac48bc7 commit 0b7fc99
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/spikeinterface/extractors/nwbextractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,6 @@ def __init__(
segment_data,
times_kwargs,
) = self._fetch_recording_segment_info_backend(file, cache, load_time_vector, samples_for_rate_estimation)

BaseRecording.__init__(self, channel_ids=channel_ids, sampling_frequency=sampling_frequency, dtype=dtype)
recording_segment = NwbRecordingSegment(
electrical_series_data=segment_data,
Expand All @@ -559,8 +558,10 @@ def __init__(
# fetch and add main recording properties
if use_pynwb:
gains, offsets, locations, groups = self._fetch_main_properties_pynwb()
self.extra_requirements.append("pynwb")
else:
gains, offsets, locations, groups = self._fetch_main_properties_backend()
self.extra_requirements.append("h5py")
self.set_channel_gains(gains)
self.set_channel_offsets(offsets)
if locations is not None:
Expand Down Expand Up @@ -772,8 +773,6 @@ def _fetch_other_properties(self, electrodes_table, electrodes_indices, columns)
#########
# Extract and re-name properties from nwbfile TODO: Should be a function
########
from pynwb.ecephys import ElectrodeGroup

properties = dict()
properties_to_skip = [
"id",
Expand All @@ -788,10 +787,7 @@ def _fetch_other_properties(self, electrodes_table, electrodes_indices, columns)
rename_properties = dict(location="brain_area")

for column in columns:
first_value = electrodes_table[column][0]
if isinstance(first_value, ElectrodeGroup):
continue
elif column in properties_to_skip:
if column in properties_to_skip:
continue
else:
column_name = rename_properties.get(column, column)
Expand Down Expand Up @@ -1015,8 +1011,10 @@ def __init__(
if load_unit_properties:
if use_pynwb:
columns = [c.name for c in self.units_table.columns]
self.extra_requirements.append("pynwb")
else:
columns = list(self.units_table.keys())
self.extra_requirements.append("h5py")
properties = self._fetch_properties(columns)
for property_name, property_values in properties.items():
values = [x.decode("utf-8") if isinstance(x, bytes) else x for x in property_values]
Expand Down

0 comments on commit 0b7fc99

Please sign in to comment.