# how to save source estamates from epoched data set with multiple events

**URL:** <https://mne.discourse.group/t/how-to-save-source-estamates-from-epoched-data-set-with-multiple-events/653>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [January 13, 2014, 6:58pm UTC](https://mne.discourse.group/t/how-to-save-source-estamates-from-epoched-data-set-with-multiple-events/653 "2014-01-13T18:58:29Z")\
**Posts on this page:** 3\
**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:** [January 13, 2014, 6:58pm UTC](https://mne.discourse.group/t/how-to-save-source-estamates-from-epoched-data-set-with-multiple-events/653/1 "2014-01-13T18:58:29Z")

</div>

Hi all,  
I am trying to extract from a structural roi a time series source estimate for each one of the epoch in each of my conditions

first I read in the saved epoched data fif file:

epochs=mne.read\_epochs(fname\_epoched)

next I apply the inverse operator that I created using the evoked data and the anatomic label previously created and execute the following:

stcs = apply\_inverse\_epochs(epochs,inverse\_operator, lambda2, method, anat\_label1,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pick\_ori="normal")

what I would like to do next is calculate the mean activation within this roi comprising 480 vertices. so that I have one average value for each of my epochs and conditions and save an output matrix comprising time series for each epoch and including a vector for event id

I tried picking up from the a similar stage in the plot\_compute\_mne\_inverse\_epochs\_in\_label.py substituting my commands above for

# Read epochs  
epochs = mne.Epochs(raw, events, event\_id, tmin, tmax, picks=picks,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;baseline=(None, 0), reject=dict(mag=4e-12, grad=4000e-13,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eog=150e-6))

# Compute inverse solution and stcs for each epoch  
stcs = apply\_inverse\_epochs(epochs, inverse\_operator, lambda2, method, label,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pick\_ori="normal")

mean\_stc = sum(stcs) / len(stcs)

but mean\_stc is not what I want and stcs does not have attribute save like for example stc.save

any help would be appreciated  
thanks dave

---

<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:** [January 13, 2014, 10:43pm UTC](https://mne.discourse.group/t/how-to-save-source-estamates-from-epoched-data-set-with-multiple-events/653/2 "2014-01-13T22:43:08Z")

</div>

hi David,

have a look at:

[http://martinos.org/mne/stable/auto\_examples/inverse/plot\_label\_source\_activations.html](http://martinos.org/mne/stable/auto_examples/inverse/plot_label_source_activations.html)

extract\_label\_time\_course will give you a time series per stc, then you can make  
an array from all time courses and save it as a numpy binary file with np.save

let me know if you need more help

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:** [January 14, 2014, 12:33am UTC](https://mne.discourse.group/t/how-to-save-source-estamates-from-epoched-data-set-with-multiple-events/653/3 "2014-01-14T00:33:23Z")

</div>

thanks I have been using this example as a base but I was curious about the following:  
1. can stc.extract\_label\_time\_course work on a epoched data . fif file containing all my event condtions  
2. lets say I want to extract as a time course just the vertices with the center of mass or perhaps an roi reflecting this vertices and a small number of neighboring vertices instead of the mean of a whole anatomic roi label. how could I do that?  
3 ) with np.save can I also ad a vector that corresponds to the event type that each epoch represents?

thanks //dave

> hi David,
> 
> have a look at:
> 
> [http://martinos.org/mne/stable/auto\_examples/inverse/plot\_label\_source\_activations.html](http://martinos.org/mne/stable/auto_examples/inverse/plot_label_source_activations.html)
> 
> extract\_label\_time\_course will give you a time series per stc, then you can make  
> an array from all time courses and save it as a numpy binary file with np.save
> 
> let me know if you need more help
> 
> HTH  
> Alex
> 
> > Hi all,  
> > I am trying to extract from a structural roi a time series source estimate for each one of the epoch in each of my conditions
> > 
> > first I read in the saved epoched data fif file:
> > 
> > epochs=mne.read\_epochs(fname\_epoched)
> > 
> > next I apply the inverse operator that I created using the evoked data and the anatomic label previously created and execute the following:
> > 
> > stcs = apply\_inverse\_epochs(epochs,inverse\_operator, lambda2, method, anat\_label1,  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pick\_ori="normal")
> > 
> > what I would like to do next is calculate the mean activation within this roi comprising 480 vertices. so that I have one average value for each of my epochs and conditions and save an output matrix comprising time series for each epoch and including a vector for event id
> > 
> > I tried picking up from the a similar stage in the plot\_compute\_mne\_inverse\_epochs\_in\_label.py substituting my commands above for
> > 
> > # Read epochs  
> > epochs = mne.Epochs(raw, events, event\_id, tmin, tmax, picks=picks,  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;baseline=(None, 0), reject=dict(mag=4e-12, grad=4000e-13,  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;eog=150e-6))
> > 
> > # Compute inverse solution and stcs for each epoch  
> > stcs = apply\_inverse\_epochs(epochs, inverse\_operator, lambda2, method, label,  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pick\_ori="normal")
> > 
> > mean\_stc = sum(stcs) / len(stcs)
> > 
> > but mean\_stc is not what I want and stcs does not have attribute save like for example stc.save
> > 
> > any help would be appreciated  
> > thanks dave
> > 
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > Mne\_analysis mailing list  
> > Mne\_analysis at nmr.mgh.harvard.edu  
> > [https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne\_analysis](https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis)
> > 
> > The information in this e-mail is intended only for the person to whom it is  
> > addressed. If you believe this e-mail was sent to you in error and the e-mail  
> > contains patient information, please contact the Partners Compliance HelpLine at  
> > [http://www.partners.org/complianceline](http://www.partners.org/complianceline) . If the e-mail was sent to you in error  
> > but does not contain patient information, please contact the sender and properly  
> > dispose of the e-mail.

David I. Leitman PhD

Research Assistant Professor  
Department of Psychiatry-  
Neuropsychiatry program  
Perelman School of Medicine  
University of Pennsylvania  
Gates Pavilion 10th floor room 1042  
3400 Spruce St  
Philadelphia, PA 19104-4283  
P: (215) 662-7389  
F: (215) 662-7903  
E: leitman at mail.med.upenn.edu  
Faculty page: [http://www.med.upenn.edu/apps/faculty/index.php/g275/p8174343](http://www.med.upenn.edu/apps/faculty/index.php/g275/p8174343)  
Lab website:  
[http://davidileitman.com](http://davidileitman.com)

The information contained in this e-mail message is intended only for the personal and confidential use of the recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify the the Neuropsychiatry Section immediately by e-mail, and delete the original message.

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