Note
This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the user guide for the big picture.
nilearn.regions.ReNA#
- class nilearn.regions.ReNA(mask_img, n_clusters=2, scaling=False, n_iter=10, threshold=1e-07, memory=None, memory_level=1, verbose=0)[source]#
 Recursive Neighbor Agglomeration (ReNA): Recursively merges the pair of clusters according to 1-nearest neighbors criterion. See 1.
- Parameters
 - mask_imgNiimg-like object
 Object used for masking the data.
- n_clusters
int, optional The number of clusters to find. Default=2.
- scaling
bool, optional If scaling is True, each cluster is scaled by the square root of its size, preserving the l2-norm of the image. Default=False.
- n_iter
int, optional Number of iterations of the recursive neighbor agglomeration. Default=10.
- threshold
floatin the open interval (0., 1.), optional Threshold used to handle eccentricities. Default=1e-7.
- memoryinstance of 
joblib.Memory,str, orpathlib.Path Used to cache the masking process. By default, no caching is done. If a
stris given, it is the path to the caching directory.- memory_level
int, optional. Rough estimator of the amount of memory used by caching. Higher value means more memory for caching. Default=1.
- verbose
int, optional Verbosity level (0 means no message). Default=0.
References
- 1
 Andres Hoyos-Idrobo, Gael Varoquaux, Jonas Kahn, and Bertrand Thirion. Recursive nearest agglomeration (rena): fast clustering for approximation of structured signals. IEEE Trans. Pattern Anal. Mach. Intell., 41(3):669–681, 3 2019. URL: https://doi.org/10.1109/TPAMI.2018.2815524, doi:10.1109/TPAMI.2018.2815524.
- Attributes
 - `labels_ `
numpy.ndarray, shape = [n_features] Cluster labels for each feature.
- `n_clusters_`
int Number of clusters.
- `sizes_`
numpy.ndarray, shape = [n_features] It contains the size of each cluster.
- `labels_ `
 
- __init__(mask_img, n_clusters=2, scaling=False, n_iter=10, threshold=1e-07, memory=None, memory_level=1, verbose=0)[source]#
 
- fit(X, y=None)[source]#
 Compute clustering of the data.
- Parameters
 - X
numpy.ndarray, shape = [n_samples, n_features] Training data.
- yIgnored
 
- X
 - Returns
 - selfReNA object
 
- transform(X, y=None)[source]#
 Apply clustering, reduce the dimensionality of the data.
- Parameters
 - X
numpy.ndarray, shape = [n_samples, n_features] Data to transform with the fitted clustering.
- X
 - Returns
 - X_red
numpy.ndarray, shape = [n_samples, n_clusters] Data reduced with agglomerated signal for each cluster.
- X_red
 
- inverse_transform(X_red)[source]#
 Send the reduced 2D data matrix back to the original feature space (voxels).
- Parameters
 - X_red
numpy.ndarray, shape = [n_samples, n_clusters] Data reduced with agglomerated signal for each cluster.
- X_red
 - Returns
 - X_inv
numpy.ndarray, shape = [n_samples, n_features] Data reduced expanded to the original feature space.
- X_inv
 
- fit_predict(X, y=None)#
 Perform clustering on X and returns cluster labels.
- Parameters
 - Xarray-like of shape (n_samples, n_features)
 Input data.
- yIgnored
 Not used, present for API consistency by convention.
- Returns
 - labelsndarray of shape (n_samples,), dtype=np.int64
 Cluster labels.
- fit_transform(X, y=None, **fit_params)#
 Fit to data, then transform it.
Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.
- Parameters
 - Xarray-like of shape (n_samples, n_features)
 Input samples.
- yarray-like of shape (n_samples,) or (n_samples, n_outputs), default=None
 Target values (None for unsupervised transformations).
- **fit_paramsdict
 Additional fit parameters.
- Returns
 - X_newndarray array of shape (n_samples, n_features_new)
 Transformed array.
- get_params(deep=True)#
 Get parameters for this estimator.
- Parameters
 - deepbool, default=True
 If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns
 - paramsdict
 Parameter names mapped to their values.
- set_params(**params)#
 Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline). The latter have parameters of the form<component>__<parameter>so that it’s possible to update each component of a nested object.- Parameters
 - **paramsdict
 Estimator parameters.
- Returns
 - selfestimator instance
 Estimator instance.