Combine epoched ave fif files?

Dear MNE community,

I've collected data for a given subject across 6 runs, which after
pre-processing, result in 6 separate *.fif files. I can extract the events
of interest, epoched and averaged separate conditions using
mne_process_raw and the offline averaging mechanism. This results in 6
separate epoched data .fif files. I can view these atop of each other in
mne_browse_raw.

A) What I really want to do is to epoch and average the 6 input *.fif
files into ONE output *.fif file for each condition. So that instead of
say 6 epoched fif files with N=20 averages for a condition, I have one
epoched fif file with N=6*20 averages for that condition.

B) Alternatively I can read the 6 averaged epoch files into matlab, and
combine them there, so that I have this information in one structure in
matlab. But then I would like to convert that structure back into a fif
file that contains the average of all trials for a given condition for a
given subject.

Can I do either A) or B) above. Thank you very much for any help you can
provide.

Best Regards,

Linda Moya

Hi Linda,

One workaround you can use in MNE-Python is to combine all the raw
instances using
raw.append()<http://martinos.org/mne/generated/mne.fiff.Raw.html#mne.fiff.Raw.append>and
all of the event instances using
mne.concatenate_events()<http://martinos.org/mne/generated/mne.concatenate_events.html#mne.concatenate_events>

Hi Linda,

mne_process_raw can handle this directly.
It can accept specification of multiple input raw files, an event file for each, and even an average file for each if needed. I have used it for this.
You can find the documentation in the version 2.7.3.pdf manual on page 48 in the section 4.2.3 Batch-mode options and in the preceding section for the options which are common with mne_browse_raw. Here are the key switches:

--raw <name>
Specifies the raw data file to be opened. This option is required for batch version, mne_process_raw. If a raw data file is not specified for the interactive version, mne_browse_raw, and empty interactive browser will open.
--events <name>
Specifies the name of a fif or text format event file (see Section 4.10.5) to be associated with a raw data file to be processed. If multiple raw data files are specified, the number of --eventsoptions can be smaller or equal to the number of raw data files. If it is equal, the event filenames will be associated with the raw data files in the order given. If it is smaller, the remaining raw data files for which an event file is not specified will not have an event file associated with them. The event file format is recognized from the file name: if it ends with .fif, the file is assumed to be in fif format, otherwise a text file is expected.
--ave <name>
Specifies the name of an off-line averaging description file. For details of the format of this file, please consult Section 4.13. If multiple raw data files are specified, the number of --ave options can be smaller or equal to the number of raw data files. If it is equal, the averaging description file names will be associated with the raw data files in the order given. If it is smaller, the last description file will be used for the remaining raw data files.
--gave <name>
If multiple raw data files are specified as input and averaging is requested, the grand average over all data files will be saved to <name>.

You can double check its grand averaging operation including your setup by handing it 2 or more copies of the same raw data file and events file. In that case, the grand average will be the same as the average of the one set of raw trials.

Don

Don Krieger, Ph.D.
Department of Neurological Surgery
University of Pittsburgh
(412)648-9654 Office
(412)521-4431 Cell/Text

Dear Don,

Thank you very much. This was exactly what I was looking for. I had tried
all of this, but somehow missed the --gave option (didn't read the manual
closely enough)...

Thank you.

Linda Moya