dendrotweaks 0.3.1__py3-none-any.whl → 0.4.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dendrotweaks/__init__.py +3 -3
- dendrotweaks/analysis/ephys_analysis.py +12 -8
- dendrotweaks/biophys/__init__.py +7 -0
- dendrotweaks/{membrane → biophys}/default_templates/NEURON_template.py +5 -3
- dendrotweaks/{membrane → biophys}/default_templates/default.py +2 -1
- dendrotweaks/{membrane → biophys}/default_templates/standard_channel.mod +5 -1
- dendrotweaks/{membrane → biophys}/groups.py +0 -5
- dendrotweaks/biophys/io/__init__.py +11 -0
- dendrotweaks/{membrane → biophys}/io/ast.py +6 -0
- dendrotweaks/{membrane → biophys}/io/code_generators.py +13 -3
- dendrotweaks/{membrane → biophys}/io/converter.py +3 -3
- dendrotweaks/{membrane → biophys}/io/factories.py +8 -6
- dendrotweaks/biophys/io/loader.py +190 -0
- dendrotweaks/{membrane → biophys}/io/parser.py +8 -8
- dendrotweaks/{membrane → biophys}/mechanisms.py +14 -10
- dendrotweaks/model.py +91 -52
- dendrotweaks/morphology/__init__.py +2 -2
- dendrotweaks/morphology/io/factories.py +5 -5
- dendrotweaks/morphology/sec_trees.py +139 -164
- dendrotweaks/morphology/seg_trees.py +41 -29
- dendrotweaks/path_manager.py +9 -11
- dendrotweaks/simulators.py +100 -54
- dendrotweaks/stimuli/populations.py +11 -0
- {dendrotweaks-0.3.1.dist-info → dendrotweaks-0.4.1.dist-info}/METADATA +2 -2
- dendrotweaks-0.4.1.dist-info/RECORD +56 -0
- {dendrotweaks-0.3.1.dist-info → dendrotweaks-0.4.1.dist-info}/WHEEL +1 -1
- dendrotweaks/membrane/__init__.py +0 -6
- dendrotweaks/membrane/io/__init__.py +0 -11
- dendrotweaks/membrane/io/loader.py +0 -90
- dendrotweaks-0.3.1.dist-info/RECORD +0 -56
- /dendrotweaks/{membrane → biophys}/default_mod/AMPA.mod +0 -0
- /dendrotweaks/{membrane → biophys}/default_mod/AMPA_NMDA.mod +0 -0
- /dendrotweaks/{membrane → biophys}/default_mod/CaDyn.mod +0 -0
- /dendrotweaks/{membrane → biophys}/default_mod/GABAa.mod +0 -0
- /dendrotweaks/{membrane → biophys}/default_mod/Leak.mod +0 -0
- /dendrotweaks/{membrane → biophys}/default_mod/NMDA.mod +0 -0
- /dendrotweaks/{membrane → biophys}/default_mod/vecstim.mod +0 -0
- /dendrotweaks/{membrane → biophys}/default_templates/template_jaxley.py +0 -0
- /dendrotweaks/{membrane → biophys}/default_templates/template_jaxley_new.py +0 -0
- /dendrotweaks/{membrane → biophys}/distributions.py +0 -0
- /dendrotweaks/{membrane → biophys}/io/grammar.py +0 -0
- /dendrotweaks/{membrane → biophys}/io/reader.py +0 -0
- {dendrotweaks-0.3.1.dist-info → dendrotweaks-0.4.1.dist-info}/licenses/LICENSE +0 -0
- {dendrotweaks-0.3.1.dist-info → dendrotweaks-0.4.1.dist-info}/top_level.txt +0 -0
dendrotweaks/simulators.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
from collections import defaultdict
|
2
2
|
import warnings
|
3
|
+
from functools import cached_property
|
3
4
|
|
4
5
|
import matplotlib.pyplot as plt
|
5
6
|
import neuron
|
@@ -9,6 +10,7 @@ h.load_file('stdrun.hoc')
|
|
9
10
|
# h.load_file('import3d.hoc')
|
10
11
|
# h.load_file('nrngui.hoc')
|
11
12
|
# h.load_file('import3d')
|
13
|
+
import numpy as np
|
12
14
|
|
13
15
|
import contextlib
|
14
16
|
|
@@ -30,34 +32,59 @@ def reset_neuron():
|
|
30
32
|
|
31
33
|
reset_neuron()
|
32
34
|
|
35
|
+
# -------------------------------------------------------
|
36
|
+
# SIMULATOR
|
37
|
+
# -------------------------------------------------------
|
38
|
+
|
33
39
|
class Simulator:
|
34
40
|
"""
|
35
41
|
A generic simulator class.
|
36
42
|
"""
|
37
43
|
def __init__(self):
|
38
|
-
self.
|
39
|
-
self.t = None
|
44
|
+
self._t = None
|
40
45
|
self.dt = None
|
41
|
-
self.
|
46
|
+
self._recordings = {'v': {}}
|
42
47
|
|
43
|
-
def
|
48
|
+
def plot_var(self, var='v', ax=None, segments=None, **kwargs):
|
49
|
+
if self._t is None:
|
50
|
+
raise ValueError('Simulation has not been run yet.')
|
51
|
+
if var not in self.recordings:
|
52
|
+
raise ValueError(f'Variable {var} not recorded.')
|
44
53
|
if ax is None:
|
45
54
|
fig, ax = plt.subplots()
|
46
55
|
if segments is None:
|
47
|
-
segments = self.recordings.keys()
|
48
|
-
for seg,
|
56
|
+
segments = self.recordings[var].keys()
|
57
|
+
for seg, x in self.recordings[var].items():
|
49
58
|
if segments and seg not in segments:
|
50
59
|
continue
|
51
|
-
ax.plot(self.t,
|
52
|
-
|
60
|
+
ax.plot(self.t, x, label=f'{var} {seg.domain} {seg.idx}', **kwargs)
|
53
61
|
if len(segments) < 10:
|
54
62
|
ax.legend()
|
55
|
-
# ax.set_ylim(-100, 60)
|
56
63
|
ax.set_xlabel('Time (ms)')
|
57
|
-
|
64
|
+
if var == 'v':
|
65
|
+
ax.set_ylabel('Voltage (mV)')
|
66
|
+
elif var.startswith('i_'):
|
67
|
+
ax.set_ylabel('Current (nA)')
|
68
|
+
return ax
|
69
|
+
|
70
|
+
def plot_voltage(self, **kwargs):
|
71
|
+
"""
|
72
|
+
Plot the recorded voltages.
|
73
|
+
"""
|
74
|
+
self.plot_var('v', **kwargs)
|
75
|
+
|
76
|
+
def plot_currents(self, **kwargs):
|
77
|
+
"""
|
78
|
+
Plot the recorded currents.
|
79
|
+
"""
|
80
|
+
ax = kwargs.pop('ax', None)
|
81
|
+
for var in self.recordings:
|
82
|
+
if var.startswith('i_'):
|
83
|
+
ax = self.plot_var(var, ax=ax, **kwargs)
|
84
|
+
|
58
85
|
|
59
86
|
|
60
|
-
class
|
87
|
+
class NeuronSimulator(Simulator):
|
61
88
|
"""
|
62
89
|
A class to represent the NEURON simulator.
|
63
90
|
|
@@ -88,10 +115,33 @@ class NEURONSimulator(Simulator):
|
|
88
115
|
self.temperature = temperature
|
89
116
|
self.v_init = v_init * mV
|
90
117
|
self._duration = 300
|
118
|
+
|
91
119
|
|
92
120
|
self.dt = dt
|
93
121
|
self._cvode = cvode
|
94
122
|
|
123
|
+
@cached_property
|
124
|
+
def recordings(self):
|
125
|
+
return {
|
126
|
+
var:{ seg: vec.to_python() for seg, vec in recs.items() }
|
127
|
+
for var, recs in self._recordings.items()
|
128
|
+
}
|
129
|
+
|
130
|
+
@cached_property
|
131
|
+
def t(self):
|
132
|
+
return self._t.to_python()
|
133
|
+
|
134
|
+
def _clean_cache(self):
|
135
|
+
"""
|
136
|
+
Clean the cache of the simulator.
|
137
|
+
"""
|
138
|
+
try:
|
139
|
+
del self.recordings
|
140
|
+
del self.t
|
141
|
+
except AttributeError:
|
142
|
+
# Property hasn't been accessed yet, so no need to delete
|
143
|
+
pass
|
144
|
+
|
95
145
|
|
96
146
|
def add_recording(self, sec, loc, var='v'):
|
97
147
|
"""
|
@@ -107,11 +157,16 @@ class NEURONSimulator(Simulator):
|
|
107
157
|
The variable to record. Default is 'v' (voltage).
|
108
158
|
"""
|
109
159
|
seg = sec(loc)
|
110
|
-
if
|
111
|
-
|
112
|
-
self.
|
113
|
-
|
114
|
-
|
160
|
+
if not hasattr(seg._ref, f'_ref_{var}'):
|
161
|
+
raise ValueError(f'Segment {seg} does not have variable {var}.')
|
162
|
+
if self._recordings.get(var, {}).get(seg):
|
163
|
+
self.remove_recording(sec, loc, var)
|
164
|
+
if var not in self._recordings:
|
165
|
+
self._recordings[var] = {}
|
166
|
+
self._recordings[var][seg] = h.Vector().record(getattr(seg._ref, f'_ref_{var}'))
|
167
|
+
self._clean_cache()
|
168
|
+
|
169
|
+
def remove_recording(self, sec, loc, var='v'):
|
115
170
|
"""
|
116
171
|
Remove a recording from the simulator.
|
117
172
|
|
@@ -123,35 +178,45 @@ class NEURONSimulator(Simulator):
|
|
123
178
|
The location along the normalized section length to remove the recording from.
|
124
179
|
"""
|
125
180
|
seg = sec(loc)
|
126
|
-
if self.
|
127
|
-
self.
|
128
|
-
self.
|
129
|
-
|
130
|
-
|
181
|
+
if self._recordings[var].get(seg):
|
182
|
+
self._recordings[var][seg] = None
|
183
|
+
self._recordings[var].pop(seg)
|
184
|
+
if not self._recordings[var]:
|
185
|
+
self._recordings.pop(var)
|
186
|
+
self._clean_cache()
|
187
|
+
|
188
|
+
def remove_all_recordings(self, var=None):
|
131
189
|
"""
|
132
190
|
Remove all recordings from the simulator.
|
133
191
|
"""
|
134
|
-
|
135
|
-
|
136
|
-
self.
|
137
|
-
|
138
|
-
|
139
|
-
|
192
|
+
variables = [var] if var else list(self._recordings.keys())
|
193
|
+
for variable in variables:
|
194
|
+
for seg in list(self._recordings.get(variable, {}).keys()):
|
195
|
+
self.remove_recording(seg._section, seg.x, variable)
|
196
|
+
if self._recordings.get(variable):
|
197
|
+
warnings.warn(f'Not all recordings were removed for variable {variable}: {self._recordings}')
|
140
198
|
|
141
199
|
|
142
200
|
def _init_simulation(self):
|
143
|
-
|
201
|
+
|
144
202
|
h.celsius = self.temperature
|
145
|
-
|
146
|
-
|
147
|
-
|
203
|
+
|
204
|
+
if self._cvode:
|
205
|
+
h.cvode.active(1)
|
206
|
+
else:
|
207
|
+
h.cvode.active(0)
|
208
|
+
h.dt = self.dt
|
209
|
+
|
148
210
|
h.finitialize(self.v_init)
|
149
|
-
|
211
|
+
|
212
|
+
if self._cvode:
|
150
213
|
h.cvode.re_init()
|
151
214
|
else:
|
152
215
|
h.fcurrent()
|
216
|
+
|
153
217
|
h.frecord_init()
|
154
218
|
|
219
|
+
|
155
220
|
def run(self, duration=300):
|
156
221
|
"""
|
157
222
|
Run a simulation.
|
@@ -161,35 +226,16 @@ class NEURONSimulator(Simulator):
|
|
161
226
|
duration : float
|
162
227
|
The duration of the simulation in milliseconds.
|
163
228
|
"""
|
164
|
-
self._duration = duration
|
165
|
-
|
166
229
|
|
167
|
-
|
168
|
-
Is = []
|
230
|
+
self._clean_cache()
|
169
231
|
|
170
|
-
|
171
|
-
# # v = h.Vector().record(seg._ref_v)
|
172
|
-
# vs.append(v)
|
173
|
-
|
174
|
-
t = h.Vector().record(h._ref_t)
|
232
|
+
self._duration = duration
|
175
233
|
|
176
|
-
|
177
|
-
# pass
|
178
|
-
# else:
|
179
|
-
# for seg in self.recordings.keys():
|
180
|
-
# if getattr(seg, f'_ref_i_{self.ch.suffix}', None) is None:
|
181
|
-
# logger.warning(
|
182
|
-
# f'No current recorded for {self.ch.suffix} at {seg}. Make i a RANGE variable in mod file.')
|
183
|
-
# continue
|
184
|
-
# I = h.Vector().record(getattr(seg, f'_ref_i_{self.ch.suffix}'))
|
185
|
-
# Is.append(I)
|
234
|
+
self._t = h.Vector().record(h._ref_t)
|
186
235
|
|
187
236
|
self._init_simulation()
|
188
237
|
|
189
238
|
h.continuerun(duration * ms)
|
190
|
-
|
191
|
-
self.t = t.to_python()
|
192
|
-
self.vs = {seg: v.to_python() for seg, v in self.recordings.items()}
|
193
239
|
|
194
240
|
|
195
241
|
def to_dict(self):
|
@@ -123,6 +123,17 @@ class Population():
|
|
123
123
|
spike_times[syn].extend(syn.spike_times)
|
124
124
|
return dict(spike_times)
|
125
125
|
|
126
|
+
@property
|
127
|
+
def n_per_seg(self):
|
128
|
+
"""
|
129
|
+
Return the number of synapses per segment.
|
130
|
+
"""
|
131
|
+
n_per_seg = {seg: 0 for seg in self.segments}
|
132
|
+
for (sec, loc), syns in self.synapses.items():
|
133
|
+
seg = sec(loc)
|
134
|
+
n_per_seg[seg] += len(syns)
|
135
|
+
return dict(n_per_seg)
|
136
|
+
|
126
137
|
|
127
138
|
def update_kinetic_params(self, **params):
|
128
139
|
"""
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: dendrotweaks
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.4.1
|
4
4
|
Summary: A toolbox for exploring dendritic dynamics
|
5
5
|
Home-page: https://dendrotweaks.dendrites.gr
|
6
6
|
Author: Roman Makarov
|
@@ -15,7 +15,7 @@ Classifier: Operating System :: OS Independent
|
|
15
15
|
Requires-Python: >=3.9
|
16
16
|
Description-Content-Type: text/markdown
|
17
17
|
License-File: LICENSE
|
18
|
-
Requires-Dist: neuron>=8.2.6
|
18
|
+
Requires-Dist: neuron>=8.2.6; sys_platform == "linux" or sys_platform == "darwin"
|
19
19
|
Requires-Dist: neuron-reduce==0.0.7
|
20
20
|
Requires-Dist: numpy<2.0.0
|
21
21
|
Requires-Dist: pandas
|
@@ -0,0 +1,56 @@
|
|
1
|
+
dendrotweaks/__init__.py,sha256=t5t6BzFqY45ePdil4bFlkEaQZiKS-KKthacbRUkwDhc,384
|
2
|
+
dendrotweaks/model.py,sha256=Y6m9U0FOoMYG3qCLZczxYfl1-nXeL-4uZNuAqrDlwPQ,69113
|
3
|
+
dendrotweaks/model_io.py,sha256=xwXKMcUle-Y0HoWFYVZu3G8v4pdQXmeaDfl2Xi65eHw,2137
|
4
|
+
dendrotweaks/path_manager.py,sha256=dai5o6UA0nk-ubwKWRu4LFdDBO77zW_SsMf6k0MLBiI,8703
|
5
|
+
dendrotweaks/simulators.py,sha256=Vg6ToTkDZ4OGcANYwYtamGnasyLNbyP8pfPHl9PnMnM,7413
|
6
|
+
dendrotweaks/utils.py,sha256=jaUJNb39Bsevg3WJByP56bO7CLj1wzlh-uGZl-lxi1I,7131
|
7
|
+
dendrotweaks/analysis/__init__.py,sha256=SEYpoQ5iXiQXyHB20-IAdDHYI-7CR5GYFXIwr-O05Ug,858
|
8
|
+
dendrotweaks/analysis/ephys_analysis.py,sha256=Caiww27p9dnL5_27OmZ95AZ_OmefvImAPyItsJMSdmA,14320
|
9
|
+
dendrotweaks/analysis/morphometric_analysis.py,sha256=5zohjGssyx-wezI-yY3Q-kYM_wzAQLLFBJ9Xk950_JY,3571
|
10
|
+
dendrotweaks/biophys/__init__.py,sha256=k0o2xwyoaJUb1lfO9OHtqxheNP6R-Ya5o0g-bJOdCZg,360
|
11
|
+
dendrotweaks/biophys/distributions.py,sha256=ADPFPA-CN7AbRJj0Ry4TxFZJhdYXJm87iIGWZSDr5vI,10299
|
12
|
+
dendrotweaks/biophys/groups.py,sha256=Q4kBIqL1-piIgrpsVq6ojinAWHiEJ1GzMjSAQ7Ni_E8,3212
|
13
|
+
dendrotweaks/biophys/mechanisms.py,sha256=j9uygcwkK6Z_08hpTHax40Wn-eV4V_k_on_KyPDnO90,18520
|
14
|
+
dendrotweaks/biophys/default_mod/AMPA.mod,sha256=HY_pWzYvaSDV-w7qruenG2mnll8v79s40HFHjUCIi4U,980
|
15
|
+
dendrotweaks/biophys/default_mod/AMPA_NMDA.mod,sha256=ztv2ePUiEQZ93-23FTkGO2DC91rehQuqo0NUIbHZ368,2318
|
16
|
+
dendrotweaks/biophys/default_mod/CaDyn.mod,sha256=gwc69K_rxu2w_mV7CnOSOnVaCMc8Z-MfdBFf6lAj4kg,1298
|
17
|
+
dendrotweaks/biophys/default_mod/GABAa.mod,sha256=jdGRid-Wzw4y9kHvq74oSMogLhSiS-Ac2DDaLOrxVi8,983
|
18
|
+
dendrotweaks/biophys/default_mod/Leak.mod,sha256=u0lwMYGgl5kNZN5W4N6YHgRSeVxb-z2oM9fqou5rCV8,420
|
19
|
+
dendrotweaks/biophys/default_mod/NMDA.mod,sha256=tT4Q5UPoeztXcQ45uZc2PUO3-8OkDLCmrS7WDsn1yQQ,1185
|
20
|
+
dendrotweaks/biophys/default_mod/vecstim.mod,sha256=iSpJgR96O2Z3pLNUFIsZ7YJ529ncKUBaZqDJvA0_oV0,965
|
21
|
+
dendrotweaks/biophys/default_templates/NEURON_template.py,sha256=MWSv2fLKGJxdt2zfSO0b74peuBC8U9j_S6AwM5URXts,14945
|
22
|
+
dendrotweaks/biophys/default_templates/default.py,sha256=7HEbR2GJEOhgiox1QtZUEuHi5ihNAHDLsXQiQk980tI,2201
|
23
|
+
dendrotweaks/biophys/default_templates/standard_channel.mod,sha256=sw80c-JyqfXNA7c7v7pZGLY-0MgFUvd3bPvJcAGXNSk,2923
|
24
|
+
dendrotweaks/biophys/default_templates/template_jaxley.py,sha256=t-GsCSUyQ7rDoaLmyuWd9bIxB8W3bCqJdnikD59EVvI,3676
|
25
|
+
dendrotweaks/biophys/default_templates/template_jaxley_new.py,sha256=I62KhnOYNV1bT-nPsDTxjIISYmDcso2X8rnsos28nYs,3631
|
26
|
+
dendrotweaks/biophys/io/__init__.py,sha256=kkmQ4L0SatI3lWd3qE8KqOIKd7x3G2OnqAAW93sWWCU,575
|
27
|
+
dendrotweaks/biophys/io/ast.py,sha256=7x_Kxz1qoQHZeIjovUNyVuKgUo4vAFKm-bd4hn9n1CI,6078
|
28
|
+
dendrotweaks/biophys/io/code_generators.py,sha256=RX0nw5-0CyWR3KOrTZUabKuPAQg2ysQ_nQi2iu9TxiE,11978
|
29
|
+
dendrotweaks/biophys/io/converter.py,sha256=5yrPJhyZbuwV7tTGoacnNOvmRdVgXPIyGfiR0PyOVzg,3371
|
30
|
+
dendrotweaks/biophys/io/factories.py,sha256=j1Hi2u-NTFFL8ElRYlgGVNHRcfKWH6o5GfKvraMTlwM,5020
|
31
|
+
dendrotweaks/biophys/io/grammar.py,sha256=TJLTDlr8Ajp3J9DJ4IvulOCcpUkYr7HnoI0TGnNuEPc,11677
|
32
|
+
dendrotweaks/biophys/io/loader.py,sha256=Wv9ZkEDyA3MkCdV0sMeRnBffg2WAI7yTV3r6C412GiY,6378
|
33
|
+
dendrotweaks/biophys/io/parser.py,sha256=boT27lFrn5LYrJnkZFs0SwrZZrkSkwO8efqGPJ4Qj0I,17914
|
34
|
+
dendrotweaks/biophys/io/reader.py,sha256=JWm5WM9illvSfDkhWEmWBcj8Y7PSi8zeZX9j1ARUHVU,6576
|
35
|
+
dendrotweaks/morphology/__init__.py,sha256=JwXmSmdn9e_jqslITEdiU9kWvzxcxT9Aw_kUkXLbm5o,353
|
36
|
+
dendrotweaks/morphology/domains.py,sha256=Y4txcGdBdl2aK1DfbTRziNtDyd6bChczwpCWE7lTFzg,2391
|
37
|
+
dendrotweaks/morphology/point_trees.py,sha256=5dUPaQXYPdJbWoD3pFI2DV2XnuFRhB5d0wTBlfmmIeI,21600
|
38
|
+
dendrotweaks/morphology/sec_trees.py,sha256=fj-1kBj7InkqB27Ux-jPidGQXts7FAPXa1m2LdzekNY,35816
|
39
|
+
dendrotweaks/morphology/seg_trees.py,sha256=-XeSJuD7ZixBJYQDzvmSEiNvOWbVmX_DanyAPkkR-NA,4042
|
40
|
+
dendrotweaks/morphology/trees.py,sha256=NrNvPMR-U0clt63eqwVJqU0H8NJgY53QGA_BkdcwkQI,16033
|
41
|
+
dendrotweaks/morphology/io/__init__.py,sha256=gAZqZdf5VKPb6ksK8Lwt7MbTAq8TDP8uq3Vs_ebNFEY,324
|
42
|
+
dendrotweaks/morphology/io/factories.py,sha256=DCE37QCloiYVro5HGihJbxPz91BB3y5NNf-oRaQ-M2g,6383
|
43
|
+
dendrotweaks/morphology/io/reader.py,sha256=hW3c541WtG1rNag_YreEhvrLzm8-OTtw0fQREeHDthM,1913
|
44
|
+
dendrotweaks/morphology/io/validation.py,sha256=lVkYw9y9yG5QpRh_N0YQ3FbZwuSUsQfSqJTMumMcDdc,7872
|
45
|
+
dendrotweaks/morphology/reduce/__init__.py,sha256=p6Mg3KDHxTt8S4DtI0m7L7MqV6dS2pdIYAwB7B-toVw,921
|
46
|
+
dendrotweaks/morphology/reduce/reduce.py,sha256=5czZDrG3xsvHn3c_tbYhUOlXgST989-RS-ntbhlvvA0,6361
|
47
|
+
dendrotweaks/morphology/reduce/reduced_cylinder.py,sha256=jGJ4J-amukRr-3DPirVR5pzNO-6H7_sZF1N_X57ZGdw,5132
|
48
|
+
dendrotweaks/stimuli/__init__.py,sha256=bFfSEZhCVpwOVEBgLe65iiY3SdpjKPhyLemC1z5OX9I,153
|
49
|
+
dendrotweaks/stimuli/iclamps.py,sha256=NjkhhwZKJR1f_g3N9BVxMVoO9ubBk5WkQ6h9Bnf9xgA,1681
|
50
|
+
dendrotweaks/stimuli/populations.py,sha256=y85v8smiMifINIqXm1O3mOINAlDTz-SPGLS78alhX5A,8325
|
51
|
+
dendrotweaks/stimuli/synapses.py,sha256=g4MgWTske2TZ2i9FIIOE8-KXNx_3dWa3zEhB2rcqYig,5470
|
52
|
+
dendrotweaks-0.4.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
53
|
+
dendrotweaks-0.4.1.dist-info/METADATA,sha256=zX87vndTAiJHfWJkywrmMiqa7lNxcg4Kwfbf6tQ0OKs,2740
|
54
|
+
dendrotweaks-0.4.1.dist-info/WHEEL,sha256=A8Eltl-h0W-qZDVezsLjjslosEH_pdYC2lQ0JcbgCzs,91
|
55
|
+
dendrotweaks-0.4.1.dist-info/top_level.txt,sha256=OzT_2BSI5j5zxC447K6Y-0W-GHbued7iX-_hFGAKMxY,13
|
56
|
+
dendrotweaks-0.4.1.dist-info/RECORD,,
|
@@ -1,6 +0,0 @@
|
|
1
|
-
from dendrotweaks.membrane.mechanisms import Mechanism, IonChannel, CaDynamics, StandardIonChannel, LeakChannel
|
2
|
-
from dendrotweaks.membrane.mechanisms import LeakChannel
|
3
|
-
from dendrotweaks.membrane.groups import SegmentGroup
|
4
|
-
from dendrotweaks.membrane.distributions import Distribution
|
5
|
-
|
6
|
-
import dendrotweaks.membrane.io as io
|
@@ -1,11 +0,0 @@
|
|
1
|
-
from dendrotweaks.membrane.io.loader import MODFileLoader
|
2
|
-
from dendrotweaks.membrane.io.converter import MODFileConverter
|
3
|
-
|
4
|
-
from dendrotweaks.membrane.io.reader import MODFileReader
|
5
|
-
from dendrotweaks.membrane.io.parser import MODFileParser
|
6
|
-
from dendrotweaks.membrane.io.code_generators import PythonCodeGenerator
|
7
|
-
from dendrotweaks.membrane.io.code_generators import NMODLCodeGenerator
|
8
|
-
|
9
|
-
from dendrotweaks.membrane.io.factories import create_channel
|
10
|
-
from dendrotweaks.membrane.io.factories import create_standard_channel
|
11
|
-
from dendrotweaks.membrane.io.factories import standardize_channel
|
@@ -1,90 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
import shutil
|
3
|
-
import subprocess
|
4
|
-
import neuron
|
5
|
-
from neuron import h
|
6
|
-
|
7
|
-
from pprint import pprint
|
8
|
-
|
9
|
-
class MODFileLoader():
|
10
|
-
|
11
|
-
def __init__(self):
|
12
|
-
self._loaded_mechanisms = set()
|
13
|
-
self.verbose = False
|
14
|
-
|
15
|
-
# LOADING METHODS
|
16
|
-
|
17
|
-
def _get_mechanism_dir(self, path_to_mod_file: str) -> str:
|
18
|
-
"""
|
19
|
-
Get the subdirectory for the given mod file.
|
20
|
-
|
21
|
-
Parameters
|
22
|
-
----------
|
23
|
-
path_to_mod_file : str
|
24
|
-
Path to the .mod file.
|
25
|
-
|
26
|
-
Returns
|
27
|
-
-------
|
28
|
-
str
|
29
|
-
Path to the subdirectory for the mechanism.
|
30
|
-
"""
|
31
|
-
mechanism_name = os.path.basename(path_to_mod_file).replace('.mod', '')
|
32
|
-
parent_dir = os.path.dirname(path_to_mod_file)
|
33
|
-
return os.path.join(parent_dir, mechanism_name)
|
34
|
-
|
35
|
-
def load_mechanism(self, path_to_mod_file: str,
|
36
|
-
recompile: bool = False) -> None:
|
37
|
-
"""
|
38
|
-
Load a mechanism from the specified mod file.
|
39
|
-
Uses the NEURON neuron.load_mechanisms method to make
|
40
|
-
the mechanism available in the hoc interpreter.
|
41
|
-
Creates a temporary directory for the mechanism files
|
42
|
-
to be able to dynamically load mechanisms.
|
43
|
-
|
44
|
-
Parameters
|
45
|
-
----------
|
46
|
-
path_to_mod_file : str
|
47
|
-
Path to the .mod file.
|
48
|
-
recompile : bool
|
49
|
-
Force recompilation even if already compiled.
|
50
|
-
"""
|
51
|
-
mechanism_name = os.path.basename(path_to_mod_file).replace('.mod', '')
|
52
|
-
mechanism_dir = self._get_mechanism_dir(path_to_mod_file)
|
53
|
-
x86_64_dir = os.path.join(mechanism_dir, 'x86_64')
|
54
|
-
|
55
|
-
if self.verbose: print(f"{'=' * 60}\nLoading mechanism {mechanism_name} to NEURON...\n{'=' * 60}")
|
56
|
-
|
57
|
-
if mechanism_name in self._loaded_mechanisms:
|
58
|
-
if self.verbose: print(f'Mechanism "{mechanism_name}" already loaded')
|
59
|
-
return
|
60
|
-
|
61
|
-
if recompile and os.path.exists(mechanism_dir):
|
62
|
-
shutil.rmtree(mechanism_dir)
|
63
|
-
|
64
|
-
if not os.path.exists(x86_64_dir):
|
65
|
-
if self.verbose: print(f'Compiling mechanism "{mechanism_name}"...')
|
66
|
-
os.makedirs(mechanism_dir, exist_ok=True)
|
67
|
-
shutil.copy(path_to_mod_file, mechanism_dir)
|
68
|
-
self._compile_files(mechanism_dir)
|
69
|
-
|
70
|
-
if hasattr(h, mechanism_name):
|
71
|
-
if self.verbose: print(f'Mechanism "{mechanism_name}" already exists in hoc')
|
72
|
-
else:
|
73
|
-
try:
|
74
|
-
neuron.load_mechanisms(mechanism_dir)
|
75
|
-
except Exception as e:
|
76
|
-
print(f"Failed to load mechanism {mechanism_name}: {e}")
|
77
|
-
return
|
78
|
-
self._loaded_mechanisms.add(mechanism_name)
|
79
|
-
if self.verbose: print(f'Loaded mechanism "{mechanism_name}"')
|
80
|
-
|
81
|
-
# HELPER METHODS
|
82
|
-
|
83
|
-
|
84
|
-
def _compile_files(self, path: str) -> None:
|
85
|
-
"""Compile the MOD files in the specified directory."""
|
86
|
-
try:
|
87
|
-
subprocess.run(["nrnivmodl"], cwd=path, check=True)
|
88
|
-
except subprocess.CalledProcessError as e:
|
89
|
-
print(f"Compilation failed: {e}")
|
90
|
-
|
@@ -1,56 +0,0 @@
|
|
1
|
-
dendrotweaks/__init__.py,sha256=Oty4wVcVFs_9w7L9peCncnzQKFubqkRHyf4c3HKfwWY,385
|
2
|
-
dendrotweaks/model.py,sha256=wy17K85d95bD1ioibhDxs8rcNCzow3BP1OVam1b1bTM,67445
|
3
|
-
dendrotweaks/model_io.py,sha256=xwXKMcUle-Y0HoWFYVZu3G8v4pdQXmeaDfl2Xi65eHw,2137
|
4
|
-
dendrotweaks/path_manager.py,sha256=SfZ7Br-WmUhpvdRTgeOqMzaYVgLpXoSGbekxJvNkZT4,8794
|
5
|
-
dendrotweaks/simulators.py,sha256=cVbzbhE48D1ovn7Rg8bU0pI9ztbEqQF2da5gnEMu8Ec,6137
|
6
|
-
dendrotweaks/utils.py,sha256=jaUJNb39Bsevg3WJByP56bO7CLj1wzlh-uGZl-lxi1I,7131
|
7
|
-
dendrotweaks/analysis/__init__.py,sha256=SEYpoQ5iXiQXyHB20-IAdDHYI-7CR5GYFXIwr-O05Ug,858
|
8
|
-
dendrotweaks/analysis/ephys_analysis.py,sha256=oXRjad34tKMDiqEO11uZibHpe2auB2GCetcgd2rVP-o,14124
|
9
|
-
dendrotweaks/analysis/morphometric_analysis.py,sha256=5zohjGssyx-wezI-yY3Q-kYM_wzAQLLFBJ9Xk950_JY,3571
|
10
|
-
dendrotweaks/membrane/__init__.py,sha256=H3KsbVQonC1BKBnuchAIxGXj5Zl-xN3egOanVUkgs-o,322
|
11
|
-
dendrotweaks/membrane/distributions.py,sha256=ADPFPA-CN7AbRJj0Ry4TxFZJhdYXJm87iIGWZSDr5vI,10299
|
12
|
-
dendrotweaks/membrane/groups.py,sha256=qN4Q-YodXVLmpGRYvWlZ7Kd9gVnLSK1l4g2Qc0T8dYs,3483
|
13
|
-
dendrotweaks/membrane/mechanisms.py,sha256=F4b6VqI3IjyoOQ6GAFvcy7er5-BFCca8JFnQB_HmjmI,18352
|
14
|
-
dendrotweaks/membrane/default_mod/AMPA.mod,sha256=HY_pWzYvaSDV-w7qruenG2mnll8v79s40HFHjUCIi4U,980
|
15
|
-
dendrotweaks/membrane/default_mod/AMPA_NMDA.mod,sha256=ztv2ePUiEQZ93-23FTkGO2DC91rehQuqo0NUIbHZ368,2318
|
16
|
-
dendrotweaks/membrane/default_mod/CaDyn.mod,sha256=gwc69K_rxu2w_mV7CnOSOnVaCMc8Z-MfdBFf6lAj4kg,1298
|
17
|
-
dendrotweaks/membrane/default_mod/GABAa.mod,sha256=jdGRid-Wzw4y9kHvq74oSMogLhSiS-Ac2DDaLOrxVi8,983
|
18
|
-
dendrotweaks/membrane/default_mod/Leak.mod,sha256=u0lwMYGgl5kNZN5W4N6YHgRSeVxb-z2oM9fqou5rCV8,420
|
19
|
-
dendrotweaks/membrane/default_mod/NMDA.mod,sha256=tT4Q5UPoeztXcQ45uZc2PUO3-8OkDLCmrS7WDsn1yQQ,1185
|
20
|
-
dendrotweaks/membrane/default_mod/vecstim.mod,sha256=iSpJgR96O2Z3pLNUFIsZ7YJ529ncKUBaZqDJvA0_oV0,965
|
21
|
-
dendrotweaks/membrane/default_templates/NEURON_template.py,sha256=BlvA48B48f0AyiepXmrOmGJL5Xe5XDshG9w6h5gDEEs,14874
|
22
|
-
dendrotweaks/membrane/default_templates/default.py,sha256=vDxND86RJEw7XHajkg5P0vM2Oss5dyW5m_ugLMeCbT0,2145
|
23
|
-
dendrotweaks/membrane/default_templates/standard_channel.mod,sha256=Jpu2rxldAE6kxaylIlPc80F5wpKETodpOvoMbFXhWTA,2861
|
24
|
-
dendrotweaks/membrane/default_templates/template_jaxley.py,sha256=t-GsCSUyQ7rDoaLmyuWd9bIxB8W3bCqJdnikD59EVvI,3676
|
25
|
-
dendrotweaks/membrane/default_templates/template_jaxley_new.py,sha256=I62KhnOYNV1bT-nPsDTxjIISYmDcso2X8rnsos28nYs,3631
|
26
|
-
dendrotweaks/membrane/io/__init__.py,sha256=r84iLBrdmCgGP-dG9iaamBHUGldtAgPyqSujU-3U8ik,584
|
27
|
-
dendrotweaks/membrane/io/ast.py,sha256=wnJNy2ga1DsZWQ1lpp1QhK2jvM4aDph7u_27VmyJcXw,5894
|
28
|
-
dendrotweaks/membrane/io/code_generators.py,sha256=jhyjvTisV-tavz_yuQ-tOa3JJ56UNUk_pkN9xS6GEqQ,11407
|
29
|
-
dendrotweaks/membrane/io/converter.py,sha256=vNCKDk0JqdoqxMWGi2AxT-TZ2YS2itUc7bpm9pRX-6o,3374
|
30
|
-
dendrotweaks/membrane/io/factories.py,sha256=rCfZiubZPmikB8nxfjh3Dzg4ZHUXgZX79kmJZDLovwI,4979
|
31
|
-
dendrotweaks/membrane/io/grammar.py,sha256=TJLTDlr8Ajp3J9DJ4IvulOCcpUkYr7HnoI0TGnNuEPc,11677
|
32
|
-
dendrotweaks/membrane/io/loader.py,sha256=vUh6YMozKD-MvrP2mNyW4-vRoYxXJwK1W4QFUSgcLGU,3042
|
33
|
-
dendrotweaks/membrane/io/parser.py,sha256=-SuY9PxlIS5l0bAGuEgLAn89n3F2Ss-X24ehGGZY81o,17921
|
34
|
-
dendrotweaks/membrane/io/reader.py,sha256=JWm5WM9illvSfDkhWEmWBcj8Y7PSi8zeZX9j1ARUHVU,6576
|
35
|
-
dendrotweaks/morphology/__init__.py,sha256=aqJTQOpRVOYcbWqZ2q4e-Oy735r9_ubW-uE_5cFZVtI,323
|
36
|
-
dendrotweaks/morphology/domains.py,sha256=Y4txcGdBdl2aK1DfbTRziNtDyd6bChczwpCWE7lTFzg,2391
|
37
|
-
dendrotweaks/morphology/point_trees.py,sha256=5dUPaQXYPdJbWoD3pFI2DV2XnuFRhB5d0wTBlfmmIeI,21600
|
38
|
-
dendrotweaks/morphology/sec_trees.py,sha256=FMreuh5mN3oXtvy13oqEc8t-r8a36CPfdkaOqeNo2ts,36894
|
39
|
-
dendrotweaks/morphology/seg_trees.py,sha256=uwL1X9qeFNyJVHua1I3rhp0fLSRrS2TAVyb1Fnw4RwQ,3595
|
40
|
-
dendrotweaks/morphology/trees.py,sha256=NrNvPMR-U0clt63eqwVJqU0H8NJgY53QGA_BkdcwkQI,16033
|
41
|
-
dendrotweaks/morphology/io/__init__.py,sha256=gAZqZdf5VKPb6ksK8Lwt7MbTAq8TDP8uq3Vs_ebNFEY,324
|
42
|
-
dendrotweaks/morphology/io/factories.py,sha256=NngNINw73diGK7fud314JzWVhxv2aYLuA9wUuQA0Diw,6344
|
43
|
-
dendrotweaks/morphology/io/reader.py,sha256=hW3c541WtG1rNag_YreEhvrLzm8-OTtw0fQREeHDthM,1913
|
44
|
-
dendrotweaks/morphology/io/validation.py,sha256=lVkYw9y9yG5QpRh_N0YQ3FbZwuSUsQfSqJTMumMcDdc,7872
|
45
|
-
dendrotweaks/morphology/reduce/__init__.py,sha256=p6Mg3KDHxTt8S4DtI0m7L7MqV6dS2pdIYAwB7B-toVw,921
|
46
|
-
dendrotweaks/morphology/reduce/reduce.py,sha256=5czZDrG3xsvHn3c_tbYhUOlXgST989-RS-ntbhlvvA0,6361
|
47
|
-
dendrotweaks/morphology/reduce/reduced_cylinder.py,sha256=jGJ4J-amukRr-3DPirVR5pzNO-6H7_sZF1N_X57ZGdw,5132
|
48
|
-
dendrotweaks/stimuli/__init__.py,sha256=bFfSEZhCVpwOVEBgLe65iiY3SdpjKPhyLemC1z5OX9I,153
|
49
|
-
dendrotweaks/stimuli/iclamps.py,sha256=NjkhhwZKJR1f_g3N9BVxMVoO9ubBk5WkQ6h9Bnf9xgA,1681
|
50
|
-
dendrotweaks/stimuli/populations.py,sha256=wZwy3PC1uRmQa-WnTLZLy7PGKCQrRJgmmhRIaGdJlLU,7991
|
51
|
-
dendrotweaks/stimuli/synapses.py,sha256=g4MgWTske2TZ2i9FIIOE8-KXNx_3dWa3zEhB2rcqYig,5470
|
52
|
-
dendrotweaks-0.3.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
53
|
-
dendrotweaks-0.3.1.dist-info/METADATA,sha256=jcnz3Eq3NdoALKHhwoE8lnrA5iSNAcO6oPBU3yZ0GJs,2687
|
54
|
-
dendrotweaks-0.3.1.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
|
55
|
-
dendrotweaks-0.3.1.dist-info/top_level.txt,sha256=OzT_2BSI5j5zxC447K6Y-0W-GHbued7iX-_hFGAKMxY,13
|
56
|
-
dendrotweaks-0.3.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|