Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check 2D spaces against list from templateflow #888

Merged
merged 2 commits into from
Aug 5, 2024
Merged
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
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
Loading