fiff_write_evoked.m - Writes only the first condition from the original file

Hello,

I am trying to overwrite an evoked file after deleting a couple of projectors from the original evoked file in Matlab. After creating the new evoked file, only the first condition from the original evoked data structure is written. I looked through the fiff_write_evoked.m script and it seems like my subject fails in the section where the epochs get written for each set(condition) in a loop.

Here are the commands I ran:

ev1 = fiff_read_evoked('ac1_BaleenHP_All-ave.fif')
ev1.info.projs(3)=
ev1.info.projs(6)=
fiff_write_evoked('ac1_BaleenHP_All-ave.fif', ev1)

(I have checked every field in the old and new evoked data structures and everything is the same expect for the number of projectors. I wanted to know where the conditions are stored in the evoked data structure?)

>>length(ev1.evoked) returns 1, but the original evoked data has 10 conditions (when I view it in mne_browse_raw). Has anyone encountered this before or am I missing any step in-between?

Thanks much!

Best,
Candida

Hey Candidia,

Yes, I ran into the same issue. If I recall correctly, the way the MATLAB
code is structured, the evoked object that is returned by fiff_read_evoked
only contains a single dataset. We hit a similar stumbling block in
mne-python a few months ago, and amended the behavior of the Evoked
instance such that saving and loading multiple evoked datasets to / from a
single .fif file is possible. While you can't save them to a single file in
MATLAB (to my knowledge), you should at least be able to load each one and
loop through them, using different "setno" parameters to select the
appropriate datasets in turn. Alternatively, you can work with mne-python,
which supports both reading and writing multiple conditions from FIF files,
as well as accessing the datasets based on the name (and type, average or
standard error) as opposed to the index in the FIF file. But this, of
course, requires more overhead in terms of installation and learning its
use.

Cheers,
Eric

Hi,

If you use fiff_read_evoked_all to read in the data (instead of
fiff_read_evoked ). It should fix your problem. fiff_write_evoked does
loop through all of the evoked "sets" when writing.

D

fiff_read_evoked_all works!

Thank you Dan, Eric for your help and explanation. :slight_smile:

Best,
Candida