Friday, June 5, 2015

Mesh/Surface Processing with Command-line SMILI tools

I recently had to do some processing for a prostate segmentation scheme I've been working on and thought some uses of SMILI tools would be helpful to others. Majority of surface processing tasks can be achieved with the milxModelApp in SMILI, a easy to use open source medical imaging library and viewer.

My tasks involved involved:
  1. copying scalars from an atlas mesh to lots of other meshes
  2. using scalars to clip the meshes
  3. computing the surface distance of the meshes to their corresponding labelled images that were created by clinical experts
  4. computing the scalar statistics across the population of meshes (my meshes already have point to point correspondence) 
Luckily, the milxModelApp application provides most of these without needing to script for multiple surfaces. Furthermore, the Qt framework is not required for these applications as they are VTK/ITK only applications (i.e. built on milxSMILI, the GUI-independent sub-library of SMILI).The following examples are for Version 0.998 (SMILI Release Beta 1).

Each one of the above tasks can be achieved as:
  1. The --scalarcopy  option in milxModelApp provides a way to do this. I did:
    milxModelApp --scalarcopy focus_atlases/focus_bladder_atlas.vtk results/bladder/asm_bladder_*.vtk -p results_scalars/bladder/
    Copy scalars from atlas mesh (focus_bladder_atlas.vtk) to other meshes in directory (results/bladder/asm_bladder_*.vtk) and output to another directory with same names.
  2. The --clip  option in milxModelApp provides a way to do this. I did:
    milxModelApp --clip 1 results_scalars/bladder/asm_bladder_*.vtk -p results_clipped/bladder/
    Clip meshes in directory keeping only parts with value of 1 and output to another directory with same names.
  3. We need to write a script for the milxHausdorffDistance application that provides this using distance maps in a straight forward way. This script is now in the repository as scripts/ An example usage of the application:
    milxHausdorffDistance results_clipped/bone/asm_bone_4.vtk -p Hausdorff/bone/bone__ -o Hausdorff/bone/bone__004.vtk --label manuals_renamed/bone/manual_case_bone_004.nii.gz --labelvalue 1 -c 004
    The distance map of the manual is created and the distances stored on the mesh thus giving the surface distances to the manual.
  4. The --scalarstats option in milxModelApp provides this. I did:
    milxModelApp --scalarstats Hausdorff/bladder/bladder__*.vtk -o bladder_stats.vtk
    Compute scalars stats (mean, variance etc. per point) of meshes in directory and output single mesh (of first mesh) with stats as arrays in mesh. You can then use sMILX viewer to view the meshes and change the loaded arrays via the Right Click->Show->Load Array menu.
Note that the milxDeformableModel app is an application derived from milxModelApp and additionally provides options for voxelising surfaces and applying image orientation to surfaces.

Hope this helps
Cheers Shakes - L3mming

No comments:

Post a Comment