-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsynapses.py
More file actions
65 lines (56 loc) · 1.93 KB
/
synapses.py
File metadata and controls
65 lines (56 loc) · 1.93 KB
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
import glob
import json
import os
from bmtk.simulator.bionet.pyfunction_cache import add_synapse_model
from neuron import h
import random
def Exp2Syn1_STSP(syn_params, sec_x, sec_id):
"""Create a Exp2Syn1_STSP synapse
:param syn_params: parameters of a synapse
:param sec_x: normalized distance along the section
:param sec_id: target section
:return: NEURON synapse object
"""
lsyn = h.Exp2Syn1_STSP(sec_x, sec=sec_id)
if syn_params.get('e'):
lsyn.e = float(syn_params['e'])
if syn_params.get('tauD1'):
lsyn.tauD1 = float(syn_params['tauD1'])
if syn_params.get('d1'):
lsyn.d1 = float(syn_params['d1'])
if syn_params.get('tauD2'):
lsyn.tauD2 = float(syn_params['tauD2'])
if syn_params.get('d2'):
lsyn.d2 = float(syn_params['d2'])
if syn_params.get('tauF'):
lsyn.tauF = float(syn_params['tauF'])
if syn_params.get('f'):
lsyn.f = float(syn_params['f'])
return lsyn
def exp2syn1_stsp(syn_params, xs, secs):
"""Create a list of Exp2Syn1_STSP synapses
:param syn_params: parameters of a synapse
:param xs: list of normalized distances along the section
:param secs: target sections
:return: list of NEURON synpase objects
"""
syns = []
for x, sec in zip(xs, secs):
syn = Exp2Syn1_STSP(syn_params, x, sec)
syns.append(syn)
return syns
def load():
add_synapse_model(Exp2Syn1_STSP, 'exp2syn1_stsp', overwrite=False)
add_synapse_model(Exp2Syn1_STSP, overwrite=False)
return
def syn_params_dicts(syn_dir='biophys_components/synaptic_models'):
"""
returns: A dictionary of dictionaries containing all
properties in the synapse json files
"""
files = glob.glob(os.path.join(syn_dir,'*.json'))
data = {}
for fh in files:
with open(fh) as f:
data[os.path.basename(fh)] = json.load(f) #data["filename.json"] = {"prop1":"val1",...}
return data