[FieldTrip] DICS beamforming
Hussain, Sara (NIH/NINDS) [F]
sara.hussain at nih.gov
Thu Apr 16 20:56:25 CEST 2020
I wanted to follow up on this problem in case anyone else was having the same one. I had been following the “Localizing visual gamma and corticomuscular coherence” tutorial, where it stated that the inputs to ft_sourceanalysis should include your leadfield in cfg.sourcemodel. However, after some debugging it become apparent that this was not recognizing the leadfield, and that the leadfield should instead be specific in cfg.grid. This completely solves the problem – and may in fact be a version-related issue.
Hopefully this can help someone else avoid frustration upon encountering a similar error!
From: "Hussain, Sara (NIH/NINDS) [F]" <sara.hussain at nih.gov>
Reply-To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Date: Friday, April 10, 2020 at 2:28 PM
To: "fieldtrip at science.ru.nl" <fieldtrip at science.ru.nl>
Subject: [FieldTrip] DICS beamforming
Hi all –
I am trying to source localize some broadband oscillatory data using the ‘dics’ beamforming option, as documented in the tutorial “Localizing visual gamma and corticomuscular coherence.” I am currently using standard mri and segmentation via the fieldtrip templates, and generating a dipole grid with 500 dipoles using the ‘basedonvol’ approach. I then compute the leadfield based on the positions of these dipoles. Up to this point, everything seems ok and checks out during plotting. But when I try to run ft_sourceanalysis I am getting the following error:
Warning: dipole lies on boundary of volume model
> In inf_medium_leadfield (line 54)
In eeg_leadfieldb (line 92)
In ft_compute_leadfield (line 443)
In beamformer_dics (line 305)
In ft_sourceanalysis (line 674)
Error using svd
Input to SVD must not contain NaN or Inf.
Error in beamformer_dics>pinv (line 643)
[U,S,V] = svd(A,0);
Error in beamformer_dics (line 336)
filt = pinv(lf' * invCf * lf) * lf' * invCf; % Gross eqn. 3, use PINV/SVD
to cover rank deficient leadfield
Error in ft_sourceanalysis (line 674)
dip(i) = beamformer_dics(grid, sens, headmodel, [], squeeze_Cf, optarg{:});
I’ve seen this error asked in other threads but I’ve tried what those suggest with no luck. I’m assuming this has something to do with the fact that the dipoles aren’t fully embedded in the grey matter – but I’ve tried changing the inward shift parameter etc during grid generation and it hasn’t solved it. Any suggestions? Code is below..
===================
% housekeeping
clearvars
basedir='/net/nindsdirfs.ninds.nih.gov/ifs/shares/HCPS/';
addpath([basedir 'SaraHussain/Analysis_Tools/fieldtrip-20160718']);
ft_defaults;
% read standard mri
cd([basedir 'SaraHussain/Analysis_Tools/fieldtrip-20160718/template/headmodel']);
mri=load('standard_mri.mat');
mri=mri.mri;
% read standard segmentation
seg=load('standard_seg.mat');
seg=seg.mri;
% read standard headmodel
vol=load('standard_bem.mat'); %vol
vol=vol.vol;
% create sourcemodel/grid based on standard mri
cfg=[];
cfg.headmodel=vol;
cfg.moveinward=2;
cfg.grid.unit='mm';
grid=ft_prepare_sourcemodel(cfg);
% check segmentation
seg.transform=mri.transform;
seg.anatomy=mri.anatomy;
cfg=[];
cfg.funparameter='gray';
ft_sourceplot(cfg,seg);
pause; close all;
% check volume conduction model
figure; ft_plot_mesh(vol.bnd(3),'facecolor','none'); %brain
figure; ft_plot_mesh(vol.bnd(2),'facecolor','none'); %skull
figure; ft_plot_mesh(vol.bnd(1),'facecolor','none'); %scalp
pause; close all;
% check electrode positions
figure;
elec=ft_read_sens('standard_1005.elc','senstype','eeg');
ft_plot_mesh(vol.bnd(3),'edgecolor','none','facecolor',[0.2 0.2 0.2],'facealpha',0.4,'edgecolor','none','edgealpha',0.05); hold on;
ft_plot_mesh(vol.bnd(2),'edgecolor','none','facealpha',0.4);
ft_plot_mesh(vol.bnd(1),'edgecolor','none','facecolor',[0.4 0.6 0.4]);
ft_plot_sens(elec,'label','yes');
pause; close all
% check grid position
figure;
ft_plot_mesh(vol.bnd(3),'edgecolor','none'); hold on; alpha 0.4; %brain
ft_plot_mesh(grid.pos(grid.inside,:));
pause; close all;
% load data
cd([basedir 'SaraHussain/SS_42H_63/clean_tep_data']);
load([peak_subj{jjj} '_double_cleaned_peak.mat']);
% demean/detrend and update channel names
cfg=[];
cfg.demean='yes';
cfg.detrend='yes';
data=ft_preprocessing(cfg,clean_data);
data.label=labels;
% select relevant post-stim latencies and channels
cfg=[];
short=ft_selectdata(cfg,data);
% calculate post-stim frequency using mtmfft approach
cfg=[];
cfg.method='mtmfft';
cfg.output='powandcsd';
cfg.tapsmofrq=48;
cfg.foi=52;
peak=ft_freqanalysis(cfg,short);
% create leadfield
cfg=[];
cfg.headmodel=vol;
cfg.grid.pos=grid.pos;
cfg.grid.inside=grid.inside;
cfg.elec=elec;
lead=ft_prepare_leadfield(cfg,peak);
% get source localized data
cfg=[];
cfg.elec=elec;
cfg.method='dics';
cfg.sourcemodel=lead;
cfg.headmodel=vol;
source_peak=ft_sourceanalysis(cfg,peak);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200416/753f1cea/attachment.htm>
More information about the fieldtrip
mailing list