code: def swap_img_hemispheres(img):
      """Perform swapping of hemispheres in the indicated NIfTI image.
  
         Use case: synchronizing ROIs across hemispheres.
  
      Parameters
      ----------
      img : Niimg-like object
          Images to swap (see :ref:`extracting_data` for a detailed description
          of the valid input types).
  
      Returns
      -------
      :class:`~nibabel.nifti1.Nifti1Image`
          Hemispherically swapped image.
  
      Notes
      -----
      Assumes that the image is sagitally aligned.
  
      Should be used with caution (confusion might be caused with
      radio/neuro conventions)
  
      Note that this does not require a change of the affine matrix.
  
      """
      from .resampling import reorder_img
  
      # Check input is really a path to a nifti file or a nifti object
      img = check_niimg_3d(img)
  
      # get nifti in x-y-z order
      img = reorder_img(img)
  
      # create swapped nifti object
      out_img = new_img_like(
          img, get_data(img)[::-1], img.affine, copy_header=True
      )
  
      return out_img
  
imports: import collections.abc
  import copy
  import itertools
  import warnings
  import nibabel
  import numpy
  from joblib import Memory, Parallel, delayed
  from scipy.ndimage import gaussian_filter1d, generate_binary_structure, label
  from scipy.stats import scoreatpercentile
  from ..None import signal
  from .._utils import _repr_niimgs, as_ndarray, check_niimg, check_niimg_3d, check_niimg_4d, fill_doc
  from .._utils.exceptions import DimensionError
  from .._utils.helpers import rename_parameters, stringify_path
  from .._utils.niimg import _get_data, safe_get_data
  from .._utils.niimg_conversions import _index_img, check_same_fov, iter_check_niimg
  from .._utils.param_validation import check_threshold
  from .._utils.path_finding import resolve_globbing
label_desc: Use image node_id 11 for calling a global function with example usage: swap_img_hemispheres(img) and returns: out_img