[FieldTrip] Error in ft_sourceanalysis: DICS

Laura Rueda Delgado Laura.Rueda at faber.kuleuven.be
Wed May 28 16:51:27 CEST 2014

Dear Johanna,

Thank you for your suggestion.

On step 2 in the code, I select from the elec structure the channels that are included in the frequency data. So the elec structure used for preparing the leadfield has 128 electrodes, the same as the data (data_rs, data 4, and therefore freqAll). I checked this precisely because I read a previous thread discussing that issue.

Best regards,

Laura Rueda Delgado

From: fieldtrip-bounces at science.ru.nl [mailto:fieldtrip-bounces at science.ru.nl] On Behalf Of Johanna Zumer
Sent: woensdag 28 mei 2014 16:42
To: FieldTrip discussion list
Subject: Re: [FieldTrip] Error in ft_sourceanalysis: DICS

Hi Laura,

Does your data have the same channels as the leadfield (as the electrodes that went in to compute the leadfield)?   I often see that error when there is a mismatch of channels in that way.


2014-05-28 15:29 GMT+01:00 Laura Rueda Delgado <Laura.Rueda at faber.kuleuven.be<mailto:Laura.Rueda at faber.kuleuven.be>>:
Dear Fieldtrip users,

I’m following the tutorial of beamformers (Source Analysis: Contrast activity to another interval<http://fieldtrip.fcdonders.nl/tutorial/beamformer>) to estimate oscillatory sources using DICS. I’ve checked the surface created after segmentation and the grid generated from the electrode positions and the headmodel. That seems to work ok. However, at the step of source analysis, I get the following error:

Error using  *
Inner matrix dimensions must agree.

Error in beamformer_dics (line 339)
        filt = pinv(lf' * invCf * lf) * lf' * invCf;              % Gross eqn. 3, use PINV/SVD to cover rank
        deficient leadfield

Error in ft_sourceanalysis (line 567)
      dip(i) = beamformer_dics(grid, sens, vol, [],  squeeze(Cf(i,:,:)), optarg{:});

Does anybody have an idea of what I’m doing wrong?
Thank you in advance for any help or suggestion!

This is my code:
%% 1 - Preparation of MRI- source space
% Read MRI
mrifile = 'Subject01\Subject01.mri';
mri = ft_read_mri(mrifile);
% Reslice to reorient images
cfg              = [];
cfg.dim          = [256 256 256];
mri              = ft_volumereslice(cfg,mri);
% Segment compartments
cfg           = [];
cfg.output    = {'brain','skull','scalp'};
segmentedmri  = ft_volumesegment(cfg, mri);
% Prepare mesh
cfg.tissue={'brain', 'skull','scalp'};
cfg.numvertices = [3000 2000 1000];
% Prepare headmodel
cfg        = [];
cfg.method ='bemcp';
vol        = ft_prepare_headmodel(cfg, bnd);
%% 2- Prepare leadfield - Creating grid
load elec_aligned2 % Obtained after adjusting electrodes on scalp surface interactively
% Three fiducial markers were added to the electrode file, and now they're
% removed so that the electrode structure has the same number of channels as the data
elec_aligned2.chanpos = elec_aligned2.chanpos(1:128, :);
elec_aligned2.elecpos = elec_aligned2.elecpos(1:128, :);
elec_aligned2.label = elec_aligned2.label(1:128, :);
cfg =[];
cfg.vol             = vol;
cfg.elec = elec_aligned2;
cfg.grid.resolution = 10;
cfg.grid.unit       = 'mm';
[grid] = ft_prepare_leadfield(cfg);
%% 3- Join rest and task data
% data_rs: resting state data
% data4: data during task
dataAll = ft_appenddata([], data_rs, data4);
cfg = [];
cfg.method    = 'mtmfft';
cfg.output    = 'powandcsd';
cfg.tapsmofrq = 4;
cfg.foilim    = [18 18];
freqAll = ft_freqanalysis(cfg, dataAll);
% all seems normal until here
%% 4- Estimate source of all data
cfg              = [];
cfg.method       = 'dics';
cfg.frequency    = 18;
cfg.grid         = grid;
cfg.vol          = vol;
cfg.elec        = elec_aligned2;
cfg.dics.projectnoise = 'yes';
cfg.dics.lambda       = '5%';
cfg.dics.keepfilter   = 'yes';
cfg.dics.realfilter   = 'yes';
sourceAll = ft_sourceanalysis(cfg, freqAll);


Laura Rueda Delgado

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/20140528/4d56ab30/attachment-0002.html>

More information about the fieldtrip mailing list