Skip to content

Commit 147d168

Browse files
committed
probe.name > probe.dscription for NP
1 parent d7ca1dc commit 147d168

File tree

5 files changed

+41
-30
lines changed

5 files changed

+41
-30
lines changed

resources/generate_neuropixels_library.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def generate_all_npx():
8080
n = probe.get_contact_count()
8181

8282
title = f"{probe.manufacturer} - {model_name}"
83-
title += f"\n{probe.name}"
83+
title += f"\n{probe.description}"
8484
title += f"\n {n}ch"
8585
if probe.shank_ids is not None:
8686
num_shank = probe.get_shank_count()

src/probeinterface/neuropixels_tools.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,21 @@ def _load_np_probe_features():
9090
}
9191

9292
# Map from ProbeInterface to ProbeTable naming conventions
93-
pi_to_pt_names = {
94-
"x_pitch": "electrode_pitch_horz_um",
95-
"y_pitch": "electrode_pitch_vert_um",
96-
"contact_width": "electrode_size_horz_direction_um",
97-
"shank_pitch": "shank_pitch_um",
98-
"shank_number": "num_shanks",
99-
"ncols_per_shank": "cols_per_shank",
100-
"nrows_per_shank": "rows_per_shank",
101-
"adc_bit_depth": "adc_bit_depth",
102-
"model_name": "description",
103-
"num_readout_channels": "num_readout_channels",
104-
"shank_width_um": "shank_width_um",
105-
"tip_length_um": "tip_length_um",
106-
}
93+
# @Chris : is this necessary ?
94+
# pi_to_pt_names = {
95+
# "x_pitch": "electrode_pitch_horz_um",
96+
# "y_pitch": "electrode_pitch_vert_um",
97+
# "contact_width": "electrode_size_horz_direction_um",
98+
# "shank_pitch": "shank_pitch_um",
99+
# "shank_number": "num_shanks",
100+
# "ncols_per_shank": "cols_per_shank",
101+
# "nrows_per_shank": "rows_per_shank",
102+
# "adc_bit_depth": "adc_bit_depth",
103+
# "model_name": "description",
104+
# "num_readout_channels": "num_readout_channels",
105+
# "shank_width_um": "shank_width_um",
106+
# "tip_length_um": "tip_length_um",
107+
# }
107108

108109

