Skip to content

Example: Transcranial current stimulation (tCS)

YannCobigo edited this page Sep 25, 2014 · 7 revisions

Table of Contents

Introduction

Input

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
  • Geometrical properties
    • FEM XML files
      • mesh_facets_subdomains.xml
      • mesh_subdomains.xml
      • mesh.xml
    • Electrodes
      • electrodes.xml

Ouput

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

Data set

Islande

In the process of simulating a transcranial current stimulation (tCS), Fijee offers three physic models in its island[1].
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

High level funcions

Examples

In this section we will show how to work with transcranial current stimulation.

Transcranial Direct Current Stimulation (tDCS.cxx)

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[2].
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;
}

CMake

The first step is to setup the CMake environment variable:

export CMAKE_PREFIX_PATH=$Fijee
$Fijee reprensents the path where it was installed. Then you can use the following CMakeLists.txt.
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 )

Results

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 T7. 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.

References

  1. ^ In Fijee, an island is a high level interface allowing different combinations of types to the end user.
  2. ^ Transcranial direct-current stimulation

Clone this wiki locally