[FieldTrip] matrix is close to singular when running ft_scalpcurrentdensity

Schoffelen, J.M. (Jan Mathijs) janmathijs.schoffelen at donders.ru.nl
Tue Sep 6 15:01:09 CEST 2022

Hi Valeria,

It’s a bit of an open door, but you get this message, because "Matrix is close to singular or badly scaled”.

That means that the outcome of the algorithm is not necessarily to be trusted. I have no clue what causes this, because I don’t have information about your data, nor about the line where this occurs. If things like these happen, my recommendation always is to look at the output on the screen (often matlab prints a line number and a function filename to give you a clue of the problematic line). If you manage to find this information, you can set a breakpoint in the code at exactly that location, and inspect the variables that go into the computation that occurs on the guilty line. If the guilty line is not easily found, then there’s no other way than setting a breakpoint early in the code and going through it step-by-step.

I assume that you are familiar with the matlab debugger. If not, it’s time to get acquainted. To get started, I think that google and youtube are your friends.

Best wishes,

On 30 Aug 2022, at 10:48, Valeria Jaramillo via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:


I tried to run ft_scalpcurrentdensity on my 128-channel EEG data (Cz recording reference) to estimate scalp current density using the surface Laplacian. When I ran it, I received this warning message:

Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 3.554116e-08.

Do you have any idea why I get this message and should I be concerned about it?

fieldtrip mailing list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20220906/b9c09ff6/attachment.htm>

More information about the fieldtrip mailing list