AnalyzingData/MNE_BaselineCorrectSTC - Meg Wiki
location: AnalyzingData / MNE_BaselineCorrectSTC

Baseline Correction for Source Estimates

Baseline-correcting MEG or EEG data does not imply that average baseline activity for source estimates is zero as well. For example, if intensitities are computed (i.e. the option --signed was NOT used), baseline activity will always be above zero. This may affect statistical tests, if conditions with different baseline levels are compared, e.g. due to different numbers of trials. It may therefore make sense to correct the baselines for the source estimates.

function corr_base_STC(filein, fileout, interval);

% subtract baseline at each vertex in MNE STC file
% filein: input STC file
% fileout: output STC file
% interval: baseline interval in milliseconds
% OH 18.1.2010

interval = interval/1000;   % now in s for MNE

datain = mne_read_stc_file(filein);

[nvert, ntime] = size(datain.data);

lats = datain.tmin:datain.tstep:datain.tmin+(ntime-1)*datain.tstep;

[tmp base1] = min( abs( lats-interval(1) ) );
[tmp base2] = min( abs( lats-interval(2) ) );
fprintf(1, 'Correcting from %f (%d) to %f (%d)\n', interval(1), base1, interval(2), base2);

meanbase = mean( datain.data(:,base1:base2), 2 );
meanbasemat = repmat(meanbase, 1, ntime);

dataout = datain;

dataout.data = datain.data - meanbasemat;

mne_write_stc_file( fileout, dataout );

CbuMeg: AnalyzingData/MNE_BaselineCorrectSTC (last edited 2013-03-08 10:02:29 by localhost)