[FieldTrip] Problem with user specified trial function

"Jörn M. Horschig" jm.horschig at donders.ru.nl
Fri May 6 14:31:24 CEST 2011


Hi Maarten,

no idea what might go wrong there (for me your code snippet works fine). 
Anyway, you could try to first round cfg.trialdef.prestim*hdr.Fs (same 
for poststim) outside the loop and store them as local variables and 
then continue without having to round in every single iteration for 
every single trial-def, e.g.:

trloff = round(-cfg.trialdef.prestim*hdr.Fs);
trldur = round((cfg.trialdef.poststim+cfg.trialdef.prestim)*hdr.Fs) - 1;
% that's from trialfun_general

I bet this will make a difference, although it should of course not. 
Maybe someone else can confirm the error with your code snippet...

Best,
Jörn



On 5/6/2011 2:10 PM, Maarten van-Casteren wrote:
>
> Hi,
>
> I've just started to use Fieldtrip and I don't
>
> have much experience with Matlab, so I could
>
> just be making a stupid mistake, but I found
>
> some very strange behavious when I tried to
>
> specify my own trailfunction.
>
> I started from the example given on the tutorial
>
> pages of the wiki. I've indicated the line of interest
>
> with an additional '->'. This is what I used:
>
> for i=1:length(event)
>
>   if strcmp(event(i).type, cfg.trialdef.eventtype)
>
>     % it is a trigger, see whether it has the right value
>
>     if ismember(event(i).value, cfg.trialdef.eventvalue)
>
>       % add this to the trl definition
>
>       begsample     = event(i).sample - cfg.trialdef.prestim*hdr.Fs;
>
>       endsample     = event(i).sample + cfg.trialdef.poststim*hdr.Fs - 1;
>
>       offset        = -cfg.trialdef.prestim*hdr.Fs;
>
>       trigger       = event(i).value; % remember the trigger 
> (=condition) for each trial
>
> ->    trl(end+1, :) = [round([begsample endsample offset])  trigger];
>
>     end
>
>   end
>
> end
>
> When I use it like this it will clip all sample and
>
> offset values at 0 -- 65536, that is the limits of an
>
> unsigned integer. I had to change the actual line
>
> that appends the trial to this to make it work:
>
> trl(end+1, :) = [double(begsample) double(endsample) double(offset) 
> double(trigger)];
>
> All values are shown by the debugger as doubles
>
> anyway, so why this explicit conversion is needed
>
> is completely beyond me.
>
> Does anyone of you know what is going on?
>
> I already asked one of the local Matlab gurus,
>
> but he was even more amazed than me...
>
> Thanks,
>
> Maarten
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip


-- 
Jörn M. Horschig
PhD Student
Donders Institute for Brain, Cognition and Behaviour
Centre for Cognitive Neuroimaging
Radboud University Nijmegen

P.O. Box 9101
NL-6500 HB Nijmegen
The Netherlands

Contact:
E-Mail: jm.horschig at donders.ru.nl
Tel:    +31-(0)24-36-68493
Web: http://www.ru.nl/donders

Visiting address:
Trigon, room 2.30
Kapitelweg 29
NL-6525 EN Nijmegen
The Netherlands

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20110506/175dc149/attachment.html>


More information about the fieldtrip mailing list