<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="">
thank Jan-Mathijs for your addition. I was counting on you…
<div class=""><br class="">
</div>
<div class="">Cheers,</div>
<div class="">Thom<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 2 May 2024, at 21:13, Schoffelen, J.M. (Jan Mathijs) 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 style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Dear Thom and Sara,
<div class=""><br class="">
</div>
<div class="">Thanks to Thom’s cue ("As I don’t know exactly how that program is used within ft_dipolefitting, somebody might feel the need to comment to my answers”) I thought that I should raise to the bait. </div>
<div class=""><br class="">
</div>
<div class="">The underlying program dipoli is used in FieldTrip as one of the methods to do forward computations, i.e. to estimate the spatial fingerprint (of a potential distribution) due to a dipolar source, defined by its parameters (location [+dipole moment]).
 As such the dipoli routine is not used for the inverse modelling, i.e. the procedure that is used to create a model that best explains a given data topography (where best explains indeed means the lowest L2 norm of the difference between observation and model).
 The non-linear search is performed by MATLAB’s optimization tools, which can be defined by the user (low-level options, typically not used by the non-super-duper-expert user) to be @fminsearch, or @fminunc, as is (to be honest) also explicitly mentioned in
 the help-section of ft_dipolefitting. If you are interested in the gory details of how exactly the minimization is done, you would need to consult the documentation of those functions.</div>
<div class="">Now, with respect to your question about the ‘area in which it will do the (grid) search’: if you use a gridsearch with a grid that is automagically constructed by a cfg.sourcemodel.resolution (please look up the previous thread where you asked
 about dipolefitting) option, the boundary of the grid is determined by the inner boundary of the volume conduction model. The non-linear search will not be constrained in space, unless you specify the cfg.dipolefit.checkinside option accordingly.</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>
<div class=""><br class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On 2 May 2024, at 10:24, Oostendorp, T.F. (Thom) 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 style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Dear Sara,
<div class=""><br class="">
</div>
<div class="">As I am the author of the underlying program dipoli that is called by ft_dipolefitting,  I think that I can answer your questions. As I don’t know exactly how that program is used within ft_dipolefitting, somebody might feel the need to comment
 to my answers.</div>
<div class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On 1 May 2024, at 17:01, Sara Cinelli 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="">Hello, <br class="">
<div class="">I'm writing you because I would like to better understand the the function for the inverse modeling (ft_dipolefitting). Here are some questions I have:</div>
<div class="">1. how much is big the grid search that the function can do at the start before the non linear search? For example, if  I specified the location of the source using the cfg.sourcemodel, how big will be the area in which it will do the grid search?</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">There is no “search grid” in ft_dipolefitting. Dipoli will not just allow a limited number of source locations, it searches the continuous space. There are some limitations: by default, the dipole location is constrained to the compartment in
 which the initial estimate you provide resides. Dipoli allows some other constraining methods: </div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "DejaVu Sans Mono";" class="">
<span style="font-variant-ligatures: no-common-ligatures" class="">Control options:</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "DejaVu Sans Mono";" class="">
<span style="font-variant-ligatures: no-common-ligatures" class="">-d [<value>]  Constrain dipoles to remain at such a distance from the</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "DejaVu Sans Mono";" class="">
<span style="font-variant-ligatures: no-common-ligatures" class="">              interfaces that the variation of 1/r^2 over any triangle</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "DejaVu Sans Mono";" class="">
<span style="font-variant-ligatures: no-common-ligatures" class="">              is less than <value>% (r is the distance from the source</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "DejaVu Sans Mono";" class="">
<span style="font-variant-ligatures: no-common-ligatures" class="">              to the surface). The default value of the criterion is 50%</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "DejaVu Sans Mono";" class="">
<span style="font-variant-ligatures: no-common-ligatures" class="">-f            Normally the sources are constrained to remain in the</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "DejaVu Sans Mono";" class="">
<span style="font-variant-ligatures: no-common-ligatures" class="">              compartment where they are in the initial estimate.</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 13px; line-height: normal; font-family: "DejaVu Sans Mono";" class="">
<span style="font-variant-ligatures: no-common-ligatures" class="">              This options lifts that constraint</span></div>
</div>
<div class=""><br class="">
</div>
The first one served to keep the dipole away from the boundary in order to prevent numerical problems. I’m not sure whether ft_dipolefitting lets you set these options.</div>
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div class="">aldo, the algorithm which is used here is just the minimization of the L2 norm?</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">Yes, it is, with the constraints mentioned above.</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div class="">2. the method for the non linear search is the gradient descent method, is it correct?</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">No, it is essentially the Marquard method, which combines steepest decent and pseudo-Newton. See T. Oostendorp and A. van Oosterom: Source Parameter Estimation in Inhomogeneous Volume Conductors of Arbitrary Shape. IEEE TRANSACTIONS ON BIOMEDICAL
 ENGINEERING, VOL. 36. NO. 3. MARCH 1989.</div>
<div class=""><br class="">
</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div class="">3. I see the possibility to choose between a 'moving' model and a 'regional' one. Is it possible to keep fixed both locations and amplitude, so the algorithm changes only the strength of the dipole?</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">Actually, the choice is between:</div>
<div class="">- a moving dipole, i.e. at each sample time a new location is fitted</div>
<div class="">- stationary dipole location and  free orientation, i.e. the best single position is fitted, but dipole orientation is free at each sample time</div>
<div class="">
<div class="">- stationary dipole location and stationary orientation, i.e. both location at orientation are fixed in time</div>
<div class=""><br class="">
</div>
<div class="">I am nog quite sure what you mean with "keep fixed both locations and amplitude, so the algorithm changes only the strength of the dipole”. Fixed amplitude and changing the strength sound opposed to me.</div>
<div class=""><br class="">
</div>
<div class="">Cheers,</div>
<div class="">Thom</div>
<div class=""><br class="">
</div>
</div>
</div>
<div class="">
<div class="">--<br class="">
dr. T.F. Oostendorp          東村      205 Dept. of Cognitive Neuroscience<br class="">
route 200, room 02.282                Donders Center for Medical Neuroscience<br class="">
phone: +31 24 3614240               Radboud University Medical Center<br class="">
Kapittelweg 29                              6525 EN Nijmegen, the Netherlands<br class="">
</div>
<div class=""><br class="">
</div>
<br class="Apple-interchange-newline">
</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%7Ce62a964b46514092871908dc6b582205%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638503273467548153%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=%2BJGzwebItQMCQ1myI08%2FMRlNewR6IcMY31IrAgXlaPY%3D&reserved=0" originalsrc="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" shash="oDhMlwM5QM46ow/mpMImyJD5AW8+E1kJQkhkt/GG0x+0D377CC1NIQ0XUDjoL1ufuFvOubQimtJfLA+z7YNW52aXHqSR0k5rFBvQzQ0tcDd0vAiXOxeG8u3FDjTb01xgnlorQOIf05TRzTrgZDpZrbyJVGWgOgzfrejFajPBWhM=" originalsrc="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" shash="DOFzI64Yan+tpxq74U94tuHJQtUHpnzh+VVdvnM24x6AAbj8fduOdxrbcWDPr8HX/EujQm9FZx3Q+GQvNOsm72LpxyNupPfZG9SjBoT4yVHbbWfN5HcWhQBUW0A74Slcj1qzLZ5+E57I1N4NKHSo9G7ZhUh8qtt6LLXagqiqW4Q=" 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%7Ce62a964b46514092871908dc6b582205%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638503273467704407%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=8WOU8Ow2LxLgQ4dRAOJlCAx0tPAchrJwU9QZXKFx8Fc%3D&reserved=0" originalsrc="https://doi.org/10.1371/journal.pcbi.1002202" shash="AgDJ072Op73P1cqAz0p6tyFM9H7y4aaZBkNQ4DgTvY4wGePDA8kkwOTf2l5mTolCQcERctuWDSNmCdW72kQvfd0Eg6DDKCDWjz+Cuk/vmB0qZC7BrVnclPLkWkZTumEfL081Hht/0NyEu3gUk7+g3TbortRrAPhGxTFrByytA14=" 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%7Ce62a964b46514092871908dc6b582205%7C084578d9400d4a5aa7c7e76ca47af400%7C1%7C0%7C638503273467704407%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=T23EAJQcmSFjxu%2F2Y6lRhsjiW7%2Fgq2YLMijyfvEouAE%3D&reserved=0" originalsrc="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" shash="aT2U3WujNbXo6gV4rP565mtB+vEVYW9oAIeZ//lpSZETgvWztwZczbDqvR4LJ3n3+SbfLvoTgcW+IHhOfWR7ckUVesseHM48AZ8L1v1ImgpAiD059bjiH+qPMLQ1nVjyIv/CHBGndGqsdHy6FgM/nYE7fV6e0raZuqGQE0nHpN8=" 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 class="">
<div>--<br class="">
dr. T.F. Oostendorp          東村      205 Dept. of Cognitive Neuroscience<br class="">
route 200, room 02.282                Donders Center for Medical Neuroscience<br class="">
phone: +31 24 3614240               Radboud University Medical Center<br class="">
Kapittelweg 29                              6525 EN Nijmegen, the Netherlands<br class="">
</div>
<div class=""><br class="">
</div>
<br class="Apple-interchange-newline">
</div>
<br class="">
</div>
</body>
</html>