-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLCNhm_main.py
178 lines (127 loc) · 6.83 KB
/
LCNhm_main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
"""
It is the main script, the core module of the LCN-HippoModel project.
Its function is to:
1. Load the parameters from the :ref:`LCNhm-configuration-file`
#. Create the pyramidal cell according to the configuration parameters through the :ref:`LCNhm-class`
#. Run the simulation
#. Save the specified physical magnitudes inside ``DIR_LOCATION``/LCNhm-results/``FolderName``
The ``FolderName`` is define by one of the :ref:`LCNhm-functions`, and looks like:
``< D(ate)YearMonthDay _ T(ime)HourMinute _ OPT_FOLDER_NAME >``
Eg.: ./ LCNhm-results / D20190730_T1030_First_Test
It will add suffixes if the folder already exists:
Eg.: ./ LCNhm-results / D20190730_T1030_First_Test_001
Eg.: ./ LCNhm-results / D20190730_T1030_First_Test_002
Eg.: ./ LCNhm-results / D20190730_T1030_First_Test_003
Eg.: ./ LCNhm-results / D20190730_T1031_First_Test
Eg.: ./ LCNhm-results / D20190730_T1031_First_Test_001
It will contain:
* **TimeSpikes.txt**: Time of spikes. If there are no spikes, it will write ``NaN``
* **Recordings_Vmem.txt**: Recordings of the membrane potential (if specified in the :ref:`LCNhm-configuration-file`)
* **Recordings_Imem.txt**: Recordings of the membrane current (if specified in the :ref:`LCNhm-configuration-file`)
* **Recordings_Pos.txt**: Spatial positions (if specified in the :ref:`LCNhm-configuration-file`)
Membrane potentials (Vmem) and membrane currents (Imem) along time of each recording site
is saved in different rows. Position is saved in different rows for each recording SIMPROP_TEMPERATURE
Functions and descriptions
--------------------------
"""
from LCNhm_configurationfile import *
from LCNhm_functions import *
from LCNhm_class import *
print '''
------------------
| LCN-HippoModel |
------------------
'''
import sys
import time
import numpy as np
import pandas as pd
from neuron import h, nrn, gui
TimeCountStart = time.time()
# -----------
# Make folder
# -----------
FolderName = make_folder(DIR_LOCATION, OPT_FOLDER_NAME)
"""
String:
Full name of folder where results will be saved
"""
print ' %3d:%.2d ... folder "%s" made'%((time.time()-TimeCountStart)/60.,round((time.time()-TimeCountStart)%60),FolderName.split('/')[-1])
Parameters = [ DIR_LOCATION, OPT_FOLDER_NAME,
SIMPROP_THETA_MODE, SIMPROP_THETA_PERIOD, SIMPROP_START_TIME, SIMPROP_SIM_TIME, SIMPROP_END_TIME, SIMPROP_DT, SIMPROP_TEMPERATURE,
CELLPROP_MORPHOLOGY, CELLPROP_INTRINSIC, CELLPROP_SYNAPTIC,
CELLPROP_INTRINSIC_IONCHS, CELLPROP_INTRINSIC_EXPERIMENT,
CELLPROP_SYNAPTIC_INPUTS, CELLPROP_SYNAPTIC_EXPERIMENT,
CURRENT_DURATION, CURRENT_DELAY, CURRENT_AMPLITUDES, CURRENT_SECTION, CURRENT_LOCATION,
RECORDING_MAGNITUDE, RECORDING_SECTION, RECORDING_LOCATION]
save_parameters(Parameters, FolderName)
# ---------------------------
# Make cell from neuron_class
# ---------------------------
# Make inputs to class
CurrentFactors = [ CURRENT_DURATION, CURRENT_DELAY, CURRENT_AMPLITUDES,
CURRENT_SECTION, CURRENT_LOCATION ]
"""
List of properties for all desired current pulses, packed to be a one of the :class:`LCNhm_class.neuron_class`'s inputs
* :const:`LCNhm_configurationfile.CURRENT_DURATION` : List of durations of each current pulse in milliseconds
* :const:`LCNhm_configurationfile.CURRENT_DELAY`: List of delays of each current pulse in milliseconds
* :const:`LCNhm_configurationfile.CURRENT_AMPLITUDES`: List of amplitudes of each current pulse in nanoampers (nA)
* :const:`LCNhm_configurationfile.CURRENT_SECTION`: List of sections of each current pulse
* :const:`LCNhm_configurationfile.CURRENT_LOCATION`: List of location along the defined :const:`LCNhm_configurationfile.CURRENT_SECTION` of each current pulse
Their length must be the same, the number of different current clamps
Click any of the links for further information
"""
IntrinsicFactors = [CELLPROP_INTRINSIC_IONCHS, CELLPROP_INTRINSIC_EXPERIMENT, CELLPROP_INTRINSIC]
"""
List:
List of all intrinsic properties, packed to be a one of the :class:`LCNhm_class.neuron_class`'s inputs
* :const:`LCNhm_configurationfile.CELLPROP_INTRINSIC_IONCHS`: Ion channels to include in the cell
* :const:`LCNhm_configurationfile.CELLPROP_INTRINSIC_EXPERIMENT`: Additional factor multiplying the following maximum conductances and axial resistance
* :const:`LCNhm_configurationfile.CELLPROP_INDIVIDUAL`: Number of the intrinsic genetic-algorithm `individual`
Click any of the links for further information
"""
SynapticFactors = [CELLPROP_SYNAPTIC_INPUTS, CELLPROP_SYNAPTIC_EXPERIMENT,
SIMPROP_THETA_MODE, SIMPROP_THETA_PERIOD, SIMPROP_START_TIME, SIMPROP_END_TIME, SIMPROP_DT, CELLPROP_SYNAPTIC]
"""
List:
List of all synaptic properties, packed to be a one of the :class:`LCNhm_class.neuron_class`'s inputs
* :const:`LCNhm_configurationfile.CELLPROP_SYNAPTIC_INPUTS` : Synaptic inputs to include in the cell
* :const:`LCNhm_configurationfile.CELLPROP_SYNAPTIC_EXPERIMENT` : Additional factor multiplying the following maximum conductances
* :const:`LCNhm_configurationfile.SIMPROP_THETA_MODE` : Set theta (``True``) or not (``False``)
* :const:`LCNhm_configurationfile.SIMPROP_THETA_PERIOD` : Theta period in milliseconds
* :const:`LCNhm_configurationfile.SIMPROP_START_TIME` : Lapse of time before starting the simulation in milliseconds
* :const:`LCNhm_configurationfile.SIMPROP_END_TIME` : Total duration of the simulation in milliseconds (:const:`LCNhm_configurationfile.SIMPROP_START_TIME` + :const:`LCNhm_configurationfile.SIMPROP_SIM_TIME`)
Click any of the links for further information
"""
# Make neuron
Pyramidal = neuron_class(MorphoName = CELLPROP_MORPHOLOGY,
IntrinsicFactors = IntrinsicFactors,
SynapticFactors = SynapticFactors,
CurrentFactors = CurrentFactors,
DirLocation = DIR_LOCATION )
"""
Object: Pyramidal from :class:`LCNhm_class.neuron_class`"""
print ' %3d:%.2d ... pyramidal cell made'%((time.time()-TimeCountStart)/60.,round((time.time()-TimeCountStart)%60))
# --------------
# Set recordings
# --------------
Recordings = recordings(Pyramidal, RECORDING_MAGNITUDE, RECORDING_SECTION, RECORDING_LOCATION)
"""Dictionary: Ouput from :func:`LCNhm_function.recordings`
with recordings of the :class:`LCNhm_class.neuron_class` Pyramidal"""
print ' %3d:%.2d ... recorings set'%((time.time()-TimeCountStart)/60.,round((time.time()-TimeCountStart)%60))
# --------------
# Run simulation
# --------------
# Set simulation parameters
h.tstop = SIMPROP_END_TIME
h.celsius = SIMPROP_TEMPERATURE
# Run
h.run()
print ' %3d:%.2d ... end of simulation'%((time.time()-TimeCountStart)/60.,round((time.time()-TimeCountStart)%60))
# ------------
# Save results
# ------------
# Detect and save spiking times, recordings and parameters
save_spiking_times(Recordings, FolderName)
save_recordings(Recordings, FolderName, RECORDING_MAGNITUDE)
print ' %3d:%.2d ... results saved'%((time.time()-TimeCountStart)/60.,round((time.time()-TimeCountStart)%60))