Machine learning models for fMRI classification
Project description
ml4fmri
A one-line Python toolkit for fMRI classification that allows you to benchmark multiple deep learning models for fMRI analysis on your data with a single function call. While designed for fMRI time series, it can work with any temporal classification task.
Originally based on the codebase behind the NeuroImage paper:
"A simple but tough-to-beat baseline for fMRI time-series classification"
Use example
You can install the package directly from PyPI:
pip install ml4fmri
For a more detailed guide, check out the Colab tutorial:
# In Python, get fMRI time series data in shape (samples, time, n_features)
# and labels in shape (samples) (binary or multiclass)
from ml4fmri import cvbench # runs CV experiments with implemented models on the given data
# Run cross-validation with all available models. See below for more info on available `models`
report = cvbench(data, labels, models='all', n_folds=5)
# Plot test AUC boxplots for all models
report.plot_scores()
# Save test and training dataframes as .csv, and metadata as .json
report.save()
# Access logs directly as variables
train_df = report.get_train_dataframe()
test_df = report.get_test_dataframe()
meta = report.get_meta()
# Inspect training curves
report.plot_training_curves()
Available Models
You can set models input in cvbench to:
- 'all' - run all models,
- 'lite' (default) – use only faster models, better for quick tests
- 'ts' – run only time series models
- 'fnc' – run only FNC models; FNC data is derived from input time series
- '<model_name>' – run only the specified model (e.g. 'meanMLP'); see ml4fmri.models README for full list
- ['<model_name_1>', '<model_name_2>'] – run only the listed models
Time Series Models
-
"meanMLP" (Time Series)
A simple MLP model for time series classification, surprisingly good for fMRi time series. Paper
Code and bib item -
"LSTM" (Time Series)
Standard LSTM recurrent network for sequence classification.
Paper
Code and bib item -
"meanLSTM" (Time Series)
A variant of LSTM where outputs are mean-aggregated across time.
Paper
Code and bib item -
"Transformer" (Time Series)
Vanilla transformer encoder for modeling temporal dependencies in fMRI time series.
Paper
Code and bib item -
"meanTransformer" (Time Series)
Transformer with temporal mean pooling for classification.
Paper
Code and bib item -
"MILC" (Time Series)
CNN+LSTM model for fMRI time series.
Paper
Code and bib item -
"BolT" (Time Series) Fused window Transformer for fMRI time series; slow but good, outperformed meanMLP on larger datasets. Paper Code and bib item
-
"DICE" (Time Series) LSTM-based connectivity estimator and classifier, works with time series. Paper Code and bib item
-
"Glacier" (Time Series) Transformer-based connectivity estimator and classifier, works with time series. Paper Code and bib item
-
"FBNetGen" (Time Series + FNC) Connectivity estimator, fuses it with FNC to do classification. Paper Code and bib item
FNC Models
-
"LR" (FNC)
Logistic regression, wired for FNC classification.
Paper
Code and bib item -
"BNT" (FNC) Transformer/GNN model for FNC classification. Paper Code and bib item
-
"BrainNetCNN" (FNC) CNN classifier, designed for FNC-like matrices in mind. Paper Code and bib item
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ml4fmri-1.0.0.tar.gz.
File metadata
- Download URL: ml4fmri-1.0.0.tar.gz
- Upload date:
- Size: 4.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98728cb8b09c375db6315bf50eb98339c4025a6a4e98807d124fc92cb1a611dc
|
|
| MD5 |
a317377da7f8a2e10c9d8cb9c652d21e
|
|
| BLAKE2b-256 |
d72dff6ac7dccd07e11a81f308a6a4d82f9f8d004e68eaabd4078fbd23f5a4a4
|
File details
Details for the file ml4fmri-1.0.0-py3-none-any.whl.
File metadata
- Download URL: ml4fmri-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a3433c4d96ba15b124cf921ecbf3fec2a3b530a26832f68a7003fded5210e66
|
|
| MD5 |
db06abd53a40d491ad2aec11a8cb903d
|
|
| BLAKE2b-256 |
4e126d2270642cb26114d866bf88d181640d1af956438872cf0752fd23514f8b
|