# Grand mean across subjects

**URL:** <https://mne.discourse.group/t/grand-mean-across-subjects/1062>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [August 16, 2016, 9:41am UTC](https://mne.discourse.group/t/grand-mean-across-subjects/1062 "2016-08-16T09:41:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [August 16, 2016, 9:41am UTC](https://mne.discourse.group/t/grand-mean-across-subjects/1062/1 "2016-08-16T09:41:30Z")

</div>

Hi,

I would like to calculate the grand mean and the standard error across  
subjects for each of my conditions. Is there a specific function in mne to  
do it starting from each subject's EvokedArray ?

Many thanks  
Emanuela  
-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20160816/39bfebac/attachment.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20160816/39bfebac/attachment.html)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [August 17, 2016, 7:25pm UTC](https://mne.discourse.group/t/grand-mean-across-subjects/1062/2 "2016-08-17T19:25:31Z")

</div>

hi,

[http://martinos.org/mne/dev/generated/mne.grand\_average.html](http://martinos.org/mne/dev/generated/mne.grand_average.html)

HTH  
Alex

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [August 24, 2016, 10:23am UTC](https://mne.discourse.group/t/grand-mean-across-subjects/1062/3 "2016-08-24T10:23:45Z")

</div>

Thanks for the response. A question remains: how can I get the standard  
error of the mean?

Greetings  
Emanuela

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [August 24, 2016, 4:11pm UTC](https://mne.discourse.group/t/grand-mean-across-subjects/1062/4 "2016-08-24T16:11:25Z")

</div>

> Thanks for the response. A question remains: how can I get the standard

error of the mean?

Greetings  
-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20160824/3a9b5c56/attachment.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20160824/3a9b5c56/attachment.html)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [August 25, 2016, 7:16am UTC](https://mne.discourse.group/t/grand-mean-across-subjects/1062/5 "2016-08-25T07:16:30Z")

</div>

Let?s say you have a list of evokeds - evokeds. To get SEM you can do the  
following:

import numpy as npfrom scipy.stats import sem

sem\_data = sem(np.stack([x.data for x in evokeds], axis=2), axis=2)

Now sem\_data is an array of size (n\_channels, n\_samples). To get the lower  
bound of the SEM you would have to subtract sem\_data form the data of your  
grand average and add it to get the upper bound.  
?

2016-08-24 12:23 GMT+02:00 Emanuela Liaci \<emanuela.liaci at [gmail.com](http://gmail.com)\>:

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [August 25, 2016, 8:44am UTC](https://mne.discourse.group/t/grand-mean-across-subjects/1062/6 "2016-08-25T08:44:58Z")

</div>

Hi,

thanks for your response. So I tried what you suggested me, by creating a  
list of evokeds (here printed the list for one condition and just 2  
subjects: [\<Evoked | comment : 'Unknown', kind : average, time :  
[-0.060000, 0.798000], n\_epochs : 48, n\_channels x n\_times : 32 x 430, ~177

> , \<Evoked | comment : 'Unknown', kind : average, time : [-0.060000,

0.798000], n\_epochs : 50, n\_channels x n\_times : 32 x 430, ~177 kB\>]).

When I do: sem\_data = sem(np.stack([x.data for x in evokeds], axis=2),  
axis=2), I get this error: AttributeError: 'module' object has no attribute  
'stack'

What does this mean?

Thanks again,  
Emanuela

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [August 25, 2016, 9:05am UTC](https://mne.discourse.group/t/grand-mean-across-subjects/1062/7 "2016-08-25T09:05:54Z")

</div>

np.stack was added in numpy version 1.10.0 - your numpy is most likely  
older (you can check what you get from np.\_\_version\_\_).  
But you can use np.dstack instead of np.stack(..., axis=2) - it will work  
on older numpy versions.  
So, try:

sem\_data = sem(np.dstack([x.data for x in evokeds]), axis=2)

?

2016-08-25 10:44 GMT+02:00 Emanuela Liaci \<emanuela.liaci at [gmail.com](http://gmail.com)\>:
