Loading Events from BIDS Dataset

I am already familiar with loading the BIDS data events using:

import pandas as pd
import mne
from mne_bids import *

bids_path = BIDSPath(
    root="~/",
    subject="01",
    task="TASK",
    datatype="eeg"
)

raw = read_raw_bids(bids_path)
events, event_id = mne.events_from_annotations(raw)

But, when I compare events with the content of *_events.tsv.

events_df = pd.read_csv("~/sub-01/eeg/sub-01_task-TASK_events.tsv", sep="\t")

I notice that the trigger values have all been reset in events and event_id, thus not matching what the data frame events_df shows me (the “true” trigger values, at column value).

I guess this is normal and wanted, since event_id stays consistent, but isn’t there an MNE BIDS function that would allow one to directly read what is written inside the *_events.tsv instead of having to pass through the annotations? Or does one have to read it manually in order to not have the trigger values reset?

FYI:

  • MNE version: 1.11.0
  • Operating system: Ubuntu 24.04.4 LTS

Hi @NKevinVI is the return_event_dict parameter what you are looking for? e.g. raw, events = mne_bids.read_raw_bids(bids_path, return_event_dict=True, …). I don’t think MNE-BIDS has a public function specifically for reading Events TSV files right now (If this is something you need, maybe consider opening a feature request on the GitHub repo).

Hi @scott-huberty, and thank you for your answer!

The return_event_dict is indeed an interesting parameter, but it only allows to return event_id:

raw, event_id = mne_bids.read_raw_bids(bids_path, return_event_dict=True)

For events, I still don’t know how to load that array with the right trigger values directly. I may open a feature if nothing is found, as you suggested.

I noticed a function to directly read events from a BIDS dataset has already been proposed here.
Thus, I will declare this post answered and closed.
:slightly_smiling_face:

PS: It still seems the main way to handle events, at least for now, is really by using the annotations system.