[FieldTrip] (no subject)
KatrinH Heimann
katrinheimann at gmail.com
Tue Dec 9 23:51:50 CET 2014
Hey Fieldtrippers,
I am fighting with a self defined trialfunction.
Basically I want to cut always at one event called ceck. If there is
another event in the piece cut out, called resp I want to log the distance
between the two of them.
I tried
function [trl, event] = response_trialfun(cfg);
% read the header information and the events from the data
hdr = ft_read_header(cfg.dataset);
event = ft_read_event(cfg.dataset);
% search for "trigger" events
value = [event(find(strcmp('pres', {event.value}))).value]';
sample = [event(find(strcmp('pres', {event.value}))).sample]';
% search for "trigger" events
value2 = [event(find(strcmp('resp', {event.value}))).value]';
sample2 = [event(find(strcmp('resp', {event.value}))).sample]';
% determine the number of samples before and after the trigger
pretrig = -round(cfg.trialdef.prestim * hdr.Fs);
posttrig = round(cfg.trialdef.poststim * hdr.Fs);
trl = [];
trlbegin = sample + pretrig
trlend = sample + posttrig
offset = sample - sample + pretrig
RT = sample2 - sample
newtrl = [trlbegin trlend offset RT];
trl = [trl; newtrl];
end
But the problem is, that not always there is this second event, so
length(sample1) is not equal to length (sample2). Now I would just like
that every time when event 2 is missing sample 2 is just set to zero, so
that the two vectors have the same length and the function is working. Is
this possible?
Thanks a million
Katrin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20141209/cdebe17c/attachment-0001.html>
More information about the fieldtrip
mailing list