API Reference#

This is the reference for classes (CamelCase names) and functions (underscore_case names) of Braindecode.

braindecode:

Classifier#

braindecode.classifier:

EEGClassifier(*args[, cropped, callbacks, ...])

Classifier that does not assume softmax activation.

Regressor#

braindecode.regressor:

EEGRegressor(*args[, cropped, callbacks, ...])

Regressor that calls loss function directly.

Models#

braindecode.models:

ShallowFBCSPNet(in_chans, n_classes[, ...])

Shallow ConvNet model from Schirrmeister et al 2017.

Deep4Net(in_chans, n_classes, ...[, ...])

Deep ConvNet model from Schirrmeister et al 2017.

EEGInception(in_channels, n_classes[, ...])

EEG Inception.

EEGITNet(n_classes, in_channels, ...[, ...])

EEG-ITNet: An Explainable Inception Temporal

EEGNetv1(in_chans, n_classes[, ...])

EEGNet model from Lawhern et al. 2016.

EEGNetv4(in_chans, n_classes[, ...])

EEGNet v4 model from Lawhern et al 2018.

HybridNet(in_chans, n_classes, ...)

Hybrid ConvNet model from Schirrmeister et al 2017.

EEGResNet(in_chans, n_classes, ...[, ...])

Residual Network for EEG.

TCN(n_in_chans, n_outputs, n_blocks, ...)

Temporal Convolutional Network (TCN) from Bai et al 2018.

SleepStagerChambon2018(n_channels, sfreq[, ...])

Sleep staging architecture from Chambon et al 2018.

SleepStagerBlanco2020(n_channels, sfreq[, ...])

Sleep staging architecture from Blanco et al 2020.

SleepStagerEldele2021(sfreq[, n_tce, ...])

Sleep Staging Architecture from Eldele et al 2021.

USleep([in_chans, sfreq, depth, ...])

Sleep staging architecture from Perslev et al 2021.

TIDNet(in_chans, n_classes, input_window_samples)

Thinker Invariance DenseNet model from Kostas et al 2020.

get_output_shape(model, in_chans, ...)

Returns shape of neural network output for batch size equal 1.

TimeDistributed(module)

Apply module on multiple windows.

Training#

braindecode.training:

CroppedLoss(loss_function)

Compute Loss after averaging predictions across time.

TimeSeriesLoss(loss_function)

Compute Loss between timeseries targets and predictions.

CroppedTrialEpochScoring(scoring[, ...])

Class to compute scores for trials from a model that predicts (super)crops.

CroppedTimeSeriesEpochScoring(scoring[, ...])

Class to compute scores for trials from a model that predicts (super)crops with time series target.

PostEpochTrainScoring(scoring[, ...])

Epoch Scoring class that recomputes predictions after the epoch on the training in validation mode.

mixup_criterion(preds, target)

Implements loss for Mixup for EEG data.

trial_preds_from_window_preds(preds, ...)

Assigning window predictions to trials while removing duplicate predictions.

predict_trials(module, dataset[, ...])

Create trialwise predictions and optionally also return trialwise labels from cropped dataset given module.

Datasets#

braindecode.datasets:

BaseDataset(raw[, description, target_name, ...])

Returns samples from an mne.io.Raw object along with a target.

BaseConcatDataset(list_of_ds[, target_transform])

A base class for concatenated datasets.

WindowsDataset(windows[, description, ...])

Returns windows from an mne.Epochs object along with a target.

MOABBDataset(dataset_name, subject_ids[, ...])

A class for moabb datasets.

HGD(subject_ids)

High-gamma dataset discribed in Schirrmeister et al. 2017.

BNCI2014001(subject_ids)

BNCI 2014-001 Motor Imagery dataset.

TUH(path[, recording_ids, target_name, ...])

