2525from .affines import AffineError , to_matvec , from_matvec , append_diag
2626from .spaces import vox2out_vox
2727from .nifti1 import Nifti1Image
28+ from .imageclasses import spatial_axes_first
2829
2930SIGMA2FWHM = np .sqrt (8 * np .log (2 ))
3031
@@ -124,9 +125,9 @@ def resample_from_to(from_img,
124125 Parameters
125126 ----------
126127 from_img : object
127- Object having attributes ``dataobj``, ``affine``, ``header``. If
128- `out_class` is not None, ``img.__class__`` should be able to construct
129- an image from data, affine and header.
128+ Object having attributes ``dataobj``, ``affine``, ``header`` and
129+ ``shape``. If ` out_class` is not None, ``img.__class__`` should be able
130+ to construct an image from data, affine and header.
130131 to_vox_map : image object or length 2 sequence
131132 If object, has attributes ``shape`` giving input voxel shape, and
132133 ``affine`` giving mapping of input voxels to output space. If length 2
@@ -153,6 +154,10 @@ def resample_from_to(from_img,
153154 resampling `from_img` into axes aligned to the output space of
154155 ``from_img.affine``
155156 """
157+ # This check requires `shape` attribute of image
158+ if not spatial_axes_first (from_img ):
159+ raise ValueError ('Cannot predict position of spatial axes for Image '
160+ 'type ' + str (type (from_img )))
156161 try :
157162 to_shape , to_affine = to_vox_map .shape , to_vox_map .affine
158163 except AttributeError :
@@ -248,9 +253,9 @@ def smooth_image(img,
248253 Parameters
249254 ----------
250255 img : object
251- Object having attributes ``dataobj``, ``affine``, ``header``. If
252- `out_class` is not None, ``img.__class__`` should be able to construct
253- an image from data, affine and header.
256+ Object having attributes ``dataobj``, ``affine``, ``header`` and
257+ ``shape``. If ` out_class` is not None, ``img.__class__`` should be able
258+ to construct an image from data, affine and header.
254259 fwhm : scalar or length 3 sequence
255260 FWHM *in mm* over which to smooth. The smoothing applies to the voxel
256261 axes, not to the output axes, but is in millimeters. The function
@@ -280,6 +285,10 @@ def smooth_image(img,
280285 Image of instance specified by `out_class`, containing data output from
281286 smoothing `img` data by given FWHM kernel.
282287 """
288+ # This check requires `shape` attribute of image
289+ if not spatial_axes_first (img ):
290+ raise ValueError ('Cannot predict position of spatial axes for Image '
291+ 'type ' + str (type (img )))
283292 if out_class is None :
284293 out_class = img .__class__
285294 n_dim = len (img .shape )
0 commit comments