Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# output NWB files
*.nwb

.idea
.vscode

# generated docs
docs/source/_format_auto_docs

Expand Down
28 changes: 19 additions & 9 deletions spec/ndx-anatomical-localization.extensions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,40 @@ groups:
doc: "A space in which the coordinates are defined"
- neurodata_type_def: Space
neurodata_type_inc: NWBContainer
doc: "a space"
doc: >
This class defines a space in which coordinates are defined. It defines a reference image and the orientation
and origin of the axes. The default space is CCFv3 with BrainGlobe coordinates."
attributes:
- name: "space_name"
doc: "name of the space"
dtype: text
required: true
- name: origin
doc: "A description of where (0,0,0) is in the space. For example, 'bregma' is a common origin for mice."
doc: >
A description of where (0,0,0) is in the space. For example, 'bregma' is a common origin for mice.
If omitted, it is assumed to be the corner opposite to the orientation. e.g. if the orientation is 'PIL'
(posterior, inferior, left; the default), the origin is assumed to be the anterior, superior, right corner.
For BrainGlobe, this value is not needed, but it is needed if you want to use, for example, IBL coordinates.
dtype: text
required: true
required: false
- name: units
doc: "The units of measurement for the x,y,z coordinates. For example, 'mm' for millimeters."
dtype: text
required: true
- name: orientation
doc: "A 3-letter string. One of A,P,L,R,S,I for each of x, y, and z. For example, the most common
orientation is 'RAS', which means x is right, y is anterior, and z is superior (a.k.a. dorsal).
For dorsal/ventral use 'S/I' (superior/inferior). In the AnatomicalCoordinatesTable, an orientation of
'RAS' corresponds to coordinates in the order of (ML (x), AP (y), DV (z))."
doc: >
A 3-letter string. One of A,P,L,R,S,I for each of x, y, and z. For example, default is 'PIL', which means
x is posterior, y is inferior (i.e. ventral), and z is left. For dorsal/ventral use 'S/I' (superior/inferior).
The default is 'PIL', which is the standard for BrainGlobe."
dtype: text
required: true
default_value: "PIL"
- neurodata_type_def: AnatomicalCoordinatesTable
neurodata_type_inc: DynamicTable
doc: "A table for storing anatomical coordinates for rows of another table determined using a single method"
doc: >
A table for storing anatomical localization of an object in a space. This is done by referencing rows of
another table. This allows for the same object to be localized in multiple spaces or using multiple different
methods.
links:
- target_type: Space
quantity: 1
Expand Down Expand Up @@ -67,4 +77,4 @@ groups:
neurodata_type_inc: VectorData
doc: "The brain region associated with the localization"
dtype: text
quantity: "?"
quantity: "?"
2 changes: 1 addition & 1 deletion spec/ndx-anatomical-localization.namespace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ namespaces:
schema:
- namespace: core
- source: ndx-anatomical-localization.extensions.yaml
version: 0.1.0
version: 0.2.0
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,28 @@ class Space(TempSpace):
@docval(
{"name": "name", "type": str, "doc": "name of the NWB object"},
{"name": "space_name", "type": str, "doc": "name of the space"},
{
"name": "origin",
"type": str,
"doc": "A description of where (0,0,0) is in the space. For example, 'bregma' is a common origin for mice.",
},
{
"name": "units",
"type": str,
"doc": "The units of measurement for the x,y,z coordinates. For example, 'mm' for millimeters.",
},
{
"name": "orientation",
"type": str,
"doc": """A 3-letter string. One of A,P,L,R,S,I for each of x, y, and z. For example, the most common
orientation is 'RAS', which means x is right, y is anterior, and z is superior (a.k.a. dorsal).
For dorsal/ventral use 'S/I' (superior/inferior). In the AnatomicalCoordinatesTable, an orientation of
'RAS' corresponds to coordinates in the order of (ML (x), AP (y), DV (z)).""",
},
dict(
name="origin",
type=str,
doc="""A description of where (0,0,0) is in the space. For example, 'bregma' is a common origin for mice.
Another approach is to use a corner of the atlas bounding box. For example, BrainGlobe uses the anterior,
superior, right corner as the origin for all of their atlases. In this case, you would specify this as 'ASR'.
The orientation should then be the opposite for each letter: 'PIL'. We use this as the default here.""",
default="ASR",
),
dict(
name="units",
type=str,
doc="The units of measurement for the x,y,z coordinates. For example, 'mm' for millimeters.",
),
dict(
name="orientation",
type=str,
doc="""A 3-letter string. One of A,P,L,R,S,I for each of x, y, and z. For example, default is 'PIL', which means
x is posterior, y is inferior (i.e. ventral), and z is left. For dorsal/ventral use 'S/I' (superior/inferior).
The default is 'PIL', which is the standard for BrainGlobe.""",
default="PIL",
),
allow_positional=AllowPositional.ERROR,
)
def __init__(self, name, space_name, origin, units, orientation):
Expand All @@ -54,6 +58,11 @@ def __init__(self, name, space_name, origin, units, orientation):
new_var = [map[var] for var in orientation]
assert len(set(new_var)) == 3, "orientation must be unique dimensions (AP, LR, SI)"

opposites = {"A": "P", "P": "A", "L": "R", "R": "L", "S": "I", "I": "S"}
if len(origin) == 3 and [x in valid_values for x in origin]:
for x,y in zip(origin, orientation):
assert x != opposites[y], "origin and orientation must be in opposite directions"

super().__init__(name=name, space_name=space_name, origin=origin, units=units, orientation=orientation)

@classmethod
Expand Down
Loading