[FieldTrip] ft_sourcegrandaverage

Raquel bibi Cohen bibi.raquel at gmail.com
Fri Oct 2 06:16:33 CEST 2015


Hi Jia,
Here is the Matlab code I wrote to automate this work for a study when this came up as an issue for me.   I  don't have Matlab on my iPad ;)  forgive me  - the condition and trial types make my example unnecessarily  complicated.  In the following example replace commandA with ft_source... This assumes you have loaded the individual data into the workspace, and you're familiar with eval and sprintf.  It can be annoying trying to get it right the first time - but well worth it in the end.  I hope it helps you. 
for itype = 1:3% loop over the target, predistractor, postdistractor, for shifting the timelock data and two distractor types conditions
for icond = 1:4 % congruent incongruent neutral
%cfg.keeptrials = 'yes';
commandA = ['grand_avg_A(' int2str(floor((itask+1)/2)) ',' int2str(itype) ',' int2str(icond) ') = ft_timelockgrandaverage(cfg'];
for isub = 1:length(subj)
commandA = [commandA sprintf(',%stimelock{%d,%d,%d}', subj{isub}, floor((itask+1)/2), itype, icond)]; %all subject grand average
ends
commandA = [commandA ')'];
cfg=[];
cfg.keepindividual = 'yes';
cfg.latency = [-.4 1];
eval(commandA)
end

Sent from my iPad

> On Sep 30, 2015, at 10:54 AM, 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
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20151002/c9e96951/attachment.html>


More information about the fieldtrip mailing list