code: def nearest_from_matrix_col(coo_matrix):
      """
      Return the nearest (smallest) for each column given an coup sparse matrix
  
      Parameters
      ----------
      coo_matrix : scipy COOrdinates sparse matrix (nb_slines x nb_slines_ref)
          Adjacency matrix containing all neighbors within the given radius
  
      Returns
      -------
      non_zero_ids : numpy array (nb_non_empty_col x 1)
          Indices of each non-empty reference (column)
      nearest_id : numpy array (nb_non_empty_col x 1)
          Indices of the nearest slines match (row)
      nearest_dist : numpy array (nb_non_empty_col x 1)
          Distance for each nearest match
      """
      non_zero_ids = np.unique(coo_matrix.col)
      sparse_matrix = np.abs(coo_matrix.tocsc())
      upper_limit = np.max(sparse_matrix.data) + 1.0
      sparse_matrix.data = upper_limit - sparse_matrix.data
      nearest_id = np.squeeze(sparse_matrix.argmax(axis=0).data)[
          non_zero_ids
      ]
      nearest_dist = upper_limit - np.squeeze(
          sparse_matrix.max(axis=0).data
      )
      return non_zero_ids, nearest_id, nearest_dist
  
file_path: dipy/dipy/segment/fss.py
imports: import warnings
  import numpy
  from scipy.sparse import coo_matrix
  from scipy.spatial import cKDTree
  from dipy.tracking.streamline import set_number_of_points
  from dipy.segment.metric import mean_euclidean_distance
  from dipy.io.stateful_tractogram import StatefulTractogram
label_desc: Use image node_id 2 for calling a global function with example usage: nearest_from_matrix_col(coo_matrix) and returns: non_zero_ids,  nearest_id,  nearest_dist