[FieldTrip] (no subject)
Lam, N.H.L. (Nietzsche)
n.lam at fcdonders.ru.nl
Fri Dec 12 10:51:20 CET 2014
Hi Katrin,
Not sure if you solved it yet, but it looks like you need to update 'newtrl' and 'trl' within your while loop, and not outside of the loop.
Best,
Nietzsche
________________________________
From: fieldtrip-bounces at science.ru.nl [fieldtrip-bounces at science.ru.nl] on behalf of KatrinH Heimann [katrinheimann at gmail.com]
Sent: 10 December 2014 12:56
To: FieldTrip discussion list
Subject: Re: [FieldTrip] (no subject)
Hey Arjen, hey all,
so, I used some if statements, yes, and now I really get lists of trialbegin, trialend, offset and RT as I wanted them, however at the end only one segment (with the last infos of the lists) is created. I just don't get what is wrong. Could you have another short look?
Thanks a million
Katrin
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('ceck', {event.value}))).value]';
sample = [event(find(strcmp('ceck', {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 = [];
trlend = []
offset = [];
RT = [];
i=7 %delete training trials
j=1
k=1
while i <= (length(sample))
if sample2(j)-sample(i)<=2500 & sample2(j)-sample(i)>=1 % find resp appearing after ceck within RT-window
trlbegin (k) = sample (i) + pretrig;
trlend (k) = sample (i) + posttrig;
offset (k) = sample (i) - sample (i) + pretrig;
RT(k) = sample2 (j) - sample (i);
i=i+1
j=j+1
k=k+1
elseif sample2(j)-sample(i)<=0
j=j+1
else
i=i+1
end
end
newtrl = [trlbegin trlend offset RT];
trl = [trl; newtrl]
2014-12-10 7:19 GMT+01:00 Arjen Stolk <a.stolk8 at gmail.com<mailto:a.stolk8 at gmail.com>>:
Het katrin, you could make a couple of conditional if statements (eg creating and changing the value of a variable event1ctr). For example, conceptually:
Event1ctr = 0
Loop start
If event1 & event1ctr == 0
Event1ctr = 1
Elseif event1 & event1ctr
Trl = ... with a zero for trlend # no event2 found
Event1ctr = 0
End
If event2
Trl = ... # normal trial
Event1ctr= 0
End
Loop end
Op 9 dec. 2014 23:52 schreef "KatrinH Heimann" <katrinheimann at gmail.com<mailto:katrinheimann at gmail.com>> het volgende:
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
_______________________________________________
fieldtrip mailing list
fieldtrip at donders.ru.nl<mailto:fieldtrip at donders.ru.nl>
http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
_______________________________________________
fieldtrip mailing list
fieldtrip at donders.ru.nl<mailto:fieldtrip at donders.ru.nl>
http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20141212/d77bec21/attachment-0002.html>
More information about the fieldtrip
mailing list