API Reference

Core

Data

Create dataloaders for brain-modeling experiments.

Experiment

Brain-modeling experiment with support for loading pretrained weights.

BenchmarkAggregator

Orchestrate multiple Experiment runs and visualise results.

BrainModule

Pytorch-lightning module for M/EEG model training.

CLI

run_benchmark

Run one or more NeuralBench experiments from Python.

run_benchmark_cli

CLI entry point for neuralbench.

Events Transforms

TextPreprocessor

Clean and filter text-related events.

SklearnSplit

Perform train/val/test split using sklearn's train_test_split.

SimilaritySplit

Perform train/val/test split based on similarity of sentence events.

PredefinedSplit

Assign train/test labels based on a predefined split, and optionally split train into validation as well.

CropSleepRecordings

Keep up to max_wake_duration_min mins of wake (W) time before and after the first and last sleep events.

CropTimelines

Crop neuro timelines.

AddDefaultEvents

Add default events to a timeline to fill out its duration.

OffsetEvents

Offset selected events by specified amounts.

Callbacks

TestFullRetrievalMetrics

Accumulate predictions on entire test set before evaluating metrics.

RecordingLevelEval

Callback to evaluate average prediction over each recording (timeline).

PlotConfusionMatrix

PlotRegressionVectors

Visualize predictions vs ground truth for multi-dimensional regression tasks.

plot_confusion_matrix

Plot confusion matrix/matrices with a shared colorbar.

Utilities

TrainerConfig

Joint configuration for Trainer and some callbacks.

load_checkpoint

Load checkpoint through state_dicts.

compute_class_weights_from_dataset

Compute class weights from training dataset for handling class imbalance.

make_weighted_sampler

Create a weighted random sampler for the given dataset to handle class imbalance.

Modules

DownstreamWrapper

Configuration for wrapping a (pretrained) model for downstream fine-tuning or linear probing.

DownstreamWrapperModel

Wrapper for downstream evaluation of pretrained models.

Configuration

setup_config

Set up neuralbench configuration.

load_config

Load neuralbench configuration.

get_config

Get the current configuration, loading it if necessary.