code: def _maximally_separated_subset(x, k):
      """
      Given a set of n points x = {x_1, x_2, ..., x_n} and a positive integer
      k < n, this function returns a subset of k points which are maximally
      spaced.
  
      Returns
      -------
      msssk: 1D array of k floats
          computed maximally-separated subset of k elements from x
  
      """
  
      # base cases
      if k < 1:
          raise ValueError("k = %i < 1 is senseless." % k)
      if k == 1:
          return [x[len(x) // 2]]
  
      # would-be maximally separated subset of k (not showing the terminal nodes)
      msss = list(range(1, len(x) - 1))
  
      # sorting is necessary for the heuristic to work
      x = np.sort(x)
  
      # iteratively delete points x_j of msss, for which x_(j + 1) - x_(j - 1) is
      # smallest, until only k - 2 points survive
      while len(msss) + 2 > k:
          # survivors
          y = np.array([x[0]] + list(x[msss]) + [x[-1]])
  
          # remove most troublesome point
          msss = np.delete(msss, np.argmin(y[2:] - y[:-2]))
  
      # return maximally separated subset of k elements
      return x[[0] + list(msss) + [len(x) - 1]]
  
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 4 for calling a global function with example usage: _maximally_separated_subset(x, k) and returns: x, list