# [FieldTrip] grand average (with average across frequencies)

kousik sarathy sarathykousik at gmail.com
Wed Jul 13 10:09:01 CEST 2016

```Hey Jose,

It might not be the most elegant solution, but I would suggest something
like ft_selectdata with ''cfg.avgovrfreq" & cfg.frequency=[10 50] arguments
before the actual grandaverage.
Hope it helps.

--
Regards,
Kousik Sarathy, S

On Wed, Jul 13, 2016 at 4:22 AM, Xie Wanze <xiew1202 at gmail.com> wrote:

>  Jose,
>  It is not difficult to do grand average across subjects or frequencies if
> I understand your questions correctly.
>  After you get the powspctrm matrix (chan x freq) for each subject, you
> can write a "for loop" to read in each person's data and then divided by
> the total number of subjects. Assuming you name your output structure as
> EEG_freq for each subject, the syntax would be something like:
>   freqtotal = []; numsubject = 0;
>   for i = 1:length(subjects)
>         if ~numsubject; freqtotal = EEG_freq.powspctrm;
>         else; freqtotal = freqtotal + EEG_freq.powspctrm;
>         end;
>         numsubject = numsubject + 1;
>  end;
>  freqavg = freqtotal / numsubject;  or freqavg = freqtotal /
> length(subjects);
>
>  To get average across frequencies, simply use the "mean" function. If you
> have the chan x pow structure for your output then use "mean (freqavg, 2)"
> will do the average across the second dimension (i.e., frequencies).
>  Or you can do the average for frequencies for each subject then do the
> average across subjects.
>
>
>  Wanze
>
>
>
> 2016-07-12 13:45 GMT-04:00 Jose <joseluisblues at gmail.com>:
>
>> dear list,
>>
>> I'm analysing CTF MEG data. I computed the power of my data for
>> frequencies from 1 to 50 Hz. Is it possible to perform a grand average
>> across my subjects, but additionally averaging across frequencies for
>> exploratory purposes? Maybe there is a way to do it with
>> ft_freqgrandaverage?, but so far I haven't find it,
>>
>> Many thanks for any hint,
>> Jose
>>
>> _______________________________________________
>> fieldtrip mailing list
>> fieldtrip at donders.ru.nl
>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20160713/a255a0a7/attachment-0002.html>
```