Description
Describe the bug
When loading in a neuralynx file that had several starts and stops in recording (therefore missing data), the events in Events.nev and global start are relative to the most recent starting recording as opposed to the first sample of the file. Then when using event_reader.rescale_event_timestamp(timestamps)
, inappropriate timestamps are returned as a result.
To Reproduce
event_reader = NeuralynxRawIO(dirname=stems[0], include_filenames=event_path)
event_reader.parse_header()
ph_reader = NeuralynxRawIO(dirname=stems[0], include_filenames=ph_path)
ph_reader.parse_header()
global_start = ph_reader.global_t_start
global_start_ev = event_reader.global_t_start
print(global_start == global_start_ev) #Returns False if the recording itself had many stops and missing data
event_timestamps, _, event_labels = event_reader.get_event_timestamps()
event_times = event_reader.rescale_event_timestamp(event_timestamps)
event_times_manual = event_timestamps*10**-6 - global_start
print(event_times==event_times_manual) # prints False if the recording has many stops and it's not reflected as an event
Expected behaviour
I expect the rescale event timestamp method on event reader to return the timestamp in seconds relative to the first sample of the entire fire. Instead, the timestamps are returned relative to the most recent 'starting recording' event which doesn't always pop up in the event_reader events, despite in showing up when I open the file in other contexts. Essentially, the global_start for events.nev doesn't match the global start for photo.ncs or other .ncs files that were recorded simultaneously.
Environment:
- OS: Windows, and tested on Linux
- Python version: 3.11.3
- Neo version: 0.13.4
Additional context
I'm only writing this so that others who are analyzing neuralynx data are aware of this potential issue. For now, I recommend avoiding the use of event_reader.rescale_event_timestamp(event_timestamps)
and loading in a recording from the dataset to get global_start
if needed. It'll take slightly longer but worth it. After getting global_start
from a file, you can manually convert the event_timestamps with
rescaled_event_timestamps = event_timestamps*10**-6 - global_start