Neuromatch Academy Computational Neuroscience Project (NMA 2025)
This repository contains the code and analyses from our NMA2025 project, where we investigated prediction-error signaling in inhibitory neurons of mouse visual cortex, using the Allen Brain Observatory Visual Behavior 2-Photon (2P) dataset.
We focused on VIP and SST neurons in the primary visual cortex (V1), exploring their response to:
- ✅ Presented vs. Omitted image flashes
- 🌄 Familiar vs. Novel image exposure
- 🧠 Trial-by-trial calcium signal analysis using event-locked measures
- 🤖 Cell-type classification via decoding models
How do VIP and SST neurons encode prediction-error signals during stimulus omissions, and how does this differ between familiar and novel visual contexts?
Our analysis pipeline was designed to investigate prediction-error signaling in VIP and SST neurons using calcium imaging data from the Allen Visual Behavior 2-Photon (2P) dataset. The pipeline consists of the following key stages:
-
Baseline Correction: We first applied baseline correction to calcium fluorescence traces to normalize across trials.
-
Averaging per Cell: We then averaged the event-locked traces across trials for each unique cell ID, under each combination of:
- Cell type (VIP or SST)
- Omission status (True or False)
- Exposure (Familiar or Novel)
-
Result: This resulted in a compact DataFrame with 640 rows and the following fields:
mouse_id
,cell_id
,cell_type
,omission
,exposure
,mean_trace
Each mean_trace
was a vector representing the average event-locked calcium signal for that condition.
From the mean_trace
vectors, we computed biologically relevant signal features such as:
- AUC (Area Under Curve)
- Peak Amplitude
- Latency to Peak
- Slope & Timing Windows
These features formed the input space for statistical analysis and supervised classification.
To test the effects of omission, exposure, and cell type on neural activity:
- We used three-way ANOVA to assess:
- Main effects of
cell_type
,exposure
, andomission
- All two-way and three-way interaction effects
- Main effects of
- We followed this with post-hoc comparisons (Tukey HSD and Hedges' g) to estimate effect sizes and pairwise differences
This revealed strong prediction-error dynamics in VIP neurons, particularly under familiar + omitted conditions.
In parallel, we also analyzed raw calcium traces using CASCADE, a state-of-the-art deep learning model for supervised spike inference (Berens et al., 2021):
-
CASCADE output:
spike_prob
— estimated spike probability per time bin -
We extracted spike-based features (e.g., average spike rate in different bins) and repeated the full factorial ANOVA
-
These results corroborated our findings using traditional calcium features
To determine if neuron types and stimulus conditions could be decoded from event-locked activity:
- We trained several classifiers on the extracted features:
- Logistic Regression
- Random Forest
- Gradient Boosting
- XGBoost
- SVM (RBF)
- k-Nearest Neighbors
To ensure generalization across individual animals, we used Leave-One-Mouse-Out (LOMO) cross-validation:
- In each fold, data from one mouse was used as the test set
- The model was trained on the remaining 12 mice
- This avoids overfitting and ensures biological generalizability across individuals
The best-performing model (Gradient Boosting) achieved:
- LOMO Accuracy: 94.5%
- Test Accuracy: 97.7%
- F1 Score: 0.976
- ROC-AUC: 0.997
Model | LOMO Accuracy | Test Accuracy | F1 Score | ROC-AUC |
---|---|---|---|---|
Gradient Boosting | 0.945 | 0.977 | 0.976 | 0.997 |
XGBoost | 0.947 | 0.969 | 0.969 | 0.996 |
Random Forest | 0.931 | 0.969 | 0.968 | 0.998 |
Logistic Regression | 0.902 | 0.953 | 0.951 | 0.984 |
SVM (RBF) | 0.880 | 0.914 | 0.913 | 0.977 |
KNN (k=7) | 0.873 | 0.898 | 0.896 | 0.958 |
- Top features: Early trial (0–500 ms) firing rate and slope
- Gradient Boosting showed strongest generalization across all 13 mice
├── EDA.ipynb # Exploratory data analysis
├── event-locked-calcium-signal_preprocessing&feature extraction_per-cell.ipynb # Event-locked signal extraction per-cell(preprocessing) and Feature extraction(processing)
├── modeling.ipynb # Classifier training & evaluation
├── event-locked-calcium-signal-MVPA # multivariate pattern analysis on unprocessed dataset(Time Resolved Decoding)
├── event-locked-calcium-signal-Hypothesis_testing_per-cell # testing hypothesis with ANOVA and post-hoc
├── event-locked-calcium-signal-cascade model.ipynb # CASCADE-based spike analysis
├── figures/ # Plots and visualizations
├── README.md # Project overview
- Source: Allen Institute Visual Behavior 2P Dataset
- Download: Figshare - Allen SDK Visual Behavior 2P
- Includes: Cre lines (Vip, Sst), image familiarity tags, 2P calcium recordings
Team Name: Feisty Bes / VIP Gladiators
Contributors:
- Hossein Damavandi
- Mohammad Saeed Soleimani
- Sotoode Aliyari
- Elnaz Abbaszadeh
- Niyayesh Yousefi
- Fatemeh Gholamzadeh
- Piet et al. (2022) Nature Neuroscience
- Najafi et al. (2023) Nature Neuroscience
- Garrett et al. (2023) eLife
- Homann et al. (2023) Nature Neuroscience
This project is released under the MIT License.