Hello,
You can index on epochs, on both IDx and condition.
from mne import Epochs, find_events
from mne.datasets import sample
from mne.io import read_raw_fif
directory = sample.data_path() / "MEG" / "sample"
raw = read_raw_fif(directory / "sample_audvis_raw.fif", preload=False)
raw.pick_types(eeg=True, stim=True)
raw.load_data()
event_id = dict(left=1, right=2)
events = find_events(raw, stim_channel="STI 014")
epochs = Epochs(
raw,
events,
event_id=event_id,
tmin=-0.2,
tmax=0.5,
reject=None,
preload=True,
)
There are 72 left epochs and 73 right epochs.
>>> epochs
<Epochs | 145 events (all good), -0.199795 - 0.499488 sec, baseline -0.199795 – 0 sec, ~34.6 MB, data loaded,
'left': 72
'right': 73>
To select the 30 first left epochs: epochs["left"][:30]
.
>>> epochs["left"][:30]
<Epochs | 30 events (all good), -0.199795 - 0.499488 sec, baseline -0.199795 – 0 sec, ~9.5 MB, data loaded,
'left': 30>
To select the 30 first epochs, left or right: epochs[:30]
.
>>> epochs[:30]
<Epochs | 30 events (all good), -0.199795 - 0.499488 sec, baseline -0.199795 – 0 sec, ~9.5 MB, data loaded,
'left': 15
'right': 15>
And so on.
Mathieu