Skip to content

Commit f553349

Browse files
committed
ENH: Rename resample() with apply()
Closes #7
1 parent 9763e62 commit f553349

File tree

5 files changed

+5
-28
lines changed

5 files changed

+5
-28
lines changed

nitransforms/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ def ndim(self):
131131
"""Access the dimensions of the reference space."""
132132
return self.reference.ndim
133133

134-
def resample(self, moving, order=3, mode='constant', cval=0.0, prefilter=True,
135-
output_dtype=None):
134+
def apply(self, moving, order=3, mode='constant', cval=0.0, prefilter=True,
135+
output_dtype=None):
136136
"""
137137
Resample the moving image in reference space.
138138

nitransforms/nonlinear.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -145,26 +145,3 @@ def map(self, x, inverse=False, index=0):
145145
# def _map_voxel(self, index, moving=None):
146146
# """Apply ijk' = f_ijk((i, j, k)), equivalent to the above with indexes."""
147147
# return tuple(self._moving[index + self.__s])
148-
149-
# def resample(self, moving, order=3, mode='constant', cval=0.0, prefilter=True,
150-
# output_dtype=None):
151-
# """
152-
# Resample the ``moving`` image applying the deformation field.
153-
154-
# Examples
155-
# --------
156-
# >>> ref = nb.load(os.path.join(datadir, 'someones_anatomy.nii.gz'))
157-
# >>> coeffs = np.zeros((6, 6, 6, 3))
158-
# >>> coeffs[2, 2, 2, ...] = [10.0, -20.0, 0]
159-
# >>> aff = ref.affine
160-
# >>> aff[:3, :3] = aff[:3, :3].dot(np.eye(3) * np.array(
161-
# ... ref.header.get_zooms()[:3]) / 6.0
162-
# ... )
163-
# >>> coeffsimg = nb.Nifti1Image(coeffs, ref.affine, ref.header)
164-
# >>> xfm = BSplineFieldTransform(ref, coeffsimg) # doctest: +SKIP
165-
# >>> new = xfm.resample(ref) # doctest: +SKIP
166-
167-
# """
168-
# self._cache_moving()
169-
# return super(BSplineFieldTransform, self).resample(
170-
# moving, order=order, mode=mode, cval=cval, prefilter=prefilter)

nitransforms/tests/test_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def _to_hdf5(klass, x5_root):
6262
xfm = TransformBase()
6363
xfm.reference = fname
6464
assert xfm.ndim == 3
65-
moved = xfm.resample(fname, order=0)
65+
moved = xfm.apply(fname, order=0)
6666
assert np.all(nb.load(fname).get_fdata() == moved.get_fdata())
6767

6868
xfm.to_filename('data.x5')

nitransforms/tests/test_linear.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def test_apply_linear_transform(
151151
assert exit_code == 0
152152
sw_moved = nb.load('resampled.nii.gz')
153153

154-
nt_moved = xfm.resample(img, order=0)
154+
nt_moved = xfm.apply(img, order=0)
155155
diff = sw_moved.get_fdata() - nt_moved.get_fdata()
156156
# A certain tolerance is necessary because of resampling at borders
157157
assert (np.abs(diff) > 1e-3).sum() / diff.size < TESTS_BORDER_TOLERANCE

nitransforms/tests/test_nonlinear.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def test_displacements_field(tmp_path, data_path, sw_tool):
5959
assert exit_code == 0
6060
sw_moved = nb.load('resampled.nii.gz')
6161

62-
nt_moved = xfm.resample(img_fname, order=0)
62+
nt_moved = xfm.apply(img_fname, order=0)
6363
nt_moved.to_filename('nt_resampled.nii.gz')
6464
diff = sw_moved.get_fdata() - nt_moved.get_fdata()
6565
# A certain tolerance is necessary because of resampling at borders

0 commit comments

Comments
 (0)