Machine Learning for Neuroscience

Translational Machine Intelligence Lab


Teaching Staff

Members of the Translational Machine Intelligence Lab delivering this module:

  • Nan Fletcher-Lloyd

  • Alex Capstick

  • Yu Chen

  • Anastasia Gailly De Taurines

  • Antigone Fogel

  • Iona Biggart

  • Payam Barnaghi

Alumni

Past members who helped make this module possible:

We would like to give thanks to Marirena Bafaloukou, Anastasia Ilina, Tianyu Cui, Ruxandra Mihai, Olivia Li, and Francesca Palermo.


Content

Deepen your understanding of machine learning as applied to neuroscience. This course will cover supervised and unsupervised techniques as well as classic machine learning methods and deep learning.

What will you do in this course?

This course will explore machine learning methods with a discussion on their use in neuroscience. We will cover several aspects of machine learning, from classical methods to deep learning.

By the end of this module, you will be able to:

  • ILO 1: Critique and contrast machine learning techniques and analyse the problem settings within which they are particularly useful.
  • ILO 2: Develop machine learning models by applying common machine learning libraries and tools.
  • ILO 3: Apply practical computational and machine learning techniques to analyse data from a variety of sources and interpret the results.
  • ILO 4: Plan and implement neural networks to develop end-to-end solutions for data analysis problems.
  • ILO 5: Justify the choice of applied machine learning models based on their appropriateness for the problem, ability to generalise and limitations.

Essential Course Material

Before taking this module, we advise that you work through the following video tutorials:

(Videos and slides for the Python tutorial are created by Nan Fletcher-Lloyd, Iona Biggart, and Antigone Fogel)

If you have any trouble installing anaconda or VSCode, please do not hesitate to contact us.

We also suggest that you complete the Python for Beginners Tutorial. If you have any difficulty/questions arising from this, we would be happy to work through these with you during the first lab.

Reading List

A good place to start is Kevin Murphy's book on Probabilistic Machine Learning. You might find it helpful to read the following sections:

  • The Introduction
  • Foundations: Probability: Univariate Models
  • Foundations: Linear Algebra

If you get through this list and would like some additional reading, let us know and we can recommend more!

Optional Course Material

In addition to the essential course material, a knowledge of linear algebra, probability theory and calculus will give you the best chance of success.


Assessments

What are you being assessed on?

We will assess your ability to apply the knowledge you haved learnt during the lectures. Questions will test your understanding of key machine learning concepts as well as your ability to apply machine learning methods in Python to a series of real-world problems.

How will this be assessed?

Through this course, you will be assessed on four piecess of coursework: three pieces of coursework completed during lab three pieces of coursework during lab sessions, and a final project. You will also be given the opportunity to complete a formative assessment (marks do not count towards your final grade for this module) for feedback on your understanding of key techniques. Marked assessments will be made available to you on Blackboard at the start of the afternoon lab sessions.


Schedule

All lectures are recorded, but the labs will not be.

Week 1 - Starting Monday 13th January
Date Time Content Files Activity Feedback Lecturer
Mon 10:30 - 12:30 1: Introduction to Machine Learning | Lecture P. Barnaghi
13:30 - 16:30 Key Machine Learning Techniques ☆
Lab P. Barnaghi
Tue 10:30 - 12:30 2: Linear Models | Lecture P. Barnaghi
13:30 - 16:30 Linear Models - Regression and Classification Models Lab P. Barnaghi
Wed 10:30 - 12:30 3: Probability and Information Theory | Lecture P. Barnaghi
13:30 - 16:30
Thur 10:30 - 12:30 4: Bayesian Models | Lecture P. Barnaghi
13:30 - 16:30 Bayesian Models Lab P. Barnaghi
Fri 10:30 - 12:30 5: Ensemble Models and Kernel Based Models | Lecture P. Barnaghi
13:30 - 16:30 Ensemble Models and Kernel Based Models ★ Lab P. Barnaghi

★: Marked labs
;
☆: Optional formative lab
;
: Slides
;
: Notes
;
: Download lab
;
: Open lab in Colab

Week 2 - Starting Monday 20th January
Date Time Content Files Activity Feedback Lecturer
Mon 10:30 - 12:30 6: Neural Networks | Lecture P. Barnaghi
13:30 - 16:30 Neural Networks ♦ Lab
P. Barnaghi
,
A. Capstick
Tue 10:30 - 12:30 7: Convolutional Neural Networks (CNNs) | Lecture P. Barnaghi
13:30 - 16:30 Convolutional Neural Networks (CNNs) ★ Lab P. Barnaghi
Wed 10:30 - 12:30 8: Applications and Neuroscience Inspired Machine Learning | Lecture P. Barnaghi
13:30 - 16:30
Thur 10:30 - 12:30 9: Responsible Machine Learning ♣ | Lecture
P. Barnaghi
,
L. Rigny
13:30 - 16:30 Use-case Evaluation ★ Lab P. Barnaghi
Fri 10:30 - 12:30 Guest Lecture - Ethical AI: Principles and Practices Lecture N. Fletcher-Lloyd
13:30 - 16:30 Debate: Should AI be used to make diagnostic decisions in healthcare? Lab N. Fletcher-Lloyd

