Changeset 403 for trunk

Show
Ignore:
Timestamp:
06/17/09 16:00:49 (3 years ago)
Author:
pierre
Message:

Add a complete function to fill SpikeTrain according to a targeted id_list

Files:
1 modified

Legend:

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

    r401 r403  
    964964                self.append(id, spiketrain) 
    965965                 
     966     
     967    def complete(self, id_list): 
     968        """ 
     969        Complete the SpikeList by adding Sempty SpikeTrain for all the ids present in 
     970        ids that will not already be in the SpikeList 
     971         
     972         Inputs: 
     973            id_list - The id_list that should be completed 
     974         
     975        Examples: 
     976            >> spklist.id_list() 
     977                [0,2,5] 
     978            >> spklist.complete(arange(5)) 
     979            >> spklist.id_list() 
     980                [0,1,2,3,4] 
     981        """ 
     982        id_list     = set(id_list) 
     983        missing_ids = id_list.difference(set(self.id_list())) 
     984        for id in missing_ids: 
     985            self.append(id, SpikeTrain([],self.t_start, self.t_stop)) 
     986         
    966987     
    967988    def id_slice(self, id_list):