<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Dear <span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 15px;">Chengyuan, </span></p>
<p><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 15px;"><br>
</span></p>
<p><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 15px;">Thank you so much for your detailed response. I came across a few similar discussions and solution
suggestions. Apparently, none of them works for my case. Setting up 'openmeeg' seems to be one possible option. </span></p>
<p><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 15px;"><br>
</span></p>
<p><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 15px;">I still could not understand, why 'bemcp' method generates 'NaN's. </span></p>
<p><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 15px;"><br>
</span></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size: 15px;">Thank you very much once again for your suggestions. </span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size: 15px;"><br>
</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size: 15px;">I would appreciate any other comments.</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size: 15px;"><br>
</span></font></p>
<p><font color="#212121" face="wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif, serif, EmojiFont"><span style="font-size: 15px;"></p>
<div style="font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
<font face="Calibri,Helvetica,sans-serif,serif,EmojiFont" size="2"><span style="font-size: 16px;">Dr. Andac Topkan</span></font></div>
<div style="font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
<font face="Calibri,Helvetica,sans-serif,serif,EmojiFont" size="2"><span style="font-size: 16px;">University of Leipzig</span></font></div>
<div style="font-family: Calibri, Helvetica, sans-serif, serif, EmojiFont; font-size: 16px; margin-top: 0px; margin-bottom: 0px;">
<font face="Calibri,Helvetica,sans-serif,serif,EmojiFont" size="2"><span style="font-size: 16px;">Department of Neurology</span></font></div>
<br>
</span></font>
<p></p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> fieldtrip <fieldtrip-bounces@science.ru.nl> on behalf of 二姬 via fieldtrip <fieldtrip@science.ru.nl><br>
<b>Sent:</b> Sunday, February 18, 2024 8:41:01 AM<br>
<b>To:</b> FieldTrip discussion list<br>
<b>Cc:</b> 二姬<br>
<b>Subject:</b> Re: [FieldTrip] Leadfield computation generates NaNs</font>
<div> </div>
</div>
<div>
<div style="background-color:#FFEB9C; width:100%; border-style: solid; border-color:#9C6500; border-width:1pt; padding:2pt; font-size:10pt; line-height:12pt; font-family:'Calibri'; color:Black; text-align: left;">
<span style="color:#9C6500; font-weight:bold;">WARNUNG:</span> Diese E-Mail kam von außerhalb der Organisation. Klicken Sie nicht auf Links oder öffnen Sie keine Anhänge, es sei denn, Sie kennen den Absender und wissen, dass der Inhalt sicher ist.
</div>
<br>
<div>
<div dir="ltr">Dear Andac Topkan,<br>
<br>
I came across your query regarding the computation of leadfields resulting in NaNs for most participants. While I am not an expert in leadfield computation myself, I recall encountering a similar discussion that might shed some light on the issue.<br>
<br>
It has been noted that using the 'bemcp' method for leadfield computation could potentially lead to the generation of NaNs due to inherent algorithmic characteristics. A commonly suggested workaround is to explore alternative methods. For instance, the 'dipoli'
method is highly recommended, albeit with the caveat that it requires a Linux environment and administrator permissions to run successfully.<br>
<br>
Alternatively, the 'openmeeg' method presents another viable option, compatible with Windows systems. However, it's worth mentioning that setting up 'openmeeg' can be somewhat complex, and the available documentation might not provide the clarity needed for
a straightforward installation.<br>
<br>
If these methods do not offer a viable solution, you might consider utilizing Brainstorm. Brainstorm is known for its user-friendly, visual, and automated approach to source modeling, which could potentially circumvent the problem you're facing.<br>
<br>
I hope this information proves helpful.
<div><br>
Best wishes in your research endeavors,<br>
<br>
Chengyuan Wu<br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">Topkan, Tugberk via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl">fieldtrip@science.ru.nl</a>> 于2024年2月18日周日 13:44写道:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="msg-3914343493346979963">
<div dir="ltr">
<div id="m_-3914343493346979963divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p>Dear Fieldtrip experts, </p>
<p><br>
</p>
<p>I am currently trying to carry out source localization of EEG oscillations of a dataset. Although computation of leadfields of some participants seems fine, the computations of most participants generate only NaNs in leadfield matrices. I took a look at
the previous messages and saw that many researchers also experienced the same problem, but could not find any relevant solution. </p>
<p><br>
</p>
<p>I would really appreciate it, if the experts with more experience on it could guide me to solve this problem.</p>
<p><br>
</p>
<p>Here is the code I currently use. </p>
<p><br>
</p>
<p></p>
<div>ft_defaults;</div>
<div>mri = ft_read_mri('f73.nii');</div>
<div><br>
</div>
<div>ft_determine_coordsys(mri)</div>
<div>cfg = [];</div>
<div>cfg.method = 'interactive'</div>
<div>[mri] = ft_volumerealign(cfg, mri);</div>
<div>save mri mri</div>
<div><br>
</div>
<div><br>
</div>
<div><span style="font-size:12pt">cfg = [];</span><br>
</div>
<div>cfg.output = {'brain','skull','scalp'};</div>
<div>cfg.scalpthreshold = 0.05;</div>
<div><span style="font-size:12pt">segmentedmri = ft_volumesegment(cfg, mri);</span><br>
</div>
<div>save segmentedmri segmentedmri</div>
<div><br>
</div>
<div><span style="font-size:12pt">cfg = [];</span><br>
</div>
<div>cfg.tissue = {'brain','skull','scalp'};</div>
<div>cfg.numvertices = [3000 2000 1000];</div>
<div>bnd = ft_prepare_mesh(cfg,segmentedmri);</div>
<div>save bnd bnd</div>
<div></div>
<div><br>
</div>
<div>cfg = [];</div>
<div>cfg.method = 'bemcp'; </div>
<div>vol = ft_prepare_headmodel(cfg, bnd);</div>
<div>save vol vol</div>
<div><br>
</div>
<div>cfg = [];</div>
<div>cfg.tissue = 'scalp';</div>
<div>cfg.numvertices = 10000;</div>
<div>scalp = ft_prepare_mesh(cfg, segmentedmri);</div>
<div>save scalp scalp</div>
<div></div>
<div><br>
</div>
<div>%get elec info</div>
<div>load(fullfile(current_dir,'elec_template.mat'));</div>
<div>elec = ft_determine_coordsys(elec)</div>
<div></div>
<div><br>
</div>
<div>% markerpos = table2cell(readtable(['load(fullfile('C:\Users\......',['elec_template.mat']));marker_positions_' subj '.csv']));</div>
<div>% markerpos = table2cell(readtable(['marker_positions_P30.csv']));</div>
<div>markerpos = table2cell(readtable(['D:......\',[subj '.csv']]));</div>
<div>%%% align the electrodes %%%</div>
<div>for i = 1:length(markerpos)</div>
<div> elec.label{i} = char(markerpos{i,2});</div>
<div> elec.elecpos(i,:) = cell2mat(markerpos(i,3:5));</div>
<div> elec.chanunit{i} = 'V';</div>
<div> elec.chantype{i} = 'eeg';</div>
<div>end</div>
<div>elec.chanpos = elec.elecpos;</div>
<div><br>
</div>
<div></div>
<div><br>
</div>
<div>nas = mri.cfg.fiducial.nas;</div>
<div>lpa = mri.cfg.fiducial.lpa;</div>
<div>rpa = mri.cfg.fiducial.rpa;</div>
<div><br>
</div>
<div>transm = mri.transform;</div>
<div><br>
</div>
<div>nas = ft_warp_apply(transm,nas, 'homogenous');</div>
<div>lpa = ft_warp_apply(transm,lpa, 'homogenous');</div>
<div>rpa = ft_warp_apply(transm,rpa, 'homogenous');</div>
<div><br>
</div>
<div>% create a structure similar to a template set of electrodes</div>
<div>fid.elecpos = [nas; lpa; rpa]; % ctf-coordinates of fiducials</div>
<div>fid.label = {'nasion','Left Tragus','Right Tragus'}; % same labels as in elec</div>
<div>fid.unit = 'mm'; % same units as mri</div>
<div><br>
</div>
<div>% alignment</div>
<div>cfg = [];</div>
<div>cfg.method = 'fiducial';</div>
<div><span style="font-size:12pt">cfg.target = fid; % see above</span><br>
</div>
<div>cfg.elec = elec;</div>
<div>cfg.headshape = vol; %scalp</div>
<div>cfg.fiducial = {'nasion','Left Tragus','Right Tragus'}; % labels of fiducials in fid and in elec</div>
<div>elec_aligned = ft_electroderealign(cfg);</div>
<div></div>
<div><br>
</div>
<div>cfg = [];</div>
<div>cfg.method = 'interactive';</div>
<div>cfg.elec = elec_aligned;</div>
<div>cfg.headshape = vol.bnd(3);</div>
<div>elec_aligned = ft_electroderealign(cfg);</div>
<div><br>
</div>
<div>save elec_aligned elec_aligned</div>
<div><br>
</div>
<div>% Create the sourcemodel</div>
<div>cfg = [];</div>
<div>cfg.resolution = 7.5;</div>
<div>cfg.threshold = 0.1;</div>
<div>cfg.smooth = 5;</div>
<div>cfg.headmodel = vol;</div>
<div><span style="font-size:12pt">sourcemodel = ft_prepare_sourcemodel(cfg);</span><br>
</div>
<div><br>
</div>
<div>% Compute the leadfield</div>
<div>cfg = [];</div>
<div>cfg.sourcemodel = sourcemodel;</div>
<div>cfg.headmodel = vol;</div>
<div>cfg.elec = elec_aligned;</div>
<div></div>
<div>cfg.channel = {'all','-AFz','-M1','-M2','-nasion','-Left Eye','-Right Eye','-Left Tragus','-Right Tragus','-nose tip','-chin tip'};</div>
<div>cfg.reducerank = 3;</div>
<div>grid = ft_prepare_leadfield(cfg);</div>
<div><br>
</div>
<div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont;font-size:16px;margin-top:0px;margin-bottom:0px">
Thanks in advance,</div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont;font-size:16px;margin-top:0px;margin-bottom:0px">
Andac Topkan</div>
<div style="font-family:Calibri,Helvetica,sans-serif,serif,EmojiFont;font-size:16px;margin-top:0px;margin-bottom:0px">
University of Leipzig</div>
<br>
</div>
<p></p>
</div>
</div>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
<a href="https://doi.org/10.1371/journal.pcbi.1002202" rel="noreferrer" target="_blank">https://doi.org/10.1371/journal.pcbi.1002202</a><br>
</div>
</blockquote>
</div>
</div>
</div>
</body>
</html>