class_docstr: A class to implement some FFT smoothers for Image objects.
  By default, this does a Gaussian kernel smooth. More choices
  would be better!
class_docstr_tok: ["A","class","to","implement","some","FFT","smoothers","for","Image","objects",".","By","default",",","this","does","a","Gaussian","kernel","smooth",".","More","choices","would","be","better","!"]
code: def _setup_kernel(self):
      if not isinstance(self.coordmap, AffineTransform):
          raise ValueError(
              "for FFT smoothing, we need a "
              "regular (affine) coordmap"
          )
      # voxel indices of array implied by shape
      voxels = np.indices(self.bshape).astype(np.float64)
      # coordinates of physical center.  XXX - why the 'floor' here?
      vox_center = np.floor((np.array(self.bshape) - 1) / 2.0)
      phys_center = self.coordmap(vox_center)
      # reshape to (N coordinates, -1).  We appear to need to assign
      # to shape instead of doing a reshape, in order to avoid memory
      # copies
      voxels.shape = (voxels.shape[0], seq_prod(voxels.shape[1:]))
      # physical coordinates relative to center
      X = (self.coordmap(voxels.T) - phys_center).T
      X.shape = (self.coordmap.ndims[1],) + tuple(self.bshape)
      # compute kernel from these positions
      kernel = self(X, axis=0)
      kernel = _crop(kernel)
      self.norms = {
          "l2": np.sqrt((kernel**2).sum()),
          "l1": np.fabs(kernel).sum(),
          "l1sum": kernel.sum(),
      }
      self._kernel = kernel
      self.shape = (
          np.ceil(
              (np.asarray(self.bshape) + np.asarray(kernel.shape)) / 2
          )
          * 2
          + 2
      ).astype(np.intp)
      self.fkernel = np.zeros(self.shape)
      slices = [
          slice(0, kernel.shape[i]) for i in range(len(kernel.shape))
      ]
      self.fkernel[tuple(slices)] = kernel
      self.fkernel = fft.rfftn(self.fkernel)
      return kernel
  
file_path: nipy/nipy/algorithms/kernel_smooth.py
imports: import gc
  import numpy
  import numpy.linalg
  from numpy import fft
  from nipy.core.api import AffineTransform, Image
  from nipy.core.reference.coordinate_map import product
  from nipy.utils import seq_prod
label_desc: Use image node_id 2 for calling the LinearFilter obj's underlying member method code with example usage: obj._setup_kernel() and returns: kernel