code: def find_maxsep_cut_coords(
      map3d, affine, slicer="z", n_cuts=None, threshold=None
  ):
      """Heuristic finds `n_cuts` with max separation along a given axis
  
      Parameters
      ----------
      map3d : 3D array
          the data under consideration
      affine : array shape (4, 4)
          Affine mapping between array coordinates of `map3d` and real-world
          coordinates.
      slicer : string, optional
          sectional slicer; possible values are "x", "y", or "z"
      n_cuts : None or int >= 1, optional
          Number of cuts in the plot; if None, then a default value of 5 is
          forced.
      threshold : None or float, optional
          Thresholding to be applied to the map.  Values less than `threshold`
          set to 0.  If None, no thresholding applied.
  
      Returns
      -------
      cuts : 1D array of length `n_cuts`
          the computed cuts
  
      Raises
      ------
      ValueError:
          If `slicer` not in 'xyz'
      ValueError
          If `ncuts` < 1
      """
      if n_cuts is None:
          n_cuts = 5
      if n_cuts < 1:
          raise ValueError("n_cuts = %i < 1 is senseless." % n_cuts)
      # sanitize slicer
      if slicer not in "xyz":
          raise ValueError(
              f"slicer must be one of 'x', 'y', and 'z', got '{slicer}'."
          )
      slicer = "xyz".index(slicer)
  
      # load data
      if map3d.ndim != 3:
          raise TypeError(
              "map3d must be 3D array, got shape %iD" % map3d.ndim
          )
  
      _map3d = np.rollaxis(map3d.copy(), slicer, start=3)
      _map3d = np.abs(_map3d)
      if threshold is not None:
          _map3d[_map3d < threshold] = 0
  
      # count activated voxels per plane
      n_activated_voxels_per_plane = np.array(
          [(_map3d[..., z] > 0).sum() for z in range(_map3d.shape[-1])]
      )
      perm = np.argsort(n_activated_voxels_per_plane)
      n_activated_voxels_per_plane = n_activated_voxels_per_plane[perm]
      good_planes = np.nonzero(n_activated_voxels_per_plane > 0)[0]
      good_planes = perm[::-1][: n_cuts * 4 if n_cuts > 1 else 1]
  
      # cast into coord space
      good_planes = np.array(
          [
              # map cut coord into native space
              np.dot(
                  affine,
                  np.array([0, 0, 0, 1])  # origin
                  + coord * np.eye(4)[slicer],
              )[slicer]
              for coord in good_planes
          ]
      )
  
      # compute cut_coords maximally-separated planes
      return _maximally_separated_subset(good_planes, n_cuts)
  
file_path: nipy/nipy/labs/viz_tools/coord_tools.py
imports: import warnings
  import numpy
  from scipy import ndimage, stats
  from ..datasets.transforms.affine_utils import get_bounds
  from ..mask import largest_cc
label_desc: Use image node_id 5 for calling a global function with example usage: find_maxsep_cut_coords(map3d, affine, slicer, n_cuts, threshold) and returns: _maximally_separated_subset