[Mne_analysis] Beginner Question: epoching with subset of channels after average re-reference

Marijn van Vliet w.m.vanvliet at gmail.com
Sat Jul 9 01:13:35 EDT 2016
Search archives:

Dear Ghislain,

you are running into something that is a little opaque in the workings of MNE: applying projectors.
When you set an average reference (either while loading the data with add_eeg_ref=True or later with a call to mne.io.set_eeg_reference(raw)) the reference isn’t directly applied. Instead, a ‘projector’ is added to the dataset to be applied at a later time. The reason for this is that it makes it easy to later look at the data with and without the projection. When you create the Epochs object, MNE tried to apply the projector. But at this stage you’ve selected only one channel, meaning MNE tries to compute an average reference using only this one channel, which doesn’t make any sense and raises a warning.

What you want to do is call raw.apply_proj() *before* you select any channels, so that the average reference is applied using all channels. Then, you can tell the Epochs object to only extract epochs for certain channels. It goes like this:

import mne
raw = mne.io.read_whatever_data_format_you_have(preload=True)
raw, _ = mne.io.set_eeg_reference(raw)
raw.apply_proj() # actually do the average reference
raw = raw.filter(some filter settings)

# selecting the indices of the channels you want
picks = [raw.ch_names.index(ch) for ch in [‘Cz’, ‘Pz’, ‘C3’, ‘C4’]] 

# creating the epochs for only the selected channels
epochs = mne.Epochs(raw, picks=picks, other_parameters_you_want)


hope that helps!
Marijn.

p.s. Before applying an average reference, *always* make sure you’ve noted any bad channels in raw.info[‘bads’] ! You don’t want to include any noisy or otherwise broken channels in the computation of your average reference. 

--
Marijn van Vliet
w.m.vanvliet at gmail.com





> On 08 Jul 2016, at 22:38, Ghislain d'Entremont <ghislaindentremont at gmail.com> wrote:
> 
> Hi all, 
> 
> I just started using MNE to analyze some EEG data I collected for a study I am conducting. So far, I've been enjoying learning about the package. The tutorials online are great. However, I seem to be stuck on something I can only imagine is straightforward. First, an overview of what I am trying to accomplish:
> 
> I use a 64-electrode cap. 
> 
> Ultimately, I want to (1) re-reference to the average of all electrodes, (2) apply some basic filters (3) look ERPs of 4 channels for various target types. 
> 
> I get stuck getting epochs (3). When trying to select one channel to epoch, I get the warning message telling me that I should not apply a projector to 1/64 of channels... 
> 
> How do I get around this given that I want to both re-reference to the average of all electrodes and only do analysis on some subset of channels. 
> 
> I imagine that it is clear that I am confused, so any conceptual tips with respect to the implementation of this package will be helpful. 
> 
> I've attached the script I have been using. The last line of that script is where I get stuck (as the comments will show). 
> 
> Any help will be greatly appreciated.
> 
> Thank you, 
> 
> Ghislain d'Entremont
> BSc, Neuroscience, Honors 
> Dalhousie University 
> tel: 902-802-5671 (text) 
> <Analysis.py>_______________________________________________
> Mne_analysis mailing list
> Mne_analysis at nmr.mgh.harvard.edu
> 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 . 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.




More information about the Mne_analysis mailing list