Manually fitting a dipole and calculating goodness of fit

Instead of using Dipole fitting process on Brainstorm to fit dipoles across all the possible source grids(around 15000), I manually fit a dipole at around 10 of the source grid location of my interest with a fixed magnitude and orientation using Brainstorm pipeline "simulate generic signal" >then create a dipole and > "simulate recording from dipole" and reconstructed the EEG/MEG signal from the dipole.

Now I want to compare the Reconstructed EEG/MEG signal I obtained from dipole simulation against the actual EEG/MEG recording of the subject that I have. I want to compare the actual EEG recording with the predicted( reconstructed EEG recording) to obtain the goodness of fit for my manually fitted dipole. How can I do that from the script?

By "manually fitted dipole", I understand that you set the position/orientation/amplitude of the dipole.
It is is not a "fitted" dipole - fitting refers to the iterative procedure of minimizing the error between a dipole and the real recordings. Let's call it your "manually defined dipole".

If you want to compare the real EEG measurements with this dipole, you can maybe:

  • simulate the EEG data from your dipole, as explained in the simulation tutorial
  • compute an error measure between the real EEG and the simulated EEG (e.g. at one given time sample #i, compute something like sum((Fsim(:,i) - Freal(:,i))^2))

@John_Mosher @Sylvain What would be the best error measure to get something close to a "goodness of fit"?

Yes, why not?

Hi @francois, the high amplitude could be because these are not epileptic spikes but spikes provided to the human head Phantom through a signal generator.

Maybe you'd be interested in reading these tutorials: