Skip to content

Commit 1f9a0cf

Browse files
authored
Check 2D spaces against list from templateflow (#888)
* Check 2D spaces against list from templateflow. * Add docstring tests.
1 parent d44bae0 commit 1f9a0cf

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

niworkflows/utils/spaces.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
]
4343
"""List of supported nonstandard reference spaces."""
4444

45+
NONSTANDARD_2D_REFERENCES = ["fsnative"]
46+
"""List of supported nonstandard 2D reference spaces."""
4547

4648
FSAVERAGE_DENSITY = {
4749
"fsaverage3": "642",
@@ -117,6 +119,16 @@ class Reference:
117119
>>> Reference('MNIPediatricAsym', {'cohort': 1}).standard
118120
True
119121
122+
>>> # Check dim property
123+
>>> Reference('func').dim
124+
3
125+
>>> Reference('MNI152NLin6Asym').dim
126+
3
127+
>>> Reference('fsnative').dim
128+
2
129+
>>> Reference('onavg').dim
130+
2
131+
120132
>>> # Equality/inequality checks
121133
>>> Reference('func') == Reference('func')
122134
True
@@ -138,6 +150,7 @@ class Reference:
138150
"""
139151

140152
_standard_spaces = tuple(_tfapi.templates())
153+
_spaces_2d = tuple(_tfapi.templates(suffix="sphere"))
141154

142155
space = attr.ib(default=None, type=str)
143156
"""Name designating this space."""
@@ -165,7 +178,7 @@ def __attrs_post_init__(self):
165178
spec["den"] = FSAVERAGE_DENSITY[space]
166179
object.__setattr__(self, "spec", spec)
167180

168-
if self.space.startswith("fs"):
181+
if (self.space in self._spaces_2d) or (self.space in NONSTANDARD_2D_REFERENCES):
169182
object.__setattr__(self, "dim", 2)
170183

171184
if self.space in self._standard_spaces:

0 commit comments

Comments
 (0)