Skip to content

Commit 31135a6

Browse files
author
sprenger
committed
[nixraw] add signal array annotations
1 parent 1057d79 commit 31135a6

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

neo/rawio/nixrawio.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44
The RawIO assumes all segments and all blocks have the same structure.
55
It supports all kinds of NEO objects.
66
7-
Author: Chek Yin Choi
7+
Author: Chek Yin Choi, Julia Sprenger
88
"""
99

10-
from .baserawio import (BaseRawIO, _signal_channel_dtype, _signal_stream_dtype,
11-
_spike_channel_dtype, _event_channel_dtype)
10+
import os.path
1211

13-
from ..io.nixio import NixIO
14-
from ..io.nixio import check_nix_version
1512
import numpy as np
13+
14+
from .baserawio import (BaseRawIO, _signal_channel_dtype, _signal_stream_dtype,
15+
_spike_channel_dtype, _event_channel_dtype)
16+
from ..io.nixio import check_nix_version
17+
1618
try:
1719
import nixio as nix
1820

@@ -241,6 +243,31 @@ def _parse_header(self):
241243
event_ann.update(self._filter_properties(props, 'event'))
242244
ev_idx += 1
243245

246+
# adding array annotations to analogsignals
247+
annotated_anasigs = []
248+
sig_ann = seg_ann['signals']
249+
stream_id = 0
250+
for da_idx, da in enumerate(group.data_arrays):
251+
if da.type != "neo.analogsignal":
252+
continue
253+
anasig_id = da.name.split('.')[-2]
254+
if anasig_id in annotated_anasigs:
255+
continue
256+
annotated_anasigs.append(anasig_id)
257+
258+
array_anno_props = []
259+
for prop in da.metadata.props:
260+
if prop.type == 'ARRAYANNOTATION':
261+
array_anno_props.append(prop)
262+
263+
props_dict = self._filter_properties(array_anno_props,
264+
"analogsignal")
265+
266+
sig_ann[stream_id]['__array_annotations__'].update(
267+
props_dict)
268+
269+
stream_id += 1
270+
244271
def _segment_t_start(self, block_index, seg_index):
245272
t_start = 0
246273
for mt in self.file.blocks[block_index].groups[seg_index].multi_tags:

0 commit comments

Comments
 (0)