Importing and Exporting Models¶
This tutorial will guide you through the process of creating, manipulating, and sharing computational neuron models using DendroTweaks. You will learn how different components work together to simulate realistic neuronal behavior.
Understanding the model architecture¶
At its core, a computational neuron model requires several key components:
Morphology: The physical structure of the neuron (dendrites, soma, axon)
Membrane Properties: Ion channels and other biophysical mechanisms
Stimulation Protocols: How we activate or inhibit the neuron via current injection or synaptic input
DendroTweaks organizes these components in a structured directory:
.
└── data/
.
.
.
└── UserModel/
├── morphology/
│ ├── cell1.swc
│ └── cell2.swc
├── biophys/
│ ├── config1.json
│ ├── config2.json
| ├── mod/
| | ├── Kv.mod
| | └── Nav.mod
| └── python/
| ├── Kv.py
| └── Nav.py
└── stimuli/
├── stim1.csv
├── stim1.json
├── stim2.csv
└── stim2.json
Each folder contains specific components of the model:
biophys/
: JSON files defining the distribution and properties of ion channels and other membrane mechanismsmod/
: NEURON mechanism files (MOD) that implement specific ion channel kinetics and other biophysical processespython/
: Python classes automatically generated from MOD filesmorphology/
: SWC files describing the morphological structure of the neuronstimuli/
: the temporal patterns (JSON) and spatial distribution (CSV) of inputs to the model and the corresponding recordings
Downloading example data¶
To follow along with this tutorial, you can download the example data from the DendroTweaks repository:
>>> import dendrotweaks as dd
>>> dd.download_example_data('path/to/local/directory')
Assembling a model¶
Assuming we have cratead a UserModel
directory with the necessary components, we can
start by creating a Model
examining the available morphologies:
>>> model = dd.Model(path_to_model='data/UserModel')
>>> model.list_morphologies()
['cell1', 'cell2']
We can load a specific morphology using the load_morphology
method:
>>> model.load_morphology('cell1')
Next, we will add biophysical properties to the model.
>>> model.list_biophys()
['config1', 'config2']
>>> model.load_biophys('config1')
Finally, we will set up the stimulation and recording protocols:
>>> model.list_stimuli()
['stim1', 'stim2']
>>> model.load_stimuli('stim1')
Switching between configurations¶
One of the key advantages of computational modeling is the ability to rapidly test different scenarios. For instance, we can change the stimulation pattern while keeping the same morphology and biophysical properties:
>>> model.load_stimuli('stim2')
We can switch to a different biophysical configuration while keeping the same morphology and stimulation pattern:
>>> model.load_biophys('config2')
It is also possible to apply the same biophysical configuration to a different morphology. This is possible because the biophysical properties are defined on the domain level, independent of the specific morphological structure. Therefore, as long as the morphologies come from the same cell type and have the same domains, the biophysical configuration can be applied to any of them.
Warning
Recordings and stimuli cannot be transferred between models with different morphologies because they are defined on the section level. Make sure to remove all recordings and stimuli before loading a new morphology.
>>> model.remove_all_recordings()
>>> model.remove_all_stimuli()
>>> model.load_morphology('cell2')