Back to the main page.

Bug 703 - trialfun_general miscalculates trldur if no poststim but prestim is given?

Status CLOSED FIXED
Reported 2011-05-27 09:48:00 +0200
Modified 2011-06-29 09:50:30 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P1 normal
Assigned to: Jörn M. Horschig
URL:
Tags:
Depends on:
Blocks:
See also:

Jörn M. Horschig - 2011-05-27 09:48:00 +0200

I am not quite sure about this one, but it seems to misbehave in the following situation. ------------ %% just give cfg a prestim period, no poststim period cfg = []; cfg.trialdef.prestim = 0.2; %cfg.trialdef.eventXXX = ...; %cfg.dataset = ...; ft_definetrial(cfg); ------------ %%% in trialfun_general, line 175 ff. % determine the number of samples that has to be read (excluding the begin sample) if ~isfield(cfg.trialdef, 'poststim') trldur = max(event(i).duration - 1, 0); else % this will not work if prestim was not defined, the code will then crash trldur = round((cfg.trialdef.poststim+cfg.trialdef.prestim)*hdr.Fs) - 1; end trlend = trlbeg + trldur; ----------- Given that we have no poststim, trldur will be the eventduration or 0, which in my case is 0. Then, 'trlend' will be set to 'trlbeg'. This, however, means that although having defined a prestim period, the trialdefinition will consist of one sample only. Is this intended to be? I would suppose it should be more like: trldur = max(event(i).duration - 1, 0) - trloff; % note that trloff is negative In this case, 'trlend' would be set to the event onset, whereas 'trlbeg' would indicate some sample before the event onset. Please let me know whether my arguing is correct, I'll correct this then asap. I am doubting since this function has been around for a while already...