Parametric non-rigid registration in ScalismoLb

Skip to first unread message

Ilaria A.

Jan 24, 2021, 6:27:30 AMJan 24
to scalismo
Hi everybody,
I have a problem, I'm using ScalismoLab for Parametric non-rigid Registration  (like in the tutorial 12). I have obtained the fittedMesh but I need the exact rappresentation of my target so I've tried to compute this code (from tutorial 12):

val targetMeshOperations = targetMesh.operations
val projection = (pt: Point[_3D]) => {
val finalTransformation = registrationTransformation.andThen(projection)
val projectedMesh = referenceMesh.transform(finalTransformation)
val resultGroup = ui.createGroup("result")
val projectionView =, projectedMesh, "projection")

but there is a problem, because I'm using ScalismoLab and 'targetMesh.operations' doesn't work. There is a way to compute this code also on ScalismoLab?

Thank you,

Marcel Luethi

Jan 25, 2021, 8:33:35 AMJan 25
to Ilaria A., scalismo
Hi Ilaria

The version of Scalismo that we use in ScalismoLab is already a bit dated and many improvements have been made since we built ScalismoLab. One of them is the mesh operations, which provides among other things, a method to find closest points on the surface induced by a triangle mesh. You can, however, replace it with
val fixedImage = Mesh.meshToDistanceImage(referenceMesh)
This approximates the distanceImage by using the closest vertex instead of the closest point on the surface. This will lead to slightly less accurate results, but should definitely be good enough for first experiments.

You can find the code for the full non-rigid registration example in Scalismo under Documents->Extra->Quickstart

Best regards,


You received this message because you are subscribed to the Google Groups "scalismo" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Ilaria A.

Jan 25, 2021, 2:26:05 PMJan 25
to scalismo
Thank you for your suggestion!

Best regards,

Marco Sensale

Feb 25, 2021, 12:42:26 PMFeb 25
to scalismo
Hi Ilaria and Marcel,

My name is Marco and I am doing my PhD at Ansys, and I am registered at the University of Sheffield. I am generally interested in simulations to aid orthopedic surgeons, and I am mainly working on the lumbar spine.

Scalismo seems a very powerful tool for SSM. While trying to understand the potential of methods behind Scalismo, I am reading the following paper:

Clogenson, Marine and Duff, John M. and Luethi, Marcel and Levivier, Marc and Meuli, Reto and Baur,
Charles and Henein, Simon. (2014) A statistical shape model of the human second cervical vertebra.
International journal of computer assisted radiology and surgery, 30.10.2014, 11 S.

As far as I understand, in this study the algorithm used for the registration did not include any projection. However, it is not reported any registration error between the fitted meshes and the original geometries from segmentation. 
Therefore, I assume that that registration error was zero. Is it possible to tune the Gaussian process and the optimization parameters so well to obtain an error equal to zero without projection? 

I think that without a projection it is very hard to obtain a perfect registration. So I was very interested by the question asked by Ilaria. In ScalismoLab, I managed to compute the projection with the following, already mentioned, lines:
val projection = (pt : Point[_3D]) => {
  val targetPoint = targetMesh.findClosestPoint(pt).point
val mesh_proj = mesh.transform(projection).

From your last email, I understand that another way to compute the projection would be by transforming surface meshes in distance images. If I understood correctly, a Distance image is a continous function that associates each point in the space to the shortest distance to the mesh.

I guess that this information could be useful to compute the projection of one fitted mesh on the target shape, but I am not sure about how to implement it. 

Any suggestions would be very much appreciated.

Sorry for the long email.

Thanks, and best regards


Marcel Luethi

Feb 26, 2021, 10:08:43 AMFeb 26
to Marco Sensale, scalismo
Hi Marco

Welcome to the scalismo community.

As we are using a Low-rank approximation of a Gaussian process model, it is usually not possible to get a registration accuracy of zero. You can, however, get really close, such that the projection step that you have mentioned does not need to do much work. For simple shapes, such as the vertebrae, I don't think you need a much more sophisticated projection method than the one you already mentioned. 

There is no version of the projection, which makes use of distance images. I guess what you are referring to is our gradient-based registration algorithm, that uses distance images. This method  often leads to more accurate results and is easier to tune than the ICP registration.

You worte that you are using ScalismoLab. I would advise you to switch to an IDE instead and use the latest version of Scalismo. To set it up and get started, you can follow the tutorials you find on the scalismo webpage: There you will also find a tutorial on registration: The advantages of using Scalismo from an IDE is not only that it is much easier to write Scala code, but also that you can use the latest versions of the library, which has evolved compared to ScalismoLab. In particular, you should also see more accurate registration results.

Best regards,


Marco Sensale

Mar 1, 2021, 9:54:04 AMMar 1
to Marcel Luethi, scalismo
Hi Marcel,

Thank you very much for your answer.

I have personally found easier to tune the ICP registration than the gradient-based registration to get smoother registration results and less skewness. 

I am gonna switch to an IDE and try the registration with the new library.

I will probably come back to the group to ask for some advice for tuning the registration with the LBFGS optimizer.

Thanks a lot, and best regards

Reply all
Reply to author
0 new messages