-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathextref.py
124 lines (99 loc) · 4.15 KB
/
extref.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
# Michele Mattioni
# Tue Aug 10 09:08:06 BST 2010
from neuronvisio.manager import BaseRef
class TimeSeries(BaseRef):
"""
Extend the classic VecRef from Neuronvisio to allocate
the biochemical results.
"""
def __init__(self, sec_name=None, vecs=None, detail=None):
BaseRef.__init__(self)
self.sec_name = sec_name
self.vecs = vecs
self.detail = detail
class WeightRef(BaseRef):
"""
Extend the classic VecRef from Neuronvisio to allocate
the biochemical results.
"""
def __init__(self, sec_name=None, vecs=None, detail=None):
BaseRef.__init__(self)
self.sec_name = sec_name
self.vecs = vecs
self.detail = detail
class FluxRef(BaseRef):
"""
Extend the classic VecRef from Neuronvisio to allocate
the K flux.
"""
def __init__(self, sec_name=None, vecs=None, detail=None):
BaseRef.__init__(self)
self.sec_name = sec_name
self.vecs = vecs
self.detail = detail
class ExtRef(object):
"Holds all the methods to add new ref to the manager"
def add_timeseries(self, manager, stim_spines, nrnSim):
"""Adding timeseries from the ecell world to the manager"""
for spine_id in stim_spines:
spine = nrnSim.spines[spine_id]
# Retrieving the biochemical timecourses
spine.ecellMan.converToTimeCourses()
time_courses = spine.ecellMan.timeCourses
pos = str(spine.pos)
parent = spine.parent.name()
detail = parent + "_" + pos
sec_name = str(spine.id)
# Adding a record for each variable
vecs = {}
time = None
for var in time_courses.keys():
time = time_courses[var][:,0]
vecs[var] = time_courses[var][:,1]
timeseriesRef = TimeSeries(sec_name=sec_name,
vecs=vecs,
detail=detail)
# Ecell use an adaptative time for the integration so the time is different
# for each spine.
# We create a custum timeseries to differentiate within them
timeseriesRef.group_id = "timeSeries_" + spine.id
manager.add_ref(timeseriesRef, time)
def add_weights(self, manager, stim_spines, nrnSim):
"""Add the weight to the manager"""
for spine_id in stim_spines:
spine = nrnSim.spines[spine_id]
pos = str(spine.pos)
parent = spine.parent.name()
detail = parent + "_" + pos
sec_name = str(spine.id)
vecs = {}
time = None
for syn in spine.synapses:
if syn.chan_type == 'ampa':
if syn.weight[0]:
time = syn.weight[0]
weight = syn.weight[1]
vecs['weight'] = weight
weightRef = WeightRef(sec_name=sec_name,
vecs=vecs,
detail=detail)
manager.add_ref(weightRef, time)
def add_kflux(self, manager, stim_spines, nrnSim):
"""Add the weight to the manager"""
for spine_id in stim_spines:
spine = nrnSim.spines[spine_id]
pos = str(spine.pos)
parent = spine.parent.name()
detail = parent + "_" + pos
sec_name = str(spine.id)
vecs = {}
time = None
for syn in spine.synapses:
if syn.chan_type == 'ampa':
if syn.weight[0]:
time = spine.k_flux[0]
vecs['k_flux'] = spine.k_flux[1]
fluxRef = FluxRef(sec_name=sec_name,
vecs=vecs,
detail=detail)
manager.add_ref(fluxRef, time)