Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

144 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Machine Learning with Normative Modeling Tutorial

Computational Psychiatry Course 2025

This repository contains written instructions, links to code, and data used for the (virtual) Machine Learning/Normative Modeling Practical at the Computational Psychiatry Course 2025 in Zurich, also presented at the Computational Psychiatry Conference 2025 in Tübingen. We encourage anyone who wants to apply or teach about normative modeling to use these tutorials freely for educational purposes.

Overview tutorial

In this tutorial you will learn:

  1. To create your own normative models using brain imaging data.
  2. Interpret and visualize the outputs of the normative models.
  3. Use the deviation scores to predict schizophrenia.

This repository is a group effort by Saige Rutherford, Thomas Wolfers and has been updated and edited by Barbora Rehák Bučková, Hannah Savage and Charlotte Fraza and in general is maintained by the Predictive Clinical Neuroscience Lab.

Prerequisite knowledge

We will be running all of our code in Google Colab Python notebooks. These are essentially Jupyter notebooks run in the ☁️ cloud ☁️. Running our code using Colab will save us from dealing with Python library installation and virtual environment setup. It also ensures that we are all working on the same operating system which makes troubleshooting much easier (since there are only 2 instructors and lots of students)!

In general, it is assumed that you have some basic experience with Python programming, for an in-depth introduction you can look at the free Python data science handbook. Furthermore, the neuromatch academy has some great resources.

If you have never used Google Colab before, you can check out an introduction notebook with helpful links here: Open In Colab

We will also be using the Pandas library for a lot of our code. There is a great intro to Pandas Colab notebook here: Open In Colab

Other helpful pandas:panda_face:/plotting:bar_chart: links (not required to do during the practical, just added for those who might need extra Python help):

  1. Pandas cheatsheet
  2. Pandas Selecting/Indexing API

⚠️ Setup instructions for Google Colab ⚠️

You can open the Python notebook that we will use in this practical directly from this Github account (the links to the notebook are at the bottom of this Read Me file). Before you open the notebook, make sure you are logged into a Google account. All of the code has been tested using Google Chrome web browser. When you are ready to begin, you will click on the different Tasks with a Google Colab button below. This will launch a new browser tab with the Google Colab notebook.

Once you are in the Colab notebook tab, in the top right corner you will see a Connect (or Reconnect) button. Click on this, and a dropdown menu will appear as shown below. Click on Connect to hosted runtime this will allow you to run the notebook using Google’s cloud resources, which are likely much faster than your computer. If you would prefer to use your own computer’s resources (this is not recommended and instructors will not be able to help you troubleshoot if you are not running the notebook in the cloud), select Connect to local runtime.

⚠️ Note: Sometimes if the notebook is left running for a long time without any activity (i.e. your computer goes to sleep), you will be disconnected from the runtime. In that case, you will need to click on this same button. It will appear as Reconnect instead of Connect. You will also need to re-run all code blocks.

➡️ In the Colab python notebook, there are 2 types of cells: text cells & code cells. The text cells have plain text in them, that the notebook will not interpret as code. These are the cells that contain the background story & task instructions. The code cells have a ▶️ play button on the left side. These are the cells that the notebook will run as code. To run a code cell, you can either click on the play button ▶️ on the left side or use ‘Shift + Enter’ (your cursor must be inside the code cell).

Now you are ready to begin coding 🧠 💻!

Good luck 🍀 and remember to have fun 😃!

Before clicking on the collab button below, make sure you are logged into a Google account and using Chrome or Firefox internet browser (hopefully a current version)

Tasks

Task 1: Fitting normative models from scratch Open In Colab

Task 2: Applying pre-trained normative models Open In Colab

Task 3: Interpreting and visualizing the outputs of normative models Open In Colab

Task 4: Using the outputs (Z-scores) as features in predictive model Open In Colab

Video

If you did not have the chance to follow the lecture live at the CPC course here is an alternative presentation given by Andre Marquand or Saige Rutherford on Normative modelling:

normative modelling lecture Normative Modelling & Single-Subject Analysis

Suggested Reading

Here we provide a non-exhaustive list of papers to help you with your understanding of the normative framework.

Extended tutorials

If you are curious about performing longitudinal normative modeling, HBR normative modeling, or other methods developed by the Predictive clinical neuroscience lab, see the extended tutorials here 🧠.

About

Code & Data for Computational Psychiatry Course Tutorial on Machine Learning

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages