mnarizzano / SEEGA

SEEG Assistant
GNU General Public License v3.0
26 stars 17 forks source link

Check if electrodes is outside or inside the brain, the pial surface #96

Closed mosenco closed 2 years ago

mosenco commented 2 years ago

I used vtkSelectEnclosedPoints() to check whenever an electrode is inside or outside the pial surface of the brain. Given a 3D position of the electrodes, check if it's inside the brain model in 3DSlicer.

Maybe it could not be precise, because the center of the cylinder (the cylinder represents the electrodes) could be outside the pial surface, but the ending part, the vertex point could be inside 4c96258

///

During the development of this new feature, i added many variables and forgot to delete unused variables 323dad0

mosenco commented 2 years ago

There is a problem with the transformation matrix. The brain model has a different cartesian reference than the cylinder, so the position at the origin (0,0,0) is geometrically different between the brain and the cylinders.

Without the transformation matrix, the vtkSelectEnclosedPoints() works fine with the function IsInside() but some cylinders that are slightly touch the brain are count as outside, while they should be counted as inside. This could lead to some problem where we don't have control to say precisely if a cylinder (that represent our electrode) is touching or not our pial surface.

Using IsInsideSurface(), given an enclosed surface, it says if a 3D position in space is inside the surface or not. To better improve our precision, for each cylinder, we can use IsInsideSurface() and check for its vertex if at least one is inside the brain to say that the cylinder is considered inside. This gives us more freedom.

mosenco commented 2 years ago

This algorithm works only if we have a pial surface named lh_pial and rh_pial. But this algorithm doesnt exist before and usually this module, the contactpositionestimator, can be used without the brain models but just with the fcsv and the volume file.

I implemented an if else, just in case if someone wants to run contactpositionestimator without the brain or with the brain. Just checking if the lh_pial and rh_pial are present 2eaf88c

mosenco commented 2 years ago

New issues came up and i had to change again the way how the modules check if lh_pial and rh_pial are present 45b53dc

mosenco commented 2 years ago

Improved the algorithm. Now the check is not just if a point (x,y,z) is inside the brain, but if the cylinder is touching the pial surface. More precise. I lowered the quality of the cylinder to 10, while previously was 100 to make the algorithm run faster. 10e1399

Removed the functions created only for testing 51b01d1