<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
OK, perhaps I was not clear enough in my earlier reply: if somehow in the underlying computations (i.e. in the creation of the sourcemodel) FieldTrip ends up with using ‘m’ as unit, then the sourcemodel will only have a single grid point. You should inspect
 the sourcemodel (after creating it with ft_prepare_sourcemodel), and only proceed if it contains a decent number of dipole positions (sourcemodel.pos), a large portion of which is in the ‘inside’ compartment (sourcemodel.inside). If this is not the case, you
 may want to change cfg.resolution into 0.01, rather than 1.
<div class=""><br class="">
</div>
<div class="">Good luck,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 17 May 2024, at 17:08, Alex Williams via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl" class="">fieldtrip@science.ru.nl</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">Hi Dr. Schofflen,
<div class=""><br class="">
</div>
<div class="">  Thanks so much for the response! I checked the metric units of the source model, head model and the grad parameter. All of them are in 'mm'. However, I ended up checking how SPM processed the meeg data and returned its D structure. It seems
 as though the grad parameter within the datareg subfield is in 'mm' but within the forward subfield of the SPM-processed structure, the grad parameter is in 'm'. The same goes for the vol parameter in the forward subfield (in 'm'). </div>
<div class=""><br class="">
</div>
<div class="">-Alex</div>
</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Fri, May 17, 2024 at 4:02 AM Schoffelen, J.M. (Jan Mathijs) via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl" class="">fieldtrip@science.ru.nl</a>> wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div style="overflow-wrap: break-word;" class=""> Hi Alex,
<div class=""><br class="">
</div>
<div class="">The first thing I would check, is whether the metric units of the sourcemodel/grad are as implicitly expected by you. The cfg.resolution argument before calling ft_prepare_sourcemodel is interpreted by ‘FieldTrip’ in the metric units that the
 primary geometric object is expressed in. I don’t know by heart which one of the geometric objects (in this case headmodel and grad) is primary in determing this (you need to read the code for that), but things might become strange if it actually is the grad,
 and if the grad is expressed in ‘m’. Because this would result in a 3D-grid with a 1 meter spacing between dipoles.</div>
<div class=""><br class="">
</div>
<div class="">Best wishes,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On 14 May 2024, at 17:15, Alex Williams via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl" target="_blank" class="">fieldtrip@science.ru.nl</a>> wrote:</div>
<br class="">
<div class="">
<div dir="ltr" class="">Hello there FieldTrip Community,
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">  I'm Alex Williams, a neuroengineering graduate student at Florida Institute of Technology. I'm relatively new to source reconstruction methods and was wondering if there may be any pointers or advice that may help guide me through the tutorials
 and documentation. I've been trying to resolve an issue with the beamformer for some time. Currently, I'm using an LCMV beamformer to source fit participant MEG data and compare those results to source results that were obtained in SPM12.  Though I'm trying
 to create a pipeline for analyzing this data set, the results I've obtained seem to have discrepancies in source variance and virtual channel signal alongside having warped sourceplots when plotting source variance.  The meeg data, D, I'm using has been converted
 from SPM to fieldtrip using the function. spm2fieldtrip(). The converted data itself has been defined, and has undergone pre-processing and time-locking in SPM. </div>
<div class=""><br class="">
</div>
<div class="">Steps I used: </div>
<div class=""><br class="">
</div>
<div class="">1. The converted meeg data, D, I'm using has been converted from SPM to fieldtrip using the function. spm2fieldtrip(). The converted data itself has been defined, and has undergone pre-processing and epoching in SPM. Since I wasn't able to find
 the covariance matrix within the D structure I was using, I applied a time-lock analysis to the D structure I had and used only the covariance matrix from those results as the cfg.cov parameter within the D matrix pre-time lock.</div>
<div class=""><br class="">
</div>
<div class="">2. ft_read_mri() used a .nifti MRI file and an empty configuration. Fiducials were taken and used in the configuration to realign the MRI using ft_volumerealign() with cfg.coordsys='neuromag'. After, segmentation was done using ft_volumesegment(),
 again with an empty configuration.</div>
