Changeset 434 for branches

Show
Ignore:
Timestamp:
08/29/09 00:13:01 (3 years ago)
Author:
lestebanez
Message:

Spikes.py : optimize the use of intervals in the PSTH for multiple spike trains

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/interval/src/signals/spikes.py

    r433 r434  
    21912191        t_max_l  = numpy.floor(t_max/time_bin) 
    21922192        result   = numpy.zeros((len(self), t_min_l+t_max_l), numpy.float32) 
     2193        events_interval = copy.copy(self.interval) 
     2194        events_interval.offset_start(t_min, colapse=True) 
     2195        events_interval.offset_stop(-t_max, colapse=True) 
     2196        events = events_interval.slice_times(events) 
     2197        assert len(events) > 0, "the PSTH windows [event-t_min, event+t_max] should be included within the spike train interval" 
    21932198        for ev in events: 
    2194            itv = Interval((ev-t_min,ev+t_max)) 
    2195            ev  = numpy.floor(ev/time_bin) 
    2196            if itv.intersect(self.interval).total_duration() == (t_max+t_min): 
    2197                count  += 1 
    2198                result += spk_hist[:,(ev-t_min_l):ev+t_max_l] 
     2199            ev  = numpy.floor((ev - self.interval.t_start())/float(time_bin)) 
     2200            count  += 1.     
     2201            result += spk_hist[(ev-t_min_l):ev+t_max_l] 
    21992202        result /= count 
    22002203        if average: