code: def bounding_box(coordmap, shape):
      """
      Determine a valid bounding box from a CoordinateMap
      and a shape.
  
      Parameters
      ----------
      coordmap : CoordinateMap or AffineTransform
         Containing mapping between voxel coordinates implied by `shape` and
         physical coordinates.
      shape : sequence of int
         shape implying array
  
      Returns
      -------
      limits : (N,) tuple of (2,) tuples of float
         minimum and maximum coordinate values in output space (range) of
         `coordmap`. N is given by coordmap.ndim[1].
  
      Examples
      --------
      Make a 3D voxel to mni coordmap
  
      >>> from nipy.core.api import vox2mni
      >>> affine = np.array([[1, 0, 0, 2],
      ...                    [0, 3, 0, 4],
      ...                    [0, 0, 5, 6],
      ...                    [0, 0, 0, 1]], dtype=np.float64)
      >>> A = vox2mni(affine)
      >>> bounding_box(A, (30,40,20))
      ((2.0, 31.0), (4.0, 121.0), (6.0, 101.0))
      """
      e = ArrayCoordMap.from_shape(coordmap, shape)
      return tuple([(r.min(), r.max()) for r in e.transposed_values])
  
file_path: nipy/nipy/core/reference/slices.py
imports: import numpy
  from nibabel.affines import from_matvec
  from .array_coords import ArrayCoordMap
  from .coordinate_map import AffineTransform
  from .coordinate_system import CoordinateSystem
  from .spaces import get_world_cs
label_desc: Use image node_id 4 for calling a global function with example usage: bounding_box(coordmap, shape) and returns: tuple