open-ephys / open-ephys-python-tools

Python code for interacting with the Open Ephys GUI
MIT License
29 stars 17 forks source link

Header not exposed through events #6

Open KylePoe opened 3 years ago

KylePoe commented 3 years ago

Hi, while I can't comment on whether this is true for all cases, the header is not exposed when loading events. Importantly, the sample rate is nowhere to be found in the recording object. As an example, let data_dir be a path pointing to a directory with .continuous and .events files.

from open_ephys.analysis import Session

session = Session(data_dir)
session.load_events()

At this point, it seems the user should be able to determine the sample rate information, as this information is contained within the header for the .events file, however it is apparently discarded:

https://github.com/open-ephys/open-ephys-python-tools/blob/5b4750fe7b357b06efca70e9a092b25bd69faf38/open_ephys/analysis/formats/OpenEphysRecording.py#L130-L140

Certainly, the header information from this events file should be accessible through a recording object. I am unsure what the best way to address is, or if it is already being worked on, but I thought I would bring attention to the problem.

EDIT: I have temporarily solved this for my personal requirements by simply storing the header dict returned by load in self.header.

jsiegle commented 3 years ago

Hi Kyle, thanks for bringing this up. We definitely want this info to be accessible in the Session object, but I'm not sure about the best place to put it.

Would it make sense to add a top-level metadata property that stores general information about the recording (e.g., start time), as well as info about individual processors? For example, the sample rate for each processor could be accessed via:

processor_id = 101
subprocessor_id  = 0
sample_rate = session.metadata.processors[processor_id][subprocessor_id].sample_rate
KylePoe commented 3 years ago

I think that would be a very natural way to do it.