Skip to content

Commit

Permalink
enh: define ndim on nonlinear transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
oesteban committed May 16, 2024
1 parent 592f91b commit 91f7ae2
Showing 1 changed file with 10 additions and 0 deletions.
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

0 comments on commit 91f7ae2

Please sign in to comment.