<div class=""><br class="">
</div>
<div class="">3. Headmodel computed using following parameters:</div>
<div class="">
<div style="padding:30px" class="">
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg = [];</span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg.method = <span style="color:rgb(167,9,245)" class="">'singleshell'</span>;</span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg.siunits = <span style="color:rgb(167,9,245)" class="">'yes'</span>;</span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg.feedback = <span style="color:rgb(167,9,245)" class="">'yes'</span>;</span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">headmodel = ft_prepare_headmodel(cfg, seg);</span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">headmodel = ft_convert_units(headmodel, <span style="color:rgb(167,9,245)" class="">
'mm'</span>); </span></div>
</div>
</div>
<div class=""><br class="">
</div>
<div class="">3. Gradiometer array was defined with ft_read_sens using the path of the meeg file. These were the parameters of the source model. </div>
<div class=""><br class="">
</div>
<div class="">
<div style="padding:30px" class="">
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg = [];</span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg.grad = grad;</span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg.headmodel = headmodel;</span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg.resolution = 1; </span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg.inwardshift = 0; </span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">sourcemodel = ft_prepare_sourcemodel(cfg);</span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<br class="">
</div>
</div>
</div>
<div class="">
<div class="">Plotting leads to this segmented mri figure (segmented mri) and headmodel-sensor model (headmodel, sourcemodel mesh and sensor array)</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<span id="m_-8919956092895501424cid:ii_lw4bp42b1" class=""><image.png></span></div>
<div class=""><br class="">
</div>
<div class=""><span id="m_-8919956092895501424cid:ii_lw4bs7iv2" class=""><Screenshot 2024-05-12 at 10.08.53 PM.png></span><br class="">
<div class="">4. After the forward model was run with prepare_leadmatrix () with following parameters:<br class="">
</div>
<div class="">
<div style="padding:30px" class="">
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg = [];</span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg.grad = grad; </span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg.headmodel = headmodel; </span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg.sourcemodel = sourcemodel;</span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg.channel = {<span style="color:rgb(167,9,245)" class="">'MEG'</span>};</span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg.singleshell.batchsize = 2000;</span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">lf = ft_prepare_leadfield(cfg,D);</span></div>
</div>
</div>
<div class="">5. And then the source model was run using an LCMV beamformer:</div>
<div class="">
<div style="padding:30px" class="">
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<div style="padding:30px" class="">
<div class=""><span class=""><span style="color:rgb(14,0,255)" class="">if </span>
isfield(D,<span style="color:rgb(167,9,245)" class="">'cov'</span>)</span></div>
<div class=""><span class="">[~, sr, ~]=svd(D.cov);</span></div>
<div class=""><span class="">clif=-diff(log10(diag(sr)));</span></div>
<div class=""><span class="">kappa=find(clif==max(clif));</span></div>
<div class=""><span class=""><span style="color:rgb(14,0,255)" class="">end</span></span></div>
</div>
</div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg = [];</span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg.method = <span style="color:rgb(167,9,245)" class="">'lcmv'</span>;</span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg.headmodel = headmodel; <span style="color:rgb(0,128,19)" class="">
% volume conduction model (headmodel)</span></span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg.sourcemodel = lf; <span style="color:rgb(0,128,19)" class="">% leadfield</span></span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg.lcmv.keepfilter = <span style="color:rgb(167,9,245)" class="">
'yes'</span>;</span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg.grad=D.grad;</span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg.keepleadfield = <span style="color:rgb(167,9,245)" class="">'yes'</span>;</span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
<span class="">cfg.lcmv.fixedori = <span style="color:rgb(167,9,245)" class="">'yes'</span>;
<span style="color:rgb(0,128,19)" class="">% project on axis of most variance using SVD</span></span></div>
<div style="font-size:13px;font-family:Menlo,Monaco,Consolas,"Courier New",monospace" class="">
cfg.lcmv.kappa.      =kappa<span class="">;</span></div>
</div>
</div>
<div class="">Which returns a source structure that seems to produce warped source variance plots and blown-up source variance values after iusing source interpolation using:                 <span style="font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:13px" class="">ft_sourceinterpolate(cfg,
 source, segmentedmri): </span></div>
<div class=""><span style="font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:13px" class=""><br class="">
</span></div>
<div class=""><span id="m_-8919956092895501424cid:ii_lw4csqcw3" class=""><Screenshot 2024-05-12 at 10.37.15 PM.png></span><br class="">
</div>
<div class=""><br class="">
</div>
<span id="m_-8919956092895501424cid:ii_lw4d8ujl4" class=""><Screenshot 2024-05-12 at 10.49.16 PM.png></span><br class="">
<div class="">I'm currently trying different parameters within the beamformer including using different weight normalization parameters to compensate for possible depth bias alongside using different lambda values. However, based on the final source plots,
 I wasn't too sure if there may have also been an issue with the coregistration of the mri or perhaps with the final source model. <font color="#888888" class=""><br class="">
