[FieldTrip] Error in ft_sourceanalysis: DICS

kousik sarathy sarathykousik at gmail.com
Wed May 28 17:37:17 CEST 2014


Ah. Interesting. Good that error changes. So that was the problem before.

Now, can you check if your Freq matrices contain any NaN's
(isnan(freqAll))?  It can happen sometimes.

--
Regards,
Kousik Sarathy, S



On Wed, May 28, 2014 at 5:31 PM, Laura Rueda Delgado <
Laura.Rueda at faber.kuleuven.be> wrote:

>  Dear Kousik,
>
>
>
> I checked the labels and they were the same, except for whether they were
> in capital letters. So I added the following before ft_sourceanalysis:
>
>
>
> freqAll.label=cellfun(@upper, freqAll.label, 'UniformOutput', 0);
>
> freqAll.labelcmb=cellfun(@upper, freqAll.labelcmb, 'UniformOutput', 0);
>
>
>
> This way the labels of the elec structure and freqAll are in capital
> letters.
>
>
>
> And now I get a different error (although still within the function
> beamformer_dics):
>
>
>
> Error using svd
>
> Input to SVD must not contain NaN or Inf.
>
>
>
> Error in beamformer_dics>pinv (line 650)
>
>   [U,S,V] = svd(A,0);
>
>
>
> 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{:});
>
>
>
>
>
> What could it be?
>
>
>
> Best regards,
>
> Laura
>
>
>
> *From:* fieldtrip-bounces at science.ru.nl [mailto:
> fieldtrip-bounces at science.ru.nl] *On Behalf Of *kousik sarathy
> *Sent:* woensdag 28 mei 2014 17:10
>
> *To:* FieldTrip discussion list
> *Subject:* Re: [FieldTrip] Error in ft_sourceanalysis: DICS
>
>
>
> Hey Laura,
>
>
>
> I too had the same suggestion as Johanna's.
>
>
>
> Another thing to check would be if the labels that you used for the
> leadfield estimation are the same as the freq data. I guess FT at some
> point would also check this to extract the indices.
>
>
>   --
>
> Regards,
>
> Kousik Sarathy, S
>
>
>
>
>
> On Wed, May 28, 2014 at 4:51 PM, Laura Rueda Delgado <
> Laura.Rueda at faber.kuleuven.be> wrote:
>
> 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.
>
>
>
> 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
>
>
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
>
>
> _______________________________________________
> 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/409700f2/attachment-0002.html>


More information about the fieldtrip mailing list