brain_pipe.preprocessing.brain.trigger.AlignPeriodicBlockTriggers

class AlignPeriodicBlockTriggers(brain_trigger_processing_fn=<function AlignPeriodicBlockTriggers.<lambda>>, postprocessing_fn=<function default_drift_correction>, data_key='data', data_trigger_key='trigger_data', data_sampling_rate_key='eeg_sfreq', stimulus_trigger_data_key='trigger_data', stimulus_trigger_sampling_rate_key='trigger_sr')

Bases: PipelineStep

Align the trigger pulses in the form of periodic blocks.

__init__(brain_trigger_processing_fn=<function AlignPeriodicBlockTriggers.<lambda>>, postprocessing_fn=<function default_drift_correction>, data_key='data', data_trigger_key='trigger_data', data_sampling_rate_key='eeg_sfreq', stimulus_trigger_data_key='trigger_data', stimulus_trigger_sampling_rate_key='trigger_sr')

Create a new MatchTriggersToStimulus instance.

Parameters:
  • data_key (str)

  • data_trigger_key (str)

  • data_sampling_rate_key (str)

  • stimulus_trigger_data_key (str)

  • stimulus_trigger_sampling_rate_key (str)

Methods

__init__([brain_trigger_processing_fn, ...])

Create a new MatchTriggersToStimulus instance.

get_trigger_indices(triggers)

Get the indices of the triggers.

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

Parse a key or a sequence of keys.

split_epochs(brain_trigger_indices, ...)

Split the EEG data into epochs.

get_trigger_indices(triggers: ndarray) ndarray

Get the indices of the triggers.

Parameters:

triggers (np.ndarray) – Raw trigger data. Should be a 1D array of 0s and 1s.

Returns:

Indices of the triggers.

Return type:

np.ndarray

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.

split_epochs(brain_trigger_indices, brain_fs, nb_epochs)

Split the EEG data into epochs.

Parameters:
  • brain_trigger_indices (np.ndarray) – Indices of the triggers in the EEG data.

  • nb_epochs (int) – Number of epochs to split the EEG data into.

Returns:

EEG data split into epochs.

Return type:

Sequence[np.ndarray]