Skip to content

Commit d31c55e

Browse files
committed
fix: use warnings, remove unused slots
1 parent a4f1655 commit d31c55e

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

nitransforms/nonlinear.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
99
"""Nonlinear transforms."""
10-
import sys
10+
from warnings import warn
1111
import numpy as np
1212
from scipy import ndimage as ndi
1313
# from gridbspline.maths import cubic
@@ -21,7 +21,7 @@
2121
class DeformationFieldTransform(TransformBase):
2222
"""Represents a dense field of displacements (one vector per voxel)."""
2323

24-
__slots__ = ['_field', '_moving', '_moving_space']
24+
__slots__ = ['_field']
2525

2626
def __init__(self, field, reference=None):
2727
"""Create a dense deformation field transform."""
@@ -34,9 +34,6 @@ def __init__(self, field, reference=None):
3434
'Number of components of the deformation field does '
3535
'not match the number of dimensions')
3636

37-
self._moving = None # Where each voxel maps to
38-
self._moving_space = None # Input space cache
39-
4037
# By definition, a free deformation field has a
4138
# displacement vector per voxel in output (reference)
4239
# space
@@ -87,8 +84,7 @@ def map(self, x, inverse=False, index=0):
8784
ijk = self.reference.index(x)
8885
indexes = np.round(ijk).astype('int')
8986
if np.any(np.abs(ijk - indexes) > 0.05):
90-
print('Some coordinates are off-grid of the displacements field.',
91-
file=sys.stderr)
87+
warn('Some coordinates are off-grid of the displacements field.')
9288
indexes = tuple(tuple(i) for i in indexes.T)
9389
return x + self._field[indexes]
9490

0 commit comments

Comments
 (0)