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 [R9432a19f6121-2].

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

Deep ConvNet model from [Rb8ef6c2733ce-1].

EEGNetv1(in_chans, n_classes[, …])

EEGNet model from [Rcbe3da2652d4-EEGNet].

EEGNetv4(in_chans, n_classes[, …])

EEGNet v4 model from [Rbd7837e27d7f-EEGNet4].

HybridNet(in_chans, n_classes, …)

Hybrid ConvNet model from [R4d1af390a17e-3].

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

Residual Network for EEG.

TCN(n_in_chans, n_outputs, n_blocks, …)

Temporal Convolutional Network (TCN) as described in [Rcfca6ae7a220-1]. Code adapted from https://github.com/locuslab/TCN/blob/master/TCN/tcn.py Parameters ———- n_in_chans: int number of input EEG channels n_outputs: int number of outputs of the decoding task (for example number of classes in classification) n_filters: int number of output filters of each convolution n_blocks: int number of temporal blocks in the network kernel_size: int kernel size of the convolutions drop_prob: float dropout probability add_log_softmax: bool whether to add a log softmax layer References ———- .. [Rcfca6ae7a220-1] Bai, S., Kolter, J. Z., & Koltun, V. (2018). An empirical evaluation of generic convolutional and recurrent networks for sequence modeling. arXiv preprint arXiv:1803.01271.

SleepStagerChambon2018(n_channels, sfreq[, …])

Sleep staging architecture from [R89163c5eab6a-1].

get_output_shape(model, in_chans, …)

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

Training

braindecode.training:

CroppedLoss(loss_function)

Compute Loss after averaging predictions across time.

CroppedTrialEpochScoring(scoring[, …])

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

PostEpochTrainScoring(scoring[, …])

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

trial_preds_from_window_preds(preds, …)

Assigning window predictions to trials while removing duplicate predictions.

Datasets

braindecode.datasets:

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

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

BaseConcatDataset(list_of_ds)

A base class for concatenated datasets.

WindowsDataset(windows[, description, transform])

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

MOABBDataset(dataset_name, subject_ids)

A class for moabb datasets.

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.

Data Utils

braindecode.datautil:

create_from_X_y(X, y, drop_last_window[, …])

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

create_fixed_length_windows(concat_ds, …)

Windower that creates sliding windows.

create_windows_from_events(concat_ds, …[, …])

Create windows based on events in mne.Raw.

exponential_moving_demean(data[, …])

Perform exponential moving demeanining.

exponential_moving_standardize(data[, …])

Perform exponential moving standardization.

zscore(data)

Zscore normalize continuous or windowed data in-place.

scale(data, factor)

Scale continuous or windowed data in-place

filterbank(raw, frequency_bands[, …])

Applies multiple bandpass filters to the signals in raw.

save_concat_dataset(path, concat_dataset[, …])

load_concat_dataset(path, preload[, …])

Load a stored BaseConcatDataset of BaseDatasets or WindowsDatasets from files.

preprocess(concat_ds, preprocessors)

Apply preprocessors to a concat dataset.

Preprocessor(fn[, apply_on_array])

Preprocessor for an MNE Raw or Epochs object.

Samplers

braindecode.samplers:

RecordingSampler(metadata[, random_state])

Base sampler simplifying sampling from recordings.

RelativePositioningSampler(metadata, …[, …])

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

Utils

braindecode.util:

set_random_seeds(seed, cuda)

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

Visualization

braindecode.visualization:

compute_amplitude_gradients(model, dataset, …)