Skip to content

Commit e792cef

Browse files
authored
Merge pull request #201 from nipy/enh/add-ndim-nonlinear
ENH: Define ``ndim`` property on nonlinear transforms
2 parents 592f91b + 91f7ae2 commit e792cef

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

nitransforms/nonlinear.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ def __repr__(self):
9898
"""Beautify the python representation."""
9999
return f"<{self.__class__.__name__}[{self._field.shape[-1]}D] {self._field.shape[:3]}>"
100100

101+
@property
102+
def ndim(self):
103+
"""Get the dimensions of the transform."""
104+
return self._field.ndim - 1
105+
101106
def map(self, x, inverse=False):
102107
r"""
103108
Apply the transformation to a list of physical coordinate points.
@@ -257,6 +262,11 @@ def __init__(self, coefficients, reference=None, order=3):
257262
'Number of components of the coefficients does '
258263
'not match the number of dimensions')
259264

265+
@property
266+
def ndim(self):
267+
"""Get the dimensions of the transform."""
268+
return self._coeffs.ndim - 1
269+
260270
def to_field(self, reference=None, dtype="float32"):
261271
"""Generate a displacements deformation field from this B-Spline field."""
262272
_ref = (

0 commit comments

Comments
 (0)