[FieldTrip] ft_sourcegrandaverage

Eelke Spaak eelke.spaak at donders.ru.nl
Wed Sep 30 17:04:00 CEST 2015

Hi Jia,

In principle: yes, that is what you should be doing. However, Matlab
provides some nice 'syntactic sugar' to achieve this much more easily
than typing it all in 'by hand'.

If you have collected your subjects in one big cell array [1]:

allsubj = {};
allsubj{1} = data_subj1;
allsubj{2} = data_subj2;

then you can use a (somewhat peculiar) Matlab syntax known as a
'comma-separated list' [2] (yes, the name of that syntax sounds pretty
intuitive, but intuitions are a bit deceiving here):

grandavg = ft_sourcegrandaverage(cfg, allsubj{:});

Hope that helps.


[1] http://uk.mathworks.com/help/matlab/cell-arrays.html
[2] http://uk.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.html

On 30 September 2015 at 15:54, Wu, Jia <jia.wu at yale.edu> wrote:
> Hi,
> If I have 100 subjects, do I have to do:
> grandavg = ft_sourcegrandaverage(cfg,s1,s2,s3,s4,s5,s6........s100)?
> Is there a better way? Or is it not what I should be doing?
> best,
> -jia

More information about the fieldtrip mailing list