Skip to content

NixIO does not preserve shape of empty waveforms #373

@JuliaSprenger

Description

@JuliaSprenger

When saving a spiketrain with a waveform array of shape (0,0,0) and loading it again using the NixIO, the new shape of the waveform array is (0,).

Here is some code showing this explicitely:

from neo import Block, Segment, SpikeTrain, NixIO
import quantities as pq
import numpy as np

bl = Block()
seg = Segment()
bl.segments.append(seg)

st = SpikeTrain([1,2,3]*pq.s,t_start=0*pq.s,t_stop=10*pq.s,
                sampling_rate=1*pq.Hz)
wfs = np.array([]).reshape((0,0,0))*pq.V
st.waveforms = wfs

bl.segments[0].spiketrains.append(st)

with NixIO('test.nix','ow') as nio:
    nio.write_block(bl)
    print('waveform shape before writing {}'
          ''.format(bl.segments[0].spiketrains[0].waveforms.shape))

with NixIO('test.nix','ro') as nio:
    block = nio.read_block()
    print('waveform shape after loading {}'
          ''.format(block.segments[0].spiketrains[0].waveforms.shape))

The prints are:

waveform shape before writing (0, 0, 0)
waveform shape after loading (0,)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions