brain_pipe.preprocessing.brain.eeg.load.LoadEEGNumpy

class LoadEEGNumpy(eeg_path_key: str | Sequence[str] | Dict[str, str] = {'data_path': 'raw'}, eeg_data_key: Dict[str, str] = {'raw': 'data'}, eeg_trigger_data_key: Dict[str, str] = {'raw': 'trigger_data'}, info_prefix: Dict[str, str] = {'raw': 'eeg_'}, channels_to_select: Sequence[str] | Sequence[int] | None = None, trigger_channel: str | int = 'Status', unit_multiplier: float | int = 1.0, additional_mapping: Mapping[str, str] = {'eeg_sfreq': 'data_fs'}, copy_data_dict: bool = False, *mne_args, **mne_kwargs)

Bases: MNELoader

Load EEG data.

This step uses MNE to load EEG data.

__init__(eeg_path_key: str | Sequence[str] | Dict[str, str] = {'data_path': 'raw'}, eeg_data_key: Dict[str, str] = {'raw': 'data'}, eeg_trigger_data_key: Dict[str, str] = {'raw': 'trigger_data'}, info_prefix: Dict[str, str] = {'raw': 'eeg_'}, channels_to_select: Sequence[str] | Sequence[int] | None = None, trigger_channel: str | int = 'Status', unit_multiplier: float | int = 1.0, additional_mapping: Mapping[str, str] = {'eeg_sfreq': 'data_fs'}, copy_data_dict: bool = False, *mne_args, **mne_kwargs)

Create a new LoadEEG instance.

Parameters:
  • eeg_path_key (str) – The key of the EEG path in the data dict.

  • eeg_data_key (str) – The key of the EEG data in the data dict.

  • eeg_trigger_data_key (str) – The key of the EEG trigger data in the data dict.

  • info_prefix (str) – The prefix to add to the keys of the EEG info dict.

  • channels_to_select (Optional[Union[Sequence[str], Sequence[int]]]) – The names of the channels to select. If None, all channels are selected. If a sequence of integers, the channels at the given indices are selected. If a sequence of strings, the channels with the given names are selected.

  • trigger_channel (Union[str, int]) – The name or index of the trigger channel.

  • unit_multiplier (Union[float, int]) – The multiplier to apply to the EEG data. MNE loads the data in Volts.

Methods

__init__([eeg_path_key, eeg_data_key, ...])

Create a new LoadEEG instance.

get_channels(eeg, channel_names, ...)

Select channels from EEG data.

parse_dict_keys(key[, name, ...])

Parse a key or a sequence of keys.

get_channels(eeg: ndarray, channel_names: Sequence[str], selected_channels: Sequence[str] | Sequence[int] | None)

Select channels from EEG data.

Parameters:
  • eeg (np.ndarray) – All available EEG data. Shape: (n_channels, n_samples)

  • channel_names (Sequence[str]) – The names of the channels in the EEG data.

  • selected_channels (Optional[Union[Sequence[str], Sequence[int]]]) – The names of the channels to select. If None, all channels are selected. If a sequence of integers, the channels at the given indices are selected. If a sequence of strings, the channels with the given names are selected.

Returns:

The selected EEG data. Shape: (n_selected_channels, n_samples)

Return type:

np.ndarray

Raises:
  • KeyError: – If a channel name is not found in the EEG data.

  • IndexError: – If a channel index is out of range.

parse_dict_keys(key: str | Sequence[str] | Mapping[str, str], name='key', require_ordered_dict=False) OrderedDict[str, str]

Parse a key or a sequence of keys.

Parameters:
  • key (Union[str, Sequence[str], Mapping[str,str]]) – A key or a sequence of keys.

  • name (str) – The name of the key. Used for error messages.

  • require_ordered_dict (bool) – If True, the key must be an OrderedDict. If False, the key can also be an ordinary dict.

Returns:

A mapping of input keys to output keys.

Return type:

OrderedDict[str, str]

Raises:

TypeError – If the key is not a string, a sequence of strings or a mapping of strings. If the key is a mapping but require_ordered_dict is True and the mapping is not an OrderedDict.