averaging in MNE

Hello,

I have a couple questions regarding averaging MEG data with MNE and I
was wondering if you could help me.

1) Is it possible to average a certain event only if something else
happened after it? For example, let's say I have conditions 1 and 2. I
want to average each condition, but only when the trigger happened and
I received a response from the subject, which is coded as a 3 in the
trigger line. In other words, average all the occurrences of 1 or 2
only when there's a 3 after them. I wrote a script to do that in
Matlab using the MNE toolbox, but since then lots of people have
joined the lab and they are not very familiar with matlab, so I was
wondering if there was a way to do such average within MNE, either by
using the GUI or a combination of .ave and .eve files.

2) Something else my script does is to average conditions across
different fif files. In the example above, I could have several fif
files with such events, and the final .fif averaged file would
represent the averages across all files. I imagine this is possible to
do with the MNE software by using the global average parameter. Is
that correct? Is there a different way to do it besides specifying a
different .ave file for each of my raw .fif files? It's usually not a
problem to do that for only a couple .fif files, but when there're
about 10 different .fif files to be averaged, it starts to get a
little cumbersome to keep track of all the .ave files, which look very
similar except for the output parameter.

Thanks,

Gustavo

HI Gustavo,

Hello,

I have a couple questions regarding averaging MEG data with MNE and
I was wondering if you could help me.

1) Is it possible to average a certain event only if something else
happened after it? For example, let's say I have conditions 1 and 2.
I want to average each condition, but only when the trigger happened
and I received a response from the subject, which is coded as a 3 in
the trigger line. In other words, average all the occurrences of 1
or 2 only when there's a 3 after them. I wrote a script to do that
in Matlab using the MNE toolbox, but since then lots of people have
joined the lab and they are not very familiar with matlab, so I was
wondering if there was a way to do such average within MNE, either
by using the GUI or a combination of .ave and .eve files.

Unfortunately, there is no direct way to do conditional averaging in
mne_process_raw/mne_browse_raw (yet). However, the easiest way around
this is to output a text format event file a and manipulate this file
so that new event numbers are assigned to the events meeting the
requested combinations. I guess such a script could be even written in
Excel.

2) Something else my script does is to average conditions across
different fif files. In the example above, I could have several fif
files with such events, and the final .fif averaged file would
represent the averages across all files. I imagine this is possible
to do with the MNE software by using the global average parameter.
Is that correct? Is there a different way to do it besides
specifying a different .ave file for each of my raw .fif files? It's
usually not a problem to do that for only a couple .fif files, but
when there're about 10 different .fif files to be averaged, it
starts to get a little cumbersome to keep track of all the .ave
files, which look very similar except for the output parameter.

You can, indeed, make a grand average file using mne_process_raw. You
can use the --saveavetag option to create the output file names
automatically. Also, if mne_process_raw runs out of ave file name
names when processing the raw files, the last one available will be
used. If you use custom event files, you can specify them on the
command line (in version 2.6).

Let's assume

my.ave is your averaging file
my1_raw.fif and my2_raw.fif are your raw data files
my1.eve and my2.eve are your event files

You can do

mne_process_raw <other options> --raw my1_raw.fif --raw my2_raw.fif --
eve my1.eve --eve my2.eve --ave my.ave --saveavetag -ave --gave my-
gave.fif

This will produce the averages in my1-ave.fif and my2-ave.fif and log
files my1-ave.log and my2-ave.log independent of what is specifie in
my.ave. Also, the my1.eve and my2.eve override the event file
specification (if any) in my.ave.

Similarly, the --savecovtag option can be used to generate the noise-
covariance calculation output file names.

I hope this helps.

- Matti

Matti,

That worked great. Thanks!

Best,

Gus

Dear all,

I have a question about conversion of fif file into mat file;. I would like to convert my raw data (fif file) into matlab file. For this, I tried to use the function mne_convert_mne_data but I have a message "no evoked data here". I have the same message if I try this with averaged data (fif file) directly obtained by on-line averaging.

I exactly wrote this command line:

mne_convert_mne_data -meas my filename.fif -mat -out my filename.mat

Something is wrong ?

Thanks for your help !

Bye

Etienne LABYT

Dear Etienne,

Here are some relevant points:

1. mne_convert_mne_data does not convert raw data files (mne_raw2mat
does this).

2. Were your data collected with MaxShield on? If so, I think even the
averages need to be passed through maxfilter before they can be
processed further (not absolutely sure about this).

3. The MNE Matlab toolbox pretty much makes mne_convert_mne_data and
mne_raw2mat obsolete. The fif files can be now read directly from
Matlab without having to waste disk space for the converted data.

- Matti