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
- info
mne.Info
|None
The
mne.Info
object with information about the sensors and methods of measurement. Only necessary ifscalings
is a dict or None.- scalings
dict
,str
, defaultNone
Scaling method to be applied to data channel wise.
if scalings is None (default), scales mag by 1e15, grad by 1e13, and eeg by 1e6.
if scalings is
dict
, keys are channel types and values are scale factors.if
scalings=='median'
,sklearn.preprocessing.RobustScaler
is used (requires sklearn version 0.17+).if
scalings=='mean'
,sklearn.preprocessing.StandardScaler
is used.
- 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 ifscalings
is a dict or None).
- info
Methods
fit
(epochs_data[, y])Standardize data across channels.
fit_transform
(epochs_data[, y])Fit to data, then transform it.
get_params
([deep])Get parameters for this estimator.
inverse_transform
(epochs_data)Invert standardization of data across channels.
set_params
(**params)Set the parameters of this estimator.
transform
(epochs_data)Standardize data across channels.
- fit(epochs_data, y=None)[source]#
Standardize data across channels.
- Parameters
- Returns
- selfinstance of
Scaler
The modified instance.
- selfinstance of
Examples using
fit
:Decoding (MVPA)
- 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
- Returns
- X
array
, shape (n_epochs, n_channels, n_times) The data concatenated over channels.
- X
Notes
This function makes a copy of the data before the operations and the memory usage may be large with big data.
Examples using
fit_transform
:Decoding (MVPA)
- inverse_transform(epochs_data)[source]#
Invert standardization of data across channels.
- Parameters
- epochs_data
array
, shape (n_epochs, n_channels, n_times) The data.
- epochs_data
- Returns
- X
array
, shape (n_epochs, n_channels, n_times) The data concatenated over channels.
- X
Notes
This function makes a copy of the data before the operations and the memory usage may be large with big data.
Examples using
inverse_transform
:Decoding (MVPA)
- set_params(**params)[source]#
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form
<component>__<parameter>
so that it’s possible to update each component of a nested object.- Parameters
- **params
dict
Parameters.
- **params
- Returns
- instinstance
The object.
- transform(epochs_data)[source]#
Standardize data across channels.
- Parameters
- epochs_data
array
, shape (n_epochs, n_channels[, n_times]) The data.
- epochs_data
- Returns
- X
array
, shape (n_epochs, n_channels, n_times) The data concatenated over channels.
- X
Notes
This function makes a copy of the data before the operations and the memory usage may be large with big data.
Examples using
transform
:Decoding (MVPA)