Skip to content

cli deformation model example

Marcel Luethi edited this page May 15, 2015 · 2 revisions

This example shows how the statismo CLI can be used to work with deformation models.

Data

As example datasets, we use the hand images that can be found in the statismo repository

Building a deformation model

The statismo CLI gives us two commands to build a deformation model. The first command can be used to learn a deformation model from given deformation fields.

statismo-build-deformation-model  -l datalist.txt  -d 2 -o deformation-model.h5

The textfile datalist.txt contains the filenames of all the deformation fields that are used to estimate the model (one filename per line).

A second possibility to define a deformation model is by specifying the deformations using a Gaussian process. This can be done using the command

statismo-build-gp-model -t deformation -d 2 -k gaussian -p 50 -s 50 -n 200 -r df-hand-1.vtk -o deformation-model.h5

Sample example shapes from the model

Once we have built a model we should visualize the deformations by sampling some random samples.

statismo-sample -t deformation -d 2 -i deformation-model.h5 -o df-sample.vtk

This command writes a deformation field (names df-sample). We can either visualize this sample directly using Paraview, or visualize its effect when it is applied to an image. This can be achieved using the utility statismo-warp-image:

statismo-warp-image -d 2 -i hand_images/hand-0.vtk -f df-sample.vtk -o warped-image.vtk

Registration

Once we have a suitable model, we can use it for registration (i.e. fitting the model to an image). This is achieved using the statismo-fit-image command. Besides the deformation model (-i), we have to specify the fixed image (-f) and moving image (-m) and a regularization weight (-w). The resulting deformation field (-e) maps each point of the fixed image to the corresponding point in the moving image. The registrered image is a backward warp of the moving image using the deformation field, which implies that if the registration was successful it should look similar as the fixed image.

statismo-fit-image -d 2 -p -i deformation-model.h5 -f hand_images/hand-0.vtk -m hand_images/hand-1.vtk -w 0.1 -o registered-image.vtk -e deformation-field.vtk

The statismo-fit-image command takes as optional parameters landmarks for the fixed and the moving image. See the documentation for additional details.