| | 395 | class 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 | |