Trouble with correspondence when building SSM

308 views
Skip to first unread message

Edwin Tay

unread,
Oct 10, 2019, 5:39:46 PM10/10/19
to scalismo
Hi, 

I am very new to Scalismo and have been trying to build a SSM using ScalismoLab. I have managed to rigidly align my dataset using ICP (image_1), but I'm having some trouble with establishing the correspondence/registration. I used the code in the quickstart to do registration but substituted RandomMeshSampler3D with FixedPointsUniformMeshSampler3D (find code attached). 

However, the meshes which I have tried to register to a reference seem to deform to a very odd shape? See image_2 for original vs image_3 for post-registration projection. 

Furthermore, I assume this effect on the meshes causes my SSM to have very rough deformations when I sample from it (image_4).

Is there a way to fix this? I'm assuming the source of the issue comes from my registration, but am not sure how to improve it. Could possibly modifying my SSM with a smooth deformation kernel help as well?

Regards,

Edwin Tay
image_1.jpg
image_2.jpg
image_3.jpg
Registration Code.txt
image_4.jpg

Marcel Luethi

unread,
Oct 12, 2019, 11:06:39 AM10/12/19
to Edwin Tay, scalismo
Hi Edwin,

Welcome to the Scalismo community :-)

Your approach is okay and with a few changes you will get a much better registration. First, you should switch to the LBFGS Optimizer instead of a Gradient Descent Optimizer. It does not require to optimally tune the step length and converges usually much faster. It only works well together with the FixedPointsUniformMeshSampler3D, but this is what you are already using. 
Furthermore, you might want to increase the scaling factor for the Gaussian kernel a bit (a good value for femur is between 80 and 150). To judge whether your model is okay sample a few random samples from it (using the gui). Your model is okay if it seems realistic that the target shape could have been generated using those random samples.

You are mentioning that you are using ScalismoLab. ScalismoLab is meant for education, but it is not necessarily suitable for real projects. If you plan any serious use of Scalismo,  we would recommend that you use Scalismo as a library instead. You can find for every tutorial in ScalismoLab a corresponding tutorial on https://scalismo.org/tutorials.html.

Best regards,

Marcel



--
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 scalismo+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalismo/0e49b823-87da-4207-aaf0-d13c56d84299%40googlegroups.com.

Edwin Tay

unread,
Oct 23, 2019, 3:26:59 PM10/23/19
to scalismo
Marcel, 

Thank you for your reply and advice on Scalismo. I tried using the LBFGS Optimizer and increasing the scaling factor, find the code attached. The results seem to have improved slightly. Image_1 and Image_2 show the pre and post-registration effects respectively. Image_3 shows the shape model I created from a reference (in red) and the target mesh (in white). Could the reason for my poor registration be just due to the size difference? Would increasing the number of sampled points help? I'm not too sure how else to proceed. Sorry for the late reply, have been really busy with other projects in university. Thanks again for taking the time to help me :)

Regards,

Edwin
To unsubscribe from this group and stop receiving emails from it, send an email to scal...@googlegroups.com.
image_1.jpg
image_2.jpg
image_3.jpg
Registration Code.txt

Marcel Luethi

unread,
Oct 24, 2019, 10:44:26 AM10/24/19
to Edwin Tay, scalismo
Hi Edwin,

There is definitely still something wrong with your registration. The results for such simple shapes as the femur should be much better (<< 1 mm average distance).

To figure out if the problem is due to the size difference, you can try to sample random shapes from the model (sing e.g. scalismo ui). If there are samples that are of similar size as your target, the size difference should not be a problem. You could also try to lower the regularization parameter and to use more points in the evaluation.

Best wishes,

Marcel

To unsubscribe from this group and stop receiving emails from it, send an email to scalismo+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalismo/4f3d96da-ef53-4ecf-93ad-fcdafd5b58a8%40googlegroups.com.

Edwin Tay

unread,
Oct 24, 2019, 7:07:58 PM10/24/19
to scalismo
Marcel, 

I have looked at sampling random shapes from my model and it seems possible. I have also tried lowering my regularization parameter and increasing the number of sampled points but to no avail. Find attached the two meshes I have been trying to register (I have been using femur 1 as the reference). I have been regularly getting avg. distances of around 2.3 and above. 

Regards,

Edwin
femur1.vtk
femur2.vtk

Dennis Madsen

unread,
Oct 25, 2019, 8:27:53 AM10/25/19
to scalismo
Hi Edwin, 

As such your code seems okay. But maybe you need some more local changes in your deformations. So using a mixture of gaussian kernels could help.  
Have a look at the repository here: https://github.com/unibas-gravis/icp-proposal/ 
Example code is given on how to construct a femur GP model using a mixture of kernels: https://github.com/unibas-gravis/icp-proposal/blob/master/src/main/scala/apps/femur/CreateGPModel.scala 
You will be using a femur GP model for registration using the simple ICP algorithm. This will usually give you avg distance error < 0.5 mm.

Alternatively try to use one of the models from: https://github.com/unibas-gravis/icp-proposal/tree/master/data/femur 
in your registration code.

Best
Dennis

Edwin Tay

unread,
Oct 26, 2019, 7:35:17 AM10/26/19
to scalismo
Dennis, 

Thank you for your advice. I have tried your method and modified my model with a couple of gaussian kernels. Then I used ICP for registration. Unfortunately, I don't have much time to commit to trying to learn Scalismo using an IDE, so for the time being, I'm using ScalismoLab but can definitely see the benefits of switching over. The projection of the fit is definitely much smoother than before (Image_1), but there is definitely room for improvement I feel. Image_2 shows my fit and my target, where the fit is in red. Find attached my code. I think I could improve on the sigma values and scaling factor of the kernels maybe? Or could the way I created the kernels themselves be improved? The average distance between my target and my fit is about 3.03 (evaluated using MeshMetrics.avgDistance).

As a side note, what's the best way to go about evaluating the average distance between my 'fit' and my target? The code I have outputs the result of the recursion but does not seem to allow me to use MeshMetrics.avgDistance(fit, newBone) as it doesn't recognise 'fit'. My workaround is to save 'fit' as a vtk file and reimport it into ScalismoLab but that seems very inefficient. 

Regards,

Edwin
image_1.jpg
image_2.jpg
registercodetest3.txt

Maia R.

unread,
Oct 20, 2021, 3:07:08 PM10/20/21
to scalismo
Hi Marcel,

This is a  very old post, I wish you could see it again.
I have a question on how did you obtain those values ( scaling factor of 80 to 150 for the femur).
Best regards
Maia

Marcel Luethi

unread,
Oct 21, 2021, 7:57:01 AM10/21/21
to Maia R., scalismo
Hi Maia

You need to understand that the scaling factor determines the variance of the point position in the model. So a scaling of 160 would mean that a deformation at a point would have 40 mm standard deviation in each direction. Such considerations allow you to guess reasonable values.

The next step is to validate your assumptions by sampling random shapes from the prior. If the deformations of the random samples lie within the expected range of your data, you can try to fit the model and see if you get good results.

Best regards,
Marcel


V R

unread,
Oct 21, 2021, 8:35:15 AM10/21/21
to Marcel Luethi, scalismo
Hi Marcel,
Thank you Marcel, so if I understand, it could be a kind of try and error with some a priori knowledge about the shape.
My challenge is that in order to have a very flexible model, I used a multiscale kernel but when I sample from the model, some samples are not realistic at all. 
Could I use the model validation to tune the kernel parameters ?
Best regards,
Maia

Maia R.

unread,
Oct 21, 2021, 1:40:36 PM10/21/21
to scalismo

Hi Marcel,
In order to be sure that there is no confusion, when you say 'scaling factor', do you mean sigma in the Gaussian or the parameter to multiply the gaussian with ?

private val baseKernel = GaussianKernel3D(90) * 10.0
is scaling factor = 90 or 10.0 ?

Sorry if I'm bit confused because, you said that the scaling factor for the femur should be 80 to 150 but for this example, it is, IMHO equal to 10, or did I misunderstand something ?

Thank you very much,
Best regards
Maia

Andreas Morel-Forster

unread,
Oct 22, 2021, 4:05:50 PM10/22/21
to scal...@googlegroups.com

Hi Maia

The scaling factor woud be 10 in this case. This relates how strong the deformations are.

But pay attention, the parameter 90 in the example is often called the lengthscale. This refers to how far on the shape things are correlated.

Best, Andreas

V R

unread,
Oct 23, 2021, 6:45:31 AM10/23/21
to Andreas Morel-Forster, scalismo
Thank you very much.
Best regards
Maia

Reply all
Reply to author
Forward
0 new messages