API Reference#

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

braindecode:

Classifier#

braindecode.classifier:

EEGClassifier(module, *args[, criterion, ...])

Classifier that does not assume softmax activation.

Regressor#

braindecode.regressor:

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

Regressor that calls loss function directly.

Models#

braindecode.models.base:

EEGModuleMixin([n_outputs, n_chans, ...])

Mixin class for all EEG models in braindecode.

braindecode.models:

ATCNet([n_chans, n_outputs, ...])

ATCNet model from Altaheri et al. (2022) [R2ecdb73d6ab9-1].

AttentionBaseNet([n_times, n_chans, ...])

AttentionBaseNet from Wimpff M et al. (2023) [R523d6c831d64-Martin2023].

BDTCN([n_chans, n_outputs, chs_info, ...])

Braindecode TCN from Gemein, L et al (2020) [Rd56781dc6fcb-gemein2020].

BIOT([emb_size, att_num_heads, n_layers, ...])

BIOT from Yang et al. (2023) [R606e26b38fe6-Yang2023].

ContraWR(n_chans, n_outputs, sfreq, ...[, steps])

Contrast with the World Representation ContraWR from Yang et al (2021) [Ra71465cb6797-Yang2021].

CTNet([n_outputs, n_chans, sfreq, chs_info, ...])

CTNet from Zhao, W et al (2024) [Rc7f1d6cec70c-ctnet].

Deep4Net([n_chans, n_outputs, n_times, ...])

Deep ConvNet model from Schirrmeister et al (2017) [Rb8ef6c2733ce-Schirrmeister2017].

DeepSleepNet([n_outputs, return_feats, ...])

Sleep staging architecture from Supratak et al. (2017) [R28b528aca953-Supratak2017].

EEGConformer([n_outputs, n_chans, ...])

EEG Conformer from Song et al. (2022) from [Rd6c0fefc356a-song2022].

EEGInceptionERP([n_chans, n_outputs, ...])

EEG Inception for ERP-based from Santamaria-Vazquez et al (2020) [R37c4761d4e92-santamaria2020].

EEGInceptionMI([n_chans, n_outputs, ...])

EEG Inception for Motor Imagery, as proposed in Zhang et al. (2021) [Rc36ed781f4f5-1].

EEGITNet([n_outputs, n_chans, n_times, ...])

EEG-ITNet from Salami, et al (2022) [R7fe571f46200-Salami2022]

EEGNetv1([n_chans, n_outputs, n_times, ...])

EEGNet model from Lawhern et al. 2016 from [Rcbe3da2652d4-EEGNet].

EEGNetv4(n_chans, n_outputs, n_times, ...)

EEGNet v4 model from Lawhern et al. (2018) [Rbd7837e27d7f-EEGNet4].

EEGNeX([n_chans, n_outputs, n_times, ...])

EEGNeX model from Chen et al. (2024) [R60f8df15fd80-eegnex].

EEGMiner([method, n_chans, n_outputs, ...])

EEGMiner from Ludwig et al (2024) [R66a8789ab6ed-eegminer].

EEGResNet([n_chans, n_outputs, n_times, ...])

EEGResNet from Schirrmeister et al. 2017 [R625b4a01fbf7-Schirrmeister2017].

EEGSimpleConv([n_outputs, n_chans, sfreq, ...])

EEGSimpleConv from Ouahidi, YE et al. (2023) [R5661533ddc63-Yassine2023].

EEGTCNet([n_chans, n_outputs, n_times, ...])

EEGTCNet model from Ingolfsson et al. (2020) [Rc25b3d8a3a40-ingolfsson2020].

Labram([n_times, n_outputs, chs_info, ...])

Labram from Jiang, W B et al (2024) [Rb5cdfc6ea4fe-Jiang2024].

MSVTNet(n_chans, n_outputs, n_times, ...)

MSVTNet model from Liu K et al (2024) from [R0733e66fed6d-msvt2024].

SCCNet([n_chans, n_outputs, n_times, ...])

SCCNet from Wei, C S (2019) [Rbd95e5cdbbde-sccnet].

SincShallowNet(num_time_filters, ...)

Sinc-ShallowNet from Borra, D et al (2020) [R4fd1ba6a7153-borra2020].

ShallowFBCSPNet([n_chans, n_outputs, ...])

Shallow ConvNet model from Schirrmeister et al (2017) [R9432a19f6121-Schirrmeister2017].

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

Sleep staging architecture from Blanco et al. (2020) from [Rb3eee9d9e81a-Blanco2020].

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

Sleep staging architecture from Chambon et al. (2018) [R89163c5eab6a-Chambon2018].

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

Sleep Staging Architecture from Eldele et al. (2021) [R63c3502458ce-Eldele2021].

SPARCNet(n_chans, n_times, n_outputs, ...)

Seizures, Periodic and Rhythmic pattern Continuum Neural Network (SPaRCNet) from Jing et al. (2023) [Rf8eed20f8ca2-jing2023].

SyncNet([n_chans, n_times, n_outputs, ...])

Synchronization Network (SyncNet) from Li, Y et al (2017) [R5cdbe961b734-Li2017].

TSceptionV1([n_chans, n_outputs, ...])

TSception model from Ding et al. (2020) from [R422d465e7195-ding2020].

TIDNet([n_chans, n_outputs, n_times, ...])

Thinker Invariance DenseNet model from Kostas et al. (2020) [Re74dd80418c9-TIDNet].

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

Sleep staging architecture from Perslev et al. (2021) [R58a5e8182f0a-1].

braindecode.models:

FilterBankLayer(n_chans, sfreq[, ...])

Apply multiple band-pass filters to generate multiview signal representation.

GeneralizedGaussianFilter(in_channels, ...)

Generalized Gaussian Filter from Ludwig et al (2024) [R9d2e5f5ce220-eegminer].

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 described 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.

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

The NMT Scalp EEG Dataset.

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.

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.

Resample([up, down, axis, window, n_jobs, ...])

Resample an array.

DropChannels(ch_names[, on_missing])

Drop channel(s).

SetEEGReference([ref_channels, projection, ...])

Specify which reference to use for EEG data.

Filter(l_freq, h_freq[, picks, ...])

Filter a subset of channels/vertices.

Pick(picks[, exclude, verbose])

Pick a subset of channels.

Crop([tmin, tmax, include_tmax, verbose])

Crop raw data file.

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.

SegmentationReconstruction(probability[, ...])

Segmentation Reconstruction from Lotte (2015) [R78e7a66c7d6f-Lotte2015].

MaskEncoding(probability[, max_mask_ratio, ...])

MaskEncoding from [R9102599ed233-1].

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.

functional.segmentation_reconstruction(X, y, ...)

Segment and reconstruct EEG data from [Rc19448ba78ac-1].

functional.mask_encoding(X, y, time_start, ...)

Mark encoding from Ding et al. (2024) from [Re49696d5b28b-ding2024].

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].