</font></div>
<font color="#888888" class="">
<div class=""><br class="">
</div>
<div class="">-Alex Williams</div>
</font></div>
</div>
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C85ab2667e0e040a532f808dc78cce55f%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638518068618062910%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=48hwqsGfv5Txiatz0PajXsYFerkho6mN9T6Z6smGCSE%3D&reserved=0" originalsrc="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" shash="kF9pePsO+ja4dnNjk3bMoVT1GnGCL1AnpcadRJg6eK85pD1+6AvKk8JvQNn5iiUCOlywn/RF8gJA2gIyUuqEqj18uzH2EOiU9jXiiYExsfG1EmRJWBtH9C2Iwfoj1QJvyBnU9kpkFT+6s4OKpp8HonGt+oWWlo4/1ogX47NL4Sw=" originalsrc="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" shash="AhD4APExgW4L3r2eMC3EmpTHtGEdj/gBRjeXFe6i6VIHD9rhy25a+pXSoU5BsQhZcUZmnrfEXUAXOdPmPj/vGdI/bM1W3HPkn/oVKm5i59Z9JKMraEd82IoTEd0+im8GpIa7JoLWL7Op2hpRJu1rxsJ/VkZlbbYtkmH9zTBLNOo=" target="_blank" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="">
<a href="https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C85ab2667e0e040a532f808dc78cce55f%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638518068618062910%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=iNFZMgmT%2BeH2tAqeiqVkSVhx5%2BNdqExo7CIqKKVCTJ8%3D&reserved=0" originalsrc="https://doi.org/10.1371/journal.pcbi.1002202" shash="Nr2Sk1LHo16xzTyxXQZNU16C6U/sPyMOfXWFz0alSDPymCtOUoDXLzji5HbzBDsdTiVUTSwMPtGHTKDLRZtpreSoqP8DlrdyXraytDEmiys6r/DQk+iSk9ebApV+fplxUPu2LMZyKg49JaWB0migNyM3SUAahk3fpPEpcR4TFvo=" originalsrc="https://doi.org/10.1371/journal.pcbi.1002202" shash="eS7wb/WCM4dFY5GCbg316hAwbZEhWC5+vPGRakm1F2d6CN/n90dx9XztGcENBpj/H2WrGmp7sydtlVAOO6CnsCRdowStzsWnJwF8Cze424HOqWp5D7WVnxP/Y69jc7vdbM2KTAqD7hXv5WqSAf83Ts47pDsrDA+rEWgV8zMxLuc=" target="_blank" class="">https://doi.org/10.1371/journal.pcbi.1002202</a><br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C85ab2667e0e040a532f808dc78cce55f%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638518068618062910%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=48hwqsGfv5Txiatz0PajXsYFerkho6mN9T6Z6smGCSE%3D&reserved=0" originalsrc="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" shash="kF9pePsO+ja4dnNjk3bMoVT1GnGCL1AnpcadRJg6eK85pD1+6AvKk8JvQNn5iiUCOlywn/RF8gJA2gIyUuqEqj18uzH2EOiU9jXiiYExsfG1EmRJWBtH9C2Iwfoj1QJvyBnU9kpkFT+6s4OKpp8HonGt+oWWlo4/1ogX47NL4Sw=" originalsrc="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" shash="ZcuvKtEuQ25wB2ZlzZrG0TjnuK1xX9qigJhtFbykSu48jBRGDYWwitZi819nzE//vgeK72Ra/BQWxkQN25jYMfEuwsZGkEHa2eZvv8girc74piwufLMOrwOPm6LDHfuVeQhjLjBEdgjs+4lD7ExgLfL1rAfUw8pnyfCXjLjLULs=" rel="noreferrer" target="_blank" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="">
<a href="https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdoi.org%2F10.1371%2Fjournal.pcbi.1002202&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C85ab2667e0e040a532f808dc78cce55f%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638518068618062910%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=iNFZMgmT%2BeH2tAqeiqVkSVhx5%2BNdqExo7CIqKKVCTJ8%3D&reserved=0" originalsrc="https://doi.org/10.1371/journal.pcbi.1002202" shash="Nr2Sk1LHo16xzTyxXQZNU16C6U/sPyMOfXWFz0alSDPymCtOUoDXLzji5HbzBDsdTiVUTSwMPtGHTKDLRZtpreSoqP8DlrdyXraytDEmiys6r/DQk+iSk9ebApV+fplxUPu2LMZyKg49JaWB0migNyM3SUAahk3fpPEpcR4TFvo=" originalsrc="https://doi.org/10.1371/journal.pcbi.1002202" shash="pBbNNjHFs6jfLdaKfGgfy5U2sDoosqV08lTGmHItUckz6bJQkvqWG76qfCBU8JZAN3cQZQjrLWI+Z9496bzZ3v8OCsQcxQDxWyFEP1Wv/uVhQopkWEYUBjpSoJAVpdb5Mpqr+qCl7Pioy7K6c8jb01YJ5YTxiNyqbDn/AUg+9Ps=" rel="noreferrer" target="_blank" class="">https://doi.org/10.1371/journal.pcbi.1002202</a><br class="">
</blockquote>
</div>
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmailman.science.ru.nl%2Fmailman%2Flistinfo%2Ffieldtrip&data=05%7C02%7Cfieldtrip%40science.ru.nl%7C85ab2667e0e040a532f808dc78cce55f%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638518068618062910%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=48hwqsGfv5Txiatz0PajXsYFerkho6mN9T6Z6smGCSE%3D&reserved=0" originalsrc="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" shash="kF9pePsO+ja4dnNjk3bMoVT1GnGCL1AnpcadRJg6eK85pD1+6AvKk8JvQNn5iiUCOlywn/RF8gJA2gIyUuqEqj18uzH2EOiU9jXiiYExsfG1EmRJWBtH9C2Iwfoj1QJvyBnU9kpkFT+6s4OKpp8HonGt+oWWlo4/1ogX47NL4Sw=" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="">
https://doi.org/10.1371/journal.pcbi.1002202<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>