Skip to content

Commit 18a9015

Browse files
authored
Merge pull request #30 from SpikeInterface/fix-29
Fix IndexError in shape_params and bump up version
1 parent 90c4034 commit 18a9015

4 files changed

Lines changed: 17 additions & 12 deletions

File tree

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# pinned dependencies to reproduce a working development environment
22
hdmf>=3.1.1
33
pynwb>=2.0.0
4-
probeinterface>=0.2.18
4+
probeinterface>=0.3.0

src/pynwb/ndx_probeinterface/io.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ def to_probeinterface(ndx_probe) -> Probe:
9393
for possible_shape_key in possible_shape_keys:
9494
if possible_shape_key in contact_table.colnames:
9595
if shape_params is None:
96-
shape_params = []
97-
shape_params.append([{possible_shape_key: val} for val in contact_table[possible_shape_key][:]])
96+
shape_params = [{} for _ in range(len(contact_table))]
97+
for i in range(len(contact_table)):
98+
shape_params[i][possible_shape_key] = contact_table[possible_shape_key][i]
9899

99100
positions = [item for sublist in positions for item in sublist]
100101
shapes = [item for sublist in shapes for item in sublist]
@@ -103,8 +104,6 @@ def to_probeinterface(ndx_probe) -> Probe:
103104
contact_ids = [item for sublist in contact_ids for item in sublist]
104105
if plane_axes is not None:
105106
plane_axes = [item for sublist in plane_axes for item in sublist]
106-
if shape_params is not None:
107-
shape_params = [item for sublist in shape_params for item in sublist]
108107
if shank_ids is not None:
109108
shank_ids = [item for sublist in shank_ids for item in sublist]
110109
if device_channel_indices is not None:
@@ -170,13 +169,19 @@ def _single_probe_to_nwb_device(probe: Probe):
170169
contact_table.add_row(kwargs)
171170

172171
annotations = probe.annotations.copy()
173-
name = annotations.pop("name") if "name" in annotations else None
174-
serial_number = annotations.pop("serial_number") if "serial_number" in annotations else None
175-
model_name = annotations.pop("model_name") if "model_name" in annotations else None
176-
manufacturer = annotations.pop("manufacturer") if "manufacturer" in annotations else None
172+
name = probe.name
173+
serial_number = probe.serial_number
174+
model_name = probe.model_name
175+
manufacturer = probe.manufacturer
176+
177+
# Remove key annotations already stored as attributes in the Probe device
178+
annotations.pop("name", None)
179+
annotations.pop("serial_number", None)
180+
annotations.pop("model_name", None)
181+
annotations.pop("manufacturer", None)
177182

178183
probe_device = Probe(
179-
name=name,
184+
name=name if name is not None else "Probe",
180185
model_name=model_name,
181186
serial_number=serial_number,
182187
manufacturer=manufacturer,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = "0.2.0"
1+
version = "0.2.1"

src/spec/create_extension_spec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def main():
99
ns_builder = NWBNamespaceBuilder(
1010
doc="""Extension for defining neural probes in the probeinterface format""",
1111
name="""ndx-probeinterface""",
12-
version="""0.1.0""",
12+
version="""0.2.1""",
1313
author=["Alessio Buccino", "Kyu Hyun Lee", "Geeling Chau"],
1414
contact=["alessiop.buccino@gmail.com", "kyuhyun9056@gmail.com", "gchau@caltech.edu"],
1515
)

0 commit comments

Comments
 (0)