Health and life sciences
Machine learning for neuroscience
Neuroscientists use machine learning to sort spikes from electrode recordings, track animal pose in video, and decode stimuli or behaviour from neural population activity. These methods turn large recordings into variables that can be compared across experiments.
How neuroscientists use machine learning
Sorting spikes from electrode recordings
Dense probes record overlapping signals from many neurons, and spike sorting assigns each detected waveform to a unit. Modern sorters use clustering over templates and handle drift during long recordings.
Real exampleKilosort4 (Pachitariu et al., 2024)Describes the Kilosort framework and a version using graph-based clustering, tested against other algorithms in a simulation framework built from densely sampled real electrical fields.
Measuring behaviour from video
Pose estimation turns raw video into coordinates for each body part, so behaviour becomes a time series that can be aligned with neural activity. A few hundred labelled frames are usually enough.
Real exampleDeepLabCut (Mathis et al., 2018)A markerless pose estimation toolbox based on transfer learning that tracked user-defined body parts across species and behaviours with roughly 200 labelled training frames.
Relating neural activity to behaviour
Embedding methods learn a joint low-dimensional space from neural and behavioural data, which can then be used for visualisation, comparison across sessions and decoding.
Real exampleCEBRA (Schneider et al., 2023)An encoding method that jointly uses behavioural and neural data in supervised or self-supervised mode to produce latent spaces, validated on calcium imaging and electrophysiology datasets across species.
Reconstructing circuits from electron microscopy
Neural networks segment electron microscopy volumes into individual neurons and detect synapses, which humans then proofread. This is what makes whole-brain wiring diagrams possible at all.
Real exampleAdult fly brain wiring diagram (Dorkenwald et al., 2024)Presents a whole-brain wiring diagram with about 5 x 10^7 chemical synapses between 139,255 reconstructed neurons of an adult fruit fly, built from automated segmentation with extensive proofreading.
Can neuroscientists learn machine learning?
Yes. Neuroscience training already covers experimental design and statistics, which is most of the hard thinking. Add Python, then classical machine learning with careful splits, then deep learning for video, imaging and large recordings. Most first projects replace a manual analysis step rather than inventing a new method.
- Python for experimental dataLoad recordings and behaviour into arrays and tables, and keep trial, session and animal identifiers attached to every row.Learn it in Python
- Statistics and validationLearn cross-validation, permutation tests and chance levels, and respect the nesting of trials inside sessions inside animals.Learn it in Statistics
- Classical machine learningUse regularised regression and classification as the workhorses for decoding and for relating variables.Learn it in Machine Learning
- Deep learning for signals and videoUse pretrained pose and segmentation models first, then train your own when the task is specific to your preparation.Learn it in Deep Learning
- Pipelines and sharingStore data in standard formats such as NWB and version your analysis code so results can be reproduced by others.
Moving from neuroscience into machine learning
If you already work in the field
Neuroscientists already have the recordings, the task design and the knowledge of what would be a real effect. Add Python and model evaluation, then automate one analysis step you currently do by hand, such as sorting or scoring behaviour, and validate it against your manual results.
If you come from data science or ML
Machine learning practitioners should learn how experiments are run, how small sample sizes are and why a session is the natural unit for a split. Start from public datasets such as those in the Allen Brain Observatory and collaborate with an experimenter from the design stage.
Roles that do this workComputational neuroscientistNeural data scientistResearch software engineer, neuroscienceBioimage analyst
Tools you will use
| Tool | What you use it for |
|---|---|
| AllenSDK | Download and analyse Allen Brain Observatory recordings and stimulus tables from Python. |
| SpikeInterface | Run and compare spike-sorting algorithms on extracellular electrode recordings. |
| DeepLabCut | Track animal body parts in video with deep learning to measure behaviour. |
| scikit-learn | Fit decoders and encoding models with cross-validation across trials and sessions. |
Public data to practise on
- Allen Brain Observatory Visual Coding: Openly available recordings from mouse visual cortex during gratings, natural scenes and movies, for stimulus decoding.
- International Brain Laboratory data: Standardised recordings and behaviour from mice performing a decision task, for decoding choices across brain regions.
Your first project
Download a drifting-gratings session from the Allen Brain Observatory with AllenSDK, decode grating direction from neural responses with logistic regression, and compare it with a shuffled-label baseline using cross-validated accuracy.
Common questions
Is machine learning replacing traditional analysis in neuroscience?
No. It adds tools for large recordings and video, while hypothesis testing, controls and causal manipulations remain the backbone of the field.
How much data does a neuroscience machine learning project need?
Pose tracking needs a few hundred labelled frames, decoding needs enough trials per condition, and representation models benefit from many sessions. Independent sessions matter more than raw hours.
Which public datasets can you start with?
The Allen Brain Observatory, DANDI and OpenNeuro host large, documented recordings with code examples, so you can build a full project without collecting data.
Does a neural network model of a brain area explain it?
A model that predicts responses well is a useful summary, not an explanation. Testing a claim still needs perturbations and predictions that could fail.
Courses for these skills
- Practical Machine Learning in PythonKeep preprocessing and evaluation inside a valid fitting workflow.51 published lessons · more lessons in production
- Statistics and Probability for Machine LearningBuild probability, inference and experimental-design foundations.41 published lessons · all planned lessons open
- Data Tools: NumPy, pandas, Matplotlib and scikit-learnWork with array representations and subject metadata.23 published lessons · all planned lessons open
New to programming or maths? Start with Python, or follow the machine learning path in order. Published lessons are free to read; compare Free and Pro.