From bf9087761cfb352a3a72de35464403bb737f0e7f Mon Sep 17 00:00:00 2001 From: rly Date: Tue, 4 Jun 2024 00:32:17 -0700 Subject: [PATCH] Add back ProbeModel.model, remove 1D contour case --- spec/ndx-extracellular-channels.extensions.yaml | 7 +++---- src/pynwb/ndx_extracellular_channels/io.py | 1 + src/pynwb/tests/test_classes.py | 6 ++++++ src/pynwb/tests/test_example_usage_all.py | 1 + src/spec/create_extension_spec.py | 12 ++++++++++-- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/spec/ndx-extracellular-channels.extensions.yaml b/spec/ndx-extracellular-channels.extensions.yaml index 0cec9c5..5e69161 100644 --- a/spec/ndx-extracellular-channels.extensions.yaml +++ b/spec/ndx-extracellular-channels.extensions.yaml @@ -89,18 +89,17 @@ groups: default_value: 2 doc: dimension of the probe required: false + - name: model + dtype: text + doc: Name of the model of the probe, e.g., 'Neuropixels 1.0'. - name: planar_contour_in_um dtype: float dims: - - - num_points - - x - - num_points - x, y - - num_points - x, y, z shape: - - - null - - 1 - - null - 2 - - null diff --git a/src/pynwb/ndx_extracellular_channels/io.py b/src/pynwb/ndx_extracellular_channels/io.py index fed582d..ca4d299 100644 --- a/src/pynwb/ndx_extracellular_channels/io.py +++ b/src/pynwb/ndx_extracellular_channels/io.py @@ -203,6 +203,7 @@ def _single_probe_to_ndx_probe( probe_model = ndx_extracellular_channels.ProbeModel( name=model_name, manufacturer=probe.manufacturer, + model=model_name, ndim=probe.ndim, planar_contour_in_um=probe.probe_planar_contour * conversion_factor, contacts_table=contacts_table, diff --git a/src/pynwb/tests/test_classes.py b/src/pynwb/tests/test_classes.py index 77f42b3..bafbf21 100644 --- a/src/pynwb/tests/test_classes.py +++ b/src/pynwb/tests/test_classes.py @@ -137,6 +137,7 @@ def test_constructor(self): pm = ProbeModel( name="Neuropixels 1.0", description="A neuropixels probe", + model="Neuropixels 1.0", manufacturer="IMEC", # TODO make planar_contour_in_um optional planar_contour_in_um=[[-10.0, -10.0], [10.0, -10.0], [10.0, 10.0], [-10.0, 10.0]], @@ -169,6 +170,7 @@ def addContainer(self): pm = ProbeModel( name="Neuropixels 1.0", description="A neuropixels probe", + model="Neuropixels 1.0", manufacturer="IMEC", planar_contour_in_um=[[-10.0, -10.0], [10.0, -10.0], [10.0, 10.0], [-10.0, 10.0]], contacts_table=ct, @@ -197,6 +199,7 @@ def test_constructor_minimal(self): pm = ProbeModel( name="Neuropixels 1.0", description="A neuropixels probe", + model="Neuropixels 1.0", manufacturer="IMEC", planar_contour_in_um=[[-10.0, -10.0], [10.0, -10.0], [10.0, 10.0], [-10.0, 10.0]], contacts_table=ct, @@ -224,6 +227,7 @@ def test_constructor(self): pm = ProbeModel( name="Neuropixels 1.0", description="A neuropixels probe", + model="Neuropixels 1.0", manufacturer="IMEC", planar_contour_in_um=[[-10.0, -10.0], [10.0, -10.0], [10.0, 10.0], [-10.0, 10.0]], contacts_table=ct, @@ -256,6 +260,7 @@ def addContainer(self): pm = ProbeModel( name="Neuropixels 1.0", description="A neuropixels probe", + model="Neuropixels 1.0", manufacturer="IMEC", planar_contour_in_um=[[-10.0, -10.0], [10.0, -10.0], [10.0, 10.0], [-10.0, 10.0]], contacts_table=ct, @@ -297,6 +302,7 @@ def _create_test_probe(): pm = ProbeModel( name="Neuropixels 1.0", description="A neuropixels probe", + model="Neuropixels 1.0", manufacturer="IMEC", planar_contour_in_um=[[-10.0, -10.0], [10.0, -10.0], [10.0, 10.0], [-10.0, 10.0]], contacts_table=ct, diff --git a/src/pynwb/tests/test_example_usage_all.py b/src/pynwb/tests/test_example_usage_all.py index 37cd78e..b5963ed 100644 --- a/src/pynwb/tests/test_example_usage_all.py +++ b/src/pynwb/tests/test_example_usage_all.py @@ -55,6 +55,7 @@ pm = ProbeModel( name="Neuropixels 1.0", description="A neuropixels probe", + model="neuropixels 1.0", manufacturer="IMEC", planar_contour_in_um=[[-10.0, -10.0], [10.0, -10.0], [10.0, 10.0], [-10.0, 10.0]], contacts_table=contacts_table, diff --git a/src/spec/create_extension_spec.py b/src/spec/create_extension_spec.py index 4a89214..7244c09 100644 --- a/src/spec/create_extension_spec.py +++ b/src/spec/create_extension_spec.py @@ -167,6 +167,14 @@ def main(): attributes=[ # inherits name, description, manufacturer from Device NWBAttributeSpec(name="ndim", doc="dimension of the probe", dtype="int", default_value=2), + NWBAttributeSpec( + # although the ProbeModel also has a name attribute, the name must be unique across all + # devices in the NWB file, and users may decide to use a more descriptive name than just + # the model name + name="model", + doc="Name of the model of the probe, e.g., 'Neuropixels 1.0'.", + dtype="text", + ), NWBAttributeSpec( name="planar_contour_in_um", # TODO should this just be "contour"? doc=("The coordinates of the nodes of the polygon that describe the shape (contour) of the probe, " @@ -175,8 +183,8 @@ def main(): "See 'probe_planar_contour' in " "https://probeinterface.readthedocs.io/en/main/format_spec.html for more details."), dtype="float", - dims=[["num_points", "x"], ["num_points", "x, y"], ["num_points", "x, y, z"]], - shape=[[None, 1], [None, 2], [None, 3]], + dims=[["num_points", "x, y"], ["num_points", "x, y, z"]], + shape=[[None, 2], [None, 3]], ), ], )