braindecode.preprocessing.CombineChannels#
- class braindecode.preprocessing.CombineChannels(groups, method='mean', keep_stim=False, drop_bad=False, *, on_missing='raise', verbose=None)[source]#
Braindecode preprocessor wrapper for
combine_channels().Combine channels based on specified channel grouping.
- Parameters:
- instinstance of Raw, Epochs, or Evoked
An MNE-Python object to combine the channels for. The object can be of type Raw, Epochs, or Evoked.
- groupsdict
Specifies which channels are aggregated into a single channel, with aggregation method determined by the
methodparameter. One new pseudo-channel is made per dict entry; the dict values must be lists of picks (integer indices ofch_names). For example:groups=dict(Left=[1, 2, 3, 4], Right=[5, 6, 7, 8])
Note that within a dict entry all channels must have the same type.
- methodstr | callable
Which method to use to combine channels. If a
str, must be one of ‘mean’, ‘median’, or ‘std’ (standard deviation). If callable, the callable must accept one positional input (data of shape(n_channels, n_times), or(n_epochs, n_channels, n_times)) and return anarrayof shape(n_times,), or(n_epochs, n_times). For example with an instance of Raw or Evoked:method = lambda data: np.mean(data, axis=0)
Another example with an instance of Epochs:
method = lambda data: np.median(data, axis=1)
Defaults to
'mean'.- keep_stimbool
If
True, include stimulus channels in the resulting object. Defaults toFalse.- drop_badbool
If
True, drop channels marked as bad before combining. Defaults toFalse.- on_missing‘raise’ | ‘warn’ | ‘ignore’
What to do if one or several event ids are not found in the recording. Valid keys are ‘raise’ | ‘warn’ | ‘ignore’ Default is
'raise'. If'warn', it will proceed but warn; if'ignore', it will proceed silently.Note
If none of the event ids are found in the data, an error will be automatically generated irrespective of this parameter.
Added in version 1.11.0.
- verbosebool | str | int | None
Control verbosity of the logging output. If
None, use the default verbosity level. See the logging documentation andmne.verbose()for details. Should only be passed as a keyword argument.
- Returns:
- combined_instinstance of Raw, Epochs, or Evoked
An MNE-Python object of the same type as the input
inst, containing one virtual channel for each group ingroups(and, ifkeep_stimisTrue, also containing stimulus channels).
See also
Methods
- fn(groups, method='mean', keep_stim=False, drop_bad=False, *, on_missing='raise', verbose=None)[source]#
Combine channels based on specified channel grouping.
- Parameters:
inst (instance of Raw, Epochs, or Evoked) – An MNE-Python object to combine the channels for. The object can be of type Raw, Epochs, or Evoked.
groups (dict) –
Specifies which channels are aggregated into a single channel, with aggregation method determined by the
methodparameter. One new pseudo-channel is made per dict entry; the dict values must be lists of picks (integer indices ofch_names). For example:groups=dict(Left=[1, 2, 3, 4], Right=[5, 6, 7, 8])
Note that within a dict entry all channels must have the same type.
method (str | callable) –
Which method to use to combine channels. If a
str, must be one of ‘mean’, ‘median’, or ‘std’ (standard deviation). If callable, the callable must accept one positional input (data of shape(n_channels, n_times), or(n_epochs, n_channels, n_times)) and return anarrayof shape(n_times,), or(n_epochs, n_times). For example with an instance of Raw or Evoked:method = lambda data: np.mean(data, axis=0)
Another example with an instance of Epochs:
method = lambda data: np.median(data, axis=1)
Defaults to
'mean'.keep_stim (bool) – If
True, include stimulus channels in the resulting object. Defaults toFalse.drop_bad (bool) – If
True, drop channels marked as bad before combining. Defaults toFalse.on_missing ('raise' | 'warn' | 'ignore') –
What to do if one or several event ids are not found in the recording. Valid keys are ‘raise’ | ‘warn’ | ‘ignore’ Default is
'raise'. If'warn', it will proceed but warn; if'ignore', it will proceed silently.Note
If none of the event ids are found in the data, an error will be automatically generated irrespective of this parameter.
Added in version 1.11.0.
verbose (bool | str | int | None) – Control verbosity of the logging output. If
None, use the default verbosity level. See the logging documentation andmne.verbose()for details. Should only be passed as a keyword argument.
- Returns:
combined_inst – An MNE-Python object of the same type as the input
inst, containing one virtual channel for each group ingroups(and, ifkeep_stimisTrue, also containing stimulus channels).- Return type:
instance of Raw, Epochs, or Evoked