Changeset 489
- Timestamp:
- 07/25/11 16:08:20 (10 months ago)
- Files:
-
- 1 modified
-
trunk/src/signals/spikes.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/signals/spikes.py
r487 r489 737 737 738 738 739 def psth(self, events, time_bin=2, t_min=50, t_max=50, display = False, kwargs={} ):739 def psth(self, events, time_bin=2, t_min=50, t_max=50, display = False, kwargs={}, average=True): 740 740 """ 741 741 Return the psth of the spike times contained in the SpikeTrain according to selected events, … … 774 774 t_start = numpy.floor(self.t_start/time_bin) 775 775 t_stop = numpy.floor(self.t_stop/time_bin) 776 result = [] 776 777 for ev in events: 777 778 ev = numpy.floor(ev/time_bin) 778 779 if ((ev - t_min_l )> t_start) and (ev + t_max_l ) < t_stop: 779 780 count += 1 780 result += spk_hist[(ev-t_min_l):ev+t_max_l] 781 result /= count 781 result += [spk_hist[(ev-t_min_l):ev+t_max_l]] 782 result = numpy.array(result) 783 if average: 784 result /= count 782 785 783 786 if not subplot or not HAVE_PYLAB: … … 2395 2398 result += spk_hist[:,(ev-t_start-t_min_l):ev-t_start+t_max_l] 2396 2399 result /= count 2397 if average:2398 result = numpy.mean(result, 0)2399 2400 2400 2401 if not subplot or not HAVE_PYLAB: … … 2407 2408 if average: 2408 2409 subplot.plot(time, result, **kwargs) 2410 subplot.errorbar(times, mean(result, 0), yerr=std(result, 0)) 2409 2411 else: 2410 2412 for idx in xrange(len(result)): … … 2417 2419 set_axis_limits(subplot, -t_min, t_max, ymin, ymax) 2418 2420 pylab.draw() 2421 if average: 2422 result = numpy.mean(result, 0) 2419 2423 return result 2420 2424 … … 2501 2505 fname = "_tmp_spikes_%05d.png" %count 2502 2506 #logging.debug("Saving Frame %s", fname) 2503 progress_bar(float(t_start)/t_stop)2507 #progress_bar(float(t_start)/t_stop) 2504 2508 pylab.savefig(fname) 2505 2509 files.append(fname)
