Long
(Long)
November 25, 2024, 4:25pm
1
MNE version: 1.7.1
operating system: windows 10
Hi, I want to find the index/offset of certain events using MNE. I started from the annotations and find the events like below:
event5,_=mne.events_from_annotations(raw3,regexp='5')
However, the event5[0] not the true offset, and to get the true offset, I also need to do below:
event5=event5[:,0]-[raw3.first_samp]*len(event5)
Is this the right behavior? I thought the events are the latency and offset has been counted already.
Best,
Long
Hi @Long
I’m not sure what you mean - I don’t think I can replicate the behavior you are describing using MNE’s sample dataset:
fname = mne.datasets.sample.data_path() / 'MEG' / 'sample' / 'sample_audvis_raw.fif'
raw = mne.io.read_raw(fname)
raw.annotations.append(onset=1, duration=1, description="TEST")
print(raw.info["sfreq"]) # 600.61 Hz
print(raw.first_samp) # 25800
print(raw.annotations.onset) # [1.] seconds
events, _ = mne.events_from_annotations(raw)
print(events) # array([[601, 0, 1]])
# Convert samples to seconds
events[:, 0] / raw.info["sfreq"] # array([1.00064103]) ... seconds
It seems to me that MNE returns event onsets in samples relative to 0 seconds, which is exactly what I would expect. Is this not what you are expecting or wanting for your data?