[FieldTrip] ft_definetrial
Hannah Anderson
handerson at usc.edu.au
Fri Jun 19 05:31:39 CEST 2020
Dear FieldTrip community
I am attempting to define a trial based on a start and end marker, and then cut the trial into 2 second segments with 0.5% overlap.
Marker Segmentation
cfg = [];
cfg.dataset = d(data).name;
cfg.continuous = 'yes';
cfg.trialfun = 'trial_fun_startend'; %trial_function for marker segmentation
cfg.trialdef.prestim = 0.2; %in seconds
cfg.trialdef.poststim = 0; %in seconds
cfg.trialdef.ntrials = inf;
cfg = ft_definetrial(cfg); % define trials
I created a trial fun which is successful in creating a trial from start marker to end marker but I get an error I get an error;
-Index in position 2 exceeds array bounds (must not exceed 2)
Error in ft_redefinetrial (line 267)
offset = newtrl(:,3);
when I try and then segment the trial into 2 second trials with overlap.
This is my trialfun:
function [trl, event] = trial_fun_startend(cfg);
hdr = ft_read_header(cfg.dataset);
event = ft_read_event(cfg.dataset);
detectflank = 'up';
value = [event(find(strcmp('STATUS', {event.type}))).value]';
sample = [event(find(strcmp('STATUS', {event.type}))).sample]';
trl = [];
sel = find(strcmp({event.type}, 'STATUS'));
event = event(sel)
begsample = event(1, 2);
endsample = event(1, 3);
offset = newtrl(:,3);
trl = [begsample endsample];
I am not sure what else I can try as the other define trial options segment the data into two trials (one for each trigger) and I need it to be one dataset starting at trigger 1 and ending at trigger 2. If anyone could offer some advice/assistance it would be greatly appreciated.
Kind regards,
Hannah
University of the Sunshine Coast l CRICOS 01595D
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200619/87ac718a/attachment.htm>
More information about the fieldtrip
mailing list