[FieldTrip] Advice on using LCMV beamformer

Schoffelen, J.M. (Jan Mathijs) jan.schoffelen at donders.ru.nl
Fri Jul 17 09:46:46 CEST 2015

Hi Stephen,

I think that you are confused because cfg.latency as an argument for ft_sourceanalysis does not have the behavior you expect it to have. That is, it will not produce different time courses of activation. At most, it will constrain the time window for which the results are returned. The reason for this is, that the spatial filter is computed from the covariance that is computed in ft_timelockanalysis. The latency across which the covariance is computed is determined by cfg.covariancewindow in ft_timelockanalysis.
In your case, I would use ‘all’ for the covariance window (thus implicitly NOT dividing into and ‘active’ and ‘baseline’ period), and use a single spatial filter across conditions. I don’t know what your rationale would be to do a ‘baseline correction’, but you could post-process the virtual channel ERF by doing a baseline subtraction by hand (e.g. by ft_preproc_baselinecorrect).
Note, that if you want to average across virtual channels, where the individual channels have been svd’ed (or something similar) you have to think about the polarity of the time series before averaging (because the polarity may be trivially opposite, leading to cancellation).
With respect to computation of the time series of a virtual channel: I indeed would compute the spatial filter for a selected number of dipole positions, and then left multiply it with the data you want to have projected into source space. There’s some documentation on the wiki as to how to do this.

Best wishes,

Jan-Mathijs Schoffelen, MD PhD, Senior researcher

Max Planck Institute for Psycholinguistics
Donders Centre for Cognitive Neuroimaging

E-mail: j.schoffelen at donders.ru.nl<mailto:j.schoffelen at donders.ru.nl>
Telephone: +31-24-3614793


On Jul 17, 2015, at 12:03 AM, Stephen Whitmarsh <stephen.whitmarsh at gmail.com<mailto:stephen.whitmarsh at gmail.com>> wrote:

Hi everyone,

I hope there is someone out there who has some time to help me with using LCMV beamformer. I have no experience with it yet, although a little with DICS, and understand they are at least conceptually very similar. However, I am running into some questions. Before I go on, my data on sensor level looks good and it works out with dipolefitting as well (attached).

I would like to beamform an early (unilaterally stimulated) sensory evoked field. There is no conditional difference, I would just like to extract the timecourse of some maximum voxels. In other words:
1) get a contralateral cluster or a number of voxels with maximum amplitude.
2) extract the timecourses of those clusters, then average them.

For step 1, it seem to have several options, either:
1a) calculate the filter on the whole timecourse (a common filter as would be used in DICS)
1b) use that common filter to calculate the amplitude of the early component
1c) do the same for the baseline period
1d) subtract the baseline activation from the active period (or take a ratio)

Alternatively, I could:
2a) beamform the active period
2b) beamform the baseline period
2c) subtract the baseline activation from the active period (or take a ratio)

Or it seems, I might even:
3a) beamform the active period
3b) divide the active period by the projected noise

Do I get this correctly? Does anyone have an argument for one of these option?

Anyway, first practical problem is that when I plot either the whole, the baseline or the activation period I get the same results (attached). A difference therefore doesn't work, obviously. So this raises the question how the selection of latency works in ft_sourceanalysis? I trust cfg.latency works, but it doesn't seem to make a difference for me. At the same time, using selectdata to select a time period doesn't make a difference either. I'm obviously doing something wrong, but what?

Anyway, when I get this figured out, I still need to extract the timecourses. How would I proceed doing this? I imagine the fastest way would not be to loop ft_sourceanalysis for each timepoint (using a common filter I would think). Should I 'manually' multiply the data with the filter?

It would be great to have some feedback on the general idea, and perhaps someone can identify what I am doing wrong (script below). I would be happy to finish the LCMV beamformer tutorial on the FT website once I get it figured out, as I can imagine more people would have these questions.

All the best and thanks,

% timelock average + covariance

cfg = [];
cfg.covariance = 'yes';
cfg.covariancewindow = 'all';
cfg.trials = find(clean_data.trialinfo(:,2) == 1);
ERF_single{isubject} = ft_timelockanalysis(cfg,clean_data);
cfg.trials = find(clean_data.trialinfo(:,2) == 2);
ERF_double{isubject} = ft_timelockanalysis(cfg,clean_data);

% combine gradiometers (single stim)
cfg = [];
ERF_single_cmb{isubject} = ft_combineplanar(cfg,ERF_single{isubject});
ERF_double_cmb{isubject} = ft_combineplanar(cfg,ERF_double{isubject});

