Changeset 446 for trunk/src/io.py

Show
Ignore:
Timestamp:
04/12/10 15:37:12 (2 years ago)
Author:
apdavison
Message:

SpikeTrain.time_slice() now (again) accepts a sequence of t_start values and a sequence of t_stop values, if you wish to extract multiple slices.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/io.py

    r445 r446  
    393393 
    394394 
     395class PyNNNumpyBinaryFile(FileHandler): 
     396     
     397    def __init__(self, filename): 
     398        FileHandler.__init__(self, filename) 
     399        self.fileobj = open(self.filename, 'r') 
     400         
     401    def read_spikes(self, params): 
     402        from NeuroTools.signals import spikes 
     403        contents = numpy.load(self.fileobj) 
     404        spike_data = contents['data'][:, (1,0)] 
     405        self.metadata = M = {} 
     406        for k,v in contents['metadata']: 
     407            M[k] = eval(v) 
     408        id_list = range(M['first_id'], M['last_id']) 
     409        t_stop = params['t_stop'] 
     410        # really need to check the agreement between file metadata and 
     411        # params for all metadata items 
     412        return spikes.SpikeList(spike_data, id_list, t_start=0.0, t_stop=t_stop, 
     413                                dims=M['dimensions']) 
     414         
     415    #def read_analogs(self, type, params): 
     416    #    contents = numpy.load(self.fileobj) 
     417    #    values, ids = contents['data'].T # need to check the shape first 
     418     
     419 
    395420 
    396421class DataHandler(object):