def _smooth_data_array(arr, affine, fwhm, copy=True):
if arr.dtype.kind == '<STR_LIT:i>':<EOL><INDENT>if arr.dtype == np.int64:<EOL><INDENT>arr = arr.astype(np.float64)<EOL><DEDENT>else:<EOL><INDENT>arr = arr.astype(np.float32)<EOL><DEDENT><DEDENT>if copy:<EOL><INDENT>arr = arr.copy()<EOL><DEDENT>arr[np.logical_not(np.isfinite(arr))] = <NUM_LIT:0><EOL>try:<EOL><INDENT>affine = affine[:<NUM_LIT:3>, :<NUM_LIT:3>]<EOL>fwhm_sigma_ratio = np.sqrt(<NUM_LIT:8> * np.log(<NUM_LIT:2>))<EOL>vox_size         = np.sqrt(np.sum(affine ** <NUM_LIT:2>, axis=<NUM_LIT:0>))<EOL>sigma            = fwhm / (fwhm_sigma_ratio * vox_size)<EOL>for n, s in enumerate(sigma):<EOL><INDENT>ndimage.gaussian_filter1d(arr, s, output=arr, axis=n)<EOL><DEDENT><DEDENT>except:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>return arr<EOL><DEDENT>
Smooth images with a a Gaussian filter.

    Apply a Gaussian filter along the three first dimensions of arr.

    Parameters
    ----------
    arr: numpy.ndarray
        3D or 4D array, with image number as last dimension.

    affine: numpy.ndarray
        Image affine transformation matrix for image.

    fwhm: scalar, numpy.ndarray
        Smoothing kernel size, as Full-Width at Half Maximum (FWHM) in millimeters.
        If a scalar is given, kernel width is identical on all three directions.
        A numpy.ndarray must have 3 elements, giving the FWHM along each axis.

    copy: bool
        if True, will make a copy of the input array. Otherwise will directly smooth the input array.

    Returns
    -------
    smooth_arr: numpy.ndarray