3434def getOrbit (data , start = None , eps = 1e-4 , col = 1 ):
3535 '''
3636 Function extracts single orbit from given data and returns it.
37- The orbit is ectracted from 'start' with accuracy of the end
38- point less than eps. The compared data is taken from
37+ The orbit is ectracted from 'start' with accuracy of the end
38+ point less than eps. The compared data is taken from
3939 the column col.
4040 '''
4141 # If no starting point is specified, start from the minimal value
@@ -45,7 +45,7 @@ def getOrbit(data, start=None, eps=1e-4, col=1):
4545 stop = start + 1
4646 avr = data [:,col ].min () + \
4747 (np .abs (data [:,col ].max ()) + np .abs (data [:,col ].min ()))/ 2
48- crossAvr = False
48+ crossAvr = False
4949 for i in range (start + 1 ,data .shape [0 ]):
5050 # Orbit have to cross maximu avarege value firs
5151 if not crossAvr :
@@ -70,8 +70,8 @@ def arcLength(data):
7070
7171def resample1d (data , ns ):
7272 '''
73- Function resamples the given data (1d line [x,y] data) using even
74- arc lenght (linear interpolation). New (resampled) data is returned.
73+ Function resamples the given data (1d line [x,y] data) using even
74+ arc lenght (linear interpolation). New (resampled) data is returned.
7575 '''
7676 # Calculating arc lenght of the bit and the whole data
7777 tot_alen = arcLength (data )
@@ -98,20 +98,20 @@ def resample1d(data, ns):
9898
9999def findSpikes (data , cols = [0 ,1 ], threshold = 20 , sampleThr = 3 ):
100100 '''
101- Function finds spikes in the given two data columns data.
102- Threshold is a slope of the tangent line. SampleThr is
101+ Function finds spikes in the given two data columns data.
102+ Threshold is a slope of the tangent line. SampleThr is
103103 minimal number of samples where slope is greater then threshold.
104104 Threshold value according to (Naundorf et al. 2006).
105105 '''
106106 if len (cols ) != 2 :
107107 raise ValueError ('List should contain to columns!' )
108-
108+
109109 st = 0 # Number of samples above threshold
110110 # List contain begining, top and end of the spike i
111111 spb = []; spm = []; spe = []
112112 # Last slope
113113 sl_last = 0
114- # Spike flag (0 - nothing, 1 - passed begining,
114+ # Spike flag (0 - nothing, 1 - passed begining,
115115 # 2 - passed midpoint, 3 - on the way down (on steep slope))
116116 spf = 0
117117 for i in range (1 ,data .shape [0 ]):
@@ -128,7 +128,7 @@ def findSpikes(data, cols=[0,1], threshold=20, sampleThr=3):
128128 spf = 2
129129 sl_last = sl
130130 continue
131-
131+
132132 # Looking for the steep slope down
133133 if spf == 2 :
134134 if np .abs (sl ) > threshold and np .sign (sl ) == - 1 :
@@ -172,7 +172,7 @@ def findADP(data, cols=[0,1], threshold=20, sampleThr=3):
172172 dx ,dy = data [spe [i ],cols ] - data [spe [i ]- 1 ,cols ]
173173 # Slope of tangent line
174174 sl_last = dy / dx
175- # If we have more spikes, look for ADP till the begining
175+ # If we have more spikes, look for ADP till the begining
176176 # of the next spike, else look till the end of the data
177177 if i + 1 < len (spe ):
178178 j_end = spb [i + 1 ]
@@ -197,13 +197,13 @@ def ISI(data, cols=[0,1], threshold=20, sampleThr=3):
197197 of ISI for the given pair. The ISI is calculated for the peak of the spikes.
198198 Threshold value according to (Naundorf et al. 2006).
199199 '''
200-
200+
201201 (spb , spm , spe ) = findSpikes (data , cols , threshold , sampleThr )
202-
202+
203203 # ISI can be calculated for at least 2 spikes
204204 if len (spm ) < 2 :
205205 return None
206-
206+
207207 return np .diff (data [spm ,cols [0 ]])
208208
209209def getDVDT (data , cols = [0 ,1 ]):
@@ -214,14 +214,14 @@ def getDVDT(data, cols=[0,1]):
214214 return np .diff (data [:,cols [1 ]])/ np .diff (data [:,cols [0 ]])
215215
216216def getThreshold (data , cols = [0 ,1 ]):
217- '''
217+ '''
218218 Function returns a threshold time and value for the first spike in the spike train.
219219 Threshold is defined as dV/dt crossing of 20 V/s (Naundorf et al. 2006).
220220 '''
221221 dv = getDVDT (data , cols )
222-
222+
223223 i = (dv >= 20 ).nonzero ()[0 ][0 ]
224-
224+
225225 return data [i ,:]
226226
227227def getTau (data , cols = [0 ,1 ]):
@@ -232,8 +232,8 @@ def getTau(data, cols=[0,1]):
232232 function does not detect the beginning of current injection by itself.
233233 '''
234234 d = np .abs (data [:,cols ].copy ())
235- v_63 = 0.63 * (d [:,cols [1 ]].max () - d [:,cols [1 ]].min ()) + d [0 ,cols [1 ]]
235+ v_63 = 0.63 * (d [:,cols [1 ]].max () - d [:,cols [1 ]].min ()) + d [0 ,cols [1 ]]
236236
237- # Index of the 63% crossing
237+ # Index of the 63% crossing
238238 i_63 = (d [:,cols [1 ]] >= v_63 ).nonzero ()[0 ][0 ]
239239 return d [i_63 ,cols [1 ]] - d [0 ,cols [1 ]]
0 commit comments