class_docstr: Recursive Neighbor Agglomeration (:term:`ReNA`).
  
  Recursively merges the pair of clusters according to 1-nearest neighbors
  criterion.
  See :footcite:t:`Hoyos2019`.
  
  Parameters
  ----------
  mask_img : Niimg-like object
      Object used for masking the data.
  
  n_clusters : :obj:`int`, default=2
      The number of clusters to find.
  
  scaling : :obj:`bool`, default=False
      If scaling is True, each cluster is scaled by the square root of its
      size, preserving the l2-norm of the image.
  
  n_iter : :obj:`int`, default=10
      Number of iterations of the recursive neighbor agglomeration.
  
  threshold : :obj:`float` in the open interval (0., 1.), default=1e-7
      Threshold used to handle eccentricities.
  %(memory)s
  %(memory_level1)s
  %(verbose0)s
  
  Attributes
  ----------
  labels_ : :class:`numpy.ndarray`, shape = [n_features]
      Cluster labels for each feature.
  
  n_clusters_ : :obj:`int`
      Number of clusters.
  
  sizes_ : :class:`numpy.ndarray`, shape = [n_features]
      It contains the size of each cluster.
  
  References
  ----------
  .. footbibliography::
class_docstr_tok: ["Recursive","Neighbor","Agglomeration","(",":","term",":","`","ReNA","`",")",".","Recursively","merges","the","pair","of","clusters","according","to","1-nearest","neighbors","criterion",".","See",":","footcite",":","t",":","`","Hoyos2019","`",".","Parameters","--","--","--","--","--","mask_img",":","Niimg-like","object","Object","used","for","masking","the","data",".","n_clusters",":",":","obj",":","`","int","`",",","default=2","The","number","of","clusters","to","find",".","scaling",":",":","obj",":","`","bool","`",",","default=False","If","scaling","is","True",",","each","cluster","is","scaled","by","the","square","root","of","its","size",",","preserving","the","l2-norm","of","the","image",".","n_iter",":",":","obj",":","`","int","`",",","default=10","Number","of","iterations","of","the","recursive","neighbor","agglomeration",".","threshold",":",":","obj",":","`","float","`","in","the","open","interval","(","0.",",","1",".",")",",","default=1e-7","Threshold","used","to","handle","eccentricities",".","%","(","memory",")","s","%","(","memory_level1",")","s","%","(","verbose0",")","s","Attributes","--","--","--","--","--","labels_",":",":","class",":","`","numpy.ndarray","`",",","shape","=","[","n_features","]","Cluster","labels","for","each","feature",".","n_clusters_",":",":","obj",":","`","int","`","Number","of","clusters",".","sizes_",":",":","class",":","`","numpy.ndarray","`",",","shape","=","[","n_features","]","It","contains","the","size","of","each","cluster",".","References","--","--","--","--","--","..","footbibliography",":",":"]
docstr: Compute clustering of the data.
  
  Parameters
  ----------
  X : :class:`numpy.ndarray`, shape = [n_samples, n_features]
      Training data.
  
  y : Ignored
  
  Returns
  -------
  self : `ReNA` object
docstr_tok: ["Compute","clustering","of","the","data",".","Parameters","--","--","--","--","--","X",":",":","class",":","`","numpy.ndarray","`",",","shape","=","[","n_samples",",","n_features","]","Training","data",".","y",":","Ignored","Returns","--","--","--","-","self",":","`","ReNA","`","object"]
code: def fit(self, X, y=None):
      """Compute clustering of the data.
  
      Parameters
      ----------
      X : :class:`numpy.ndarray`, shape = [n_samples, n_features]
          Training data.
  
      y : Ignored
  
      Returns
      -------
      self : `ReNA` object
  
      """
      X = check_array(
          X, ensure_min_features=2, ensure_min_samples=2, estimator=self
      )
      n_features = X.shape[1]
  
      if not isinstance(self.mask_img, (str, Nifti1Image)):
          raise ValueError(
              "The mask image should be a Niimg-like"
              f"object. Instead a {type(self.mask_img)} object was provided."
          )
  
      if self.memory is None or isinstance(self.memory, str):
          self.memory_ = Memory(
              location=self.memory, verbose=max(0, self.verbose - 1)
          )
      else:
          self.memory_ = self.memory
  
      if self.n_clusters <= 0:
          raise ValueError(
              "n_clusters should be an integer greater than 0."
              f" {self.n_clusters} was provided."
          )
  
      if self.n_iter <= 0:
          raise ValueError(
              "n_iter should be an integer greater than 0."
              f" {self.n_iter} was provided."
          )
  
      if self.n_clusters > n_features:
          self.n_clusters = n_features
          warnings.warn(
              "n_clusters should be at most the number of features. "
              f"Taking n_clusters = {n_features} instead."
          )
  
      n_components, labels = self.memory_.cache(
          recursive_neighbor_agglomeration
      )(
          X,
          self.mask_img,
          self.n_clusters,
          n_iter=self.n_iter,
          threshold=self.threshold,
          verbose=self.verbose,
      )
  
      sizes = np.bincount(labels)
      sizes = sizes[sizes > 0]
  
      self.labels_ = labels
      self.n_clusters_ = np.unique(self.labels_).shape[0]
      self.sizes_ = sizes
  
      return self
  
imports: import warnings
  import numpy
  from joblib import Memory
  from nibabel import Nifti1Image
  from scipy.sparse import coo_matrix, csgraph, dia_matrix
  from sklearn.base import BaseEstimator, ClusterMixin, TransformerMixin
  from sklearn.utils import check_array
  from sklearn.utils.validation import check_is_fitted
  from nilearn._utils import fill_doc
  from nilearn.image import get_data
  from nilearn.masking import unmask_from_to_3d_array
label_desc: Use image node_id 3 for calling the ReNA obj's underlying member method code with example usage: obj.fit(X, y) and returns: self