109110
def get_probe_length(probe_part_number: str) -> int:
@@ -271,9 +272,8 @@ def _make_npx_probe_from_description(probe_description, model_name, elec_ids, sh
271272
positions = np.stack((x_pos, y_pos), axis=1)
272273

273274
# construct Probe object
274-
probe = Probe(
275-
ndim=2, si_units="um", model_name=model_name, manufacturer="imec", name=probe_description["description"]
276-
)
275+
probe = Probe(ndim=2, si_units="um", model_name=model_name, manufacturer="imec")
276+
probe.description = probe_description["description"]
277277
probe.set_contacts(
278278
positions=positions,
279279
shapes="square",
@@ -905,14 +905,12 @@ def read_openephys(
905905
)
906906
num_shanks = pt_metadata["num_shanks"]
907907

908-
model_name = pt_metadata.get("description")
909-
if model_name is None:
910-
model_name = "Unknown"
908+
description = pt_metadata.get("description")
911909

912910
elec_ids = []
913911
for i, pos in enumerate(positions):
914912
# Do not calculate contact ids if the model name is not known
915-
if model_name == "Unknown":
913+
if description is None:
916914
elec_ids = None
917915
break
918916

@@ -1060,6 +1058,7 @@ def read_openephys(
10601058
pt_metadata, probe_part_number, elec_ids, shank_ids=shank_ids, mux_table=mux_table
10611059
)
10621060
probe.serial_number = np_probe_info["serial_number"]
1061+
probe.name = np_probe_info["name"]
10631062

10641063
probe.annotate(
10651064
part_number=np_probe_info["part_number"],

src/probeinterface/probe.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,18 @@ def manufacturer(self, value):
201201
# we remove the annotation if it exists
202202
_ = self.annotations.pop("manufacturer", None)
203203

204+
@property
205+
def description(self):
206+
return self.annotations.get("description", None)
207+
208+
@description.setter
209+
def description(self, value):
210+
if value is not None:
211+
self.annotate(description=value)
212+
else:
213+
# we remove the annotation if it exists
214+
_ = self.annotations.pop("description", None)
215+
204216
def get_title(self) -> str:
205217
if self.contact_positions is None:
206218
txt = "Undefined probe"

tests/test_io/test_openephys.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ def test_NP1_subset():
8585
validate_probe_dict(probe_dict)
8686

8787
assert probe_ap.get_shank_count() == 1
88-
assert "1.0" in probe_ap.name
88+
assert "1.0" in probe_ap.description
8989
assert probe_ap.get_contact_count() == 200
9090

9191
probe_lf = read_openephys(data_path / "OE_Neuropix-PXI-subset" / "settings.xml", stream_name="ProbeA-LFP")
9292
probe_dict = probe_lf.to_dict(array_as_list=True)
9393
validate_probe_dict(probe_dict)
9494

9595
assert probe_lf.get_shank_count() == 1
96-
assert "1.0" in probe_lf.name
96+
assert "1.0" in probe_lf.description
9797
assert len(probe_lf.contact_positions) == 200
9898

9999
# Not specifying the stream_name should raise an Exception, because both the ProbeA-AP and
@@ -109,7 +109,7 @@ def test_multiple_probes():
109109
validate_probe_dict(probe_dict)
110110

111111
assert probeA.get_shank_count() == 1
112-
assert "1.0" in probeA.name
112+
assert "1.0" in probeA.description
113113

114114
probeB = read_openephys(
115115
data_path / "OE_Neuropix-PXI-multi-probe" / "settings.xml",

tests/test_io/test_spikeglx.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_get_saved_channel_indices_from_spikeglx_meta():
4343

4444
def test_NP1():
4545
probe = read_spikeglx(data_path / "Noise_g0_t0.imec0.ap.meta")
46-
assert "1.0" in probe.name
46+
assert "1.0" in probe.description
4747

4848

4949
def test_NP_phase3A():
@@ -66,7 +66,7 @@ def test_NP_phase3A():
6666

6767
def test_NP2_1_shanks():
6868
probe = read_spikeglx(data_path / "p2_g0_t0.imec0.ap.meta")
69-
assert "2.0" in probe.name
69+
assert "2.0" in probe.description
7070
assert probe.get_shank_count() == 1
7171

7272

@@ -163,7 +163,7 @@ def test_NP2_4_shanks_with_different_electrodes_saved():
163163
def test_NP1_large_depth_span():
164164
# Data provided by Tom Bugnon NP1 with large Depth span
165165
probe = read_spikeglx(data_path / "allan-longcol_g0_t0.imec0.ap.meta")
166-
assert "1.0" in probe.name
166+
assert "1.0" in probe.description
167167
assert probe.get_shank_count() == 1
168168
ypos = probe.contact_positions[:, 1]
169169
assert (np.max(ypos) - np.min(ypos)) > 7600
@@ -173,7 +173,7 @@ def test_NP1_other_example():
173173
# Data provided by Tom Bugnon NP1
174174
probe = read_spikeglx(data_path / "doppio-checkerboard_t0.imec0.ap.meta")
175175
print(probe)
176-
assert "1.0" in probe.name
176+
assert "1.0" in probe.description
177177
assert probe.get_shank_count() == 1
178178
ypos = probe.contact_positions[:, 1]
179179
assert (np.max(ypos) - np.min(ypos)) > 7600
@@ -317,7 +317,7 @@ def test_ultra_probe():
317317

318318
def test_CatGT_NP1():
319319
probe = read_spikeglx(data_path / "catgt.meta")
320-
assert "1.0" in probe.name
320+
assert "1.0" in probe.description
321321

322322

323323
def test_snsGeomMap():

0 commit comments

Comments
 (0)