<div dir="ltr"><div><div><div><div><div><div>Dear Kastouri,<br><br></div>My hunch is that either ft_prepare_headmodel or ft_prepare_leadfield fail in generating a proper forward model for localization purposes.<br></div>I would check that ft_prepare_headmodel's vol structure contains sensible data by plotting both the 'bnd' triangulated surface and the EEG electrodes together (you should be able to find instructions on the wiki) in the same image. Sometimes units (mm,cm) or coregistration (left/right swap) might influence a good outcome.<br></div>Accordingly the grid.leadfield structure will not make sense because it uses the incorrect outcome of the vol structure.<br><br></div>So if you manage to solve the 1st problem you'll kill two bird with a stone<br></div>Good luck!<br></div>Cris<br><div><div><div><div><br><br><br><br></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 31, 2017 at 12:50 PM, Kasturi Barik <span dir="ltr"><<a href="mailto:kash.kgp@gmail.com" target="_blank">kash.kgp@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr"><pre style="white-space:pre-wrap"><i style="color:rgb(0,0,0)">Dear all,
</i><i style="color:rgb(0,0,0)">
</i><i style="color:rgb(0,0,0)">I am trying to perform source localization in the frequency domain </i></pre><pre style="white-space:pre-wrap"><i style="color:rgb(0,0,0)">from EEG data using 'DICS' . As I have no mri data of the participants, </i></pre><pre style="white-space:pre-wrap"><i style="color:rgb(0,0,0)">I am using </i><font color="#000000"><i>'Subject01.mri' to read the anatomical data with ft_read_mri. </i></font></pre><pre style="white-space:pre-wrap"><font color="#000000"><i>The </i></font><i>head model created with 'bemcp'.</i></pre><pre style="white-space:pre-wrap"><i style="color:rgb(0,0,0)">Code:</i></pre><pre style="white-space:pre-wrap"><font face="arial, helvetica, sans-serif"><i style="color:rgb(0,0,0)">%% </i><font color="#000000"><i>Read the anatomical data</i></font></font></pre><pre style="white-space:pre-wrap"><i style="font-family:arial,sans-serif"><font color="#000000"><font face="arial, helvetica, sans-serif">mri = ft_read_mri('Subject01.mri');</font></font></i></pre><pre style="white-space:pre-wrap"><font face="arial, helvetica, sans-serif"><i style="color:rgb(0,0,0)">%% </i></font><font face="arial, helvetica, sans-serif" color="#000000"><i>Segment the anatomical information & triangulate the surfaces</i></font></pre><div style="font-size:12.8px"><i><font color="#000000">load segmentedmri % load from </font></i><a href="ftp://ftp.fieldtriptoolbox.org/pub/fieldtrip/tutorial/headmodel_eeg/segmentedmri.mat" class="m_3169683296666377404m_-8657161844681314279gmail-m_8088325427694831497gmail-urlextern" title="ftp://ftp.fieldtriptoolbox.org/pub/fieldtrip/tutorial/headmodel_eeg/segmentedmri.mat" rel="nofollow" style="color:rgb(51,153,243);box-sizing:border-box;background-color:transparent;outline:0px;background-repeat:no-repeat;background-position:0px 50%;padding:0px 0px 0px 18px;background-image:url("");font-family:"Open Sans","Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;text-align:justify" target="_blank">ftp server</a><span style="color:rgb(102,102,102);font-family:"Open Sans","Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;text-align:justify;background-color:rgb(255,255,204)"> (segmentedmri.mat).</span><i><br></i></div><div style="font-size:12.8px"><i><font color="#000000">load bnd</font></i></div><div style="font-size:12.8px"><i><font color="#000000"><br></font></i></div><div style="font-size:12.8px"><i><font color="#000000">%% </font></i><font color="#000000"><i>Create the headmodel</i></font></div><div style="font-size:12.8px"><i><font color="#000000"><div>cfg = [];</div><div>cfg.method = 'bemcp'; </div><div>vol = ft_prepare_headmodel(cfg, bnd);</div><div><br></div><div>%% Position of the electrodes<br></div><div><div><i style="color:rgb(34,34,34)"><font color="#000000"><div style="display:inline"><div style="display:inline">load('Face_sub.mat'); % data of participants' electrode positions</div> </div></font></i><br></div><div>electrodes = Face_sub.elec;</div></div><div><br></div><div>%% Interactive alignment<br></div><div><div>cfg = [];</div><div>cfg.method = 'interactive';</div><div>cfg.elec = electrodes;</div><div>cfg.headshape = vol.bnd(3); % scalp</div><div>elec_aligned = ft_electroderealign(cfg);</div><div><br></div><div>%% Compute leadfield:<br></div><div><div>cfg = [];</div><div>cfg.elec = elec_aligned;</div><div>cfg.vol = vol;</div><div>cfg.channel = {'EEG'};</div><div>[grid] = ft_prepare_leadfield(cfg);</div></div></div><div><br></div><div><div>%% Source Analysis</div><div>cfg = []; </div><div>cfg.method = 'dics';</div><div>cfg.frequency = 10; </div><div>cfg.grid = grid;</div><div>cfg.vol = vol;</div><div>cfg.dics.projectnoise = 'yes';</div><div>cfg.dics.lambda = 0;</div><div>sourceFace = ft_sourceanalysis(cfg, face_data); % face_data is obtained from the FT_FREQANALYSIS % <i><font color="#000000"> <div style="display:inline"><div style="display:inline"> </div></div></font></i></div><div><i><font color="#000000"><div style="display:inline"><div style="display:inline"><br></div></div></font></i></div><div><i><font color="#000000"><div style="display:inline"><div style="display:inline">[%% time frequency analysis </div> </div></font></i><i style="color:rgb(34,34,34)"><font color="#000000"><div style="display:inline"><i style="color:rgb(34,34,34)"><font color="#000000">|</font></i></div></font></i></div><div>| cfg = []; <i style="color:rgb(34,34,34)"><font color="#000000"> <div style="display:inline"><i style="color:rgb(34,34,34)"><font color="#000000">|</font></i></div></font></i></div><div><i style="color:rgb(34,34,34)"><font color="#000000"><div style="display:inline"><i style="color:rgb(34,34,34)"><font color="#000000">|</font></i></div> </font></i> cfg.channel = 'EEG'; <i style="color:rgb(34,34,34)"><font color="#000000"> <div style="display:inline"><i style="color:rgb(34,34,34)"><font color="#000000">|</font></i></div></font></i></div><div><i style="color:rgb(34,34,34)"><font color="#000000"><div style="display:inline"><i style="color:rgb(34,34,34)"><font color="#000000">|</font></i></div> </font></i><i style="color:rgb(34,34,34)"><font color="#000000"><div style="display:inline"><div style="display:inline"> cfg.method = 'mtmfft'; </div> </div></font></i><i style="color:rgb(34,34,34)"><font color="#000000"><div style="display:inline"><i style="color:rgb(34,34,34)"><font color="#000000">|</font></i></div></font></i></div><div><i style="color:rgb(34,34,34)"><font color="#000000"><div style="display:inline"><i style="color:rgb(34,34,34)"><font color="#000000">|</font></i></div> </font></i> cfg.output = 'powandcsd'; <i style="color:rgb(34,34,34)"><font color="#000000"> <div style="display:inline"><i style="color:rgb(34,34,34)"><font color="#000000">|</font></i></div></font></i></div><div><i style="color:rgb(34,34,34)"><font color="#000000"><div style="display:inline"><i style="color:rgb(34,34,34)"><font color="#000000">|</font></i></div> </font></i> cfg.tapsmofrq = 4; <i style="color:rgb(34,34,34)"><font color="#000000"> <div style="display:inline"><i style="color:rgb(34,34,34)"><font color="#000000">|</font></i></div></font></i></div><div><i style="color:rgb(34,34,34)"><font color="#000000"><div style="display:inline"><i style="color:rgb(34,34,34)"><font color="#000000">|</font></i></div> </font></i> cfg.foi = 1:1:40; <i style="color:rgb(34,34,34)"><font color="#000000"> <div style="display:inline"><i style="color:rgb(34,34,34)"><font color="#000000">|</font></i></div></font></i></div><div><i style="color:rgb(34,34,34)"><font color="#000000"><div style="display:inline"><i style="color:rgb(34,34,34)"><font color="#000000">|</font></i></div> </font></i> face_data = ft_freqanalysis(cfg, Face_sub); ]</div></div></font></i></div><pre style="white-space:pre-wrap"><i style="color:rgb(0,0,0)">When running DICS with these settings </i><i style="color:rgb(0,0,0)">I am getting the following error message:</i></pre><pre style="white-space:pre-wrap"><i><font color="#000000">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 568)
dip(i) = beamformer_dics(grid, sens, vol, [],
squeeze(Cf(i,:,:)), optarg{:});
Error in SourceAnalysis (line 133)
sourceFace = ft_sourceanalysis(cfg, face_data);<br></font></i></pre><div style="font-size:12.8px"><br></div><div style="font-size:12.8px"><pre style="white-space:pre-wrap"><i><font color="#000000"> I am not able to detect, where is the problem. Another issue I have found that 'vol.mat' or 'grid.leadfield' are all NaN value. I cannot understand how to solve it. I would be very thankful if you can help me in this regard. </font></i></pre></div><span class="HOEnZb"><font color="#888888"><span class="m_3169683296666377404HOEnZb"><font color="#888888"><br><div><br></div></font></span></font></span></div></div><span class="HOEnZb"><font color="#888888"><br clear="all"><div><br></div>-- <br><div class="m_3169683296666377404gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">Thanks & Regards<div><br></div><div><font color="#0000ff"><b>Kasturi Barik</b></font><br><div><b><br></b></div><div><span style="color:rgb(102,0,204);font-family:tahoma,sans-serif">MS Research Scholar</span><br style="color:rgb(102,0,204);font-family:tahoma,sans-serif"><span style="color:rgb(102,0,204);font-family:tahoma,sans-serif">Audio and Bio-signal Processing Lab</span><br style="color:rgb(102,0,204);font-family:tahoma,sans-serif"><span style="color:rgb(102,0,204);font-family:tahoma,sans-serif">Department of Electronics and Electrical Engineering</span><br style="color:rgb(102,0,204);font-family:tahoma,sans-serif"><span style="color:rgb(102,0,204);font-family:tahoma,sans-serif">Indian Institute of Technology Kharagpur</span><br style="color:rgb(102,0,204);font-family:tahoma,sans-serif"><span style="color:rgb(102,0,204);font-family:tahoma,sans-serif">Mob: <a href="tel:+91%2089024%2000644" value="+918902400644" target="_blank">+91-8902400644</a></span><b><br></b></div></div></div></div></div></div>
</font></span></div>
<br>______________________________<wbr>_________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">https://mailman.science.ru.nl/<wbr>mailman/listinfo/fieldtrip</a><br></blockquote></div><br></div>