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.experimental.surface.SurfaceLabelsMasker

class nilearn.experimental.surface.SurfaceLabelsMasker(labels_img, label_names=None, reports=True, **kwargs)[source]

Extract data from a SurfaceImage, averaging over atlas regions.

Parameters:
labels_imgSurfaceImage object

Region definitions, as one image of labels.

label_nameslist of str, default=None

Full labels corresponding to the labels image.

Attributes:
labels_data_numpy.ndarray
labels_numpy.ndarray
label_names_numpy.ndarray
__init__(labels_img, label_names=None, reports=True, **kwargs)[source]
labels_img
label_names
labels_data_
labels_
label_names_
fit(img=None, y=None)[source]

Prepare signal extraction from regions.

Parameters:
imgSurfaceImage object

Mesh and data for both hemispheres.

yNone

This parameter is unused. It is solely included for scikit-learn compatibility.

Returns:
SurfaceLabelsMasker object
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 (see sklearn.set_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • 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 in fit.

Returns:
selfobject

The updated object.

set_inverse_transform_request(*, masked_img='$UNCHANGED$')

Request metadata passed to the inverse_transform method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to inverse_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 to inverse_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:
masked_imgstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for masked_img parameter in inverse_transform.

Returns:
selfobject

The updated object.

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(*, img='$UNCHANGED$')

Request metadata passed to the transform method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to 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 to 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:
imgstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for img parameter in transform.

Returns:
selfobject

The updated object.

transform(img)[source]

Extract signals from fitted surface object.

Parameters:
imgSurfaceImage object

Mesh and data for both hemispheres.

Returns:
outputnumpy.ndarray

Signal for each element. shape: (img data shape, total number of vertices)

fit_transform(img, y=None)[source]

Prepare and perform signal extraction from regions.

Parameters:
imgSurfaceImage object

Mesh and data for both hemispheres.

yNone

This parameter is unused. It is solely included for scikit-learn compatibility.

Returns:
numpy.ndarray

Signal for each element. shape: (img data shape, total number of vertices)

inverse_transform(masked_img)[source]

Transform extracted signal back to surface object.

Parameters:
masked_imgnumpy.ndarray

Extracted signal.

Returns:
SurfaceImage object

Mesh and data for both hemispheres.

generate_report()[source]

Generate a report.

Examples using nilearn.experimental.surface.SurfaceLabelsMasker

A short demo of the surface images & maskers

A short demo of the surface images & maskers