[FieldTrip] Conditional trial definition
Daria Laptinskaya
daria.laptinskaya at googlemail.com
Thu Feb 26 15:13:51 CET 2015
Dear fieldtrippers,
I would like to evaluate a reaction time experiment.
Hence for me two types of trigger are of interest: the onset of the
stimulus and the reaction to it.
I found this function at the fieldtrip homepage:
function [trl, event] = mytestfunction(cfg);
hdr = ft_read_header(cfg.dataset);
event = ft_read_event(cfg.dataset);
value = [event(find(strcmp('trigger', {event.type}))).value]';
sample = [event(find(strcmp('trigger', {event.type}))).sample]';
pretrig = -round(cfg.trialdef.pre * hdr.Fs);
posttrig = round(cfg.trialdef.post * hdr.Fs);
trl = [];
for j = 1:(length(value)-1)
trl1 = value(j);
trl2 = value(j+1);
if trl1==3 && trl2==5
trlbegin =sample(j) + pretrig;
trlend = sample(j) + posttrig;
offset =pretrig;
newtrl = [trlbegin trlend offset];
trl = [trl; newtrl];
end
end
Creating the sample-matrix I get a long string (all values in one field
without delimiter). I think it’s because my values are in string format
(‘DI11’, ‘DIN1’, …). Does anyone have an idea, for example how to convert
the string values to numbers in this case? Or an other advise for a
solution of this problem.
Looking forward to support!
Daria
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150226/d9f34063/attachment-0001.html>
More information about the fieldtrip
mailing list