-
Notifications
You must be signed in to change notification settings - Fork 6
Example: Head model
This Library is a non-optional first step of all Fijee's applications. This package is devoted to generate models meshes with physics parameters. The library can produce a patient customized head model or the 4-spheres model meshes.
At each tetrahedron of the mesh Fijee matches the local isotropic or anisotripic electrical conductivity depending on the head tissue.
Input files for this island are the analyse files from FreeSurfer, MNE and SPM. Fijee tries to be as compatible as possible with FreeSufer files organization. Fijee produce a directory fem in $SUBJECTS_DIR/$SUBJECT. In this directory, input directory gather all usfull input for Fijee.
- mri
- aseg.{hdr,img,nii}
- SPM
- STL
- SUBJECT_brain_surface.stl
- SUBJECT_inner_skull_surface.stl
- SUBJECT_outer_skin_surface.stl
- SUBJECT_outer_skull_surface.stl
- lh.pial.stl
- lh.smoothwm.stl
- rh.pial.stl
- rh.smoothwm.stl
The output are split in two sets: Physics properties and Geometrical properties.
In the Physics properties set of output we have the electrical conductivity tensor elements XML file (CXX.xml). They represent the electrical conductivity 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 second part are the dipoles distribution and the parcellation. The Parcellation is a subdivision of the gray mater in parcels. The file dipoles.xml can hold several thousands to hundred of thousands of dipoles. Dipoles are regularly distributed in the gray matter thickness. However, the distribution density is very high. In source localization purpose, it can be more relevant to use parecellation.xml distribution file. the file parcellation.xml has the exact same structure as dipoles.xml file. Asking for a much more reasonable number of parcels (e.g. 1200 parcels) we end up with a lighter dipoles distribution: the center of mass of each parcel being a dipole.
Nota: the parcellation is only available with the class Build_dipoles_list_high_density for the head model. In case of spheres study, the user has to create its own dipole.xml file. For instance, for a brain tissue with a isotropic electrical conductivity <math>\sigma = 0.33 S.m</math> and a dipole aligned with <math>X</math> axis at the position <math>\vec{r} = (0.77,0,0)^{T}</math>, the XML file is the following
<?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>
In the Geometrical properties set of output we have the 3D labeled image (head_model.inr) and the tetrahedralization (out.mesh). The file out.file can be visualized with medit_linux software. The FEM XML files are used in the finite element method.
- Physics properties
- Electrical conductivity
- C00.xml
- C01.xml
- C02.xml
- C11.xml
- C12.xml
- C22.xml
- Dipoles distribution
- dipoles.xml
- parcellation.xml
- Electrical conductivity
- Geometrical properties
- Image
- head_model.inr
- out.mesh
- FEM XML files
- mesh_facets_subdomains.xml
- mesh_subdomains.xml
- mesh.xml
- Image
In the process of building the head model mesh, Fijee offers two main options in its island[1]. The first option produces the patient customized head model mesh with physics parameters. The second option creates a 4-spheres model mesh with physics parameters.
The latest is used for easy and fast calculation. It also offers the possibility of the Verification process for algorithm: results can be checked with a closed form.
template < typename Labeled_domain,
typename Conductivity,
typename Mesher,
typename Dipole_distribution > class Mesh_generator
The different types that can be used in the template are the following:
- Head simulation:
- Domains::Head_labeled_domain
- Domains::Head_conductivity_tensor
- Domains::Build_mesh
- Dipole generation
- Domains::Build_dipoles_list_high_density
- Build_dipoles_list_knn
- Spheres simulation:
- Domains::Spheres_labeled_domain
- Domains::Spheres_conductivity_tensor
- Domains::Build_mesh
- Dipole generation
- Domains::Build_dipoles_list_high_density
- Build_dipoles_list_knn
void
Mesh_generator< Labeled_domain, Conductivity, Mesher, Dipole_distribution >::make_inrimage()
void
Mesh_generator< Labeled_domain, Conductivity, Mesher, Dipole_distribution >::make_conductivity()
void
Mesh_generator< Labeled_domain, Conductivity, Mesher, Dipole_distribution >::make_output()
In this section we will show how to generate the two models of meshes.
In this example we will produce a head model using the high density dipole distribution.
#include <fijee.h>
//
// VTK
//
#include <vtkSmartPointer.h>
#include <vtkTimerLog.h>
//
// Name space
//
int
main()
{
//
// Time log
FIJEE_TIME_PROFILER("main");
//
// TODO remove VTK traces
// Time log
vtkSmartPointer<vtkTimerLog> timerLog = vtkSmartPointer<vtkTimerLog>::New();
//
std::cout << "Process started at: " << timerLog->GetUniversalTime() << std::endl;
//
// Access parameters
Domains::Access_parameters* parameters = Domains::Access_parameters::get_instance();
parameters->init();
//
//
Domains::Mesh_generator< Domains::Head_labeled_domain,
Domains::Head_conductivity_tensor,
Domains::Build_mesh,
Domains::Build_dipoles_list_high_density > generator;
//
generator.make_inrimage();
generator.make_conductivity();
//
generator.make_output();
//
// Time log
timerLog->MarkEvent("Stop the process");
std::cout << "Events log:" << *timerLog << std::endl;
//
//
return EXIT_SUCCESS;
}
In this example we will produce a 4-spheres model using the high density dipole distribution.
#include <fijee.h>
//
// VTK
//
#include <vtkSmartPointer.h>
#include <vtkTimerLog.h>
//
// Name space
//
int
main()
{
//
// Time log
FIJEE_TIME_PROFILER("main");
//
// TODO remove VTK traces
// Time log
vtkSmartPointer<vtkTimerLog> timerLog = vtkSmartPointer<vtkTimerLog>::New();
//
std::cout << "Process started at: " << timerLog->GetUniversalTime() << std::endl;
//
// Access parameters
Domains::Access_parameters* parameters = Domains::Access_parameters::get_instance();
parameters->init();
//
//
Domains::Mesh_generator< Domains::Spheres_labeled_domain,
Domains::Spheres_conductivity_tensor,
Domains::Build_mesh,
Domains::Build_dipoles_list_high_density > generator;
//
generator.make_inrimage();
generator.make_conductivity();
//
generator.make_output();
//
// Time log
timerLog->MarkEvent("Stop the process");
std::cout << "Events log:" << *timerLog << std::endl;
//
//
return EXIT_SUCCESS;
}
Fijee works closely with FreeSurfer results. To run Fijee, the user has to setup the environment variables:
export SUBJECTS_DIR=/path/to/FreeSufer/subjects
export SUBJECT=subject_to_study
For Find_package purposes, the user is invited to set the CMAKE_PREFIX_PATH environment variable. This is used when searching for include files and libraries.
export CMAKE_PREFIX_PATH=/path/to/Fijee/install/
The user can copy the sources in the previous sections and the following CMakeLists.txt.
cmake_minimum_required( VERSION 2.6.0 )
#
# Application's name
PROJECT( Mesh_generation )
#
# 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 definition
add_definitions( -O3 -std=c++0x -Wno-deprecated )
#
# Build application
add_executable( Mesh_generation MACOSX_BUNDLE Mesh_generation )
#
target_link_libraries( Mesh_generation
${Fijee_LIBRARIES}
${VTK_LIBRARIES}
${gsl_LIBRARIES}
${zlib_LIBRARIES}
CGAL CGAL_ImageIO
gmp boost_system metis )
then
mkdir build
cd build
cp $CMAKE_PREFIX_PATH/share/fijee.xml .
cmake ../
make
Now you can run the program you just built and see the result in $SUBJECTS_DIR/$SUBJECT/fem/output
- ^ In Fijee, an island is a high level interface allowing different combinations of types to the end user.