# MNE python group data

**URL:** <https://mne.discourse.group/t/mne-python-group-data/731>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [May 21, 2014, 2:29am UTC](https://mne.discourse.group/t/mne-python-group-data/731 "2014-05-21T02:29:14Z")\
**Posts on this page:** 5\
**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:** [May 21, 2014, 2:29am UTC](https://mne.discourse.group/t/mne-python-group-data/731/1 "2014-05-21T02:29:14Z")

</div>

Hi MNE list,

I'm working with group data that's been preprocessed in MNE then grand averaged into a numpy array and am interested in using some of the plotting methods available, however none seem to take plain numpy array data. Is there any way to copy over relevant information from say an individual's object (like times, channel listings etc) and "wrap" it to the array?

Thanks and my apologies if this is a relatively simple question.

Peter

---

<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:** [May 21, 2014, 2:45am UTC](https://mne.discourse.group/t/mne-python-group-data/731/2 "2014-05-21T02:45:34Z")

</div>

Hi Peter,

Here's some sample code that grand-averages stc files from one hemisphere  
(I imagine it should work the same for e.g. evoked sensor data; I haven't  
tried it for this, though; also note that here my stc files are all morphed  
to fsaverage, hence the last line):

# path to data  
stcdir = \<path to where stc files are saved\>

# participant list  
participants = \<list of participant IDs\>

# template for the filenames  
fname = os.path.join( stcdir, '%s-' + '-lh.stc' )

# read all subjects' stc files into a big list of stc files  
stcs = [mne.read\_source\_estimate(fname % subject) for subject in  
participants]

# average (by summing the stcs and then dividing by the number of subjects  
stc\_avg = reduce(add, stcs)  
stc\_avg /= len(stcs)

stc\_avg.subject = 'fsaverage'

The output of this can then be plotted the same way as a single-participant  
stc could be.

Best,  
Steve

Stephen Politzer-Ahles  
New York University, Abu Dhabi  
Neuroscience of Language Lab  
[http://www.nyu.edu/projects/politzer-ahles/](http://www.nyu.edu/projects/politzer-ahles/)

---

<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:** [May 21, 2014, 2:47am UTC](https://mne.discourse.group/t/mne-python-group-data/731/3 "2014-05-21T02:47:40Z")

</div>

I believe that they're working on this, but it's not in an official  
release. If you check out the repository on github, there's some code in  
mne.io.array that should work (more or less), but it's not fully vetted yet  
so might be a bit buggy...

---

<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:** [May 21, 2014, 7:57am UTC](https://mne.discourse.group/t/mne-python-group-data/731/4 "2014-05-21T07:57:20Z")

</div>

Hi Peter,

Are the averaged data time courses from vertices on the template  
(fsaverage) brain? If so, you could do:

mne.SourceEstimate to create an stc object in Python. However, you would  
need to know what type of source space was used to create the MNE (or at  
least which version of the fsaverage brain the data were projected to).

Does this help?

Cheers,  
Andy

---

<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:** [May 22, 2014, 2:26am UTC](https://mne.discourse.group/t/mne-python-group-data/731/5 "2014-05-22T02:26:24Z")

</div>

Hi Stephen, Chris and Andy,

Thanks very much for your advice! Sorry for not being explicit that it was sensor level data. Stephen's suggestion worked a treat!

Peter