Temple University Hospital (TUH) EEG Corpus (www.isip.piconepress.com/projects/tuh_eeg/html/downloads.shtml#c_tueg).

TUHAbnormal(path[, recording_ids, ...])

Temple University Hospital (TUH) Abnormal EEG Corpus.

SleepPhysionet([subject_ids, recording_ids, ...])

Sleep Physionet dataset.

BCICompetitionIVDataset4([subject_ids])

BCI competition IV dataset 4.

create_from_X_y(X, y, drop_last_window, sfreq)

Create a BaseConcatDataset of WindowsDatasets from X and y to be used for decoding with skorch and braindecode, where X is a list of pre-cut trials and y are corresponding targets.

create_from_mne_raw(raws, ...[, ...])

Create WindowsDatasets from mne.RawArrays

create_from_mne_epochs(list_of_epochs, ...)

Create WindowsDatasets from mne.Epochs

Preprocessing#

braindecode.preprocessing:

create_windows_from_events(concat_ds[, ...])

Create windows based on events in mne.Raw.

create_fixed_length_windows(concat_ds[, ...])

Windower that creates sliding windows.

create_windows_from_target_channels(concat_ds)

exponential_moving_demean(data[, ...])

Perform exponential moving demeanining.

exponential_moving_standardize(data[, ...])

Perform exponential moving standardization.

scale(data, factor)

DEPRECATED: will be removed in 0.8.0.

filterbank(raw, frequency_bands[, ...])

Applies multiple bandpass filters to the signals in raw.

preprocess(concat_ds, preprocessors[, ...])

Apply preprocessors to a concat dataset.

Preprocessor(fn, *[, apply_on_array])

Preprocessor for an MNE Raw or Epochs object.

Data Utils#

braindecode.datautil:

save_concat_dataset(path, concat_dataset[, ...])

load_concat_dataset(path, preload[, ...])

Load a stored BaseConcatDataset of BaseDatasets or WindowsDatasets from files.

Samplers#

braindecode.samplers:

RecordingSampler(metadata[, random_state])

Base sampler simplifying sampling from recordings.

SequenceSampler(metadata, n_windows, ...[, ...])

Sample sequences of consecutive windows.

RelativePositioningSampler(metadata, ...[, ...])

Sample examples for the relative positioning task from [R0467437a2408-Banville2020].

BalancedSequenceSampler(metadata, n_windows)

Balanced sampling of sequences of consecutive windows with categorical targets.

Augmentation#

braindecode.augmentation:

Transform([probability, random_state])

Basic transform class used for implementing data augmentation operations.

IdentityTransform([probability, random_state])

Identity transform.

Compose(transforms)

Transform composition.

AugmentedDataLoader(dataset[, transforms, ...])

A base dataloader class customized to applying augmentation Transforms.

TimeReverse(probability[, random_state])

Flip the time axis of each input with a given probability.

SignFlip(probability[, random_state])

Flip the sign axis of each input with a given probability.

FTSurrogate(probability[, ...])

FT surrogate augmentation of a single EEG channel, as proposed in [Ra7c6c14d9bd9-1].

ChannelsShuffle(probability[, p_shuffle, ...])

Randomly shuffle channels in EEG data matrix.

ChannelsDropout(probability[, p_drop, ...])

Randomly set channels to flat signal.

GaussianNoise(probability[, std, random_state])

Randomly add white noise to all channels.

ChannelsSymmetry(probability, ordered_ch_names)

Permute EEG channels inverting left and right-side sensors.

SmoothTimeMask(probability[, ...])

Smoothly replace a randomly chosen contiguous part of all channels by zeros.

BandstopFilter(probability, sfreq[, ...])

Apply a band-stop filter with desired bandwidth at a randomly selected frequency position between 0 and max_freq.

FrequencyShift(probability, sfreq[, ...])

Add a random shift in the frequency domain to all channels.

SensorsRotation(probability, ...[, axis, ...])

Interpolates EEG signals over sensors rotated around the desired axis with an angle sampled uniformly between -max_degree and max_degree.

SensorsZRotation(probability, ordered_ch_names)

Interpolates EEG signals over sensors rotated around the Z axis with an angle sampled uniformly between -max_degree and max_degree.

SensorsYRotation(probability, ordered_ch_names)

Interpolates EEG signals over sensors rotated around the Y axis with an angle sampled uniformly between -max_degree and max_degree.

SensorsXRotation(probability, ordered_ch_names)

Interpolates EEG signals over sensors rotated around the X axis with an angle sampled uniformly between -max_degree and max_degree.

Mixup(alpha[, beta_per_sample, random_state])

Implements Iterator for Mixup for EEG data.

functional.identity(X, y)

Identity operation.

functional.time_reverse(X, y)

Flip the time axis of each input.

functional.sign_flip(X, y)

Flip the sign axis of each input.

functional.ft_surrogate(X, y, ...[, ...])

FT surrogate augmentation of a single EEG channel, as proposed in [R52a4658fffa7-1].

functional.channels_dropout(X, y, p_drop[, ...])

Randomly set channels to flat signal.

functional.channels_shuffle(X, y, p_shuffle)

Randomly shuffle channels in EEG data matrix.

functional.channels_permute(X, y, permutation)

Permute EEG channels according to fixed permutation matrix.

functional.gaussian_noise(X, y, std[, ...])

Randomly add white Gaussian noise to all channels.

functional.smooth_time_mask(X, y, ...)

Smoothly replace a contiguous part of all channels by zeros.

functional.bandstop_filter(X, y, sfreq, ...)

Apply a band-stop filter with desired bandwidth at the desired frequency position.

functional.frequency_shift(X, y, delta_freq, ...)

Adds a shift in the frequency domain to all channels.

functional.sensors_rotation(X, y, ...)

Interpolates EEG signals over sensors rotated around the desired axis with the desired angle.

functional.mixup(X, y, lam, idx_perm)

Mixes two channels of EEG data.

Utils#

braindecode.util:

set_random_seeds(seed, cuda[, cudnn_benchmark])

Set seeds for python random module numpy.random and torch.

Visualization#

braindecode.visualization:

compute_amplitude_gradients(model, dataset, ...)

plot_confusion_matrix(confusion_mat[, ...])

Generates a confusion matrix with additional precision and sensitivity metrics as in [R8046536b33dd-1].