Giter Club home page Giter Club logo

fmri-s4's Introduction

fMRI-S4

This the official Pytorch implementation of the paper fMRI-S4: Learning short- and long-range dynamic fMRI dependencies using 1D Convolutions and State Space Models

Setup

Requirements

This repository requires Python 3.8+ ,Pytorch 1.9+ and Pytorch Lightning Other packages are listed in requirements.txt.

Data

Datasets and Dataloaders

The Abide dataset can be requested from here The Mddrest dataset can be requested from here

The Mddrest provide the pre-processed timecourses directly. For ABIDE you can generate the time-courses using nilearn. You can see an example of how to parcellate the data and extract the timecourses in 'data_notebook/parcellate.ipynb' To integrate it directly to the code, you can organize the paths and into a csv file as in provided in the examples in 'csvfiles/' All logic for creating and loading datasets to the model is in datasets.py.

Cauchy Kernel

The S4 module relies on the "Cauchy kernel" described in the paper. The implementation of this requires a custom CUDA kernel. To install it, Run python setup.py install from the directory extensions/cauchy/.

Running Experiments

Examples of how to train the model using different configurations

python main.py  --dataset ABIDE --atlas HO --n_conv_layers 1 --n_s4_layers 2
python main.py --dataset Mddrest --atlas AAL --n_conv_layers 3 --n_s4_layers 0

The default parameters are described in the paper. You can play around to find the best configuration that works best for your dataset. I observed a relatively robust performance using different hyper-parameters configurations. I recommended using the weights&biases sweep function for hyper-parameters search.

Explainability

Not written in the paper. I have experimented with visualizing the salient ROIs using different methods in the Captum Library. Feature Permutation with a mask covering the entire temporal profile of regions seems to work best for me. However this needs more exploration. I have tried with simple experiments where I create synthetic classes by classify fMRI with corrupted vs uncorrupted time-courses in certain regions and it seems to work fine. See 'interpret.py' for an example.

Citation

A large body of the code used for the S4 model was adopted from this repo, so please if you find any part of this work valuable cite their work along with ours.


@misc{https://doi.org/10.48550/arxiv.2208.04166,
  title = {fMRI-S4: learning short- and long-range dynamic fMRI dependencies using 1D Convolutions and State Space Models},
  doi = {10.48550/ARXIV.2208.04166},
  author = {El-Gazzar, Ahmed and Thomas, Rajat Mani and Van Wingen, Guido},
  publisher = {arXiv},
  year = {2022},
  }


@inproceedings{gu2022efficiently,
  title={Efficiently Modeling Long Sequences with Structured State Spaces},
  author={Gu, Albert and Goel, Karan and R\'e, Christopher},
  booktitle={The International Conference on Learning Representations ({ICLR})},
  year={2022}
}

fmri-s4's People

Contributors

zhreyu avatar elgazzarr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.