[Mne_analysis] Simple way of averaging evoked responses over channels?

Denis-Alexander Engemann denis.engemann at gmail.com
Sat Jul 13 13:38:03 EDT 2013
Search archives:

Hi Kari,

you might want to take a look at the mne.layouts module,
there you'll find a few recently added functions that help dealing with
such cases:

mne.layouts.layout._pair_grad_sensors
mne.layouts.layout._pair_grad_sensors_from_ch_names
mne.layouts.layout._merge_grad_data


You can say something like:

from mne.layouts.layout import _merge_grad_data, _pair_grad_sensors

picks, pos = _pair_grad_sensors(evoked.info)  #  get indices of grad pairs

data = _merge_grad_data(evoked.data[picks])  # merge grads


I hope this helps,
Denis



On Sat, Jul 13, 2013 at 7:11 PM, Kari Aliranta <
kari.p.aliranta at student.jyu.fi> wrote:

>
> Hi,
>
> I have a collection of epochs for a single type of event, and I've been
> using this script here to average and visualize them:
>
> http://martinos.org/mne/auto_examples/plot_topo_compare_conditions.html
>
>
> Now I'm trying to average the responses over the gradiometer channels of
> a given lobe (left temporal, right temporal etc.) with roughly the
> following algorithm:
>
> 1. For each pair of gradiometer channels in the lobe: sum the vectors
> (Take data for single channel of the pair, rise it to the power of 2, do
> the same for the data of the other channel in the pair. Sum the previous
> values and take a square root of them).
>
> 2. Average the data received in step 1.
>
> 3. Vizualize the result as a single graph.
>
>
> I didn't find a straightforward example about this in the docs, so I'm
> trying to code something to make it work. However, the problems are the
> following:
>
> - How do you get the channel data to average in step 1? Specifically,
> how do you get the data for a specific gradiometer channel? For example,
> if I know I need to get the data for gradiometer channel 0222, how can
> it be done?
>
> - If you need the data for the paired gradiometer channel of the channel
> x (in case of the channel 0222 this would probably be 0223), how do you
> get it? How do the indexes in evoked.data actually work in this regard?
>
> Currently I have the following code. ChannelList is a list of all
> channels in a lobe, from which the gradiometer channels are then
> separated. The format of the channelList is
> ['0223','0222','0212','0213','0133', ...etc.].
>
>
>          evoked = epoch.average()
>          # Get all the channels names in evoked
>          ch_names = evoked[0].ch_names
>          ch_names = _clean_names(ch_names)
>
>          # Check that the channels we want to show actually are in the
> evoked
>          # channel list
>          channelListSet = set(channelList)
>          ch_namesSet = set(ch_names)
>          channelsToAverage = channelListSet.intersection(ch_namesSet)
>
>          # Get only the gradiometer channels
>          channelsToAverageGrad = None
>          for a in channelsToAverage:
>              if (a[-1] == 2 or a[-1] == 3):
>                  channelsToAverageGrad.append(a)
>
>          averagedFinal = None
>          # TODO Get index from channel names, to get the data from evoked.
>          # Then do the actual vector summing and averaging
>          for chname in channelsToAverageGrad:
>              ch_idx = ch_names.index(chname)
>              evoked.data[ch_idx:(ch_idx+1),:]
>
> _______________________________________________
> 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.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20130713/7cd7985a/attachment.html 


More information about the Mne_analysis mailing list