This repo will contain all of the code to support:
(1) Simulating Ball & Stick neurons using NEURON
(2) Training DNN twins of single neuron models using pytorch
An accompaying dataset can be found on kaggle at ball-and-stick-neuron-data with two pre-prepared datasets with very different input-output complexities:
- BallAndStickNeuron_Soma_Hay2011_Dend_Lxd_2048um_x_1_0um_8segs - large dendrite (~3.5 times lambda) - with NMDA synapses
- BallAndStickNeuron_Soma_Hay2011_Dend_Lxd_128um_x_4_0um_8segs - small dendrite (~0.1 times lambda) - with AMPA synapses (basically a point neuron)
An accompanying possible assignment for potential students to get started with the code base can be found at Example Assignment and also under the pdf folder.
In order of how a new user would want to use the repo
simulate_ball_and_stick_neuron.ipynb- Tutorial for building and simulating ball-and-stick neuron models using NEURON simulator with Hay2011 active conductances, demonstrating the effect of dendritic length on spatial integration.create_dataset_BS_neuron.ipynb- Generate training/validation/test datasets by simulating Ball & Stick neurons with randomized input patterns, post-processing filtering, and visualizing dataset statistics.create_dataset_BS_neuron_AMPA_point.ipynb- Specialized dataset generation for the small dendrite cable configuration (128um x 4.0um, ~0.1 lambda) with AMPA synapses, creating the point neuron-like behavior dataset.create_dataset_BS_neuron_NMDA_cable.ipynb- Specialized dataset generation for the large dendrite cable configuration (2048um x 1.0um, ~3.5 lambda) with NMDA synapses, creating the spatially extended cable neuron dataset.train_DNN_twin_of_BS_neuron.ipynb- Train deep neural networks (TCN, ResNetTCN, ELM, or Transformer) to act as fast approximations of biophysical neuron models, with multi-task learning for spikes, somatic and dendritic voltages, and instantaneous firing rates.train_DNN_twin_of_BS_neuron_AMPA_point.ipynb- Training script specifically configured for the AMPA point neuron dataset.train_DNN_twin_of_BS_neuron_NMDA_cable.ipynb- Training script specifically configured for the NMDA long and wide cable neuron dataset.
- example colab notebook that properly installs neuron and compiles the mod files tutorial_NEURON_starter_code
-
neuron_model_ball_and_stick.py- Implementation of the Ball & Stick neuron model with active soma (Hay2011) and passive dendrite (passive biophysics) with various synaptic inputs (AMPA, NMDA, NMDA wth human parameters) -
create_dataset_BS_neuron.py- Dataset generation script that creates training/validation/test data by simulating Ball & Stick neurons with various input patterns and storing the output in an orderly fashion for easy loading and access- uses the
neuron_model_ball_and_stick.pyfor simulating the Ball & Stick neuron - uses the
inspect_and_prune_neuron_dataset.pyfor dataset sample filtering functions
- uses the
-
train_DNN_twin_of_BS_neuron.py- Main training script for DNN twin models- uses the
dataloader_BS_neuron.pyfor loading a previously created dataset - uses the
twin_model_definitions.pyfor creating the DNN twin model - uses the
evaluate_twin_model.pyfor functions to evaluate the trained model
- uses the
-
dataloader_BS_neuron.py- PyTorch DataLoader for efficiently loading neuron simulation data for training/evaluation -
evaluate_twin_model.py- script that loads a previously trained twin model and evaluates it on a given neuron simulation dataset -
twin_model_definitions.py- contains the class definitions for various DNN twin architectures (TCN, ResNetTCN, ELM, Transformer).- uses the
torch_module_definitions.pyfor the torch modules used in the twin models
- uses the
-
torch_module_definitions.py- contains the class definitions for various torch modules used in the repo.
config.py- configuration file containing data and model paths, and other global settings
This work builds upon and inspired by:
- David Beniaguev, Idan Segev, and Michael London. (2021). Single Cortical Neurons as Deep Artificial Neural Networks. Neuron, 109(17), 2727–2739.e3. https://doi.org/10.1016/j.neuron.2021.07.002
-
Ido Aizenbud, Daniela Yoeli, David Beniaguev, Christiaan PJ de Kock, Michael London, and Idan Segev. (2024). What Makes Human Cortical Pyramidal Neurons Functionally Complex. Available via PubMed Central (PMC): https://pmc.ncbi.nlm.nih.gov/articles/PMC11702691/
-
Etay Hay, Sean Hill, Felix Schürmann, Henry Markram, and Idan Segev. (2011). “Models of Neocortical Layer 5b Pyramidal Cells Capturing a Wide Range of Dendritic and Perisomatic Active Properties.” Edited by Lyle J. Graham. PLoS Computational Biology 7 (7): e1002107. doi. https://doi.org/10.1371/journal.pcbi.1002107
-
Aaron Spieler, Nasim Rahaman, Georg Martius, Bernhard Schölkopf, and Anna Levina. (2023). The ELM Neuron: an Efficient and Expressive Cortical Neuron Model Can Solve Long-Horizon Tasks. https://arxiv.org/abs/2306.16922