Skip to content

Commit 1e24932

Browse files
authored
Merge pull request #27 from SpikeInterface/fix-tests
Update probeinterface version and fix tests
2 parents dd2f93d + f595084 commit 1e24932

File tree

3 files changed

+15
-25
lines changed

3 files changed

+15
-25
lines changed

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.17
4+
probeinterface>=0.2.18

src/pynwb/ndx_probeinterface/io.py

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
inverted_unit_map = {v: k for k, v in unit_map.items()}
1212

1313

14-
def from_probeinterface(probe_or_probegroup: Union[Probe, ProbeGroup]) -> List[Device]:
14+
def from_probeinterface(probe_or_probegroup: Union[Probe, ProbeGroup],
15+
name: Optional[str] = None) -> List[Device]:
1516
"""
1617
Construct ndx-probeinterface Probe devices from a probeinterface.Probe
1718
@@ -32,7 +33,7 @@ def from_probeinterface(probe_or_probegroup: Union[Probe, ProbeGroup]) -> List[D
3233
probes = probe_or_probegroup.probes
3334
devices = []
3435
for probe in probes:
35-
devices.append(_single_probe_to_nwb_device(probe))
36+
devices.append(_single_probe_to_nwb_device(probe, name=name))
3637
return devices
3738

3839

@@ -116,8 +117,8 @@ def to_probeinterface(ndx_probe) -> Probe:
116117
return probeinterface_probe
117118

118119

119-
def _single_probe_to_nwb_device(probe: Probe):
120-
from pynwb import load_namespaces, get_class
120+
def _single_probe_to_nwb_device(probe: Probe, name: Optional[str]=None):
121+
from pynwb import get_class
121122

122123
Probe = get_class("Probe", "ndx-probeinterface")
123124
ContactTable = get_class("ContactTable", "ndx-probeinterface")
@@ -126,14 +127,8 @@ def _single_probe_to_nwb_device(probe: Probe):
126127
contact_plane_axes = probe.contact_plane_axes
127128
contact_ids = probe.contact_ids
128129
contacts_arr = probe.to_numpy()
129-
shank_ids = probe.shank_ids
130130
planar_contour = probe.probe_planar_contour
131131

132-
if shank_ids is not None:
133-
unique_shanks = np.unique(shank_ids)
134-
else:
135-
unique_shanks = ["0"]
136-
137132
shape_keys = []
138133
for shape_params in probe.contact_shape_params:
139134
keys = list(shape_params.keys())
@@ -161,21 +156,13 @@ def _single_probe_to_nwb_device(probe: Probe):
161156
kwargs["shank_id"] = probe.shank_ids[index]
162157
contact_table.add_row(kwargs)
163158

164-
if "serial_number" in probe.annotations:
165-
serial_number = probe.annotations["serial_number"]
166-
else:
167-
serial_number = None
168-
if "model_name" in probe.annotations:
169-
model_name = probe.annotations["model_name"]
170-
else:
171-
model_name = None
172-
if "manufacturer" in probe.annotations:
173-
manufacturer = probe.annotations["manufacturer"]
174-
else:
175-
manufacturer = None
159+
serial_number = probe.serial_number
160+
model_name = probe.model_name
161+
manufacturer = probe.manufacturer
162+
name = name if name is not None else probe.name
176163

177164
probe_device = Probe(
178-
name=probe.annotations["name"],
165+
name=name,
179166
model_name=model_name,
180167
serial_number=serial_number,
181168
manufacturer=manufacturer,

src/pynwb/tests/test_probe.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ def test_constructor_from_probe_single_shank(self):
7878
contact_table = device_w_indices.contact_table
7979
np.testing.assert_array_equal(contact_table["device_channel_index_pi"][:], device_channel_indices)
8080

81+
devices_w_names = Probe.from_probeinterface(probe, name="Test Probe")
82+
assert devices_w_names[0].name == "Test Probe"
83+
8184
def test_constructor_from_probe_multi_shank(self):
8285
"""Test that the constructor from Probe sets values as expected for multi-shank."""
8386

@@ -110,7 +113,7 @@ def test_constructor_from_probegroup(self):
110113
"""Test that the constructor from probegroup sets values as expected."""
111114

112115
probegroup = self.probegroup
113-
global_device_channel_indices = np.arange(probegroup.get_channel_count())
116+
global_device_channel_indices = np.arange(probegroup.get_contact_count())
114117
probegroup.set_global_device_channel_indices(global_device_channel_indices)
115118
devices = Probe.from_probeinterface(probegroup)
116119
probes = probegroup.probes

0 commit comments

Comments
 (0)