Code to calculate left atrial geometry statistics from a segmentation
{: .no_toc }
{: .no_toc .text-delta }
- TOC {:toc}
This page documents a technique to calculate the area and perimeter of the mitral valve annulus. By specifying the -c flag in the call to LAstatistics.py, it is also possible to output the atrial volume and surface area which may be a better solution than here.
View it on GitHub{: .btn .fs-5 .mb-4 .mb-md-0 }
git clone https://github.com/drsewilliams/LAstatistics LAstatistics
cd LAstatistics
./run.sh ./vtkfiles
hVtk = VTKReader('openfile')
hVtk.readAllData()
h = drawFreeBoundary(hVtk.getTriRep, 'k')
l = lineLength(h)
batchProcessMitralStatistics
Left atrial shells should be placed in the ./vtkfiles subdirectory first. Note it is important not to have a trainling /
after the folder specified for the .vtk file locations.
- VTK - see vtk.org or install with homebrew
vtkMassProperties
see this VTKExample.pvpython
- see ParaView/Python Scripting. Note that pvpython must be accessible on the system path.
The initial run script serves to iterate through every .vtk file in the vtkfile directory. The LAstatistics.py program is called, via pvpython on each file in turn.
This python program does the main body of the work as follows.
- Loads a vtk file
- Runs Feature Edges to identify the mitral valve annulus
- Uses Delaunay 2D followed by Extract Surface to create a mesh of the mitral valve annulus.
- By default, this mesh is saved next to the input file with the suffix
__MV__
. - Uses Append Geometry followed by Extract Surface to create a closed volume representing the LA. By default the closed shell is not written to disk.
LAstatistics.py accepts the following input
`-h` --help
`-i` --the input VTK file
`-c` --specify the output file for the closed mesh (multiple formats are possible including .vtk and .stl). If blank, no file is written to disk.
`-m` --specify the output file for the mitral valve annulus. If blank, no file is written to disk.
`-s` --run in silent mode.
Finally, MassProperties is called on the mitral annulus mesh and the mitral area is calculated. If a closedmesh has been saved by specifying the -c flag in the call to LAstatistics.py, then in addition the left atrial surface area and left atrial volume are also calculated.
MassProperties has to be compiled with VTK, and subsequently placed in a directory on your path, e.g. /Users/<user>/Documents/bin
The resulting mitral annulus segmentation can be loaded into Matlab using VTKReader
, and the length of the perimeter calcualted using freeBoundary
and lineLength
, all of which are available in the standard WLCD library.
In addition, a batch processing script is available (batchProcessLAStatistics.m
) which applies these functions to every .vtk containing __MV__
in the filename. For example,
batchProcessMitralStatistics
./vtkfiles/leftatriumexample.vtk
===================================
MITRAL VALVE PROPERTIES
Volume: 2265.75
VolumeX: -2264.47
VolumeY: -2266.23
VolumeZ: -2263.78
Area: 2382.81
MinCellArea: 2.24307e-06
MinCellArea: 262.869
NormalizedShapeIndex: 1.69005