capping number of trials per condition in -gave.fif using mne_process_raw

Hello,

I'm using mne_process_raw to create grandaveraged data for each
individual subject. Each subject's data were collected over five runs
and so are saved in 5 raw fiff files.

The task included 5 different trial types presented in a mixed-event
design. I'd like to set a cap on the number of trials per condition,
such that even if a subject completed 90 trials of Condition #1 over the
5 runs, for example, only the first 75 will be saved in his grandaverage
file.

I tried to implement this by writing a matlab script that reads the
event files for each run and removes events from each condition until
the cap is met. But, for some subjects, this results in a completely
empty event file for run 5 (the script begins with the last run),
causing mne_process_raw to exit when I actually try to produce the average.

Is anyone aware of a simpler way to control the number of trials used to
compute the grandaverage using mne_process_raw?

Also, while I was working on this, I noticed the following window output
by process_raw:
"filter: .5 .... 120 Hz bins : 6 .... 1636 of 4097 hpw : 3 lpw : 34
Highpass filter will work as specified
filter: 0 .... 40 Hz bins : 0 .... 545 of 4097 hpw : 3 lpw : 34
Highpass filter will work as specified"

I specify a 120 Hz lp filter and a .5 Hz hp filter in my input to
process_raw, so I was surprised to see what seems to be an additional 40
Hz lp filter being applied. Can anyone comment on why this might be?

Thanks,

Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20120723/981c91bc/attachment.html

Hi Matt,

You are using the nightly build which has a separate filter setting for EOG. mne_process_raw --help reveals:

        --eoghighpass val/Hz EOG highpass corner (default = 0.0 Hz)
        --eoglowpass val/Hz EOG lowpass corner (default = 40.0 Hz)
        --eoghighpassw val/Hz EOG highpass transition width (default = 0.0 Hz)
        --eoglowpassw val/Hz EOG lowpass transition width (default = 5.0 Hz)

In your particular example, the MEG/EEG data are filtered from 0.5 to 120 Hz according to your specification but the default lowpass (40 Hz) is used for EOG.

- Matti

Hey Matt,

Here's what we do when dealing with trial counts. First, we equalize
trial counts across conditions to avoid bias. We do this because we
noticed that when using the absolute value of MNE/dSPM estimates to
perform paired comparisons (condition A versus condition B) across
vertices and time points, using the absolute value produces a bias
toward more activation in the lower-trial-count condition. For
example, imagine if noise were normally distributed for the MNE or
dSPM score (with mean equal to the true activation level), then the
magnitude of those estimates will yield from a folded normal
distribution, where the mean (which we want to think of as just the
magnitude of the real activation) is now influenced by the standard
deviation of the original noise. This is a problem because that
effective standard deviation depends in part on the trial count used
to calculate the mean.

In any case, to equalize the trial counts, we subsample our data and
underpower our analysis by taking trials that are equally spaced
throughout the runs. This is done because in our data, the
lower-trial-count conditions typically are spread throughout the
recording session, as well. By undersampling evenly across the
recording session, we're trying to maximize how well we match the
noise characteristics under all conditions. This becomes a tad bit
more difficult to do correctly because MNE rejecting trials under
certain criteria also removes trials from analysis, but it can be
done.

But, either way it's done---with our spread undersampling or your
using the first N trials---you're eventually going to hit the problem
you're dealing with, where there are no trials to average over for
particular runs. The solution we use is to check to see if a run is
used, and if it's not, remove its parameters from the call to
mne_process_raw. Since you're coding MATLAB anyway, hopefully this
isn't too big a pain.

Cheers,
Eric

Hi Eric,

Thanks for the additional details. The code I have in place handles
rejected trials by reading off the 'omit' markers from the log file and
preventing those trials from being included in the 'capped' event files,
like you suggest.

If anyone else is looking to implement something similar, I've attached
a sample m file, although I can't make any promises about efficiency or
readability.

Thanks,

Matt