[FieldTrip] Error in ft_sourceanalysis: DICS

Johanna Zumer johanna.zumer at gmail.com
Wed May 28 16:41:54 CEST 2014


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.

Best,
Johanna


2014-05-28 15:29 GMT+01:00 Laura Rueda Delgado <
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=[];
>
> cfg.tissue={'brain', 'skull','scalp'};
>
> cfg.numvertices = [3000 2000 1000];
>
> bnd=ft_prepare_mesh(cfg,segmentedmri);
>
> % 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);
>
>
>
>
>
> Cheers,
>
>
>
> Laura Rueda Delgado
>
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20140528/01103d1a/attachment-0002.html>


More information about the fieldtrip mailing list