<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Dear Jeff,<div><br></div><div>From what you describe I don't really know what's going wrong. Are you using the headsurface file generated with the polhemus? It could be that this causes the problem. For the singleshell model to work, you need a triangulated surface. The headsurface file contains only a point cloud. Matlab tries to create a triangulation from this point cloud, and I could imagine that this triangulation misbehaves here, leading some nans here and there (judging from your message this happens when the normals to the triangles are computed), which eventually cause nans all over the place. For the time being you could try to use a different volume conductor model (localspheres), or you may want to use a structural MRI for the singleshell creation (if available), to verify that the problem is caused by the headsurface file and not by fieldtrip.</div><div><br></div><div>Best,</div><div><br></div><div>Jan-Mathijs</div><div><br><div><div>On May 9, 2011, at 10:12 PM, Jeff Stout wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div><table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font: inherit; "><div id="yiv1429399256"><table cellspacing="0" cellpadding="0" border="0" id="yiv1429399256bodyDrftID" class="yiv1429399256"><tbody><tr><td id="yiv1429399256drftMsgContent" style="font: inherit; font-family: arial; font-size: 10pt; "><div id="yiv1429399256" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; ">Hi, </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; ">I am having trouble generating leadfields for source analysis. I am using data from a 4D magnetometer system (Magnes 3600), at St. Louis University.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; ">The data is averged time domain data. The volume conductor is a single shell model generated from the headshape file(~4000 vert. and 8000 triangles). I have vizualized the volume conductor, sensors, and "inside" grid and they appear to be in the correct locations relative to each other. I have performed this analysis using the default source space for 4D ('m') and I have tried it scaling the headshape and sensors into cm to conform with the ctf source space. Below is part of my code and the warning thrown by matlab. After the calculation of the leadfields, it is apparent that they are all NaN's, so I am unable to generate source activations.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">cfg = [];</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">cfg.headshape = shape;</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">shape.pnt = shape.pnt*100;</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">shape.unit = 'cm';</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">[vol,cfg] = ft_prepare_singleshell(cfg)</font></div></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">cfg = [];</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">cfg.grad = avg.grad; </font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">cfg.grad.pnt = cfg.grad.pnt*100;</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">cfg.grad.unit = 'cm';</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">cfg.vol = vol;</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">cfg.sourceunits = 'cm';</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">cfg.coordsys = 'ctf';</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">cfg.reducerank ='no'; </font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">cfg.channel = {'MEG'};</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">cfg.grid.resolution = 2</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">[vol, sens] = ft_prepare_vol_sens(vol, cfg.grad)</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">[grid] = ft_prepare_leadfield(cfg)</font><font class="yiv1429399256Apple-style-span" face="times, serif" size="3"> </font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">>> [grid] = ft_prepare_leadfield(cfg)</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">using headmodel specified in the configuration</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">using gradiometers specified in the configuration</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">computing surface normals</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">Warning: Matrix is singular, close to singular or badly scaled. <<<<<<<<<<</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif"> Results may be inaccurate. RCOND = NaN. </font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">> In forward/private/meg_ini>getcoeffs at 111</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif"> In forward/private/meg_ini at 53</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif"> In ft_prepare_vol_sens at 275</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif"> In fieldtrip-20110507/private/prepare_headmodel at 114</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif"> In ft_prepare_leadfield at 150</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">creating dipole grid based on automatic 3D grid with specified resolution</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">3528 dipoles inside, 0 dipoles outside brain</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">making tight grid</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">3528 dipoles inside, 0 dipoles outside brain</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">computing leadfield</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">computing leadfield 1/3528</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">computing leadfield 2/3528</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">computing leadfield 3/3528</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="yiv1429399256Apple-style-span" face="times, serif">computing leadfield 4/3528 ......</font></div></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; ">The leadfield data generated is a matrix of NaN's, which appear to be an issue when evaluating bas and gradbas in the get_coeffs subfunction <span class="yiv1429399256Apple-style-span" style="font-size: medium; ">[bas,gradbas]=legs(x1,n1,order,scale).</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; "><span class="yiv1429399256Apple-style-span" style="font-size: medium; "><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; "><span class="yiv1429399256Apple-style-span" style="font-size: medium; ">Does anyone know how to resolve this issue? Any help will be greatly appreciated.</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; "><span class="yiv1429399256Apple-style-span" style="font-size: medium; "><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; "><span class="yiv1429399256Apple-style-span" style="font-size: medium; ">Thanks,<br>Jeff Stout</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; "><span class="yiv1429399256Apple-style-span" style="font-size: medium; "><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; "><span class="yiv1429399256Apple-style-span" style="font-size: medium; "><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; "><span class="yiv1429399256Apple-style-span" style="font-size: medium; "><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; "><span class="yiv1429399256Apple-style-span" style="font-size: medium; "><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; "><span class="yiv1429399256Apple-style-span" style="font-size: medium; "><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; "><span class="yiv1429399256Apple-style-span" style="font-size: medium; "><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: times, serif; color: rgb(0, 0, 0); font-size: 12pt; "><font class="yiv1429399256Apple-style-span" face="'times new roman', 'new york', times, serif"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; color: rgb(0, 0, 0); font-family: times, serif; font-size: 12pt; "></div></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-size: 12pt; font-family: times, serif; "></div></div></div></td></tr></tbody></table></div></td></tr></tbody></table>_______________________________________________<br>fieldtrip mailing list<br><a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br><a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></div></span></blockquote></div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Dr. J.M. (Jan-Mathijs) Schoffelen </div><div>Donders Institute for Brain, Cognition and Behaviour, <br>Centre for Cognitive Neuroimaging,<br>Radboud University Nijmegen, The Netherlands</div><div><a href="mailto:J.Schoffelen@donders.ru.nl">J.Schoffelen@donders.ru.nl</a></div><div>Telephone: 0031-24-3614793</div></div></span></div></span> </div><br></div></body></html>