Neuroinflab / kESI

GNU General Public License v3.0
2 stars 5 forks source link

kESI experiments on 4 spheres models #20

Open mdovgialo opened 3 months ago

mdovgialo commented 3 months ago

Todo:

From #17 we now have forward solver for point sources - electrodes and arbitrary meshes. But it seems to work correctly only for 4 spheres meshes in vaccuum

https://github.com/Neuroinflab/kESI/tree/dev/20_experiments_with_4_spheres

mdovgialo commented 3 months ago

Interesting problem:

Electrode Fp2_L2 - deep in the brain, correction field:

Image

Fp2_L1 - shallow in the brain

Image

Fp2 - 1 mm in the scalp tissue:

Image

The solution is spherically symmetrical almost perfectly!

If you play with colors and contrast you can BARELY see a border:

Image

This could explain why 10-20 scalp electrode kCSD and kESI solutions are basically identical!

Need to check the potential...

mdovgialo commented 3 months ago

trying different electrode depths

Image

4 spheres model, 0.005 max element size

Image

Correction (v_kesi - v_kcsd)

Seems like electrode position in respect of mesh vertices matters a lot for the correction. I guess this is the singularity problem

Image

But also, I think there is not enough accuracy in the mesh around electrodes. Feel like the best way to solve it is to use MFEM dynamic refinement, or add real, physical electrodes as mesh elements.

mdovgialo commented 3 months ago

Using scalp electrodes at 88mm close to the internal layer of the mesh, creates "better" correction:

image

But the kESI Eigensources and solution is still almost exactly the same as kCSD, except of some small differences. My guess it's because we increased the accuracy of local sampling around electrode, but the long reaching "visibility" stays the same.

mdovgialo commented 3 months ago

Should come back to this after solving image-to-mesh problem and trying out on some realistic meshes.

mdovgialo commented 3 months ago

Trying to solve 3 layered 10-05 system, kCSD and kESI eigensources still look pretty much identical.

10-05_layers_eigenvectors.webm

Solutions (ground truth is overlaid) of 4 spheres with a dipole, red circles are electrodes:

kESI:

image

kCSD:

image

kESI - kCSD:

Image

The difference exists, it doesn't seem to be a numerical noise, but CSD solution is on a scale between [-4000; 4000] units, and the difference is between [-0.005; 0.005] units, so it's basically a few parts per million, and is mostly around the ground truth and borders. So the kESI might influence the solution a bit, in this spherical case.

potential:

image

Maybe 3 spheres with these electrodes is just too symmetrical? Maybe worth trying on a realistic model??

mdovgialo commented 2 months ago

Potential from point CSD in the center and top of the 4 spheres,

Horizontal - Z axis in meters.

Fully analytical solution in infinite 0.33 conductivity space anal_potential_homogenious

MFEM solution, 4 spheres model, with grounding plate on the bottom of air volume, all volumes have 0.33 conductivity: mfem_potential_homogenious

MFEM solution 4 spheres model, realistic conductivities: mfem_potential_4spheres

mdovgialo commented 2 weeks ago

After some refactor of signal generator, implementing very basic point dipole, some testing of forward modelling using MFEM in 4 spheres model:

Dipoles

