<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Hi Jia,</div><div id="AppleMailSignature">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. </div><div id="AppleMailSignature"><span style="background-color: rgba(255, 255, 255, 0);">for itype = 1:3% loop over the target, predistractor, postdistractor, for shifting the timelock data and two distractor types conditions<br>for icond = 1:4 % congruent incongruent neutral<br>%cfg.keeptrials = 'yes';<br>commandA = ['grand_avg_A(' int2str(floor((itask+1)/2)) ',' int2str(itype) ',' int2str(icond) ') = ft_timelockgrandaverage(cfg'];<br>for isub = 1:length(subj)<br>commandA = [commandA sprintf(',%stimelock{%d,%d,%d}', subj{isub}, floor((itask+1)/2), itype, icond)]; %all subject grand average<br>ends</span></div><div id="AppleMailSignature"><span style="background-color: rgba(255, 255, 255, 0);">commandA = [commandA ')'];<br>cfg=[];<br>cfg.keepindividual = 'yes';<br>cfg.latency = [-.4 1];<br>eval(commandA)<br>end</span></div><div id="AppleMailSignature"><br>Sent from my iPad</div><div><br>On Sep 30, 2015, at 10:54 AM, Wu, Jia <<a href="mailto:jia.wu@yale.edu">jia.wu@yale.edu</a>> wrote:<br><br></div><blockquote type="cite"><div>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">



<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hi,<br>
<br>
If I have 100 subjects, do I have to do:<br>
grandavg = ft_sourcegrandaverage(cfg,s1,s2,s3,s4,s5,s6........s100)?<br>
<br>
Is there a better way? Or is it not what I should be doing?<br>
<br>
best,<br>
-jia<br>
</div>


</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>fieldtrip mailing list</span><br><span><a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a></span><br><span><a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></span></div></blockquote></body></html>