This repository contains the codebase for my Final Degree Project (Trabajo de Fin de Grado - TFG). The project explores and compares methods for Simulation-Based Inference (SBI) to estimate the underlying synaptic coupling parameters of a cortical neural circuit using macroscopic signals like the Current Dipole Moment (CDM).
The activity of complex biophysical networks, such as Leaky Integrate-and-Fire (LIF) neural models, is highly dependent on their internal parameters (e.g., recurrent synaptic connections:
Two main approaches are evaluated and compared using the Sequence Neural Posterior Estimation (SNPE) algorithm from the sbi library:
- Raw Time-Series Embedding: Feeding the raw CDM signals directly into a fully connected embedding neural network to learn a summary representation.
- Feature Extraction: Extracting 22 canonical time-series characteristics using the
pycatch22package and using these features to estimate the posterior distribution.
Both results are robustly cross-validated (10-fold CV) and assessed using metrics like Parameter Recovery Error (PRE), covariance between 2D marginals, and Posterior Predictive Checks (PPC).
| Simulation Data | Neural Spikes |
|---|---|
![]() |
![]() |
LIF_model/: Contains codes and simulation data of the biophysical Leaky Integrate-and-Fire network.extract_features.py: Script to process simulation data, prune the transient responses, and extract 22 scalar features per signal using thepycatch22package.SBI_CDM.py: Performs Simulation-Based Inference directly on the raw CDM macroscopic signals leveraging a fully connected embedding network.SBI.py: Performs Simulation-Based Inference over the previously extracted canonical features (fromextract_features.py). Includes comprehensive evaluation (PRE, PCC, and sample visualization pairs).mouses_features.py&mouse_study.py: Scripts aimed at applying the developed methodology to study empirical recordings obtained from mouse models.
The project relies on the following key libraries:
numpy,matplotlib,scikit-learntorch(PyTorch) for neural networkssbifor Simulation-Based Inference toolspycatch22for time-series feature extraction
- Feature Extraction: If working with the feature-based pipeline, run
extract_features.pyover your simulation folders to generate thefeatures.npyandtheta_data.npydatasets. - Inference (Raw Data): Run
SBI_CDM.pyto train the neural density estimators on the raw current dipole moments. - Inference (Features): Run
SBI.pyto train and evaluate the SNPE process using the pre-extractedpycatch22features. Results will be evaluated step-by-step per CV fold.
Alejandro Rueda López (Final Degree Project / TFG)

