code: def gibbs_removal(
      vol, slice_axis=2, n_points=3, inplace=True, num_processes=1
  ):
      """Suppresses Gibbs ringing artefacts of images volumes.
  
      Parameters
      ----------
      vol : ndarray ([X, Y]), ([X, Y, Z]) or ([X, Y, Z, g])
          Matrix containing one volume (3D) or multiple (4D) volumes of images.
      slice_axis : int (0, 1, or 2)
          Data axis corresponding to the number of acquired slices.
          Default is set to the third axis.
      n_points : int, optional
          Number of neighbour points to access local TV (see note).
          Default is set to 3.
      inplace : bool, optional
          If True, the input data is replaced with results. Otherwise, returns
          a new array.
          Default is set to True.
      num_processes : int or None, optional
          Split the calculation to a pool of children processes. This only
          applies to 3D or 4D `data` arrays. Default is 1. If < 0 the maximal
          number of cores minus ``num_processes + 1`` is used (enter -1 to use
          as many cores as possible). 0 raises an error.
  
      Returns
      -------
      vol : ndarray ([X, Y]), ([X, Y, Z]) or ([X, Y, Z, g])
          Matrix containing one volume (3D) or multiple (4D) volumes of corrected
          images.
  
      Notes
      -----
      For 4D matrix last element should always correspond to the number of
      diffusion gradient directions.
  
      References
      ----------
      Please cite the following articles
      .. [1] Neto Henriques, R., 2018. Advanced Methods for Diffusion MRI Data
             Analysis and their Application to the Healthy Ageing Brain
             (Doctoral thesis). https://doi.org/10.17863/CAM.29356
      .. [2] Kellner E, Dhital B, Kiselev VG, Reisert M. Gibbs-ringing artifact
             removal based on local subvoxel-shifts. Magn Reson Med. 2016
             doi: 10.1002/mrm.26054.
  
      """
      nd = vol.ndim
  
      # check matrix dimension
      if nd > 4:
          raise ValueError("Data have to be a 4D, 3D or 2D matrix")
      elif nd < 2:
          raise ValueError("Data is not an image")
  
      if not isinstance(inplace, bool):
          raise TypeError("inplace must be a boolean.")
  
      num_processes = determine_num_processes(num_processes)
  
      # check the axis corresponding to different slices
      # 1) This axis cannot be larger than 2
      if slice_axis > 2:
          raise ValueError(
              "Different slices have to be organized along"
              + "one of the 3 first matrix dimensions"
          )
  
      # 2) Reorder axis to allow iteration over the first axis
      elif nd == 3:
          vol = np.moveaxis(vol, slice_axis, 0)
      elif nd == 4:
          vol = np.moveaxis(vol, (slice_axis, 3), (0, 1))
  
      if nd == 4:
          inishap = vol.shape
          vol = vol.reshape(
              (inishap[0] * inishap[1], inishap[2], inishap[3])
          )
  
      # Produce weighting functions for 2D Gibbs removal
      shap = vol.shape
      G0, G1 = _weights(shap[-2:])
  
      # Copy data if not inplace
      if not inplace:
          vol = vol.copy()
  
      # Run Gibbs removal of 2D images
      if nd == 2:
          vol[:, :] = _gibbs_removal_2d(
              vol, n_points=n_points, G0=G0, G1=G1
          )
      else:
          pool = Pool(num_processes)
  
          partial_func = partial(
              _gibbs_removal_2d, n_points=n_points, G0=G0, G1=G1
          )
          vol[:, :, :] = pool.map(partial_func, vol)
          pool.close()
          pool.join()
  
      # Reshape data to original format
      if nd == 3:
          vol = np.moveaxis(vol, 0, slice_axis)
      if nd == 4:
          vol = vol.reshape(inishap)
          vol = np.moveaxis(vol, (0, 1), (slice_axis, 3))
  
      return vol
  
file_path: dipy/dipy/denoise/gibbs.py
imports: from functools import partial
  from multiprocessing import Pool
  import numpy
  import scipy
  from dipy.utils.multiproc import determine_num_processes
  from dipy.utils.deprecator import deprecated_params
  import scipy.fft
label_desc: Use image node_id 5 for calling a global function with example usage: gibbs_removal(vol, slice_axis, n_points, inplace, num_processes) and returns: vol