Standardize channel data. This class scales data for each channel. It differs from scikit-learn classes (e.g., :class:`sklearn.preprocessing.StandardScaler`) in that it scales each *channel* by estimating μ and σ using data from all time points and epochs, as opposed to standardizin
| 126 | |
| 127 | @fill_doc |
| 128 | class Scaler(MNETransformerMixin, BaseEstimator): |
| 129 | """Standardize channel data. |
| 130 | |
| 131 | This class scales data for each channel. It differs from scikit-learn |
| 132 | classes (e.g., :class:`sklearn.preprocessing.StandardScaler`) in that |
| 133 | it scales each *channel* by estimating μ and σ using data from all |
| 134 | time points and epochs, as opposed to standardizing each *feature* |
| 135 | (i.e., each time point for each channel) by estimating using μ and σ |
| 136 | using data from all epochs. |
| 137 | |
| 138 | Parameters |
| 139 | ---------- |
| 140 | %(info)s Only necessary if ``scalings`` is a dict or None. |
| 141 | scalings : dict, str, default None |
| 142 | Scaling method to be applied to data channel wise. |
| 143 | |
| 144 | * if scalings is None (default), scales mag by 1e15, grad by 1e13, |
| 145 | and eeg by 1e6. |
| 146 | * if scalings is :class:`dict`, keys are channel types and values |
| 147 | are scale factors. |
| 148 | * if ``scalings=='median'``, |
| 149 | :class:`sklearn.preprocessing.RobustScaler` |
| 150 | is used (requires sklearn version 0.17+). |
| 151 | * if ``scalings=='mean'``, |
| 152 | :class:`sklearn.preprocessing.StandardScaler` |
| 153 | is used. |
| 154 | |
| 155 | with_mean : bool, default True |
| 156 | If True, center the data using mean (or median) before scaling. |
| 157 | Ignored for channel-type scaling. |
| 158 | with_std : bool, default True |
| 159 | If True, scale the data to unit variance (``scalings='mean'``), |
| 160 | quantile range (``scalings='median``), or using channel type |
| 161 | if ``scalings`` is a dict or None). |
| 162 | """ |
| 163 | |
| 164 | def __init__(self, info=None, scalings=None, with_mean=True, with_std=True): |
| 165 | self.info = info |
| 166 | self.with_mean = with_mean |
| 167 | self.with_std = with_std |
| 168 | self.scalings = scalings |
| 169 | |
| 170 | def fit(self, epochs_data, y=None): |
| 171 | """Standardize data across channels. |
| 172 | |
| 173 | Parameters |
| 174 | ---------- |
| 175 | epochs_data : array, shape (n_epochs, n_channels, n_times) |
| 176 | The data to concatenate channels. |
| 177 | y : array, shape (n_epochs,) |
| 178 | The label for each epoch. |
| 179 | |
| 180 | Returns |
| 181 | ------- |
| 182 | self : instance of Scaler |
| 183 | The modified instance. |
| 184 | """ |
| 185 | epochs_data = self._check_data(epochs_data, y=y, fit=True, multi_output=True) |
no outgoing calls