Skip to content

Commit

Permalink
Check 2D spaces against list from templateflow (#888)
Browse files Browse the repository at this point in the history
* Check 2D spaces against list from templateflow.

* Add docstring tests.
  • Loading branch information
tsalo authored Aug 5, 2024
1 parent d44bae0 commit 1f9a0cf
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion niworkflows/utils/spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
]
"""List of supported nonstandard reference spaces."""

NONSTANDARD_2D_REFERENCES = ["fsnative"]
"""List of supported nonstandard 2D reference spaces."""

FSAVERAGE_DENSITY = {
"fsaverage3": "642",
Expand Down Expand Up @@ -117,6 +119,16 @@ class Reference:
>>> Reference('MNIPediatricAsym', {'cohort': 1}).standard
True
>>> # Check dim property
>>> Reference('func').dim
3
>>> Reference('MNI152NLin6Asym').dim
3
>>> Reference('fsnative').dim
2
>>> Reference('onavg').dim
2
>>> # Equality/inequality checks
>>> Reference('func') == Reference('func')
True
Expand All @@ -138,6 +150,7 @@ class Reference:
"""

_standard_spaces = tuple(_tfapi.templates())
_spaces_2d = tuple(_tfapi.templates(suffix="sphere"))

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

if self.space.startswith("fs"):
if (self.space in self._spaces_2d) or (self.space in NONSTANDARD_2D_REFERENCES):
object.__setattr__(self, "dim", 2)

if self.space in self._standard_spaces:
Expand Down

0 comments on commit 1f9a0cf

Please sign in to comment.