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.
(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?
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.
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.