% load headmodel MEG
temp = load(['/home/stephen/analysis/metacognition/sourcemodel/pp_' num2str(isubject) '_headmodel_singleshell.mat']);
headmodel_meg{isubject} = temp.headmodel_meg;

% headmodel_meg = ft_convert_units(headmodel_meg, 'cm');
gridtemp = load(['/home/stephen/analysis/metacognition/sourcemodel/pp_' num2str(isubject) '_grid.mat']);

hdr             = ft_read_header(flist{1});
cfg             = [];
cfg.grad        = hdr.grad;
cfg.vol         = headmodel_meg{isubject};
cfg.grid        = gridtemp.grid;
cfg.channel     = {'MEGGRAD'};
cfg.normalize   = 'yes';
leadfield       = ft_prepare_leadfield(cfg);

% get the filter
cfg = [];
cfg.method              = 'lcmv';
cfg.grid                = leadfield;
cfg.vol                 = headmodel_meg{isubject};
cfg.keepfilter          = 'yes';
cfg.senstype            = 'meg';
cfg.channel             = 'meggrad';
cfg.lcmv.fixedori       = 'yes'; % use only right gradiometers
cfg.reducerank          = 2;
source_lcmv_single{isubject}   = ft_sourceanalysis(cfg, ERF_single{isubject});
source_lcmv_double{isubject}   = ft_sourceanalysis(cfg, ERF_double{isubject});

% project post stim latency with previous common filter

cfg = [];
cfg.latency = latency;
ERF_single_latency{isubject} = ft_selectdata(cfg,ERF_single{isubject});

cfg = [];
cfg.method              = 'lcmv';
cfg.grid                = leadfield;
cfg.vol                 = headmodel_meg{isubject};
cfg.grid.filter         = source_lcmv_single{isubject}.avg.filter;
cfg.channel             = 'meggrad';
cfg.senstype            = 'meg';
% cfg.latency             = latency;
cfg.lcmv.fixedori       = 'yes';
cfg.reducerank          = 2;
source_lcmv_single_latency{isubject} = ft_sourceanalysis(cfg, ERF_single_latency{isubject});

% baseline

cfg = [];
cfg.latency = [-0.2 0];
ERF_single_baseline{isubject} = ft_selectdata(cfg,ERF_single{isubject});

cfg = [];
cfg.method              = 'lcmv';
cfg.grid                = leadfield;
cfg.vol                 = headmodel_meg{isubject};
cfg.grid.filter         = source_lcmv_single{isubject}.avg.filter;
cfg.channel             = 'meggrad';
cfg.senstype            = 'meg';
% cfg.latency             = latency;
cfg.lcmv.fixedori       = 'yes';
cfg.reducerank          = 2;
source_lcmv_single_baseline{isubject} = ft_sourceanalysis(cfg, ERF_single_baseline{isubject});

% get difference between baseline and component
source_lcmv_single_diff{isubject} = source_lcmv_single_latency{isubject};
source_lcmv_single_diff{isubject}.avg.pow = source_lcmv_single_latency{isubject}.avg.pow - source_lcmv_single_baseline{isubject}.avg.pow;

template_mri = ft_read_mri(['/opt/fieldtrip/external/spm8/templates/T1.nii']);

cfg = [];
cfg.voxelcoord = 'no';
cfg.parameter = 'avg.pow';
cfg.interpmethod = 'nearest';
source_lcmv_single_int{isubject} = ft_sourceinterpolate(cfg, source_lcmv_single{isubject}, template_mri);
source_lcmv_single_latency_int{isubject} = ft_sourceinterpolate(cfg, source_lcmv_single_latency{isubject}, template_mri);
source_lcmv_single_diff_int{isubject} = ft_sourceinterpolate(cfg, source_lcmv_single_diff{isubject}, template_mri);

cfg = [];
cfg.method = 'slice';
cfg.funparameter = 'avg.pow';
cfg.maskparameter = cfg.funparameter;
cfg.funcolorlim = [3e-22 5e-22];
% ft_sourceplot(cfg,source_lcmv_single_latency_int{isubject});
% ft_sourceplot(cfg,source_lcmv_single_int{isubject});

cfg = [];
cfg.method = 'slice';
cfg.funparameter = 'pow';
cfg.funcolorlim = [-1e-23 1e-23];

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/20150717/a5f7b3f5/attachment-0002.html>

More information about the fieldtrip mailing list