code: def shifted_domain_origin(mapping, difference_vector, new_origin):
      """Shift the origin of the domain
  
      Parameters
      ----------
      difference_vector : array
         Representing the difference shifted_origin-current_origin in the
         domain's basis.
  
      Examples
      --------
      >>> A = np.random.standard_normal((5,6))
      >>> A[-1] = [0,0,0,0,0,1]
      >>> affine_transform = AffineTransform(CS('ijklm', 'oldorigin'), CS('xyzt'), A)
      >>> affine_transform.function_domain
      CoordinateSystem(coord_names=('i', 'j', 'k', 'l', 'm'), name='oldorigin', coord_dtype=float64)
  
      A random change of origin
  
      >>> difference = np.random.standard_normal(5)
  
      The same affine transformation with a different origin for its domain
  
      >>> shifted_affine_transform = shifted_domain_origin(affine_transform, difference, 'neworigin')
      >>> shifted_affine_transform.function_domain
      CoordinateSystem(coord_names=('i', 'j', 'k', 'l', 'm'), name='neworigin', coord_dtype=float64)
  
      Let's check that things work
  
      >>> point_in_old_basis = np.random.standard_normal(5)
  
      This is the relation ship between coordinates in old and new origins
  
      >>> np.allclose(shifted_affine_transform(point_in_old_basis), affine_transform(point_in_old_basis+difference))
      True
      >>> np.allclose(shifted_affine_transform(point_in_old_basis-difference), affine_transform(point_in_old_basis))
      True
      """
      new_function_domain = CoordinateSystem(
          mapping.function_domain.coord_names,
          new_origin,
          coord_dtype=mapping.function_domain.coord_dtype,
      )
  
      ndim = new_function_domain.ndim
      shift_matrix = np.identity(
          ndim + 1, mapping.function_domain.coord_dtype
      )
      shift_matrix[:-1, -1] = np.array(difference_vector)
      shift_map = AffineTransform(
          new_function_domain, mapping.function_domain, shift_matrix
      )
  
      if isinstance(mapping, AffineTransform):
          return _compose_affines(mapping, shift_map)
      else:
          return _compose_cmaps(mapping, _as_coordinate_map(shift_map))
  
imports: import warnings
  import numpy
  import numpy.linalg
  from nibabel import io_orientation
  from nibabel.affines import from_matvec, to_matvec
  from .coordinate_system import CoordinateSystem, is_coordsys, safe_dtype
  from .coordinate_system import product
label_desc: Use image node_id 4 for calling a global function with example usage: shifted_domain_origin(mapping, difference_vector, new_origin) and returns: _compose_affines, _compose_cmaps