common spatial filter in lcmv beamforming

Mon Nov 23 19:11:41 CET 2009

Dear Fieldtrip Users,

I have a question on computing common spatial filter for the time domain
data (ERP) using lcmv beamforming.

My experiment is a bilateral tactile discrimination task measured with
the 275-channel CTF system.
There are two experimental conditions that I want to compare within
subjects on the source level. As the baseline between the two conditions
might not be homogeneous, I would like to compute two common spatial
filters based on the pooled data of both conditions for baseline and for
the ERP during the tactile stimulation respectively.

According to the example matlab script of computing common spatial
filters on frequency data posted on the Fieldtrip website, I adapted it
to the lcmv beamforming on the time domain data. The script is attach at
the end.

As my original trial length is 5.5s (-1.5 to 4s,  -1s is visual
instruction onset, 0s to 0.6s is tactile stimulation), the projection of
each single trial through the common filter became extremely
computationally demanding. Then I redefined the trials according to the
time window of interest (as was suggested in the frequency domain source
analysis), I got different source results as the beamformer_lcmv seem to
take the average of the whole given data length and the covariance of
the specified window to calculate the spatial filter.

Now I realized that it was not correct to define such short time period
for the averaged data and that I probably should have taken a longer
time window, such as [-1.4 0.6]s that covers both baseline and tactile
stimulation. But I am not clear about what kind of time window would be
appropriate in my case?
I have tried a couple of different time windows but so far I haven't got
clear bilateral primary somatosensory sources yet, actually not even
close to it, so I know I must have done something wrong.

Any suggestions would be very much appreciated.

Best regards,

cfg                  = [];          = {'MEG'};
cfg.blc              = 'no';
cfg.keeptrials       = 'yes';
tlckavg              = timelockanalysis(cfg, data);

cfg                  = [];          = {'MEG'};
cfg.blc              = 'no';
cfg.removemean       = 'no';
cfg.covariance       = 'yes';
cfg.keeptrials       = 'yes';
cfg.covariancewindow = [0.05 0.07];
% cfg.latency          = [0.05 0.07];
tlckavg_toi          = timelockanalysis(cfg, tlckavg);
cfg.covariancewindow = [-1.37 -1.35];
% cfg.latency          = [-1.37 -1.35];
tlckavg_blc          = timelockanalysis(cfg, tlckavg);

cfg               = [];
cfg.method        = 'lcmv';
cfg.grid          = grid;
cfg.vol           = vol;
cfg.lambda        = '5%';
cfg.keepfilter    = 'yes';
source            = sourceanalysis(cfg, tlckavg);

cfg               = [];
cfg.method        = 'lcmv';
cfg.grid          = grid;       % previously computed grid
cfg.vol           = vol;        % previously computed volume conduction
cfg.grid.filter   = source.avg.filter; % use the common filter computed
in the previous step!
cfg.lambda        = '5%';
cfg.rawtrial      = 'yes';      % project each single trial through the

 source  = sourceanalysis(cfg, tlckavg);


Yiwen Li Hegner , PhD
Institute of Medical Psychology and  Behavioral Neurobiology
University of Tübingen

The aim of this list is to facilitate the discussion between users of the FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also and

More information about the fieldtrip mailing list