★: Marked labs
;
: Slides
;
: Notes
;
: Download lab
;
: Open lab in Colab

♦: Guest Lecture: Introduction to Pytorch, Alex Capstick

♣: Guest Lecture: Large Language Models for Electronic Healthcare Records (EHR) Data Analysis, Louise Rigny (Data Scientist, Great Ormond Street Hospital for Children)

Week 3 - Starting Monday 27th January
Date Time Content Files Activity Feedback Lecturer
Mon 10:30 - 12:30 Review and Project (Q/A) Lecture P. Barnaghi
13:30 - 16:30 Project Lab P. Barnaghi
Tue 10:30 - 12:30 Project Lab P. Barnaghi
13:30 - 16:30 Project Lab P. Barnaghi
Wed 10:30 - 12:30 Project Lab P. Barnaghi
13:30 - 16:30

March/April 2025

In March/April 2025, there will be an optional series on Generative AI and Large Language Models (LLMs) covering the topics:

  • Variational Auto-encoders
  • Transformers and Large Language Models
  • Diffusion Models

Last year's slides and recordings are available here.


Lectures

The slides are by Payam Barnaghi, whilst the notes are written by Nan Fletcher-Lloyd.

Content to get you started:

The lecture slides are available here:

Click here to download the notes as one PDF document.
Annotated slides: GitHub link.

Labs

Labs and assessments are produced by Payam Barnaghi, Nan Fletcher-Lloyd, Alex Capstick, Yu Chen, Marirena Bafaloukou, Anastasia Ilina, Anastasia Gailly de Taurines, Antigone Fogel, and Iona Biggart. The entire github repository can be downloaded as a zip file using this link. This includes the labs and a copy of this website, which can be opened locally.

The following links are to the individual labs, already run and stored in GitHub. Clicking any of the "Open in Colab" buttons will open that lab in Google Colab, which allows you to run code from your browser with a GPU if selected.

Lab Notebooks:


Setting Up Your Conda Environment

The following are the steps to set up your environment if you will be running the labs locally:

  1. Install Miniconda here.
  2. On Windows open Anaconda Prompt and on Mac/Linux open Terminal.
  3. To create an environment for the course, run:
    conda create -n ml4ns python=3.11.5
            
  4. Download the the requirements.txt file (from here) and place it in your root directory.
  5. Activate your environment:
    conda activate ml4ns
            
  6. Install the requirements:
    pip install -r requirements.txt
            
  7. If you're on Mac or Windows (without a GPU), you can install Pytorch using the below. If you have a GPU, you can install Pytorch using the command on the Pytorch website.
    pip3 install torch torchvision torchaudio
            
  8. Install Transformers using:
    pip install transformers
            
  9. Recommended: Install VScode here.
  10. Open VSCode and open the Jupyter Notebook files, or open Jupyter Lab using the below and then open the Jupyter Notebook files:
    jupyter lab
            
  11. If you are using VSCode, you need to install the Jupyter Notebook extension.
  12. In VScode, select the Python interpreter for your environment (top right, usually!).
  13. If everything has worked then in the Python environment you should be able to run:
    
                  import torch
                
    Then:
    
                  torch.cuda.is_available()
                
    And if you have a GPU, you should see True, otherwise False.

Each session:

  • If you're using Jupyter Lab, every time you go to work on this project you'll need to activate your environment by running conda activate ml4ns using either the Terminal (Mac) or Anaconda Prompt (Windows). Then you may enter the command jupyter lab to open Jupyter Lab.

  • If you're using VSCode, you'll need to select the Python environment for each new file you open.


GitHub

The GitHub repository for this course is available here: GitHub


A Machine Learning Demo

This is a simple demo that shows you how cool machine learning is! This model is running in your browser and will predict the number of stars from a film review. Try it out!


Contact Us

If you want to contact Payam Barnaghi, send an email to: p.barnaghi@imperial.ac.uk or use the links on the staff images to contact a specific person.


Affiliation


Licensing

This work is licensed under a CC BY 4.0 License:

Software elements are additionally licensed under the BSD (3-Clause) License.