mri2mne
Home FR

Events in an external file

Your triggers are not in the EEG but in a separate file (e.g. an MNE -eve.fif, or an array you build). Here is how to pass them.

Three ways to pass events

The events argument accepts a path, the keyword "find", or a NumPy array already in memory.

1. An MNE -eve.fif file

result = reconstruct_sources(
    subject="sample", output_dir="D:/derivatives",
    t1_path="D:/anat/sample_T1w.nii.gz",
    eeg_file="D:/eeg/sample.edf",
    digitization="D:/dig/sample.elc",
    simnibs_bin_dir="C:/Users/me/SimNIBS-4.5/bin",
    events="D:/eeg/sample-eve.fif",       # <- external file
    event_id={"aud_l": 1, "aud_r": 2},    # conditions to keep
    tmin=-0.2, tmax=0.5,
)

The file follows the MNE format: three columns (sample, previous value, code). event_id selects which codes to epoch and names them.

2. Detection from the trigger channel

If the pulses are on a stim channel inside the EEG, "find" calls mne.find_events.

events="find", event_id={"aud_l": 1}

3. A hand-built array

Useful when the times come from a behavioural log. Columns: sample, 0, code.

import numpy as np
events = np.array([[500, 0, 1],
                   [1200, 0, 1],
                   [2100, 0, 2]])
reconstruct_sources(..., events=events, event_id={"aud_l": 1, "aud_r": 2})
Peak topography once the epochs are averaged.
Peak topography once the epochs are averaged.