Changeset 492

Show
Ignore:
Timestamp:
08/23/11 20:01:06 (9 months ago)
Author:
emuller
Message:

threshold_detection now returns empty numpy array instead of list for no spikes (return type should be consistent irrespective of # of spikes returned). Fixes to slice_exclude_events, cov

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/signals/analogs.py

    r491 r492  
    258258             
    259259        if len(cutout) <= 0: 
    260             events = [] 
     260            events = numpy.zeros(0) 
    261261        else: 
    262262            take = numpy.where(numpy.diff(cutout)>1)[0]+1 
     
    411411            assert numpy.iterable(events), "events should be a SpikeTrain object or an iterable object" 
    412412        assert (t_min >= 0) and (t_max >= 0), "t_min and t_max should be greater than 0" 
    413         assert len(events) > 0, "events should not be empty and should contained at least one element" 
     413 
     414        # if no events to remove, return self 
     415        if len(events)==0: 
     416            yield self 
     417            return 
    414418         
    415419        t_last = self.t_start 
    416420        for spike in events: 
     421            # skip spikes which aren't close to the signal interval 
     422            if spike+t_min<self.t_start or spike-t_min>self.t_stop: 
     423                continue 
     424             
    417425            t_min_local = numpy.max([t_last, spike-t_min]) 
    418426            t_max_local = numpy.min([self.t_stop, spike+t_max]) 
    419             if t_min_local>t_last: 
     427 
     428            if t_last<t_min_local: 
    420429                yield self.time_slice(t_last, t_min_local) 
     430 
    421431            t_last = t_max_local 
    422432 
     
    455465 
    456466        assert signal.dt == self.dt 
    457         assert signal.duration()==self.duration() 
     467        assert signal.signal.shape==self.signal.shape 
    458468 
    459469        return mean(self.signal*signal.signal)-mean(self.signal)*(mean(signal.signal))