Registration (1/2)

 

In this tutorial, we will see how to perform a registration between a pair of skull profiles. What you need is a terminal to run Deformetrica and Matlab to visualize data and results.

Data and scripts are in the folder deformetrica-[version]/tutorials/Registration1/.

Registration1

1. The data:

  • We aim to register the skull of australopithecus to the skull of homo sapiens sapiens.
  • Run in Matlab the script viewData.m to look at the two “skulls” we will use. They are saved as VTK PolyData in .vtk files. The files contain the vertices and edges of the curves delineating the contours of the skull profiles.
  • The script uses our VTKPolyDataReader.m that can be found in deformetrica-[version]/utilities/matlab/.

2. Pre-processing and design choices

  • The very first thing to do is to perform a global alignment of the shapes. Deformetrica is based on non-linear deformations, which must follow rigid/affine/translation+rotation kind of alignment. This is an important step, since the deformation you will obtain greatly depends on this initial alignment. Here, we consider that the shapes are already aligned, so we have nothing else to do (Note that we could have also scaled the data)
  • The second most important thing to do is to choose the shape representation. Here, we deal with curves, so the most natural choice is NonOrientedPolyLine, which is based on the concept of varifolds (see Section “To go further” below for other representations). No point correspondence is needed, ordering of the vertices does not matter.

3. Run Deformetrica

  • Before running Deformetrica, we need to set up at least (and in most cases, at most) 3 parameters in two .xml files, which you can find in the folder:
    • paramDiffeos.xml: this file contains the parameters of the diffeos, as well as optional parameters for the optimization:
      • kernel-width: is the parameter of the Gaussian kernel for the deformations. The deformation needs to scale the overall shape and inflate the cranium, which are fairly large deformation patterns. Considering the size of the shape, a kernel width of 40 or 50 seems reasonable.
      • kernel-type: cudaexact would be the way to go but the choice of the kernel evaluation depends of many parameters (number of points, the spatial extent of the data, computer architecture, etc.). That’s the reason why we advice to experiment this parameter on a sample your data in order to determine what will be the best suited kernel type for your simulations.
      • The other parameters are optional and their default values work just fine. Here, we just set the number of time points (for the sampling of point trajectories during deformation) to 20, in order to have nice movies at the end. Run time scales linearly with this parameter…
    • paramCurves.xml: this file contains the type of shape representation and their parameters
      • deformable-object-type is the name of the shape representation, here NonOrientedPolyLine
      • kernel-width is the kernel of the varifold metric on which is based the NonOrientedPolyLine representation.
      • data-sigma is the square-root of the weight of the data term, as compared to the weight of the regularity term of 1. Here, we choose a small data-sigma to enforce a good matching accuracy.
  • Now, we’re all set. Run in a terminal the script ./registration.sh

Note: Here we use the Deformetrica command sparseMatching2 since our data are 2D. Use sparseMatching3 for 3D data!

In the 2D version of Deformetrica, the z-coordinate of the input data is ignored. The .vtk files of the skulls are 3D (as required by the .vtk format) with the z-coordinate which is equal to 0.

4. Output and results

  •  The algorithm generated a number of output files:
    • skull_australopithecus__t_*.vtk are the frames of the optimal estimated deformation of the source shape
    • CP_final.txt and Mom_final.txt are the parameters of the estimated deformation. The coordinates of the optimal position of control points in the former, the values of the optimal momentum vectors attached to the control points in the latter
    • Run viewResults_Registration.m in Matlab to see the movie of the deformation
    • The result might not look perfect to you: adjust the parameters to your taste! For instance, you can try deformation kernel width = 30 and varifold kernel width = 20 to capture finer details. However, keep in mind that decreasing kernel widths increases run time…

5. Using deformation in post-processing/analysis

  • Now that we have the deformation parameters in CP_final.txt, Mom_final.txt and paramDiffeos.xml, we can play with it! For instance:
    • we can use the inverse deformation to map the deformed skull back to the source. This is a way to check the numerical accuracy of the inverse deformation
    • we can deform any shape in space using the deformation or its inverse
  • Run the script ./deformLattice.sh in the Terminal to deform a regular lattice of points (in lattice.vtk) using the deformation.
  • Run the script viewResults_LatticeDeformation.m in Matlab to see the result.
  • Run the script ./deformBackward.sh in the Terminal. It computes (i) the deformation of the deformed australopithecus skull back to the source space and (ii) the deformation of the neandertalis skull using the inverse deformation.
  • Run the script viewResults_BackwardDeformation.m in Matlab to see the results. Whether it is interesting computation is another question…

 

 

Comments are closed.