[FieldTrip] ft_sourcegrandaverage

Stephen Whitmarsh stephen.whitmarsh at ki.se
Fri Oct 2 10:32:47 CEST 2015


Hi Jia, (and hi Raquel!)

Perhaps easiest is if you get all your subjects in a MATLAB struct, e.g. data{1}, data{2}, etc. Then you can just enter that structure in the FieldTrip functions that take multiple dataset such as ft_timelockgrandaverage and ft_freqanalysis, with e.g. timelockgrandaverage(cfg,data{:})

Cheers,
stephen


From: fieldtrip-bounces at science.ru.nl [mailto:fieldtrip-bounces at science.ru.nl] On Behalf Of Raquel bibi Cohen
Sent: 02 October 2015 06:17
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Subject: Re: [FieldTrip] ft_sourcegrandaverage

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<mailto: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<mailto: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/e1f90a4f/attachment.html>


More information about the fieldtrip mailing list