Brain encoding and decoding¶
This jupyter book presents an introduction to brain encoding and decoding using fMRI. Brain decoding is a type of model where we try to guess what a subject is doing, based on recordings of brain activity. Brain encoding is the reverse operation, where we use machine learning tools to predict the activity of the brain, either based on annotations of the cognitive states of the subject, or using features learned by an artificial neural network presented with the same stimuli as the subject. The tutorials make heavy use of nilearn manipulate and process fMRI data, as well as scikit-learn and pytorch to apply machine learning techniques on the data.
This resource was developed for use at the Montreal AI and Neuroscience (MAIN) conference in November 2021.
There are two ways to run the tutorials: local installation and Binder.
Local installation (Recommended)¶
You need to have access to a terminal with Python 3. If you have setup your environment based on instructions of MAIN educational installation guide, you are good to go 🎉
If it not already the case, here is a quick guide to install python 3 on any OS.
Clone/download this repository to your machine and navigate to the directory.
git clone https://github.com/main-educational/brain_encoding_decoding.git cd brain_encoding_decoding
We encourage you to use a virtual environment for this tutorial (and for all your projects, that’s a good practice). To do this, run the following command in your terminal, it will create the environment in a folder named
python3 -m venv env_tuto
Then the following command will activate the environment:
Finally, you can install the required libraries:
pip install -r binder/requirements.txt
Navigate to the content of the book:
Now that you are all set, you can run the notebooks with the command:
Click on the
.mdfiles. They will be rendered as jupyter notebooks 🎉
If you wish to run the tutorial in Binder, click on the rocket icon to launch the notebook 🚀
The computing resource on Binder is limited. Some cells might not execute correctly, or the data download will not be completed. For the full experience, we recommend using the local set up instruction.
Parts of the tutorial are directly adapted from a nilearn tutorial on the Haxby dataset.
Some images and code are used from a previous iteration of this tutorial, prepared by Dr Yu Zhang.
It is rendered here using Jupyter Book,
Martin Schrimpf, Jonas Kubilius, Ha Hong, Najib J Majaj, Rishi Rajalingham, Elias B Issa, Kohitij Kar, Pouya Bashivan, Jonathan Prescott-Roy, Franziska Geiger, Kailyn Schmidt, Daniel L K Yamins, and James J DiCarlo. Brain-Score: which artificial neural network for object recognition is most Brain-Like? bioRxiv, pages 407007, January 2020.