Skip to content

Commit

Permalink
change name of target_object to localized_entity
Browse files Browse the repository at this point in the history
  • Loading branch information
bendichter committed Aug 21, 2024
1 parent 38074c4 commit d01e51a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion spec/ndx-anatomical-localization.extensions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ groups:
neurodata_type_inc: VectorData
doc: "The z coordinate"
quantity: 1
- name: target_object
- name: localized_entity
neurodata_type_inc: DynamicTableRegion
doc: "The object to which the coordinates refer (e.g. electrode)"
quantity: 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from hdmf.common import DynamicTable
from hdmf.utils import docval, get_docval, AllowPositional
from pynwb import get_class, register_class
from hdmf.utils import get_docval, AllowPositional

from pynwb import get_class, register_class, docval, register_map

TempSpace = get_class("Space", "ndx-anatomical-localization")
TempAnatomicalCoordinatesTable = get_class("AnatomicalCoordinatesTable", "ndx-anatomical-localization")
Expand Down Expand Up @@ -56,20 +56,20 @@ class AnatomicalCoordinatesTable(TempAnatomicalCoordinatesTable):
{"name": "space", "type": Space, "doc": "space of the table"},
{"name": "method", "type": str, "doc": "method of the table"},
{"name": "target", "type": DynamicTable,
"doc": 'target table. ignored if a "target_object" column is provided in "columns"', "default": None},
"doc": 'target table. ignored if a "localized_entity" column is provided in "columns"', "default": None},
*get_docval(DynamicTable.__init__),
allow_positional=AllowPositional.ERROR,
)
def __init__(self, **kwargs):
columns = kwargs.get("columns")
target = kwargs.pop("target")
if not columns or "target_object" not in [c.name for c in columns]:
# set the target table of the "target_object" column only if the "target_object" column is not in "columns"
if not columns or "localized_entity" not in [c.name for c in columns]:
# set the target table of the "localized_entity" column only if the "localized_entity" column is not in "columns"
if target is None:
raise ValueError(
'"target" (the target table that contains the objects that have these coordinates) '
'must be provided in AnatomicalCoordinatesTable.__init__ '
'if the "target_object" column is not in "columns".')
kwargs["target_tables"] = {"target_object": target}
'if the "localized_entity" column is not in "columns".')
kwargs["target_tables"] = {"localized_entity": target}

super().__init__(**kwargs)
6 changes: 3 additions & 3 deletions src/pynwb/tests/test_anatomical_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_create_anatomical_coordinates_table():
method="method",
space=space,
)
[table.add_row(x=1.0, y=2.0, z=3.0, brain_region="CA1", target_object=x) for x in range(5)]
[table.add_row(x=1.0, y=2.0, z=3.0, brain_region="CA1", localized_entity=x) for x in range(5)]

localization.add_anatomical_coordinates_tables([table])

Expand All @@ -43,10 +43,10 @@ def test_create_anatomical_coordinates_table():

assert read_coordinates_table.method == "method"
assert read_coordinates_table.description == "Anatomical coordinates table"
assert read_coordinates_table.target_object.table is read_electrodes_table
assert read_coordinates_table.localized_entity.table is read_electrodes_table
assert read_coordinates_table.space.fields == Space.get_predefined_space("CCFv3").fields
npt.assert_array_equal(read_coordinates_table["x"].data[:], np.array([1.0, 1.0, 1.0, 1.0, 1.0]))
npt.assert_array_equal(read_coordinates_table["y"].data[:], np.array([2.0, 2.0, 2.0, 2.0, 2.0]))
npt.assert_array_equal(read_coordinates_table["z"].data[:], np.array([3.0, 3.0, 3.0, 3.0, 3.0]))
npt.assert_array_equal(read_coordinates_table["brain_region"].data[:], np.array(["CA1", "CA1", "CA1", "CA1", "CA1"]))
npt.assert_array_equal(read_coordinates_table["target_object"].data[:], np.array([0, 1, 2, 3, 4]))
npt.assert_array_equal(read_coordinates_table["localized_entity"].data[:], np.array([0, 1, 2, 3, 4]))

0 comments on commit d01e51a

Please sign in to comment.