[FieldTrip] (no subject)

Arjen Stolk a.stolk8 at gmail.com
Wed Dec 10 07:19:28 CET 2014


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>
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
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20141210/0fd01728/attachment.html>


More information about the fieldtrip mailing list