diff --git a/README.md b/README.md index 604937e..3af4c58 100644 --- a/README.md +++ b/README.md @@ -171,7 +171,7 @@ classDiagram columns -------------------------------------- id : VectorData[int] - relative_position_in_mm : List[Tuple[float, float], Tuple[float, float, float]] + relative_position_in_um : List[Tuple[float, float], Tuple[float, float, float]] --> reference : str, optional contact_id : VectorData[str], optional shank_id : VectorData[str], optional diff --git a/spec/ndx-extracellular-channels.extensions.yaml b/spec/ndx-extracellular-channels.extensions.yaml index 2f06c16..ccfa640 100644 --- a/spec/ndx-extracellular-channels.extensions.yaml +++ b/spec/ndx-extracellular-channels.extensions.yaml @@ -5,7 +5,7 @@ groups: doc: Metadata about the contacts of a probe, compatible with the ProbeInterface specification. datasets: - - name: relative_position_in_mm + - name: relative_position_in_um neurodata_type_inc: VectorData dtype: float dims: @@ -18,7 +18,7 @@ groups: - 2 - - null - 3 - doc: Relative position of the contact in millimeters, relative to `reference`. + doc: Relative position of the contact in micrometers, relative to `reference`. attributes: - name: reference dtype: text diff --git a/src/pynwb/ndx_extracellular_channels/io.py b/src/pynwb/ndx_extracellular_channels/io.py index bde7094..7a24314 100644 --- a/src/pynwb/ndx_extracellular_channels/io.py +++ b/src/pynwb/ndx_extracellular_channels/io.py @@ -80,7 +80,7 @@ def to_probeinterface(ndx_probe: ndx_extracellular_channels.Probe) -> probeinter ndx_extracellular_channels.Probe.probe_model.manufacturer -> probeinterface.Probe.manufacturer ndx_extracellular_channels.Probe.probe_model.ndim -> probeinterface.Probe.ndim ndx_extracellular_channels.Probe.probe_model.planar_contour_in_um -> probeinterface.Probe.probe_planar_contour - ndx_extracellular_channels.Probe.probe_model.contacts_table["relative_position_in_mm"] -> + ndx_extracellular_channels.Probe.probe_model.contacts_table["relative_position_in_um"] -> probeinterface.Probe.contact_positions ndx_extracellular_channels.Probe.probe_model.contacts_table["shape"] -> probeinterface.Probe.contact_shapes ndx_extracellular_channels.Probe.probe_model.contacts_table["contact_id"] -> probeinterface.Probe.contact_ids @@ -121,7 +121,7 @@ def to_probeinterface(ndx_probe: ndx_extracellular_channels.Probe) -> probeinter possible_shape_keys = ["radius_in_um", "width_in_um", "height_in_um"] contacts_table = ndx_probe.probe_model.contacts_table - positions.append(contacts_table["relative_position_in_mm"][:]) + positions.append(contacts_table["relative_position_in_um"][:]) shapes.append(contacts_table["shape"][:]) if "contact_id" in contacts_table.colnames: if contact_ids is None: @@ -198,7 +198,7 @@ def _single_probe_to_ndx_probe( for index in np.arange(probe.get_contact_count()): kwargs = dict( - relative_position_in_mm=probe.contact_positions[index], + relative_position_in_um=probe.contact_positions[index], plane_axes=probe.contact_plane_axes[index], shape=contacts_arr["contact_shapes"][index], ) diff --git a/src/pynwb/tests/test_classes.py b/src/pynwb/tests/test_classes.py index 575ac6e..325e4de 100644 --- a/src/pynwb/tests/test_classes.py +++ b/src/pynwb/tests/test_classes.py @@ -34,7 +34,7 @@ def test_constructor_add_row(self): # for testing, mix and match different shapes. np.nan means the radius/width/height does not apply ct.add_row( - relative_position_in_mm=[10.0, 10.0], + relative_position_in_um=[10.0, 10.0], shape="circle", contact_id="C1", shank_id="shank0", @@ -45,7 +45,7 @@ def test_constructor_add_row(self): ) ct.add_row( - relative_position_in_mm=[20.0, 10.0], + relative_position_in_um=[20.0, 10.0], shape="square", contact_id="C2", shank_id="shank0", @@ -57,13 +57,13 @@ def test_constructor_add_row(self): # TODO might be nice to put this on the constructor of ContactsTable as relative_position__reference # without using a custom mapper - ct["relative_position_in_mm"].reference = "The bottom tip of the probe" + ct["relative_position_in_um"].reference = "The bottom tip of the probe" assert ct.name == "ContactsTable" assert ct.description == "Test contacts table" - assert ct["relative_position_in_mm"].reference == "The bottom tip of the probe" + assert ct["relative_position_in_um"].reference == "The bottom tip of the probe" - assert ct["relative_position_in_mm"].data == [[10.0, 10.0], [20.0, 10.0]] + assert ct["relative_position_in_um"].data == [[10.0, 10.0], [20.0, 10.0]] assert ct["shape"].data == ["circle", "square"] assert ct["contact_id"].data == ["C1", "C2"] assert ct["shank_id"].data == ["shank0", "shank0"] @@ -89,7 +89,7 @@ def addContainer(self): # for testing, mix and match different shapes. np.nan means the radius/width/height does not apply ct.add_row( - relative_position_in_mm=[10.0, 10.0], + relative_position_in_um=[10.0, 10.0], shape="circle", contact_id="C1", shank_id="shank0", @@ -100,7 +100,7 @@ def addContainer(self): ) ct.add_row( - relative_position_in_mm=[20.0, 10.0], + relative_position_in_um=[20.0, 10.0], shape="square", contact_id="C2", shank_id="shank0", @@ -128,7 +128,7 @@ def test_constructor(self): description="Test contacts table", ) ct.add_row( - relative_position_in_mm=[10.0, 10.0], + relative_position_in_um=[10.0, 10.0], shape="circle", ) @@ -155,7 +155,7 @@ def test_constructor_no_name(self): description="Test contacts table", ) ct.add_row( - relative_position_in_mm=[10.0, 10.0], + relative_position_in_um=[10.0, 10.0], shape="circle", ) @@ -181,7 +181,7 @@ def addContainer(self): description="Test contacts table", ) ct.add_row( - relative_position_in_mm=[10.0, 10.0], + relative_position_in_um=[10.0, 10.0], shape="circle", ) @@ -329,7 +329,7 @@ def test_constructor_minimal(self): description="Test contacts table", ) ct.add_row( - relative_position_in_mm=[10.0, 10.0], + relative_position_in_um=[10.0, 10.0], shape="circle", ) @@ -360,7 +360,7 @@ def test_constructor(self): description="Test contacts table", ) ct.add_row( - relative_position_in_mm=[10.0, 10.0], + relative_position_in_um=[10.0, 10.0], shape="circle", ) @@ -398,7 +398,7 @@ def addContainer(self): description="Test contacts table", ) ct.add_row( - relative_position_in_mm=[10.0, 10.0], + relative_position_in_um=[10.0, 10.0], shape="circle", ) @@ -432,15 +432,15 @@ def _create_test_probe(): description="Test contacts table", ) ct.add_row( - relative_position_in_mm=[10.0, 10.0], + relative_position_in_um=[10.0, 10.0], shape="circle", ) ct.add_row( - relative_position_in_mm=[10.0, 10.0], + relative_position_in_um=[10.0, 10.0], shape="circle", ) ct.add_row( - relative_position_in_mm=[10.0, 10.0], + relative_position_in_um=[10.0, 10.0], shape="circle", ) diff --git a/src/pynwb/tests/test_example_usage_all.py b/src/pynwb/tests/test_example_usage_all.py index 631a871..e33eb32 100644 --- a/src/pynwb/tests/test_example_usage_all.py +++ b/src/pynwb/tests/test_example_usage_all.py @@ -30,7 +30,7 @@ def test_all_classes(): ) # for demonstration, mix and match different shapes. np.nan means the radius/width/height does not apply contacts_table.add_row( - relative_position_in_mm=[10.0, 10.0], + relative_position_in_um=[10.0, 10.0], contact_id="C1", shank_id="shank0", plane_axes=[[1.0, 0.0], [0.0, 1.0]], @@ -40,7 +40,7 @@ def test_all_classes(): height_in_um=np.nan, ) contacts_table.add_row( - relative_position_in_mm=[20.0, 10.0], + relative_position_in_um=[20.0, 10.0], contact_id="C2", shank_id="shank0", plane_axes=[[1 / np.sqrt(2), 1 / np.sqrt(2)], [-1 / np.sqrt(2), 1 / np.sqrt(2)]], @@ -220,7 +220,7 @@ def test_all_classes(): assert read_contacts_table.name == "contacts_table" assert read_contacts_table.description == "Test contacts table" - npt.assert_array_equal(read_contacts_table["relative_position_in_mm"].data[:], [[10.0, 10.0], [20.0, 10.0]]) + npt.assert_array_equal(read_contacts_table["relative_position_in_um"].data[:], [[10.0, 10.0], [20.0, 10.0]]) npt.assert_array_equal(read_contacts_table["shape"].data[:], ["circle", "square"]) npt.assert_array_equal(read_contacts_table["contact_id"].data[:], ["C1", "C2"]) npt.assert_array_equal(read_contacts_table["shank_id"].data[:], ["shank0", "shank0"]) diff --git a/src/pynwb/tests/test_example_usage_probeinterface.py b/src/pynwb/tests/test_example_usage_probeinterface.py index 2df5ae0..2b19549 100644 --- a/src/pynwb/tests/test_example_usage_probeinterface.py +++ b/src/pynwb/tests/test_example_usage_probeinterface.py @@ -113,7 +113,7 @@ def test_from_probeinterface(): assert nwbfile.devices["probe0"].probe_model.manufacturer == "Neuronexus" assert nwbfile.devices["probe0"].probe_model.ndim == 2 npt.assert_array_equal(nwbfile.devices["probe0"].probe_model.planar_contour_in_um, polygon) - npt.assert_allclose(nwbfile.devices["probe0"].probe_model.contacts_table.relative_position_in_mm, positions) + npt.assert_allclose(nwbfile.devices["probe0"].probe_model.contacts_table.relative_position_in_um, positions) npt.assert_array_equal(nwbfile.devices["probe0"].probe_model.contacts_table["shape"].data[:], "circle") npt.assert_array_equal(nwbfile.devices["probe0"].probe_model.contacts_table["radius_in_um"].data[:], 5.0) @@ -124,7 +124,7 @@ def test_from_probeinterface(): assert nwbfile.devices["probe1"].probe_model.ndim == 2 npt.assert_allclose(nwbfile.devices["probe1"].probe_model.planar_contour_in_um, probe1.probe_planar_contour) npt.assert_allclose( - nwbfile.devices["probe1"].probe_model.contacts_table.relative_position_in_mm, probe1.contact_positions + nwbfile.devices["probe1"].probe_model.contacts_table.relative_position_in_um, probe1.contact_positions ) npt.assert_array_equal(nwbfile.devices["probe1"].probe_model.contacts_table["shape"].data[:], "circle") npt.assert_array_equal( @@ -138,7 +138,7 @@ def test_from_probeinterface(): assert nwbfile.devices["probe2"].probe_model.ndim == 2 npt.assert_allclose(nwbfile.devices["probe2"].probe_model.planar_contour_in_um, probe2.probe_planar_contour) npt.assert_allclose( - nwbfile.devices["probe2"].probe_model.contacts_table.relative_position_in_mm, probe2.contact_positions + nwbfile.devices["probe2"].probe_model.contacts_table.relative_position_in_um, probe2.contact_positions ) npt.assert_array_equal(nwbfile.devices["probe2"].probe_model.contacts_table["shape"].data[:], "square") npt.assert_array_equal( @@ -154,7 +154,7 @@ def test_from_probeinterface(): nwbfile.devices["renamed_probe3"].probe_model.planar_contour_in_um, probe3.probe_planar_contour ) npt.assert_allclose( - nwbfile.devices["renamed_probe3"].probe_model.contacts_table.relative_position_in_mm, + nwbfile.devices["renamed_probe3"].probe_model.contacts_table.relative_position_in_um, probe3.contact_positions, ) npt.assert_array_equal(nwbfile.devices["renamed_probe3"].probe_model.contacts_table["shape"].data[:], "circle") @@ -184,8 +184,8 @@ def test_to_probeinterface(): description="a table with electrode contacts", columns=[ pynwb.core.VectorData( - name="relative_position_in_mm", - description="the relative position of the contact in mm", + name="relative_position_in_um", + description="the relative position of the contact in micrometers", data=[ (0.0, 0.0), (0.0, 20.0), @@ -241,7 +241,7 @@ def test_to_probeinterface(): assert pi_probe0.serial_number == "0123" assert pi_probe0.model_name == "a1x32-edge-5mm-20-177_H32" assert pi_probe0.manufacturer == "Neuronexus" - npt.assert_array_equal(pi_probe0.contact_positions, probe_model0.contacts_table.relative_position_in_mm) + npt.assert_array_equal(pi_probe0.contact_positions, probe_model0.contacts_table.relative_position_in_um) npt.assert_array_equal(pi_probe0.contact_shapes, "circle") npt.assert_array_equal(pi_probe0.to_numpy()["radius"], 5.0) @@ -251,7 +251,7 @@ def test_to_probeinterface(): # for testing, mix and match different shapes. np.nan means the radius/width/height does not apply ct2.add_row( - relative_position_in_mm=[10.0, 10.0], + relative_position_in_um=[10.0, 10.0], shape="circle", contact_id="C1", shank_id="shank0", @@ -261,7 +261,7 @@ def test_to_probeinterface(): height_in_um=np.nan, ) ct2.add_row( - relative_position_in_mm=[20.0, 10.0], + relative_position_in_um=[20.0, 10.0], shape="square", contact_id="C2", shank_id="shank0", @@ -292,7 +292,7 @@ def test_to_probeinterface(): assert pi_probe1.serial_number == "7890" assert pi_probe1.model_name == "Neuropixels 1.0" assert pi_probe1.manufacturer == "IMEC" - npt.assert_array_equal(pi_probe1.contact_positions, probe_model1.contacts_table.relative_position_in_mm) + npt.assert_array_equal(pi_probe1.contact_positions, probe_model1.contacts_table.relative_position_in_um) npt.assert_array_equal(pi_probe1.contact_shapes, ["circle", "square"]) npt.assert_array_equal( pi_probe1.contact_plane_axes, @@ -320,6 +320,6 @@ def test_to_probeinterface(): assert pi_probe.serial_number == "0123" assert pi_probe.model_name == "a1x32-edge-5mm-20-177_H32" assert pi_probe.manufacturer == "Neuronexus" - npt.assert_array_equal(pi_probe.contact_positions, probe_model0.contacts_table.relative_position_in_mm) + npt.assert_array_equal(pi_probe.contact_positions, probe_model0.contacts_table.relative_position_in_um) npt.assert_array_equal(pi_probe.to_numpy()["radius"], 5.0) npt.assert_array_equal(pi_probe.contact_shapes, "circle") diff --git a/src/spec/create_extension_spec.py b/src/spec/create_extension_spec.py index 64ed3f9..4ac2bf0 100644 --- a/src/spec/create_extension_spec.py +++ b/src/spec/create_extension_spec.py @@ -41,9 +41,9 @@ def main(): default_name="contacts_table", datasets=[ NWBDatasetSpec( - name="relative_position_in_mm", + name="relative_position_in_um", neurodata_type_inc="VectorData", - doc="Relative position of the contact in millimeters, relative to `reference`.", + doc="Relative position of the contact in micrometers, relative to `reference`.", dtype="float", dims=[["num_contacts", "x, y"], ["num_contacts", "x, y, z"]], shape=[[None, 2], [None, 3]],