Skip to content

Wrong dtype when reading old TDT files (tev) with new tdtio? #198

@ablot

Description

@ablot

Hello,

I'm trying to read a TDT file with the 0.3.X branch (which seems to be the default when install neo with pip, I have 0.3.3). Neo does not crash but the data does not look at all correct. I think the data is read as float64 whatever the actual dtype is (the same file could be read with the master branch).

Part of the problem might come from in tdtio.py L225:

In [12]: print anaSig.lazy_dtype
int16
In [13]:  print anaSig.dtype
float64
In [14]: v[channel] = anaSig.duplicate_with_new_array(np.zeros((anaSig.lazy_shape) , 
dtype = anaSig.lazy_dtype)*pq.V )
In [15]: print v[channel].dtype
float64

v[channel].dtype is not a anaSig.lazy_dtype. this seems to be because of the pq.V:

In [17]:  v[channel] = anaSig.duplicate_with_new_array(np.zeros((anaSig.lazy_shape) , 
dtype = anaSig.lazy_dtype) )
In [18]: print v[channel].dtype
int16

I tried to simply remove the pq.V just to try, but it's obviously not the solution since I run into some problem downstream (traceback below). What should be the dtype of v[channel]? Is it linked to the tev file? (does it work with a sev file)?

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-6-6f5fc22ee99c> in <module>()
----> 1 bl = tdtreader.read_block()

/home/blota/anaconda/envs/ip_notebook/lib/python2.7/site-packages/neo/io/tdtio.py in read_block(self, lazy, cascade)
    285                         s = int((h['size']*4-40)/dt.itemsize)
    286                         a.fid.seek(h['eventoffset'])
--> 287                         a[ a.pos:a.pos+s ]  = np.fromstring( a.fid.read( s*dt.itemsize ), dtype = a.dtype)
    288                         a.pos += s
    289 

ValueError: could not broadcast input array from shape (2048) into shape (512)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions