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.RegionExtractor#
- class nilearn.regions.RegionExtractor(maps_img, mask_img=None, min_region_size=1350, threshold=1.0, thresholding_strategy='ratio_n_voxels', extractor='local_regions', smoothing_fwhm=6, standardize=False, detrend=False, low_pass=None, high_pass=None, t_r=None, memory=Memory(location=None), memory_level=0, verbose=0)[source]#
Class for brain region extraction.
Region Extraction is a post processing technique which is implemented to automatically segment each brain atlas maps into different set of separated brain activated region. Particularly, to show that each decomposed brain maps can be used to focus on a target specific Regions of Interest analysis.
See 1.
New in version 0.2.
- Parameters
- maps_img4D Niimg-like object
Image containing a set of whole brain atlas maps or statistically decomposed brain maps.
- mask_imgNiimg-like object or None, optional
Mask to be applied to input data, passed to NiftiMapsMasker. If None, no masking is applied.
- min_region_size
float
, optional Minimum volume in mm3 for a region to be kept. For example, if the voxel size is 3x3x3 mm then the volume of the voxel is 27mm^3. Default=1350mm^3, which means we take minimum size of 1350 / 27 = 50 voxels.
- thresholdnumber, optional
A value used either in ratio_n_voxels or img_value or percentile thresholding_strategy based upon the choice of selection. Default=1.0.
- thresholding_strategy
str
{‘ratio_n_voxels’, ‘img_value’, ‘percentile’}, optional If default ‘ratio_n_voxels’, we apply thresholding that will keep the more intense nonzero brain voxels (denoted as n_voxels) across all maps (n_voxels being the number of voxels in the brain volume). A float value given in threshold parameter indicates the ratio of voxels to keep meaning (if float=2. then maps will together have 2. x n_voxels non-zero voxels). If set to ‘percentile’, images are thresholded based on the score obtained with the given percentile on the data and the voxel intensities which are survived above this obtained score will be kept. If set to ‘img_value’, we apply thresholding based on the non-zero voxel intensities across all maps. A value given in threshold parameter indicates that we keep only those voxels which have intensities more than this value. Default=’ratio_n_voxels’.
- extractor{‘local_regions’, ‘connected_components’}, optional
This option can take two values:
‘connected_components’: each component/region in the image is extracted automatically by labelling each region based upon the presence of unique features in their respective regions.
‘local_regions’: each component/region is extracted based on their maximum peak value to define a seed marker and then using random walker segmentation algorithm on these markers for region separation.
Default=’local_regions’.
- smoothing_fwhm
float
, optional. If
smoothing_fwhm
is notNone
, it gives the full-width at half maximum in millimeters of the spatial smoothing to apply to the signal. Use this parameter to smooth an image to extract most sparser regions.Note
This parameter is passed to
nilearn.regions.connected_regions
. It will be used only ifextractor='local_regions'
.Note
Please set this parameter according to maps resolution, otherwise extraction will fail.
Default=6mm.
- standardize
bool
, optional. If
standardize
is True, the data are centered and normed: their mean is put to 0 and their variance is put to 1 in the time dimension. Default=False.Note
Recommended to set to True if signals are not already standardized. Passed to
NiftiMapsMasker
.- detrend
bool
, optional Whether to detrend signals or not.
Note
Passed to
nilearn.signal.clean
.Default=False.
- low_pass
float
or None, optional Low cutoff frequency in Hertz. If specified, signals above this frequency will be filtered out. If None, no low-pass filtering will be performed. Default=None.
Note
Passed to
nilearn.signal.clean
.- high_pass
float
, optional High cutoff frequency in Hertz. If specified, signals below this frequency will be filtered out. Default=None.
Note
Passed to
nilearn.signal.clean
.- t_r
float
or None, optional Repetition time, in seconds (sampling period). Set to
None
if not provided. Default=None.Note
Passed to
nilearn.signal.clean
.- memoryinstance of
joblib.Memory
orstr
Used to cache the masking process. By default, no caching is done. If a
str
is 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=0.
- verbose
int
, optional Verbosity level (0 means no message). Default=0.
See also
nilearn.regions.connected_label_regions
A function can be readily used for extraction of regions on labels based atlas images.
References
- 1
Alexandre Abraham, Elvis Dohmatob, Bertrand Thirion, Dimitris Samaras, and Gael Varoquaux. Region segmentation for sparse decompositions: better brain parcellations from rest fMRI. Sparsity Techniques in Medical Imaging, September 2014. URL: https://hal.inria.fr/hal-01093944.
- Attributes
- `index_`
numpy.ndarray
Array of list of indices where each index value is assigned to each separate region of its corresponding family of brain maps.
- `regions_img_`
nibabel.nifti1.Nifti1Image
List of separated regions with each region lying on an original volume concatenated into a 4D image.
- `index_`
- __init__(maps_img, mask_img=None, min_region_size=1350, threshold=1.0, thresholding_strategy='ratio_n_voxels', extractor='local_regions', smoothing_fwhm=6, standardize=False, detrend=False, low_pass=None, high_pass=None, t_r=None, memory=Memory(location=None), memory_level=0, verbose=0)[source]#
- fit_transform(imgs, confounds=None, sample_mask=None)[source]#
Prepare and perform signal extraction.
- generate_report(displayed_maps=10)[source]#
Generate an HTML report for the current
NiftiMapsMasker
object.Note
This functionality requires to have
Matplotlib
installed.- Parameters
- displayed_maps
int
, orlist
, orndarray
, or “all”, optional Indicates which maps will be displayed in the HTML report.
If “all”: All maps will be displayed in the report.
masker.generate_report("all")
If a
list
orndarray
: This indicates the indices of the maps to be displayed in the report. For example, the following code will generate a report with maps 6, 3, and 12, displayed in this specific order:
masker.generate_report([6, 3, 12])
If an
int
: This will only display the first n maps, n being the value of the parameter. By default, the report will only contain the first 10 maps. Example to display the first 16 maps:
masker.generate_report(16)
Default=10.
- displayed_maps
- Returns
- reportnilearn.reporting.html_report.HTMLReport
HTML report for the masker.
- 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.
- inverse_transform(region_signals)[source]#
Compute voxel signals from region signals
Any mask given at initialization is taken into account.
- Parameters
- region_signals2D numpy.ndarray
Signal for each region. shape: (number of scans, number of regions)
- Returns
- voxel_signalsnibabel.Nifti1Image
Signal for each voxel. shape: that of maps.
- 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.
- transform(imgs, confounds=None, sample_mask=None)[source]#
Apply mask, spatial and temporal preprocessing
- Parameters
- imgs3D/4D Niimg-like object
See http://nilearn.github.io/manipulating_images/input_output.html Images to process. It must boil down to a 4D image with scans number as last dimension.
- confoundsCSV file or array-like, optional
This parameter is passed to signal.clean. Please see the related documentation for details. shape: (number of scans, number of confounds)
- sample_maskAny type compatible with numpy-array indexing, optional
shape: (number of scans - number of volumes removed, ) Masks the niimgs along time/fourth dimension to perform scrubbing (remove volumes with high motion) and/or non-steady-state volumes. This parameter is passed to signal.clean.
New in version 0.8.0.
- Returns
- region_signals2D numpy.ndarray
Signal for each element. shape: (number of scans, number of elements)
- transform_single_imgs(imgs, confounds=None, sample_mask=None)[source]#
Extract signals from a single 4D niimg.
- Parameters
- imgs3D/4D Niimg-like object
See http://nilearn.github.io/manipulating_images/input_output.html Images to process. It must boil down to a 4D image with scans number as last dimension.
- confoundsCSV file or array-like, optional
This parameter is passed to signal.clean. Please see the related documentation for details. shape: (number of scans, number of confounds)
- sample_maskAny type compatible with numpy-array indexing, optional
shape: (number of scans - number of volumes removed, ) Masks the niimgs along time/fourth dimension to perform scrubbing (remove volumes with high motion) and/or non-steady-state volumes. This parameter is passed to signal.clean.
New in version 0.8.0.
- Returns
- region_signals2D numpy.ndarray
Signal for each map. shape: (number of scans, number of maps)
Examples using nilearn.regions.RegionExtractor
#
Regions extraction using dictionary learning and functional connectomes
Regions Extraction of Default Mode Networks using Smith Atlas