Skip to content

Make attribute and annotation handling more consistent between NixIO and NixIOFr #1211

Open
@JuliaSprenger

Description

@JuliaSprenger

Describe the bug
Depending on the IO used to load a nix file the loaded neo objects have different attribute values and annotations. This is confusing for the user and leads to inconsistencies.

To Reproduce
One example demonstrating the descrepancies is the file_origin attributes, as can be demonstrated via

from neo import Block, Segment, AnalogSignal
import quantities as pq

asig = AnalogSignal([1,2,3]*pq.V, sampling_rate=1*pq.Hz, file_origin='mydir/anasig_data.txt', array_annotations={'file_origin': ['mydir/single_channel_data.txt']})
bl = Block(file_origin='mydir/block_data.txt')
bl.segments.append(Segment(file_origin='mydir/segment_data.txt'))
bl.segments[0].analogsignals.append(asig)


from neo import NixIO
nio = NixIO('test.nix', 'ow')
nio.write_block(bl)

# reading attributes via NixIO
bl2 = nio.read_block()
print('Attributes read by NixIO')
print(bl2.file_origin)
print(bl2.segments[0].file_origin)
print(bl2.segments[0].analogsignals[0].file_origin)
print(bl2.segments[0].analogsignals[0].array_annotations)
nio.close()

# reading attributes via NixIOfr
from neo.io import NixIOFr
nio = NixIOFr('test.nix')
bl2 = nio.read_block()
print('Attributes read by NixIOFr')
print(bl2.file_origin)
print(bl2.segments[0].file_origin)
print(bl2.segments[0].analogsignals[0].file_origin)
print(bl2.segments[0].analogsignals[0].array_annotations)

This returns

None
None
None
{'file_origin': array(['mydir/single_channel_data.txt'], dtype='<U29')}
Attributes read by NixIOFr
test.nix
test.nix
test.nix
{'channel_names': array([''], dtype='<U1'), 'channel_ids': array(['0'], dtype='<U1')}

Expected behaviour
Both IOs should yield neo objects with the same attributes and values

Environment:

  • OS: Linux
  • Python version: 3.9.5
  • Neo version: 0.12.0.dev0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions