Assuming you have loaded your EEG data into a raw
variable (using functions such as ft_preprocessing
or fieldtripread
), here is an example code that extracts all the epochs using the ft_redefinetrial
function:
main.m414 chars10 lines
This code defines trial epochs based on a trigger event type and a range of trigger values (eventvalue
). The prestim
and poststim
parameters specify the length of time (in seconds) to extract before and after the trigger event.
The output variable epochs
will contain all the extracted epochs as separate trials, which you can then use for further analysis.
Note: Before running this code, make sure you have added FieldTrip to your Matlab path by running ft_defaults
or adding the FieldTrip folder to your Matlab path manually.
gistlibby LogSnag