-
Notifications
You must be signed in to change notification settings - Fork 266
Closed
Description
Hello,
I am working with data read from a NIX file using NixIO, which also contain epochs for the individual trials.
However, when I cut the main segment using one epoch, the nix_name annotation in the resulting segment is the same as the Epoch object used to cut the data.
The code below reproduces the behavior with generated data.
import neo
from neo import utils as neo_utils
import numpy as np
import quantities as pq
# Generate a segment with data. Annotations as expected from reading a NIX file
signal = neo.AnalogSignal(np.random.random((90000, 5)), units=pq.uV,
sampling_rate=30000*pq.Hz, name="Electrode data",
nix_name="neo.analogsignal.ca2b24032c0b4c0497856e24b69268c0",
implantation_site="M1")
segment = neo.Segment(name="Segment 0", description="Test segment",
nix_name="neo.segment.1dab77a06b734b638f13e9c19d76d6df")
segment.analogsignals = [signal]
# Generate epoch to cut between 1 and 2 s, with annotations
epoch = neo.Epoch([1]*pq.s, [1]*pq.s, name="Epoch 1", description="Test epoch",
trial_number=1, trial_protocol=10,
nix_name="neo.epoch.da832a0d90c8479abd2247aff4840133")
# Cut the segment using the epoch
trial_segment = neo_utils.cut_segment_by_epoch(segment, epoch)[0]
# Inspect the annotations
print(trial_segment.annotations)
The output is
{'nix_name': 'neo.epoch.da832a0d90c8479abd2247aff4840133', 'trial_number': 1, 'trial_protocol': 10}
One solution would be to store all the available identification attributes of the Epoch object (name, description, nix_name) as a dict in an annotation source_epoch. Or to explicitly ignore the nix_name annotations during the cut.
Thank you,
Cristiano