diff --git a/nitransforms/nonlinear.py b/nitransforms/nonlinear.py index 8cfb4a62..79c3aa45 100644 --- a/nitransforms/nonlinear.py +++ b/nitransforms/nonlinear.py @@ -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. @@ -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 = (