# Open Anatomy Export in gltf format

**URL:** <https://discourse.slicer.org/t/open-anatomy-export-in-gltf-format/34819>\
**Category:** Support\
**Tags:** extensions-manager, file-export, openanatomy\
**Created:** [March 11, 2024, 10:43am UTC](https://discourse.slicer.org/t/open-anatomy-export-in-gltf-format/34819 "2024-03-11T10:43:57Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Caterina](https://avatars.discourse-cdn.com/v4/letter/c/439d5e/32.png) [@Caterina](https://discourse.slicer.org/u/Caterina)\
**Post date:** [March 11, 2024, 10:43am UTC](https://discourse.slicer.org/t/open-anatomy-export-in-gltf-format/34819/1 "2024-03-11T10:43:57Z")

</div>

Dear support,  
I used Lung CT Segmented and Analyzer extensions and I exported lung volume from segmentation and vessels from CT Analyzer in gltf format using Open Anatomy.  
The visualization in Slicer showed good details of lung with internal vessels.  
When I open the same gltf file with several online gltf viewer ([https://gltf-viewer.donmccurdy.com/](https://gltf-viewer.donmccurdy.com/), [glTF Sample Viewer](https://github.khronos.org/glTF-Sample-Viewer-Release/)), the models of lungs are correctly represented while the vessels models appeared as an unrealistic tetrahedral structure. what could be the problem?  
Thanks

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 12, 2024, 12:24pm UTC](https://discourse.slicer.org/t/open-anatomy-export-in-gltf-format/34819/2 "2024-03-12T12:24:55Z")

</div>

Could you please attach a few screenshots of the appearance in 3D Slicer and in the glTF viewers?

---

<div class="post-metadata">

**Author:** ![Caterina](https://avatars.discourse-cdn.com/v4/letter/c/439d5e/32.png) [@Caterina](https://discourse.slicer.org/u/Caterina)\
**Post date:** [March 12, 2024, 12:33pm UTC](https://discourse.slicer.org/t/open-anatomy-export-in-gltf-format/34819/3 "2024-03-12T12:33:06Z")

</div>

Here the screenshot of the visualization using Slicer and the gltfviewer online.

 ![Lung + Vessels](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/f/df40278fce94f3085535013099e15a7f07a0bf47.jpeg)  
 ![Screenshot 2024-03-12 alle 13.26.35](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/4/549b33ce731b74544289ac8d4b7e181dea8092b9.jpeg)  
The same situation occurs when I consider lung vessels as total segmentation results.  
Thanks

---

<div class="post-metadata">

**Author:** ![Caterina](https://avatars.discourse-cdn.com/v4/letter/c/439d5e/32.png) [@Caterina](https://discourse.slicer.org/u/Caterina)\
**Post date:** [March 16, 2024, 5:59pm UTC](https://discourse.slicer.org/t/open-anatomy-export-in-gltf-format/34819/4 "2024-03-16T17:59:18Z")

</div>

Thanks to the help of @lassoan, I found out glTF only supports PBR shading (Figure in the upper side).  
Just other few questions:  
-Why if I export only the segmentation, the lung models are correctly visible and the vessels not?  
-So the correct procedure is to convert segmentation to models, set the PBR interpolation and then export in gltf format using Open Anatomy Export?  
-The vessels segmentation in Slicer (using chest ct of your database) appeared with poor dimensional resolution (vessels seems to be unreal). Can I ask you the best results concerning lung vessels segmentation and what resolution and type of source dicoms should be considered?  
Thank you

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 17, 2024, 12:13am UTC](https://discourse.slicer.org/t/open-anatomy-export-in-gltf-format/34819/5 "2024-03-17T00:13:29Z")

</div>

> [@Caterina](#):
>
> Why if I export only the segmentation, the lung models are correctly visible and the vessels not?

The gltTF file is generated the same way, regardless of the input is a segmentation or a model tree. Please compare the two files (they are just simple text files that you can open in any text editor or text comparison tool) and let us know what the differences are.

However, it would better if you used a 3D viewer that propertly supports transparent surface rendering (can do depth sorting, depth peeling, or similar methods).

> [@Caterina](#):
>
> So the correct procedure is to convert segmentation to models, set the PBR interpolation and then export in gltf format using Open Anatomy Export?

What you describe works but more complex than necessary.

> [@Caterina](#):
>
> The vessels segmentation in Slicer (using chest ct of your database) appeared with poor dimensional resolution (vessels seems to be unreal). Can I ask you the best results concerning lung vessels segmentation and what resolution and type of source dicoms should be considered?

For high-quality vessel segmentation you need high-resolution images. Typical resolution for surgical planning is 1mm. For vessel segmentation (especially for veins) you may need contrast agent.

* * *

For your information, Slicer now offers fully automated lung, lobes, airways, and vessel segmentation. There are several active discussions about it see for example here:

> [@Using MONAI label to fine tune the vessel segmentation](https://discourse.slicer.org/t/using-monai-label-to-fine-tune-the-vessel-segmentation/34869):
>
> Hi, I have acheived robust and satisfactory segmentation result when using lungCTsegmenter before. [image] However, if i use other samples(LIDC-IDRI dataset), most of the results have lung/vessel leaks. Should I use MONAI label to finetune the vessel segmentation part, or this is not a good use case? Since I watch this demo: [[MONAI Label Workshop - Project Week 37] ](https://www.youtube.com/watch?v=wtiEe_jiUzg&t=5531s) (1:35:27) and t…

---

<div class="post-metadata">

**Author:** ![Caterina](https://avatars.discourse-cdn.com/v4/letter/c/439d5e/32.png) [@Caterina](https://discourse.slicer.org/u/Caterina)\
**Post date:** [March 18, 2024, 9:11am UTC](https://discourse.slicer.org/t/open-anatomy-export-in-gltf-format/34819/6 "2024-03-18T09:11:24Z")

</div>

Dear @lassoan,  
first of all thanks for support and for informations.

> [@lassoan](#):
>
> Please compare the two files (they are just simple text files that you can open in any text editor or text comparison tool) and let us know what the differences are.

I will check and share with you the differences.

> [@lassoan](#):
>
> What you describe works but more complex than necessary.

What do you mean?

> [@lassoan](#):
>
> For high-quality vessel segmentation you need high-resolution images. Typical resolution for surgical planning is 1mm. For vessel segmentation (especially for veins) you may need contrast agent.
> 
> * * *
> 
> For your information, Slicer now offers fully automated lung, lobes, airways, and vessel segmentation.

Thanks for sharing with me this extention. I compared the results of segmentation using: a) Lung segmentation extension and then vessels segmentation using Total segmentation and b) Monai extension. I used the same source origin (toracic volumetric with high resolution (slice thickness: 1 mm)). In both cases, if I zoom on vessels resolution, the result is not good (see picture in attach).

 ![Screenshot_3](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/d/7dfdc49713eba4f454ae8368d1b37fdfa6aad9fc.jpeg).  
So, in order to have good resolution on vessels segmentation, I need contrast agent dicom?  
Thanks

---

<div class="post-metadata">

**Author:** ![klc](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/klc/32/68248_2.png) [@klc](https://discourse.slicer.org/u/klc)\
**Post date:** [March 21, 2024, 5:26pm UTC](https://discourse.slicer.org/t/open-anatomy-export-in-gltf-format/34819/7 "2024-03-21T17:26:21Z")

</div>

Hi professor, looks like I have some problem when I am exporting the segmentation to gltf, the segmetation from slicer looks like this

 ![WhatsApp Image 2024-03-19 at 14.32.08_0c92a6f3](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/8/6824278c7150b4a94aaff10129783b0224738df0.jpeg)

However, when exported to unity, the blood vessels in the gltf become like this  
 ![WhatsApp Image 2024-03-21 at 23.39.09_2ccb8ed4](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/c/bc34fd69528d7e3fceaa92bb1136ed2c0599f582.jpeg)  
 ![WhatsApp Image 2024-03-21 at 15.23.22_f7fa8218](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/9/b9aa7dc607f8ff2ea4d675f8da7f0d6cd5135356.jpeg)

I tried using an online gltf viewer and it seems that there is a similar problem:

 ![WhatsApp Image 2024-03-22 at 00.14.29_7d52cf30](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/2/22543d2d445848f12a77b3f57eb43ce476171845.jpeg)

May I know what can be done to solve this problem

Thank you

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 21, 2024, 7:05pm UTC](https://discourse.slicer.org/t/open-anatomy-export-in-gltf-format/34819/8 "2024-03-21T19:05:07Z")

</div>

For intricate structures like this, you need to reduce the decimation.

---

<div class="post-metadata">

**Author:** ![klc](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/klc/32/68248_2.png) [@klc](https://discourse.slicer.org/u/klc)\
**Post date:** [March 22, 2024, 5:31am UTC](https://discourse.slicer.org/t/open-anatomy-export-in-gltf-format/34819/9 "2024-03-22T05:31:50Z")

</div>

Thank you for your prompt response. I followed this video for decimation and indeed got better results.

[![](https://img.youtube.com/vi/d-0y7BHJ0oU/maxresdefault.jpg "Reduce the File Size of Your 3D Model - "Decimation" [3D Slicer Workflow]") ](https://www.youtube.com/watch?v=d-0y7BHJ0oU)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/e/4eaba74614615f672275c42d8b9f203125b2e9ad.png)

May I also know that if there are little pieces of blood fragments near the blood vessel but they are not connected (see attached), apart from manually segmenting them out, is there a better way in the surface tool box extensions or other extensions to clean them up.

thank you very much

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 22, 2024, 12:11pm UTC](https://discourse.slicer.org/t/open-anatomy-export-in-gltf-format/34819/10 "2024-03-22T12:11:11Z")

</div>

Small vessels are usually not needed for surgical planning and just occlude relevant parts, so commonly users apply Islands effect / Keep largest island method on the automatic vessel extraction result to get rid of them.

---

<div class="post-metadata">

**Author:** ![klc](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/klc/32/68248_2.png) [@klc](https://discourse.slicer.org/u/klc)\
**Post date:** [March 22, 2024, 5:43pm UTC](https://discourse.slicer.org/t/open-anatomy-export-in-gltf-format/34819/11 "2024-03-22T17:43:56Z")

</div>

Thank you  
Sorry for asking again. I found that for some other samples, the black spots still persist after numerous decimation, I have used larger value for decimation and tried other methods in the surface toolbox (uniform remesh, decimate, smooth, compute surface normals) If i use keep largest or island, it will only get a sub part of the vessels since they are not connected. I am still not sure why this problem happened, do you have other suggestions to solve it ?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/5/c51352c3fcee396a37677996faa4cfbb1de7b1dc.jpeg)

Moreover, may I know is it possible to write a simple python script that can eliminate small fragments that are smaller than some size (e.g. 10 mm)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/a/ca3afd42142109ea4f2bed6332693c51f6c0df91.jpeg)

Thank you very much for your response.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 22, 2024, 6:47pm UTC](https://discourse.slicer.org/t/open-anatomy-export-in-gltf-format/34819/12 "2024-03-22T18:47:36Z")

</div>

You can use many tools in Segment Editor to get rid of small vessels but preserve large ones. It is an independent question from glTF export and is discussed in separate topics on this forum. Please read [recent topics related to lung](https://discourse.slicer.org/tag/lung) and if you have trouble producing good lung vessel segmentation then you can ask for more help by commenting in those topics.

> [@klc](#):
>
> have used larger value for decimation and tried other methods in the surface toolbox (uniform remesh, decimate, smooth, compute surface normals)

These are all unnecessary. What I meant is to simply decrease the “Reduction factor” in the OpenAnatomy Export module to a lower value to preserve more details. If you set the slider to 0 then the exported glTF file will contain the exact same details as you see in Slicer.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/8/38e53daa82f026ff2198394a26ebb7c1a2719144.png)

---

<div class="post-metadata">

**Author:** ![klc](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/klc/32/68248_2.png) [@klc](https://discourse.slicer.org/u/klc)\
**Post date:** [March 23, 2024, 3:28am UTC](https://discourse.slicer.org/t/open-anatomy-export-in-gltf-format/34819/13 "2024-03-23T03:28:16Z")

</div>

Thank you for your prompt response. I found that the exported blood vessels was not displayed correctly in gltf or obj. I have tried 0.0 decimation value. I have tried different platforms, meshlab, online viewer and unity but the result is still the same.

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/f/bfe99db068ba7cb38b2fb8e85e82c06640f9c709.png)  
blood vessels in unity obj

![WhatsApp Image 2024-03-22 at 18.27.22_8df728f9](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/f/bff1fbc066f857a07edbb0d34b1e8216c8a1f606.jpeg)  
blood vessels in unity gltf

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/3/f366e03cc1511dc99e6bd7e33da4a6a251832950.png)  
blood vessels in meshlab obj

Steps to reproduce:  
Data: LIDC-IDRI-0078  
Slicer 5.6.1, Slicer 5.7.0 Preview release.  
Use MONAI Auto 3D seg, lung 2.0.1 to produce lung segmentation  
Export to gltf using Openanatomy export

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/6/16a54505b4bbf71af43d91210cadb754b899ba68.png)  
This is the expected vessels in slicer

May I know if there is any workaround?

Thank you very much

---

<div class="post-metadata">

**Author:** ![klc](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/klc/32/68248_2.png) [@klc](https://discourse.slicer.org/u/klc)\
**Post date:** [March 23, 2024, 6:08am UTC](https://discourse.slicer.org/t/open-anatomy-export-in-gltf-format/34819/14 "2024-03-23T06:08:44Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/0/c0aafba82898d90d6e781c2858eff9e662c3cc88.jpeg)  
I found that the decimation process also produced some errors in slicer but was not able to resolve them.

The errors prevented the GLTF file from being opened in Unity, causing compatibility issues. If I opened the gltf file on gltf viewer online, looks like the vessel can be shown clearly but there are still a lot of errors as shown on the left bottom corner.

 ![WhatsApp Image 2024-03-23 at 13.33.13_353048f6](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/8/18cac6441c0a9143a6d9222410f4cb0cd1d12b75.jpeg)  
Fig 1: The vessels are shown correctly on gltfviewer after decimation  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/e/1ea3bd168e92b3650bfd19b9b2f63cd1d4b99a61.jpeg)  
errors of the gltf file after decimation

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/a/faea78178137f08265ce4073043024bb6ee6cb40.png)

On the other hand, I used the CT chest sample from slicer and created a lung segmentation using v2.0.1 MONAI 3D Auto Seg and the blood vessels have similar problem. The attached picture didn’t undergo any decimation. The result after decimation is similar too.

I use both Slicer 5.6.1 and preview release version. For the 5.6.1 version, the problem persist after decimation. For the preview release version, the display results after decimation are acceptable but with errors, those errors prevent the file from being opened in Unity.

Please check if the openanatomy export to gltf function is working correctly

@lassoan @rbumm

Thank you very much.

---

<div class="post-metadata">

**Author:** ![Caterina](https://avatars.discourse-cdn.com/v4/letter/c/439d5e/32.png) [@Caterina](https://discourse.slicer.org/u/Caterina)\
**Post date:** [April 2, 2024, 8:20am UTC](https://discourse.slicer.org/t/open-anatomy-export-in-gltf-format/34819/15 "2024-04-02T08:20:40Z")

</div>

Dear @lassoan.  
I have similar problems of @klc.  
In addition, when I export models with several % of trasparency in gltf format using OpenAnatomy and I visualize them on Hololens 2 device, the models are always opaque.  
Can you please suggest me a solution?  
Thanks
