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.maskers.SurfaceMapsMasker¶
- class nilearn.maskers.SurfaceMapsMasker(maps_img=None, mask_img=None, allow_overlap=True, smoothing_fwhm=None, standardize=False, standardize_confounds=True, detrend=False, high_variance_confounds=False, low_pass=None, high_pass=None, t_r=None, memory=None, memory_level=1, verbose=0, reports=True, cmap='inferno', clean_args=None)[source]¶
Extract data from a SurfaceImage, using maps of potentially overlapping brain regions.
Added in version 0.11.1.
- Parameters:
- maps_img
SurfaceImage
Set of maps that define the regions. representative time course per map is extracted using least square regression. The data for each hemisphere is of shape (n_vertices_per_hemisphere, n_regions).
- mask_img
SurfaceImage
, optional, default=None Mask to apply to regions before extracting signals. Defines the overall area of the brain to consider. The data for each hemisphere is of shape (n_vertices_per_hemisphere, n_regions).
- allow_overlap
bool
, default=True If False, an error is raised if the maps overlaps (ie at least two maps have a non-zero value for the same voxel).
- smoothing_fwhm
float
, optional. If smoothing_fwhm is not None, it gives the full-width at half maximum in millimeters of the spatial smoothing to apply to the signal. This parameter is not implemented yet.
- standardize{‘zscore_sample’, ‘zscore’, ‘psc’, True, False}, default=False
Strategy to standardize the signal:
'zscore_sample'
: The signal is z-scored. Timeseries are shifted to zero mean and scaled to unit variance. Uses sample std.'zscore'
: The signal is z-scored. Timeseries are shifted to zero mean and scaled to unit variance. Uses population std by calling defaultnumpy.std
with N -ddof=0
.'psc'
: Timeseries are shifted to zero mean value and scaled to percent signal change (as compared to original mean signal).True
: The signal is z-scored (same as option zscore). Timeseries are shifted to zero mean and scaled to unit variance.False
: Do not standardize the data.
- standardize_confounds
bool
, default=True If set to True, the confounds are z-scored: their mean is put to 0 and their variance to 1 in the time dimension.
- detrend
bool
, optional Whether to detrend signals or not.
- high_variance_confounds
bool
, default=False If True, high variance confounds are computed on provided image with
nilearn.image.high_variance_confounds
and default parameters and regressed out.- low_pass
float
or None, default=None Low cutoff frequency in Hertz. If specified, signals above this frequency will be filtered out. If None, no low-pass filtering will be performed.
- high_pass
float
, default=None High cutoff frequency in Hertz. If specified, signals below this frequency will be filtered out.
- t_r
float
or None, default=None Repetition time, in seconds (sampling period). Set to None if not provided.
- memoryNone, instance of
joblib.Memory
,str
, orpathlib.Path
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
, default=1 Rough estimator of the amount of memory used by caching. Higher value means more memory for caching. Zero means no caching.
- verbose
int
, default=0 Verbosity level (0 means no message).
- reports
bool
, default=True If set to True, data is saved in order to produce a report.
- cmap
matplotlib.colors.Colormap
, orstr
, optional The colormap to use. Either a string which is a name of a matplotlib colormap, or a matplotlib colormap object. default=”inferno” Only relevant for the report figures.
- clean_args
dict
or None, default=None Keyword arguments to be passed to
nilearn.signal.clean
called within the masker.
- maps_img
- Attributes:
- maps_img_
SurfaceImage
The same as the input maps_img, kept solely for consistency across maskers.
- n_elements_
int
The number of regions in the maps image.
- maps_img_
- __init__(maps_img=None, mask_img=None, allow_overlap=True, smoothing_fwhm=None, standardize=False, standardize_confounds=True, detrend=False, high_variance_confounds=False, low_pass=None, high_pass=None, t_r=None, memory=None, memory_level=1, verbose=0, reports=True, cmap='inferno', clean_args=None)[source]¶
- fit(img=None, y=None)[source]¶
Prepare signal extraction from regions.
- Parameters:
- img
SurfaceImage
object or None, default=None This parameter is currently unused.
- yNone
This parameter is unused. It is solely included for scikit-learn compatibility.
- img
- Returns:
- SurfaceMapsMasker object
- transform(img, confounds=None, sample_mask=None)[source]¶
Extract signals from surface object.
- Parameters:
- img
SurfaceImage
object orlist
ofSurfaceImage
ortuple
ofSurfaceImage
Mesh and data for both hemispheres/parts. The data for each hemisphere is of shape (n_vertices_per_hemisphere, n_timepoints).
- confounds
numpy.ndarray
,str
,pathlib.Path
,pandas.DataFrame
orlist
of confounds timeseries, default=None Confounds to pass to
nilearn.signal.clean
.- sample_maskNone, Any type compatible with numpy-array indexing, or
list
of shape: (number of scans - number of volumes removed) for explicit index, or (number of scans) for binary mask, default=None sample_mask to pass to
nilearn.signal.clean
.
- img
- Returns:
- region_signals:
numpy.ndarray
Signal for each region as provided in the maps (via maps_img). shape: (n_timepoints, n_regions)
- region_signals:
- fit_transform(img, y=None, confounds=None, sample_mask=None)[source]¶
Prepare and perform signal extraction from regions.
- Parameters:
- img
SurfaceImage
object orlist
ofSurfaceImage
ortuple
ofSurfaceImage
Mesh and data for both hemispheres. The data for each hemisphere is of shape (n_vertices_per_hemisphere, n_timepoints).
- yNone
This parameter is unused. It is solely included for scikit-learn compatibility.
- confounds
numpy.ndarray
,str
,pathlib.Path
,pandas.DataFrame
orlist
of confounds timeseries, default=None Confounds to pass to
nilearn.signal.clean
.- sample_maskNone, Any type compatible with numpy-array indexing, or
list
of shape: (number of scans - number of volumes removed) for explicit index, or (number of scans) for binary mask, default=None sample_mask to pass to
nilearn.signal.clean
.
- img
- Returns:
- region_signals:
numpy.ndarray
Signal for each region as provided in the maps (via maps_img). shape: (n_timepoints, n_regions)
- region_signals:
- inverse_transform(region_signals)[source]¶
Compute vertex signals from region signals.
- Parameters:
- region_signals: :obj:`numpy.ndarray`
Signal for each region as provided in the maps (via maps_img). shape: (n_timepoints, n_regions)
- Returns:
- vertex_signals:
SurfaceImage
Signal for each vertex projected on the mesh of the maps_img. The data for each hemisphere is of shape (n_vertices_per_hemisphere, n_timepoints).
- vertex_signals:
- get_metadata_routing()¶
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routingMetadataRequest
A
MetadataRequest
encapsulating routing information.
- 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_fit_request(*, img='$UNCHANGED$')¶
Request metadata passed to the
fit
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline
. Otherwise it has no effect.- Parameters:
- imgstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
img
parameter infit
.
- Returns:
- selfobject
The updated object.
- set_inverse_transform_request(*, region_signals='$UNCHANGED$')¶
Request metadata passed to the
inverse_transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed toinverse_transform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it toinverse_transform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline
. Otherwise it has no effect.- Parameters:
- region_signalsstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
region_signals
parameter ininverse_transform
.
- Returns:
- selfobject
The updated object.
- set_output(*, transform=None)¶
Set output container.
See Introducing the set_output API for an example on how to use the API.
- Parameters:
- transform{“default”, “pandas”}, default=None
Configure output of transform and fit_transform.
“default”: Default output format of a transformer
“pandas”: DataFrame output
“polars”: Polars output
None: Transform configuration is unchanged
Added in version 1.4: “polars” option was added.
- Returns:
- selfestimator instance
Estimator instance.
- 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.
- set_transform_request(*, confounds='$UNCHANGED$', img='$UNCHANGED$', sample_mask='$UNCHANGED$')¶
Request metadata passed to the
transform
method.Note that this method is only relevant if
enable_metadata_routing=True
(seesklearn.set_config
). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed totransform
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it totransform
.None
: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str
: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED
) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline
. Otherwise it has no effect.- Parameters:
- confoundsstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
confounds
parameter intransform
.- imgstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
img
parameter intransform
.- sample_maskstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
sample_mask
parameter intransform
.
- Returns:
- selfobject
The updated object.