/Reconstruct_CARTO

Reconstructs a simulatable 3D mesh from in-vivo CARTO mapping data

Primary LanguagePython

Reconstruct_CARTO

This repository provides code capable of reconstructing a simulatable 3D mesh from clinical CARTO mapping data, providing control over mesh resolution, conduction velocity distributions and non-conductive regions. The mesh thickness is currently fixed at 5 mm

Requirements:

Some requirements are not automatically installable. These requirements are:

  • tetgen 1.6.0 (Download here)
    • The tetgen command should be aliased to the tetgen executable, located at <tetgen_installation_folder>/tetgen1.6.0/build/tetgen
  • PyMesh 0.3 (Download here)
    • Do NOT install PyMesh with pip. This is another module with the same name. Download, build and install according to the setup as provided by the PyMesh docs.
    • Installing the third-party dependencies can be done as specified in the docs, but also by running ./build.py all in the directory third_party.

To install the remaining requirements, run

pip install -r requirements.txt

This will install the following modules, or update them if they are not already installed:

  • PyVista
  • tqdm
  • matplotlib
  • numpy
  • sklearn
  • pandas

Usage

Reconstructing involves taking an input .mesh file and making it into a tetrahedron mesh with user-defined resolution. Conduction velocities can already be interpolated on this mesh if a .csv file containing point coordinates and speed values is passed as an optional argument.

python reconstruct.py <carto name> --<speed_file>

Interpolating conduction velocities can also be done after reconstruction, e.g. in case you want to select non-conductive regions on the mesh after the reconstruction. To this end, a .csv file with point coordinates and conduction velocity values need to be passed as an argument to the runfile apply_cv.py.

python apply_cv.py <reconstructed .vtk mesh name> --<speed_file> --<write_adjust> --<region_dir>  --<ncv> --<speed_col> --<writeVTK>

Keep in mind that using command-line arguments will override any setting defined in the settings.ini file.

Alternatively, if you want full control over the mesh reconstruction and its intermediate steps, you can also import the CartoMesh class and its dependencies. This provides more control over the reconstruction process than just the two runfiles reconstruct.py and apply_cv.py along with the settings file settings.ini.

>>> from carto_mesh import *
>>> m = CartoMesh('filename.mesh')
>>> m.reconstruct()

Documentation

Documentation can be found here

Contact

Feel free to report any bugs, issues or propose features either directly via github, or per mail