docs: def centerdistance_xdminus1(image, dim, voxelspacing = None, mask = slice(None)):
      r"""
      Implementation of `centerdistance` that allows to compute sub-volume wise
      centerdistances.
      
      The same notes as for `centerdistance` apply.
      
      Parameters
      ----------
      image : array_like or list/tuple of array_like 
          A single image or a list/tuple of images (for multi-spectral case).
      dim : int or sequence of ints
          The dimension or dimensions along which to cut the image into sub-volumes.
      voxelspacing : sequence of floats
          The side-length of each voxel.
      mask : array_like
          A binary mask for the image.
      
      Returns
      -------
      centerdistance_xdminus1 : ndarray
          The distance of each voxel to the images center in the supplied dimensions.
      
      Raises
      ------
      ArgumentError
          If a invalid dim index of number of dim indices were supplied
  
      Examples
      --------
      Considering a 3D medical image we want to compute the axial slice-wise
      centerdistances instead of the ones over the complete image volume. Assuming that
      the third image dimension corresponds to the axial axes of the image, we call
          
      >>> centerdistance_xdminus1(image, 2)
      
      Note that the centerdistance of each slice will be equal.
  
      """
      # pre-process arguments
      if type(image) == tuple or type(image) == list:
          image = image[0]
      
      if type(dim) is int:
          dims = [dim]
      else:
          dims = list(dim)
          
      # check arguments
      if len(dims) >= image.ndim - 1:
          raise ArgumentError('Applying a sub-volume extraction of depth {} on a image of dimensionality {} would lead to invalid images of dimensionality <= 1.'.format(len(dims), image.ndim))
      for dim in dims:
          if dim >= image.ndim:
              raise ArgumentError('Invalid dimension index {} supplied for image(s) of shape {}.'.format(dim, image.shape))
      
      # extract desired sub-volume
      slicer = [slice(None)] * image.ndim
      for dim in dims: slicer[dim] = slice(1)
      subvolume = numpy.squeeze(image[slicer])
      
      # compute centerdistance for sub-volume and reshape to original sub-volume shape (note that normalization and mask are not passed on in this step)
      o = centerdistance(subvolume, voxelspacing).reshape(subvolume.shape)
      
      # re-establish original shape by copying the resulting array multiple times
      for dim in sorted(dims):
          o = numpy.asarray([o] * image.shape[dim])
          o = numpy.rollaxis(o, 0, dim + 1)
          
      # extract intensities / centerdistance values, applying normalization and mask in this step
      return intensities(o, mask)