7
7
#
8
8
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
9
9
"""Nonlinear transforms."""
10
- import sys
10
+ from warnings import warn
11
11
import numpy as np
12
12
from scipy import ndimage as ndi
13
13
# from gridbspline.maths import cubic
21
21
class DeformationFieldTransform (TransformBase ):
22
22
"""Represents a dense field of displacements (one vector per voxel)."""
23
23
24
- __slots__ = ['_field' , '_moving' , '_moving_space' ]
24
+ __slots__ = ['_field' ]
25
25
26
26
def __init__ (self , field , reference = None ):
27
27
"""Create a dense deformation field transform."""
@@ -34,9 +34,6 @@ def __init__(self, field, reference=None):
34
34
'Number of components of the deformation field does '
35
35
'not match the number of dimensions' )
36
36
37
- self ._moving = None # Where each voxel maps to
38
- self ._moving_space = None # Input space cache
39
-
40
37
# By definition, a free deformation field has a
41
38
# displacement vector per voxel in output (reference)
42
39
# space
@@ -87,8 +84,7 @@ def map(self, x, inverse=False, index=0):
87
84
ijk = self .reference .index (x )
88
85
indexes = np .round (ijk ).astype ('int' )
89
86
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.' )
92
88
indexes = tuple (tuple (i ) for i in indexes .T )
93
89
return x + self ._field [indexes ]
94
90
0 commit comments