-
Notifications
You must be signed in to change notification settings - Fork 6
Example: Transcranial current stimulation (tCS)
The technologies pertaining to transcranial current brain stimulation (tCS), is a family of related noninvasive techniques including direct current (tDCS), alternating current (tACS), and random noise current stimulation (tRNS). These techniques are based on the delivery of weak currents through the scalp (with electrode current intensity) at low frequencies (typically inferior to 1 kHz) resulting in weak electric fields in the brain (with amplitudes of about 0.2-2 V/m)[1].
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. The last file is an XML file (electrodes.xml) gathering electrode properties and localization.
- 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
- Electrodes
- electrodes.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 eeg_forward.xml is an XML file gathering the time series of data simulated at the electrodes. This is the forward simulation file used to compare with real data collection.
- Geometrical representation
- boundaries.pvd
- domains.pvd
- Physical results
- eeg_forward.xml
- tDCS_time_series.pvd
- tDCS_current_density_time_series.pvd
- tDCS_E_time_series.pvd
- tDCS_Current_density_4_5_6.vtu
- tDCS_potential_4_5_6.vtu
- tDCS_potential_4_5.vtu
In the process of simulating a transcranial current stimulation (tCS), Fijee offers three physic models in its island[2].
The first model is the transcranial direct current stimulation. The user applies direct current on a setup of electrodes. The sum of the current must be zero.
The second model is the transcranial alternating current stimulation. The user applies alternating current on a setup of electrodes. The sum of the current must be zero.
The third model is the transcranial direct current stimulation for local conductivity scanning. The user applies current on a setup of electrodes to locally find out the electrical conductivity. The sum of the current must be zero.
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:
- Transcranial current stimulation
- Solver::tCS_tDCS
- Solver::tCS_tACS
- Local conductivity estimation
- Solver::tCS_tDCS_local_conductivity
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 transcranial current stimulation.
tDCS is a form of neurostimulation which uses constant, low current delivered directly to the brain area of interest via small electrodes. It was originally developed to help patients with brain injuries such as strokes. Tests on healthy adults demonstrated that tDCS can increase cognitive performance on a variety of tasks, depending on the area of the brain being stimulated. It has been utilized to enhance language and mathematical ability, attention span, problem solving, memory, and coordination[3].
To apply current on the patient head, the user has to fill up the electrodes.xml file (e.g. electrode T7 has 1mA and T8 has -1mA). The user must respect the conservation property: the sum of applied current must be 0.<
br>
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::tCS_tDCS,
solver_parameters->get_number_of_threads_() > 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( tDCS )
#
# 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( tDCS MACOSX_BUNDLE tDCS )
#
target_link_libraries( tDCS
${Fijee_LIBRARIES}
${VTK_LIBRARIES}
${gsl_LIBRARIES}
${zlib_LIBRARIES}
CGAL CGAL_ImageIO gmp boost_system metis )
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 modified the electrodes.xml output file. We changed I="0.001" (Ampere) at the electrode labeled label="T7"; and we applied I="-0.001" (Ampere) at the electrode labeled label="T8". This setup conserve the current neutrality principal. The user is free to apply all sort of setup as long as the current neutrality is respected.
In the case of tCS, the primary output will be the potential simulated at electrodes T7 and T8. We can visualize the electrical density flow in gray and white matter of a real head model. It is also possible to visualize the electrical field flowing in the brain (due to the similarity with the electrical current density, we won't display this physical variable).
If the spheres meshes were generated instead of a head model, we have the same type of results: density flow in the spheres.
tACS is a form of neurostimulation which uses constant, low alternating current delivered directly to the brain area of interest via small electrodes[3].
This example could be interpreted as HD_tACD. We apply four electrodes with a quarter of the absolute value of a fifth electrode. The two set of electrodes have an opposite phase of alternate current oscillation around a tDCS mean value. The integrate value of those current is still null.
If Dolfin was compiled with VIENNACL_WITH_OPENMP, the user can allocate the number of CPU to solve the PDE problem.
export OMP_NUM_THREADS=Num_of_CPU
template < typename Physical_model,
int num_of_threads = 1 > class Model_solver
The user has to keep in mind the bottle neck he creates asking for more CPU than he has.
The first program will change the file electrodes.xml to electrodes_tACS.xml giving the current oscillations time series.
#include<fijee.h>
//
//
//
int main()
{
//
//
Solver::PDE_solver_parameters* solver_parameters = Solver::PDE_solver_parameters::get_instance();
//
solver_parameters->init();
//
// tACS electrodes' setup
std::vector< std::tuple<std::string, double> > positive_electrodes;
positive_electrodes.push_back( std::make_tuple("C4", 0.00112 /*[A]*/) );
//
std::vector< std::tuple<std::string, double> > negative_electrodes;
negative_electrodes.push_back( std::make_tuple("T8", -0.00112 / 4. /*[A]*/) );
negative_electrodes.push_back( std::make_tuple("F8", -0.00112 / 4. /*[A]*/) );
negative_electrodes.push_back( std::make_tuple("C4", -0.00112 / 4. /*[A]*/) );
negative_electrodes.push_back( std::make_tuple("P8", -0.00112 / 4. /*[A]*/) );
// Electrodes::Electrodes_setup< Electrodes::Electrodes_tACS >
Electrodes::Electrodes_tACS electrodes_setting( positive_electrodes, negative_electrodes,
10 /* [Hz]*/, 0.0005 /* [A] Amplitude */,
0.1 /* [s] elapse time */,
1. /* [s] starting time */ );
//
electrodes_setting.output_XML( solver_parameters->get_files_path_output_() );
//
//
return EXIT_SUCCESS;
}
#include<fijee.h>
//
//
//
int main()
{
//
//
Solver::PDE_solver_parameters* solver_parameters = Solver::PDE_solver_parameters::get_instance();
//
solver_parameters->init();
//
// Physical models:
// export OMP_NUM_THREADS=2
Solver::Model_solver< /* physical model */ Solver::tCS_tACS,
/* number_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( tACS )
#
# 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( tACS MACOSX_BUNDLE tACS )
#
target_link_libraries( tACS
${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.
The following movies shows the tACS for potential mapping for a sphere and electrical current density for a sphere.
- ^ Ruffini, G, Wendling, F, Merlet, I, Molaee-Ardekani, B, Mekonnen, A, Salvador, R, Soria-Frisch, A, Grau, C, Dunne, S, Miranda, PC (2013). Transcranial current brain stimulation (tCS): models and technologies. IEEE Trans Neural Syst Rehabil Eng, 21, 3:333-45.
- ^ In Fijee, an island is a high level interface allowing different combinations of types to the end user.
- a b Transcranial direct-current stimulation