Sphere radii in meters: brain, csf, skull, scalp: 0.079, 0.082, 0.086, 0.09 Sphere conductances: 0.33, 1.65, 0.0165, 0.33, 1e-10 (last one - air is only used in mfem, analytical model doesn't have it)

Slice along Z axis at X, Y = (0, 0)

image

image

point_dip_mfem_4sph

source_type x   y   z   ori_x   ori_y   ori_z   sepera  size    frequency   phase           moment
dipole      0   0   0   0       1   NAN NAN 76      5.60024664008999    100

gauss_dip_mfem_4sph

source_type x   y   z   ori_x   ori_y   ori_z   seperation  size    frequency   phase           amplitude
dipole      0   0   0   0   0   1   1       3   67      6.23679640668398    100

gausss_dip_kcsd.nii.gz

source_type x   y   z   ori_x   ori_y   ori_z   seperation  size    frequency   phase           amplitude
dipole      0   0   0   0   0   1   1       3   67      6.07443711518915    100

Monopoles

Slice along Z axis at X, Y = (0, 0)

image

image

gauss_mon_kcsd

source_type x   y   z   ori_x   ori_y   ori_z   seperation  size    frequency   phase           amplitude
monopole    0   0   0                       1   70      4.12748723235593    100

gauss_mon_mfem_4sph

source_type x   y   z   ori_x   ori_y   ori_z   seperation  size    frequency   phase           amplitude
monopole    0   0   0                       1   70      3.23643567590633    100

point_mon_mfem_4sph

source_type x   y   z   ori_x   ori_y   ori_z   seperation  size    frequency   phase           amplitude
monopole    0   0   0                       1   80      0.796161017437315   100

Point Dipole MFEM vs Analytical 4 sphere model

Horizontal

image

image

Higher contrast:

image

image

Vertical

Slice

point_dipole_mfem_4sph

image

image

image

Something is weird with how layers react??

source_type x   y   z   ori_x   ori_y   ori_z   seperation  size    frequency   phase           moment
pointdipole 0   0   30  0   0   1   None        None    76      1.39303222062097    100

point_dipole_anal_4sph

source_type x   y   z   ori_x   ori_y   ori_z   seperation  size    frequency   phase           moment
pointdipole 0   0   30  0   0   1   None        None    76      2.27378002952686    100

3D view

image

image

Higher contrast

image

image

mdovgialo commented 2 weeks ago

Small experiments with dipoles

4 spheres dipoles, real spheres

Sphere radii in meters: brain, csf, skull, scalp: 0.079, 0.082, 0.086, 0.09 Sphere conductances: 0.33, 1.65, 0.0165, 0.33, 1e-10 (last one - air is only used in mfem, analytical model doesn't have it)

Slice along Z axis at X, Y = (0, 0)

point dipol 4 spheres analytic vs point dipole free space vs point dipole mfem 4 spheres

Image

Image

4 spheres dipoles, shperes set to homogeneous

Sphere radii in meters: brain, csf, skull, scalp: 0.079, 0.082, 0.086, 0.09 Sphere conductances: 0.33, 0.33, 0.33, 0.33 , 0.33

Image

Image

Image (blue and orange are merged)

Point source, 4 spheres homogeneus + optional last element as air

Sphere radii in meters: brain, csf, skull, scalp: 0.079, 0.082, 0.086, 0.09 Sphere conductances: 0.33, 0.33, 0.33, 0.33, 1e-10 (last one - air is only used in mfem, analytical model doesn't have it) alternatively Sphere conductances: 3, 3, 3, 3, 1e-10 (last one - air is only used in mfem, analytical model doesn't have it)

Image Image Image Image

kCSD - free space solution (had to rescale it x10 for some reason... something with normalisation??? It's correct for point sources when calculating electrodes...)

Something doesn't work... sigma 3.0 kCSD fits sigma 0.33 MFEM, sigma 0.3 kCSD fits 3.0 MFEM??

mdovgialo commented 1 week ago

MFEM problem with conductances parameter

Point source solutions

monopole_kcsd

As we can see, potential shrinks when conductance increases

Current MFEM solution is opposite!

monopole_kesi

Similar with dipoles:

kCSD point dipole:

dipole_kcsd

Analytical point dipole:

dipole_analytic

kESI point dipole:

dipole_kesi

Conductance relationship is reversed!

4 Sphere solution vs kCSD solution also have some differences, on the edge of the spheres and just above the defined depth

Overall:

image

4 shpere edge:

image

Intermediate part has good corcondance with free space dipole:

image

mdovgialo commented 1 week ago

kESI forward sim with a point source breaks down at sigma > 0.7?

kESI vs kCSD, monopole

monopole_kesi_0 33

monopole_kesi_0 55

monopole_kesi_0 66

monopole_kesi_0 77