proc get_EPSP_amp() { local baseline_t, baseline_pts, EPSP_graph, EPSP_trace, IPSP_graph, IPSP_trace
baseline_t = 5 // milliseconds
baseline_pts = baseline_t * steps_per_ms
EPSP_graph = 0
EPSP_trace = ExINPUT
IPSP_graph = 1
IPSP_trace = 0
max_Ex_EPSP_amp = get_graph_max_amp(EPSP_graph, EPSP_trace, baseline_pts)
max_Inh_EPSP_amp = get_graph_max_amp(IPSP_graph, IPSP_trace, baseline_pts)
//return max_Ex_EPSP_amp max_Inh_EPSP_amp
//return
} // End getEPSPamp
objref Xvec, Yvec
func get_graph_max_amp() { local graph_idx, graph_line_nr, baseline_pts, baseline_avg, max_val, graph_size, amplitude
// Function that gets maximal AMPLITUDE from a plot. Returned value will thus be maximal
// value subtracted from the first 'baseline_pts'
graph_idx = $1 // Window/Graph index
graph_line_nr = $2 // Line index within a graph
baseline_pts = $3 // # of points in the beggining of the line to be considered as baseline
// get 'line_nr' trace from Graph['graph_idx']
Xvec = new Vector()
Yvec = new Vector()
Graph[graph_idx].getline(graph_line_nr, Xvec, Yvec) // Gets 2nd line from plot
// Get baseline of graph, FROM FIRST 'baseline_t' milliseconds, so that true EPSP amplitude is computed
baseline_avg = 0
for (i = 0; i < baseline_pts; i = i +1) {
baseline_avg = baseline_avg + Yvec.x(i)
}
baseline_avg = baseline_avg / baseline_pts
max_val = Yvec.x(0) // Just initializes max_val as first element of graph
graph_size = Yvec.size()
for (i=0; i < graph_size; i = i+1) {
if (Yvec.x(i) > max_val) {
max_val = Yvec.x(i)
}
//print Yvec.x(i)
}
amplitude = max_val - baseline_avg
return amplitude
} // End get_graph_max_amp
objref slope_indep_vec, temp_data_vec, temp_res_data_vec
slope_indep_vec = new Vector(t_slope_window/dt)
slope_indep_vec.indgen()
temp_data_vec = new Vector(t_slope_window/dt)
temp_res_data_vec = new Vector(t_slope_window/dt)
slope_p1=1
slope_p2=0
func get_EPSP_slope() { local pstart, pend, pwindow, pstep, maxslope, xmaxslope, i
// INPUTS (un time)
//tstart = $1
//tend = $2
//twindow = $3
//tstep = $4
// Converts variable above to points
pstart = int($1/dt)
pend = int($2/dt)
pwindow = int($3/dt)
pstep = int($4/dt)
// Computes max slope
maxslope=0
xmaxslope=0
for (i = pstart; i <= pend; i = i + pstep) {
slope = (v_trace.x(i+pwindow-1) - v_trace.x(i))/((pwindow-1)*dt)
// temp_data_vec.copy(v_trace, i, i+pwindow-1)
// temp_data_vec.fit(temp_res_data_vec, "line", slope_indep_vec, &slope_p1, &slope_p2)
// slope = slope_p1
if (slope > maxslope) {
maxslope = slope
xmaxslope = i
}
// If window is getting points above threshold, breaks the loop (because this should mean AP, thus EPSP has passed already)
if (v_trace.x[i+pwindow-1] > Ex[ExINPUT].soma.Thr_ExIAF ) { break } // This exits the loop
}
// Draws the slope line
if (0) {
Graph[0].beginline(1,2)
Graph[0].line(xmaxslope*dt, v_trace.x[xmaxslope]+400) // (x,y)
Graph[0].line((xmaxslope+pwindow-1)*dt, v_trace.x[xmaxslope+pwindow-1]+400)
Graph[0].flush()
}
return maxslope
}