mne.decoding.Scaler#

class mne.decoding.Scaler(info=None, scalings=None, with_mean=True, with_std=True)[source]#

Standardize channel data.

This class scales data for each channel. It differs from scikit-learn classes (e.g., sklearn.preprocessing.StandardScaler) in that it scales each channel by estimating μ and σ using data from all time points and epochs, as opposed to standardizing each feature (i.e., each time point for each channel) by estimating using μ and σ using data from all epochs.

Parameters:
infomne.Info | None

The mne.Info object with information about the sensors and methods of measurement. Only necessary if scalings is a dict or None.

scalingsdict, str, default None

Scaling method to be applied to data channel wise.

with_meanbool, default True

If True, center the data using mean (or median) before scaling. Ignored for channel-type scaling.

with_stdbool, default True

If True, scale the data to unit variance (scalings='mean'), quantile range (scalings='median), or using channel type if scalings is a dict or None).

Methods

fit(epochs_data[, y])

Standardize data across channels.

fit_transform(epochs_data[, y])

Fit to data, then transform it.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

inverse_transform(epochs_data)

Invert standardization of data across channels.

set_fit_request(*[, epochs_data])

Request metadata passed to the fit method.

set_inverse_transform_request(*[, epochs_data])

Request metadata passed to the inverse_transform method.

set_output(*[, transform])

Set output container.

set_params(**params)

Set the parameters of this estimator.

set_transform_request(*[, epochs_data])

Request metadata passed to the transform method.

transform(epochs_data)

Standardize data across channels.

fit(epochs_data, y=None)[source]#

Standardize data across channels.

Parameters:
epochs_dataarray, shape (n_epochs, n_channels, n_times)

The data to concatenate channels.

yarray, shape (n_epochs,)

The label for each epoch.

Returns:
selfinstance of Scaler

The modified instance.

fit_transform(epochs_data, y=None)[source]#

Fit to data, then transform it.

Fits transformer to epochs_data and y and returns a transformed version of epochs_data.

Parameters:
epochs_dataarray, shape (n_epochs, n_channels, n_times)

The data.

yNone | array, shape (n_epochs,)

The label for each epoch. Defaults to None.

Returns:
Xarray, shape (n_epochs, n_channels, n_times)

The data concatenated over channels.

Notes

This function makes a copy of the data before the operations and the memory usage may be large with big data.

get_metadata_routing()[source]#

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)[source]#

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(epochs_data)[source]#

Invert standardization of data across channels.

Parameters:
epochs_dataarray, shape ([n_epochs, ]n_channels, n_times)

The data.

Returns:
Xarray, shape (n_epochs, n_channels, n_times)

The data concatenated over channels.

Notes

This function makes a copy of the data before the operations and the memory usage may be large with big data.

set_fit_request(*, epochs_data: bool | None | str = '$UNCHANGED$') Scaler[source]#

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.

New in v1.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:
epochs_datastr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for epochs_data parameter in fit.

Returns:
selfobject

The updated object.

set_inverse_transform_request(*, epochs_data: bool | None | str = '$UNCHANGED$') Scaler[source]#

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.

New in v1.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:
epochs_datastr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for epochs_data parameter in inverse_transform.

Returns:
selfobject

The updated object.

set_output(*, transform=None)[source]#

Set output container.

See Introducing the set_output API for an example on how to use the API.

Parameters:
transform{“default”, “pandas”, “polars”}, 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

New in v1.4: “polars” option was added.

Returns:
selfestimator instance

Estimator instance.

set_params(**params)[source]#

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(*, epochs_data: bool | None | str = '$UNCHANGED$') Scaler[source]#

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.

New in v1.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:
epochs_datastr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for epochs_data parameter in transform.

Returns:
selfobject

The updated object.

transform(epochs_data)[source]#

Standardize data across channels.

Parameters:
epochs_dataarray, shape (n_epochs, n_channels[, n_times])

The data.

Returns:
Xarray, shape (n_epochs, n_channels, n_times)

The data concatenated over channels.

Notes

This function makes a copy of the data before the operations and the memory usage may be large with big data.

Examples using mne.decoding.Scaler#

Decoding (MVPA)

Decoding (MVPA)