Tutorial 3 giving unexpected results for mean mesh (for both STL and PLY formats)

82 views
Skip to first unread message

Cory Ferraz

unread,
Dec 21, 2021, 4:38:24 AM12/21/21
to scalismo
Hello!

I am working on tutorial 3 and I have been having difficulties getting good results for both deformation fields and the average mesh for a sample of three C1's (cervical spine). Please see the attached results.

I have tried both ply and stl file formats. Used icp, and landmark based rigid fit to bring the three meshes in alignment and have used two different sets of three C1's. I do not know what else to do except use a different software like geomagic to calculate my desired reference mesh (mean mesh of 20+ sample C1's). I have even reduced the mesh so that all three meshes have equal vertices and faces. 

Regards,
Cory
deformation field.JPG
equal vertices and faces.jpg
icp rigid fit 3 meshes.jpg
mean mesh.jpg

Max

unread,
Dec 23, 2021, 4:39:49 AM12/23/21
to scalismo
Hi Cory,

it seems your meshes are not in correspondence. If they were, there would be no need to "reduce the mesh so that all three meshes have equal vertices and faces". Correspondence means that all meshes share the same topology (equal number of vertices and same triangulation) and that semantically equal points have the same point id. This can be achieved by registering a common reference mesh to all three (or two, if you use the first mesh of your data set as reference) meshes of your data set. Did you use the registered meshes together with the reference mesh to calculate the mean deformation?

Best
Max

Cory Ferraz

unread,
Dec 23, 2021, 5:50:59 PM12/23/21
to scalismo
Nice to meet you Max,

Maybe I am confused but I thought running the ICP rigid fit (tutorial 10) would both align the target mesh to the reference mesh as well as register the target mesh to the reference mesh (via  LandmarkRegistration.rigid3DLandmarkRegistration).

What I performed above was run the ICP for rigid alignment (from tutorial 10) two separate times to align + register mesh2 and mesh3 to my reference, mesh1.  I have been saving the ICP_rigid_fit models of each using the UI, placing them in a new folder with mesh1, then running the code for tutorial 3 to get the mean mesh + deformation field (unsuccessfully). Where am I making a mistake? Is there a step I am missing?

My goal for this next step is to take my 20+ samples, register them and find the mean mesh of the 20+ samples to use as my reference for my SSM. Any examples of a program already written would be very beneficial too since I am a beginner to intermediate coder at best.


Cory

Max

unread,
Dec 27, 2021, 4:06:42 PM12/27/21
to scalismo
Hi Cory,

rigid ICP will not establish proper dense correspondence as it only aligns two meshes using a global, rigid transformation applied to each point of a mesh. You need to run a non-rigid registration (such as described in Tutorial 11 or 12, for example) in which a reference mesh is fitted towards each of your target meshes. Afterward, all meshes share the same topology (namely those of the chosen reference mesh) and semantically equal points have the same id (provided your registration is good enough).

Hope this helps!

Best
Max
Message has been deleted

Cory Ferraz

unread,
Dec 28, 2021, 2:55:10 AM12/28/21
to scalismo
I figured it out Max. Thank you for the guidance!

Cory

Cory Ferraz

unread,
Dec 30, 2021, 12:23:54 PM12/30/21
to scalismo
One more question. I developed a pdm using tutorial 6. How do I save the pdm (.h5 file) so that I can use it in future tutorials?

Up to now, I have been saving my meshes using the Scalismo UI (right clicking the mesh and saving manually). However, with the models I am unable to do that. I apologize for the simple question. I am learning scala as I use your software and I am still a beginner.

Cory

Marcel Luethi

unread,
Dec 30, 2021, 3:21:10 PM12/30/21
to Cory Ferraz, scalismo
Dear Cory

No need to apologize :-)

You cannot save the model from the ui, but  you can save it from Scalismo using the following code:
val pdm : PointDistributionModel = ???
StatisticalModelIO.writeStatisticalPointModel3D(pdm, new java.io.File("filename.h5")).get

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/48a232e1-3cb8-4463-a9b3-cfe765637bd4n%40googlegroups.com.

Cory Ferraz

unread,
Jan 7, 2022, 4:34:19 AM1/7/22
to scalismo
Hi Marcel,

When I run the code I am receiving a type mismatch. The model I am providing is finding my pdm to be type "PointDistributionModel[_3D, TriangleMesh]" when it is requiring " "PointDistributionModel[_3D, UnstructuredPointsDomain]". 

I believe it is supposed to be "StatisticalModelIO.writeStatisticalTriangleMeshModel3D(model, new java.io.File("filename1.h5")).get" instead correct?

Cory

Marcel Luethi

unread,
Jan 7, 2022, 9:33:09 AM1/7/22
to Cory Ferraz, scalismo
Dear Cory

Yes you are right. Sorry for that . My autocompletion must have messed that up and I have not checked it.

Best regards
Marcel

Cory Ferraz

unread,
Jan 27, 2022, 3:24:54 AM1/27/22
to scalismo
How do you save a mesh file from scalismo (within the code)? None of the "StatisticalModelIO.write..." commands are working. I am trying to write a code that is a large loop that rigidly aligns meshes > registers them > takes the mean mesh > creates and writes the model.  Currently the only way I can save a mesh is within the scalismo UI.

Dennis Madsen

unread,
Jan 27, 2022, 7:47:29 AM1/27/22
to scalismo
Hi Cory, 

This can be done with the MeshIO module, 
e.g. 
val mesh: TriangleMesh[_3D] = ???
MeshIO.writeMesh(mesh, new File("mesh.ply")) 

The type can either be .stl, .ply, or .vtk. 

For meshes in correspondence, I would advise you NOT to use .stl, as we sometimes see problems with that format. 

Best
Dennis

Reply all
Reply to author
Forward
0 new messages