//This file analyses AP characteritics : Amplitude, half-width, and peeak of the second derivatives


objref timeS, dv2Peak


proc soma_analysis(){
	
timeS = new Vector()
dv2Peak = new Vector()
	
iTh = somaD1_late.indwhere(">=", 10) // threshold for AP 10 mV/s on the first derivative
threshold = somaVm_late.x[iTh]
print "index is : ", iTh
print "threshold is : ", threshold	

vMax = somaVm_late.max()
iMax = somaVm_late.indwhere("==", vMax)
AP = vMax-threshold
print "AP ampl is : ", AP	

vHalf = (AP/2)+threshold
print "half amplitude is : ", vHalf

timeS.indvwhere(somaVm_late, ">=", vHalf)
iStart = timeS.min()
iEnd = timeS.max()
tStart = somaT_late.x[iStart]
tEnd = somaT_late.x[iEnd]
HW = tEnd-tStart
print tStart, tEnd, HW

for a=iTh, iMax-1 {		

	if (somaD2_late.x[a]>=somaD2_late.x[a-1] && somaD2_late.x[a]>=somaD2_late.x[a+1] ){
		print "dv2 is ", somaD2.x[a]
	dv2Peak.append(somaD2_late.x[a])
	print "nb de pics de dv2 ", dv2Peak.size()
	lpeak = dv2Peak.size()-1
	} 

}	

peakIS = dv2Peak.x[0]
peakSD = dv2Peak.x[lpeak]
print "peak IS ",peakIS, "peak SD  ", peakSD					
}