For developer team: How is dipole fitting exactly performed?

Hi,

I have been exploring dipole fitting tutorials for a while now. I was curious to know how dipole is fitted on MNE. Lets say that I have my EEG recording with a certain event of interest ( spike), and that I want to fit a dipole in the brain based on that given spike. How does MNE fit dipoles in the source grids?

Does it first iterate the value of dipole amplitude in nAm or pAm and then proceeds with different orientations on source grids to compute the best goodness of fit, or does the process of searching for optimum amplitude and orientation (to explain the given event/spike ) happen at the same time?

My professor wanted me to work on something called Global Optimization where we search for the best fitting source grid location for dipole by varying amplitude and orientation in loops to compute the Goodness of fit for the given dipole. But I wanted to first check if this is the method already employed by MNE or not.

Could anyone from the developer team explain to me in detail how Dipole fitting is performed on MNE, and also if instead of getting just one dipole at location of best goodness of fit,*** is there a way that I can see the maximum values of goodness of fit for dipoles computed at each source grid locations*** ( best goodness of fit value obtained for lets say each of 15000 source grid locations)?

hi,

MNE optimizes the mean squared error between data and dipole model taking into account the noise
covariance. You can see this as L2 norm on the whitened data (see eg Engemann et al. 2015 https://www.semanticscholar.org/paper/Automated-model-selection-in-covariance-estimation-Engemann-Gramfort/34b659eeb98727fc37b7e60c0d652fcb20ccb870)

first it tries to find a good initial position of the dipole by only considering a discrete regular grid.
Then it iterates and aims to refine the location of the dipole by making small changes in location
and orientation. Amplitude is easier to optimize when location and orientation are set.

you can look at the MNE code at:

https://github.com/mne-tools/mne-python/blob/main/mne/dipole.py#L829

you see it uses scipy fmin_cobyla function for the model optimization.

Alex

2 Likes