[FieldTrip] LCMV beamformer source reconstruction

Alistair Vardy - 3ME A.N.Vardy at tudelft.nl
Tue Oct 30 15:45:59 CET 2012

Dear Jorn, Johanna,

Thank you for your replies. I was making a couple of mistakes. I wasn't using the parameters correctly and now use cfg.lcmv.<parameter> which works. The mismatch between the number of channels and the size of the filter was due to the strange situation that ASA channel labels sometimes uppercase letters (from the electrode file) and sometimes lowercase (from the header file). Fieldtrip does not understand AFZ but knows AFz for example.
The routine ft_prepare_vol_sense.m thus discarded half of the channels.

I found  the voxel with the maximal power and reconstructing the dipole moment at that particular source for each trial using the following code which I found in an earlier post somewhere:

trialN     = size(timelock0.trial,1);
for trial_tel = 1:trialN
    sourceDiff.trial(trial_tel).mom = sourceDiff.avg.filter{maxind}*data0FIC.trial{trial_tel};

where maxind is the index of the voxel with maximum power. Timelock0 takes each trial with a window of [-0.5 0.5] s around each event. I will use a SVD to determine the power of the source for each trial separately.

Thanks again for your help!


From: fieldtrip-bounces at science.ru.nl [mailto:fieldtrip-bounces at science.ru.nl] On Behalf Of Johanna Zumer
Sent: Tuesday, October 30, 2012 10:37 AM
To: FieldTrip discussion list
Subject: Re: [FieldTrip] LCMV beamformer source reconstruction

Dear Alistair,

In addition to the informative response from Jörn, I just wanted to add:

One tiny thing I note is that you type cfg.lmvc.lambda which should be cfg.lcmv.lambda.

Why is your filter of size 3x65?   Shouldn't it be 3x125 (3 source orientations x 125 EEG channels)?

2012/10/30 "Jörn M. Horschig" <jm.horschig at donders.ru.nl<mailto:jm.horschig at donders.ru.nl>>
Dear Alistair,

I am not quite sure whether I understand your request correctly, but you are looking for help to get the maximum activity per trial in your source reconstructed data? I guess your confusion arises because of the different subfields, so here a short explanation:

Every dipole has strengths in 3 directions (think of it as magnetic field strength in the x,y and z direction), this is stored in .mom
In order to get it down to one number instead of three, there are different possibilities, but what's roughly happening by default is that an SVD is computed then the principal direction is taken, i.e. the strongest of these three vectors. This is what you find back in .pow.  The filter matrix is the filter per grid position to get from your sensor data to the source data. Noise is an approximation of the noise level per trial.

So, if you want to get the maximum activity, I would suggest to take [~, idx] = max(sourceDiff.avg.pow{i}), where idx then is the the grid position of maximal power. If you are interested in the maximum over e.g. the posterior part of the brain, you should limit your search. You can best do that by using sourceDiff.pos and an atlas.

If that does not answer your question, feel free to clarify your request ;)


On 10/25/2012 10:40 PM, Alistair Vardy - 3ME wrote:
Hi all,

I trying to reconstruct the activity in a source using the LCMV beamformer with EEG data. My code follows several examples that stop at the source localization. Unfortunately, I am unable to reconstruct the source.

The data is a series of 198 button presses, self-paced. The two time locked data sets are pre- and post-event windows. The data is filtered in the beta band (13-30 Hz). There are 128 EEG channels, three of which are excluded due to excessive noise. The data was re-referenced to the common average. The source that provides the normalized difference in power between the two time windows has a field avg with subfields, filter, noise, pow, and mom:

sourceDiff =

        dim: [17 13 14]
       time: [1x819 double]
        pos: [3094x3 double]
     inside: [1x1567 double]
    outside: [1x1527 double]
     method: 'average'
        avg: [1x1 struct]
        cfg: [1x1 struct]


ans =

       pow: [1x3094 double]
       mom: {1x3094 cell}
     noise: [1x3094 double]
    filter: {1x3094 cell}

The moment entries are sized  3 x 819, the filter 3 x 65.

I hope someone can help me with the code required to reconstruct the source at the voxel with the largest power during the entire duration of each trial. The code used to determine the source is below. MRI, head model and leadfield were computed as well but are not included in the code below.

Kind regards,


channel         = {'EEG', '-AFF1', '-AFZ', '-AF1'};

cfg1                 = [];
cfg1.keeptrials      = 'yes';
cfg1.covariance      = 'yes';
cfg1.channel         = channel;
dataPre             = ft_redefinetrial(cfg1, data1FIC);
timelock1           = ft_timelockanalysis(cfg1, dataPre);

cfg2                 = [];
cfg2.keeptrials      = 'yes';
cfg2.covariance      = 'yes';
cfg2.channel         = channel;
dataPost            = ft_redefinetrial(cfg2, data2FIC);
timelock2           = ft_timelockanalysis(cfg2, dataPost);

%% Source analysis
cfg = [];
cfg.grid = grid;
cfg.hdmfile = volname;
cfg.elec = sens;
cfg.vol = vol;
cfg.method = 'lcmv';
cfg.channel = channel;
cfg.lcmv.keeptrials = 'yes';
% cfg.lcmv.projectnoise = 'yes';
cfg.lmvc.lambda     = '5%';
cfg.lcmv.keepfilter = 'yes';
[source1] = ft_sourceanalysis(cfg, timelock1);
[source2] = ft_sourceanalysis(cfg, timelock2);

sourceDiff = source2;
sourceDiff.avg.pow = (source2.avg.pow - source1.avg.pow) ./ source1.avg.pow;


fieldtrip mailing list

fieldtrip at donders.ru.nl<mailto:fieldtrip at donders.ru.nl>



Jörn M. Horschig

PhD Student

Donders Institute for Brain, Cognition and Behaviour

Centre for Cognitive Neuroimaging

Radboud University Nijmegen

Neuronal Oscillations Group

FieldTrip Development Team

P.O. Box 9101

NL-6500 HB Nijmegen

The Netherlands


E-Mail: jm.horschig at donders.ru.nl<mailto:jm.horschig at donders.ru.nl>

Tel:    +31-(0)24-36-68493<tel:%2B31-%280%2924-36-68493>

Web: http://www.ru.nl/donders

Visiting address:

Trigon, room 2.30

Kapittelweg 29

NL-6525 EN Nijmegen

The Netherlands

fieldtrip mailing list
fieldtrip at donders.ru.nl<mailto:fieldtrip at donders.ru.nl>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20121030/e7fdf890/attachment-0002.html>

More information about the fieldtrip mailing list