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

ENH: Define ndim property on nonlinear transforms #201

Merged
merged 1 commit into from
May 16, 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
10 changes: 10 additions & 0 deletions nitransforms/nonlinear.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ def __repr__(self):
"""Beautify the python representation."""
return f"<{self.__class__.__name__}[{self._field.shape[-1]}D] {self._field.shape[:3]}>"

@property
def ndim(self):
"""Get the dimensions of the transform."""
return self._field.ndim - 1

def map(self, x, inverse=False):
r"""
Apply the transformation to a list of physical coordinate points.
Expand Down Expand Up @@ -257,6 +262,11 @@ def __init__(self, coefficients, reference=None, order=3):
'Number of components of the coefficients does '
'not match the number of dimensions')

@property
def ndim(self):
"""Get the dimensions of the transform."""
return self._coeffs.ndim - 1

def to_field(self, reference=None, dtype="float32"):
"""Generate a displacements deformation field from this B-Spline field."""
_ref = (
Expand Down
Loading