-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathneuronFunctions.py
51 lines (41 loc) · 1.4 KB
/
neuronFunctions.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
from neuron import h
from neuron.units import ms, mV, µm
h.load_file('stdrun.hoc')
def simulate(tstop=25,v_init=-75,celsius=34):
# Set initial voltage for all sections
h.finitialize(v_init * mV)
h.celsius = celsius
h.continuerun(tstop * ms)
def record(section,loc,recVar='_ref_v'):
"""Record a section at location. Record membrane voltage unless specified with recVar."""
tv = h.Vector()
tv.record(h._ref_t)
data = h.Vector()
data.record(getattr(section(loc),recVar))
return data,tv
def attachCC(section, delay=5, dur=1, amp=.1, loc=0.5):
stim = h.IClamp(section(loc))
stim.delay = delay
stim.dur = dur
stim.amp = amp
return stim
def attachAlpha(section, seg, onset=5, tau=1, gmax=.1, eRev=0):
syn = h.AlphaSynapse(section(seg))
syn.onset = onset
syn.tau = tau
syn.gmax = gmax
return syn
def returnSegment(nseg,seg):
dx = 1.0/nseg # it'll be broken up into segments that are this wide
dxShift = dx/2.0 # shift to center of segment
if seg==-1: seg=nseg
return dx*seg-dxShift
def conductanceFromCurrent(i,v,e):
g = 1e4 * i / (v-e)
return g
def showNeuronMorphology():
shape_window = h.PlotShape() # without extra specification, this doesn't show diameters.... so it just looks like a line
shape_window.exec_menu('Show Diam')
def deleteEverything():
for sec in h.allsec():
h.delete_section(sec=sec)