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.

get_default_dataloaders

Return the train/val/test DataLoaders for a task's default data config.

BrainModule

Pytorch-lightning module for M/EEG model training.

Running the benchmark¶

Three entry points onto the same experiments – the neuralbench command, the same selections from Python, and one model you built over a selection. They are compared in the quickstart.

run_benchmark_cli

CLI entry point for neuralbench.

run_benchmark

Run one or more NeuralBench experiments from Python.

check_model

Push synthetic batches of a selection's shapes through model.

evaluate_model

Run model on a selection of tasks and return the results.

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.