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

Kari Aliranta kari.p.aliranta at student.jyu.fi
Sat Jul 13 13:11:57 EDT 2013
Search archives:

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),:]




More information about the Mne_analysis mailing list