Overview
Contents
Overview#
This is a short introduction to sinaps for new users.
The primary data structures of sinaps are:
Section
wich aims to represent a segment of a neuron with uniform physicals valuesNeuron
wich aims to represent a complete neuron is a directed graph whose edges are ofSection
type.Channels
wich aim to represent ionic channels with various dynamics. Several channels are already implemented, such as Hodgkin-Huxley channels, Pulse currents or AMPA receptors.
The outputs of a simulation are:
Electric potential, at each position in the neuron, for each time point
Electric currents computed from channels defined in the neuron, each postion, each time point
Concentration of species, at each position in the neuron, for each time point
The package can be imported as follows:
[1]:
import sinaps as sn
Object creation#
Creating an empty Neuron
:
[2]:
nrn = sn.Neuron()
Creating a Section
, letting sinaps setting default attribute:
[3]:
sec = sn.Section()
Adding HodgkinHuxley
channels (sodium, potassium and leak) to the newly created section:
[4]:
sec.add_channel(sn.channels.Hodgkin_Huxley())
Adding a Hodgkin-Huxley type calcium channel:
[5]:
sec.add_channel(sn.channels.Hodgkin_Huxley_Ca())
Adding a PulseCurrent
channel with a current of 200
pA, between t =2
and t=5
ms, at the beginning of the section (position 0
):
[6]:
sec.add_channel(sn.channels.PulseCurrent(200,2,5),0)
Adding the section s
to the neuron nrn
as an edge between nodes 0
and 1
:
[7]:
nrn.add_section(sec,0,1)
Adding two new sections * sec2
with a radius of 2
μm * sec3
with a length of 200
μm
[8]:
sec2 = sn.Section(a = 2)
sec3 = sn.Section(L = 200)
nrn.add_sections_from_dict({
sec2:(1,2),
sec3:(1,3)
})
Plotting the neuron structure:
[9]:
nrn.plot()
Calculating layout...[OK]
[9]:
Adding calcium ions in the model:
[10]:
nrn.add_species(sn.Species.Ca,C0=2E-4, D=100) # For the sake of the example, we increase the calcium diffusion coefficient to speed-up its dynamics, in order to observe variations within 50 ms.
Running simulation#
Creating a Simulation
of neuron nrn
with spatial resolution 10
μm:
[11]:
sim = sn.Simulation(nrn,dx=10)
Running the simulation for timespan 0
to 50
ms.
[12]:
sim.run((0,50))
100%|██████████| 50.0/50 [00:02<00:00, 20.39ms/s]
Results of the simulation are stored as pandas Dataframe:
[13]:
sim.V
[13]:
Section | Section0000 | ... | Section0002 | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Position (μm) | 5.0 | 15.0 | 25.0 | 35.0 | 45.0 | 55.0 | 65.0 | 75.0 | 85.0 | 95.0 | ... | 105.0 | 115.0 | 125.0 | 135.0 | 145.0 | 155.0 | 165.0 | 175.0 | 185.0 | 195.0 |
Time | |||||||||||||||||||||
0.000000 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | ... | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 | 0.000000e+00 |
0.000009 | -2.666092e-07 | -2.666092e-07 | -2.666092e-07 | -2.666092e-07 | -2.666092e-07 | -2.666092e-07 | -2.666092e-07 | -2.666092e-07 | -2.666066e-07 | -2.655348e-07 | ... | -1.518839e-36 | -3.683640e-39 | -8.933931e-42 | -2.166746e-44 | -5.255010e-47 | -1.274497e-49 | -3.091039e-52 | -7.496696e-55 | -1.818174e-57 | -4.420311e-60 |
0.000017 | -5.332102e-07 | -5.332102e-07 | -5.332102e-07 | -5.332102e-07 | -5.332102e-07 | -5.332102e-07 | -5.332102e-07 | -5.332102e-07 | -5.331990e-07 | -5.298292e-07 | ... | -2.226100e-35 | -5.822772e-38 | -1.514984e-40 | -3.923580e-43 | -1.012046e-45 | -2.601149e-48 | -6.664197e-51 | -1.702519e-53 | -4.338305e-56 | -1.105701e-58 |
0.000104 | -3.198502e-06 | -3.198502e-06 | -3.198502e-06 | -3.198502e-06 | -3.198502e-06 | -3.198502e-06 | -3.198500e-06 | -3.198433e-06 | -3.195528e-06 | -3.071596e-06 | ... | -1.223602e-24 | -2.844991e-26 | -6.614874e-28 | -1.538021e-29 | -3.576043e-31 | -8.314639e-33 | -1.933232e-34 | -4.494947e-36 | -1.045131e-37 | -2.486497e-39 |
0.000191 | -5.862975e-06 | -5.862975e-06 | -5.862975e-06 | -5.862975e-06 | -5.862975e-06 | -5.862975e-06 | -5.862966e-06 | -5.862630e-06 | -5.851409e-06 | -5.506585e-06 | ... | -1.694736e-23 | -4.254388e-25 | -1.062186e-26 | -2.639415e-28 | -6.531533e-30 | -1.610402e-31 | -3.957683e-33 | -9.698040e-35 | -2.370257e-36 | -5.919767e-38 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
44.995915 | 1.457756e-01 | 1.462924e-01 | 1.473259e-01 | 1.488769e-01 | 1.509466e-01 | 1.535368e-01 | 1.566495e-01 | 1.602876e-01 | 1.644538e-01 | 1.691516e-01 | ... | 1.923908e-01 | 1.935948e-01 | 1.946656e-01 | 1.956030e-01 | 1.964068e-01 | 1.970769e-01 | 1.976131e-01 | 1.980154e-01 | 1.982836e-01 | 1.984177e-01 |
46.496669 | 8.945049e-02 | 8.989337e-02 | 9.077948e-02 | 9.210991e-02 | 9.388649e-02 | 9.611170e-02 | 9.878869e-02 | 1.019212e-01 | 1.055137e-01 | 1.095709e-01 | ... | 1.298739e-01 | 1.309308e-01 | 1.318710e-01 | 1.326944e-01 | 1.334007e-01 | 1.339895e-01 | 1.344609e-01 | 1.348145e-01 | 1.350503e-01 | 1.351683e-01 |
47.997422 | 4.379940e-02 | 4.415709e-02 | 4.487296e-02 | 4.594831e-02 | 4.738519e-02 | 4.918644e-02 | 5.135559e-02 | 5.389689e-02 | 5.681528e-02 | 6.011636e-02 | ... | 7.681423e-02 | 7.768715e-02 | 7.846403e-02 | 7.914455e-02 | 7.972841e-02 | 8.021534e-02 | 8.060514e-02 | 8.089764e-02 | 8.109271e-02 | 8.119027e-02 |
49.875495 | 1.901671e-03 | 2.152505e-03 | 2.654713e-03 | 3.409594e-03 | 4.419191e-03 | 5.686271e-03 | 7.214318e-03 | 9.007517e-03 | 1.107074e-02 | 1.340954e-02 | ... | 2.542159e-02 | 2.605335e-02 | 2.661587e-02 | 2.710881e-02 | 2.753187e-02 | 2.788481e-02 | 2.816741e-02 | 2.837951e-02 | 2.852098e-02 | 2.859173e-02 |
50.000000 | -3.092591e-04 | -6.524872e-05 | 4.233110e-04 | 1.157715e-03 | 2.139995e-03 | 3.372907e-03 | 4.859916e-03 | 6.605188e-03 | 8.613578e-03 | 1.089061e-02 | ... | 2.259949e-02 | 2.321560e-02 | 2.376419e-02 | 2.424495e-02 | 2.465757e-02 | 2.500181e-02 | 2.527745e-02 | 2.548432e-02 | 2.562231e-02 | 2.569133e-02 |
261 rows × 40 columns
Viewing results#
Plotting up to 10 curves distributed evenly on the neuron:
[14]:
sim.plot()
[14]:
Plotting the Hodgkin-Huxley currents:
[15]:
sim.plot.I(sn.channels.Hodgkin_Huxley)
[15]:
Getting a field view of the potential:
[16]:
sim.plot.V_field()
[16]:
Running the electrodiffusion part:
[17]:
sim.run_diff(max_step=1)
100%|██████████| 50.0/50 [00:01<00:00, 40.02ms/s]
Plotting the calcium concentration dynamics
[18]:
sim.plot.C(sn.Species.Ca)
[18]:
[19]:
sim.plot.C_field(sn.Species.Ca)
[19]: