Scale model in gltf

Good morning,
I performed segmentation and I would like to scale the results of segmentation in gltf format.
Actually I can scale the model in stl using Surface Toolbox or save the unscaled model in gltf.
I need to scale the model and export it in gltf.
Can I hace suggestion about this topic?

Then why can’t you export the scaled model from Surface toolbox as GLTF?

Surface Toolbox allows to scale segmentation objects (stl or obj).
OpenAnatomy allows to export gltf model but it doesn’t see segmentation objects previously scaled with Surface Toolbox.

That doesn’t sound right.

You should be able to export models from OpenAnatomy, not just segmentation. They need to be under a subject hierarachy, thought i believe. So try making a folder within your data module, move your scaled model under that folder and then try the OA one more time.

This worked for me with 5.4.

Thanks for suggestions.
Since my segmentation is made up of many segmentations (result from TotalSegmentation), when I export the models, many models are also created. Is there a way to merge them together before scaling them and then export them to gltf?Thanks

I’ve checked the glTF standard and actually the length unit is specified to be in meters. So, I’ve updated the OpenAnatomy export module to always export in meters. You can get the updated extensions from the Extensions Manager tomorrow or later.

Thank you very much for support and for information. Hasn’t the unit of measurement for the OpenAnatomy export module been meters so far? Concerning the way to merge the segmentations together and then export them to gltf, can you please suggest me a solution?

Length unit in Slicer (and in DICOM and in all medical image computing software) is millimeters. OpenAnatomy export module has exported all models in millimeters, too.

In the latest module, I’ve included a millimeter to meter scaling transformation in the root of the glTF file, so we comply to glTF specifications.

You can verify distances in a glTF file using an independent viewer, such as - just drag-and-drop the exported glTF file to the viewer and use the measurement tool.

Dear Prof Lasso,
thanks a lot for the updates and for modifying the OpenAnatomy Export module.
However, I can’t see a millimeter to meter scaling transformation in the root of the glTF file.
Can you please share with me a screenshot of the modified module?

I’ve already provided the link to the change above, but here it is again:

Note that you need to use the latest Slicer Stable Release or latest Slicer Preview Release to get extension updates.

Thanks a lot.
I’m using 5.4.0 version. I also checked the updates of openAnatomy module from extentions manager.

It should be all good then. To confirm, you can click the “Edit” button to load the .py file and see if the changes in the commit that I linked above are there.

Thanks again. Here the screen of the .py file in which the changes you made
are present.

But there is no selection on the user interface related to dimension conversion.

According to glTF standard, the distance unit in the world coordinate system is meter. Therefore we do not allow the user to select units but always use meter.

Dear Prof Lasso,
thanks a lot for support and for your patience.
I need to export segmentation results from TotalSegmentation (several volumes) as gltf file with the same dimensions that I see on 3d slicer (for example around 650 mm).
Actually, after exporting using OpenAnatomy, the dimension will be 650 m.
So I need to scale before exporting as gltf. Is there a way to scale all volumes of a segmentation at once?

There is something amiss here. You wouldn’t see 650mm being reported as 650m. You should see 650mm being reported as 0.65m in the software you are loading the exported glTF file, because the scaleToMeters function shown above divides the values by 1000, if the units are millimeters (which is default in slicer).

Regardless if you want to try this on your own for further troubleshooting, create a linear transform whose first three diagonals are 0.001, and then put your segmentation under it, and harden the transform (that’s what the code snipped above is doing).

Then you can perhaps figure out where the issue is coming from.

Please check in the Extensions Manager if you have the latest version of the SlicerOpenAnatomy extension installed:

If you have this version, then you can do a simple test to confirm it works well:

As you can see, the segment length measurement result was the same in Slicer (114mm) and in the glTF viewer (0.111m).

Maybe you haven’t used the current version of SlicerOpenAnatomy extension or you used a glTF viewer that measured distance incorrectly.