-
Notifications
You must be signed in to change notification settings - Fork 6
Example: Source localization
The finite element method (FEM) input are the mesh rendering output. The input split in two sets: Physics properties and Geometrical properties.
In the Physics properties set of input we have the electrical conductivity tensor elements XML file (CXX.xml). They represent the tensor:
<math> \bar{\bar{\sigma}} = \left( \begin{array}{CCC} C_{00} & C_{01} & C_{02} \\ C_{01} & C_{11} & C_{12} \\ C_{02} & C_{12} & C_{22} \\ \end{array} \right) </math>
The CXX.xml files describe one tensor <math>\bar{\bar{\sigma}}</math> associated with each tetrahedron centroid.
In the Geometrical properties set of input we have the FEM XML files used in the finite element method. Last files are XML file (dipoles.xml and parcellation.xml) gathering dipoles properties, localization and parcellation.
Nota: paracellation.xml file is created using the class Build_dipoles_list_high_density for the head model. For the shperes, neither dipoles.xml nor parcellation.xml are created. The user has to create it him/herselft:
<?xml version="1.0" encoding="UTF-8"?>
<fijee xmlns:fijee="https://github.com/Fijee-Project/Fijee">
<dipoles size="1">
<dipole index="0" x="0.077" y="0." z="0." vx="0." vy="0." vz="1." I="1e-09" index_cell="0" index_parcel="0" lambda1="0.33" lambda2="0.33" lambda3="0.33" />
</dipoles>
</fijee>
- Physics properties
- Electrical conductivity
- C00.xml
- C01.xml
- C02.xml
- C11.xml
- C12.xml
- C22.xml
- Electrical conductivity
- Geometrical properties
- FEM XML files
- mesh_facets_subdomains.xml
- mesh_subdomains.xml
- mesh.xml
- Dipoles
- dipoles.xml
- parcellation.xml
- FEM XML files
The output of the FEM give VTK images for the geometric control check and physical results. File with pvd and vtu extensions can be visualized with ParaView.
The file leadfield_matrix.xml is an XML file. It represents the leadfield matrix: the dipoles impact on the electrods. This is the forward simulation file used to compare with real data collection.
- Geometrical representation
- boundaries.pvd
- domains.pvd
- Physical results
- leadfield_matrix.xml
- dipole_X.pvd
- dipole_0_4_5_6.vtu
In the process of simulating a electric source in the brain, Fijee offers two physic models in its island[1].
The first model is the source localization by subtraction method. The second model is the source localization by the direct method.
template < typename Physical_model,
int num_of_threads = 1 > class Model_solver
The different types of Physical_model that can be used in the template are the following:
- Source localization
- Solver::SL_subtraction
- Solver::SL_direct
void
Model_solver<Physical_model, num_of_threads>::solver_loop()
void
Model_solver<Physical_model, num_of_threads>::XML_output()
In this section we will show how to work with source localization.
Most source localization techniques by measuring the Electroencephalography implies the existence of one or several dipole sources. The solution to the forward potential is first calculated based on the model the direct model, then on the subtraction model.
ViennaCL users can use OMP_NUM_THREADS variable
export OMP_NUM_THREADS=Num_of_CPU
OMP_NUM_THREADS restricts the number of parallel CPU used to solve PDE problems. Otherwise, OpenMP uses all CPU available.
#include<fijee.h>
//
//
//
int main()
{
//
//
Solver::PDE_solver_parameters* solver_parameters = Solver::PDE_solver_parameters::get_instance();
//
solver_parameters->init();
//
// export OMP_NUM_THREADS=2
Solver::Model_solver< /* physical model */ Solver::SL_subtraction,
/* umber_of_threads */ 4 > model;
//
std::cout << "Loop over solvers" << std::endl;
model.solver_loop();
model.XML_output();
//
//
return EXIT_SUCCESS;
}
The first step is to setup the CMake environment variable:
export CMAKE_PREFIX_PATH=$Fijee
cmake_minimum_required( VERSION 2.6.0 )
#
# Application's name
PROJECT( SourceLocalization )
#
# Project conf
find_package( Fijee REQUIRED )
#
include_directories( ${Fijee_INCLUDE_DIRS} )
link_directories( ${Fijee_LIBRARY_DIRS} )
#
# Other libraries
find_package( PkgConfig REQUIRED )
#
pkg_check_modules( gsl REQUIRED gsl )
pkg_check_modules( zlib REQUIRED zlib )
#
# Other compillation definitions
add_definitions( -O3 -std=c++0x -Wno-deprecated )
#
# Build application
add_executable( SourceLocalization MACOSX_BUNDLE SourceLocalization )
#
target_link_libraries( SourceLocalization
${Fijee_LIBRARIES}
${VTK_LIBRARIES}
${gsl_LIBRARIES}
${zlib_LIBRARIES}
CGAL CGAL_ImageIO dolfin metis
gmp boost_system )
Fijee offers many type of output. Those output can be customized in the sources and reached out from the data set.
In this example we used the source localization with the subtraction method. The direct method is also available, but gives several order of magnitude less precises results. Depending of the chose the user made on its simulation (head model or 4-spheres) the user can run the same program to get dipole simulation in a head model or a dipole simulation in the spheres.
- ^ In Fijee, an island is a high level interface allowing different combinations of types to the end user.