Changeset 342
- Timestamp:
- 11/15/08 16:28:02 (2 months ago)
- Files:
-
- trunk/src/signals.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/signals.py
r337 r342 239 239 240 240 return spike_times 241 242 def jitter(self,jitter): 243 """ 244 Returns a new SpikeTrain with spiketimes jittered by a normal distribution. 245 246 Inputs: 247 jitter - sigma of the normal distribution 248 249 Examples: 250 >> st_jittered = st.jitter(2.0) 251 """ 252 253 return SpikeTrain(self.spike_times+numpy.random.normal(loc=0.0,scale=jitter,size=self.spike_times.shape[0]),t_start=self.t_start,t_stop=self.t_stop) 241 254 242 255 … … 2291 2304 assert t_stop<=self.t_stop 2292 2305 assert t_stop>t_start 2293 2306 2294 2307 t = self.time_axis() 2295 2308 i_start = numpy.searchsorted(t,t_start,'right')-1 … … 2301 2314 return result 2302 2315 2303 def threshold_detection(self, threshold=None, format=None ):2316 def threshold_detection(self, threshold=None, format=None,sign='above'): 2304 2317 """ 2305 2318 Returns the times when the analog signal crosses a threshold. … … 2311 2324 format - when 'raw' the raw events array is returned, 2312 2325 otherwise this is a SpikeTrain object by default 2326 sign - 'above' detects when the signal gets above the threshodl, 'below when it gets below the threshold' 2313 2327 2314 2328 Examples: … … 2318 2332 2319 2333 assert threshold is not None, "threshold must be provided" 2320 2321 above = numpy.where(self.signal > threshold)[0] 2322 if len(above) <= 0: 2334 2335 if sign is 'above': 2336 cutout = numpy.where(self.signal > threshold)[0] 2337 elif sign in 'below': 2338 cutout = numpy.where(self.signal < threshold)[0] 2339 2340 if len(cutout) <= 0: 2323 2341 events = [] 2324 2342 else: 2325 take = numpy.where(numpy.diff( above)>1)[0]+12343 take = numpy.where(numpy.diff(cutout)>1)[0]+1 2326 2344 take = numpy.append(0,take) 2327 2345 2328 2346 time = self.time_axis() 2329 events = time[ above][take]2347 events = time[cutout][take] 2330 2348 2331 2349 if format is 'raw': … … 2335 2353 2336 2354 2337 def event_triggered_average(self, events, average = True, t_min = 0, t_max = 100, display = False, kwargs={}):2355 def event_triggered_average(self, events, average = True, t_min = 0, t_max = 100, display = False, with_time = False, kwargs={}): 2338 2356 """ 2339 2357 Return the spike triggered averaged of an analog signal according to selected events, … … 2398 2416 2399 2417 if not subplot or not ENABLE_PLOTS: 2400 return result 2418 if with_time: 2419 return result, time_axis 2420 else: 2421 return result 2401 2422 else: 2402 2423 xlabel = "Time (ms)"

