[FieldTrip] Problem with user specified trial function

Maarten van-Casteren Maarten.van-Casteren at mrc-cbu.cam.ac.uk
Fri May 6 14:10:13 CEST 2011


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

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


More information about the fieldtrip mailing list