save/read problem neo 0.5.0

42 views
Skip to first unread message

MCzerwinski

unread,
Apr 7, 2017, 8:05:21 AM4/7/17
to Neural Ensemble

Hi all


I am working with neo for some time, but recently only updated it.

So I am trying to save a preprocessed signal, neo object, and load it later with a different python script.

I was using hdf5, but I see now that saving is not supported by neo.
I am in a point that I cant save my segment/analog signal with annotations, and later load it.


Earlier it was easy:
iom = neo.io.hdf5IO(filename)
iom.save(segment)
iom.close()

iom2 = neo.io.hdf5IO(filename)
loaded = iom2.get()
iom2.close()


Right now I tried:
iom = neo.io.PickleIO(filename)
block = neo.block.Block(segment)
block.annotations= segment.annotations #all segment, block and analogsignal have those annotations
iom.write_block(block)  #I tried with segment also

iom2 = neo.io.PickleIO(filename)
loaded = iom2.read_block()
#block = iom2.read()
iom2.close()

Here the signal was properly printed, with annotations, but the 'loaded' variable is not defined. In one or two loading functions, it was 'None'


iom = neo.io.NeoMatlabIO(filename+'.mat')
block = neo.block.Block(segment)
block.annotations= segment.annotations #all segment, block and analogsignal have those annotations
iom.write_block(block)  #I tried with segment also

iom2 = neo.io.NeoMatlabIO(filename+'.mat')
segment = iom2.read()
iom2.close()

With matlab (I dont want to use matlab fileformat in python because of speed) I was finnaly able to load the signal, but without the annotations. Which is a pity, not to have channel indexes etc.


Is it a bug, or am I using a wrong IO/ using it incorrect?
Is there a way to do this other than saving the signal and the annotations independently?


Michal Czerwinski

Andrew Davison

unread,
Apr 18, 2017, 4:47:09 AM4/18/17
to Neural Ensemble
Dear Michal,


On Friday, 7 April 2017 14:05:21 UTC+2, MCzerwinski wrote:

I was using hdf5, but I see now that saving is not supported by neo.
I am in a point that I cant save my segment/analog signal with annotations, and later load it.


Earlier it was easy:
iom = neo.io.hdf5IO(filename)
iom.save(segment)
iom.close()

iom2 = neo.io.hdf5IO(filename)
loaded = iom2.get()
iom2.close()

NeoHdf5IO has been replaced with NixIO, which is also based on HDF5, but is more widely supported. NeoHdf5IO still supports reading files created with an earlier version of Neo, but you should then save them with NixIO. 

 
Right now I tried:
iom = neo.io.PickleIO(filename)
block = neo.block.Block(segment)
block.annotations= segment.annotations #all segment, block and analogsignal have those annotations
iom.write_block(block)  #I tried with segment also

iom2 = neo.io.PickleIO(filename)
loaded = iom2.read_block()
#block = iom2.read()
iom2.close()

Here the signal was properly printed, with annotations, but the 'loaded' variable is not defined. In one or two loading functions, it was 'None'

This looks like a bug. Please could you create a ticket in the issue tracker? https://github.com/NeuralEnsemble/python-neo/issues/new
 
iom = neo.io.NeoMatlabIO(filename+'.mat')
block = neo.block.Block(segment)
block.annotations= segment.annotations #all segment, block and analogsignal have those annotations
iom.write_block(block)  #I tried with segment also

iom2 = neo.io.NeoMatlabIO(filename+'.mat')
segment = iom2.read()
iom2.close()

With matlab (I dont want to use matlab fileformat in python because of speed) I was finnaly able to load the signal, but without the annotations. Which is a pity, not to have channel indexes etc.

This also looks like a bug. Please could you also create a ticket about the lack of annotations in NeoMatlabIO?
 
Regards,

Andrew


Reply all
Reply to author
Forward
0 new messages