[FieldTrip] ft_timelockgrandaverage -- bug or as-designed?

Alik Widge alik.widge at gmail.com
Tue Feb 11 17:11:54 CET 2014


I have encountered a behavior with ft_timelockgrandaverage that seems to me
to be a bug, but I'm not quite sure. Hence why I am asking here and not
just filing a bug. I'm using the attached .mat, and you can replicate the
behavior with:

        cfg = [];
        cfg.channel = 'all';
        cfg.keepindividual = 'no';
        cfg.method = 'within';

out_data = ft_timelockgrandaverage(cfg,Dstruct.on.MSITOnset.global.x{:});


This will crash due to an array dimension mismatch. It does so because my
different subjects/blocks in x{:} have different numbers of samples. Up
around line 147, the ft_ function goes through varargin{:} and cuts down
the averaged variable (in my case, 'avg') so that it has the same number of
samples in each of the varargin{:} data structures.
The thing that I feel is a bug: it cuts the data, (expressed as
varargin{i}.(cfg.parameter) ), but it does NOT similarly cut the variance (
varargin{i}.var ) or the per-timepoint DOF ( varargin{i}.dof ). As a
result, when it gets to line 193 and tries to do

      avgmat(s, :, :) = varargin{s}.(cfg.parameter).*varargin{s}.dof;

the (cfg.parameter) and dof matrices are now of different sizes, and we
crash.

I can add my desired behavior to a local copy of the function and keep
working, but would appreciate some advice on whether this is actually a
bug, or somehow a design feature that I've failed to understand.


Alik Widge
alik.widge at gmail.com
(206) 866-5435
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20140211/3d50a068/attachment-0001.html>


More information about the fieldtrip mailing list