code: def xminus1d(img, fun, dim, *args, **kwargs):
      r"""
      Applies the function fun along all X-1D dimensional volumes of the images img
      dimension dim.
  
      E.g. you want to apply a gauss filter to each slice of a 3D MRI brain image,
      simply supply the function as fun, the image as img and the dimension along which
      to iterate as dim.
  
      Parameters
      ----------
      img : ndarray
          The image to apply the function ``fun`` to.
      fun : function
          A image modification function.
      dim : integer
          The dimension along which to apply the function.
  
      Returns
      -------
      output : ndarray
          The result of the operation over the image ``img``.
  
      Notes
      -----
      With ``*args`` and ``**kwargs``, arguments can be passed to the function ``fun``.
      """
      slicer = [slice(None)] * img.ndim
      output = []
      for slid in range(img.shape[dim]):
          slicer[dim] = slice(slid, slid + 1)
          output.append(
              fun(numpy.squeeze(img[slicer]), *args, **kwargs)
          )
      return numpy.rollaxis(numpy.asarray(output), 0, dim + 1)
  
imports: import numpy
  from scipy.ndimage import _ni_support
  from ..io import header
label_desc: Use image node_id 1 for calling a global function with example usage: xminus1d(img, fun, dim) and returns: numpy