@@ -115,10 +115,13 @@ def resample_from_to(from_img,
115115 to_vox_map ,
116116 order = 3 ,
117117 mode = 'constant' ,
118- cval = 0. ,
118+ cval = 0. ,
119119 out_class = Nifti1Image ):
120120 """ Resample image `from_img` to mapped voxel space `to_vox_map`
121121
122+ Resample using N-d spline interpolation (where N is given by the `order`
123+ argument).
124+
122125 Parameters
123126 ----------
124127 from_img : object
@@ -168,17 +171,17 @@ def resample_from_to(from_img,
168171 rzs ,
169172 trans ,
170173 to_shape ,
171- order = order ,
172- mode = mode ,
173- cval = cval )
174+ order = order ,
175+ mode = mode ,
176+ cval = cval )
174177 return out_class (data , to_affine , from_img .header )
175178
176179
177180def resample_to_output (in_img ,
178- voxel_sizes = None ,
181+ voxel_sizes = None ,
179182 order = 3 ,
180183 mode = 'constant' ,
181- cval = 0. ,
184+ cval = 0. ,
182185 out_class = Nifti1Image ):
183186 """ Resample image `in_img` to output voxel axes (world space)
184187
@@ -190,15 +193,16 @@ def resample_to_output(in_img,
190193 an image from data, affine and header.
191194 voxel_sizes : None or sequence
192195 Gives the diagonal entries of ``out_img.affine` (except the trailing 1
193- for the homogenous coordinates) (``out_img.affine == np.diag(voxel_sizes
194- + [1])``). If None, return identity `out_img.affine`.
196+ for the homogenous coordinates) (``out_img.affine ==
197+ np.diag(voxel_sizes + [1])``). If None, return identity
198+ `out_img.affine`.
195199 order : int, optional
196200 The order of the spline interpolation, default is 3. The order has to
197201 be in the range 0-5 (see ``scipy.ndimage.affine_transform``).
198202 mode : str, optional
199- Points outside the boundaries of the input are filled according
200- to the given mode ('constant', 'nearest', 'reflect' or 'wrap').
201- Default is 'constant' (see ``scipy.ndimage.affine_transform``).
203+ Points outside the boundaries of the input are filled according to the
204+ given mode ('constant', 'nearest', 'reflect' or 'wrap'). Default is
205+ 'constant' (see ``scipy.ndimage.affine_transform``).
202206 cval : scalar, optional
203207 Value used for points outside the boundaries of the input if
204208 ``mode='constant'``. Default is 0.0 (see
@@ -219,11 +223,11 @@ def resample_to_output(in_img,
219223 # looks like when resampled into world coordinates
220224 in_shape = in_img .shape
221225 n_dim = len (in_shape )
222- if n_dim < 3 : # Expand image to 3D, make voxel sizes match
226+ if n_dim < 3 : # Expand image to 3D, make voxel sizes match
223227 new_shape = in_shape + (1 ,) * (3 - n_dim )
224- data = in_img .get_data ().reshape (new_shape ) # 2D data should be small
228+ data = in_img .get_data ().reshape (new_shape ) # 2D data should be small
225229 in_img = out_class (data , in_img .affine , in_img .header )
226- if not voxel_sizes is None and len (voxel_sizes ) == n_dim :
230+ if voxel_sizes is not None and len (voxel_sizes ) == n_dim :
227231 # Need to pad out voxel sizes to match new image dimensions
228232 voxel_sizes = tuple (voxel_sizes ) + (1 ,) * (3 - n_dim )
229233 out_vox_map = vox2out_vox ((in_img .shape , in_img .affine ), voxel_sizes )
@@ -232,8 +236,8 @@ def resample_to_output(in_img,
232236
233237def smooth_image (img ,
234238 fwhm ,
235- mode = 'nearest' ,
236- cval = 0. ,
239+ mode = 'nearest' ,
240+ cval = 0. ,
237241 out_class = Nifti1Image ):
238242 """ Smooth image `img` along voxel axes by FWHM `fwhm` millimeters
239243
@@ -291,6 +295,6 @@ def smooth_image(img,
291295 # Do the smoothing
292296 sm_data = spnd .gaussian_filter (img .dataobj ,
293297 vox_sd ,
294- mode = mode ,
295- cval = cval )
298+ mode = mode ,
299+ cval = cval )
296300 return out_class (sm_data , img .affine , img .header )
0 commit comments