# Python script for converting nrrd to gltf

**URL:** <https://discourse.slicer.org/t/python-script-for-converting-nrrd-to-gltf/38101>\
**Category:** Development\
**Created:** [August 28, 2024, 8:56pm UTC](https://discourse.slicer.org/t/python-script-for-converting-nrrd-to-gltf/38101 "2024-08-28T20:56:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![anuragp2018](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/anuragp2018/32/77765_2.png) [@anuragp2018](https://discourse.slicer.org/u/anuragp2018)\
**Post date:** [August 28, 2024, 8:56pm UTC](https://discourse.slicer.org/t/python-script-for-converting-nrrd-to-gltf/38101/1 "2024-08-28T20:56:18Z")

</div>

Hello  
i want python script that convert nrrd to 3d like slicer convert 3d.

---

<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:** [August 28, 2024, 8:58pm UTC](https://discourse.slicer.org/t/python-script-for-converting-nrrd-to-gltf/38101/2 "2024-08-28T20:58:22Z")

</div>

NRRD is already 3D, no conversion is necessary. Do you need the data in a certain file format?

---

<div class="post-metadata">

**Author:** ![anuragp2018](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/anuragp2018/32/77765_2.png) [@anuragp2018](https://discourse.slicer.org/u/anuragp2018)\
**Post date:** [August 29, 2024, 3:44am UTC](https://discourse.slicer.org/t/python-script-for-converting-nrrd-to-gltf/38101/3 "2024-08-29T03:44:38Z")

</div>

yes in gltf or glb format

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [August 29, 2024, 9:01am UTC](https://discourse.slicer.org/t/python-script-for-converting-nrrd-to-gltf/38101/4 "2024-08-29T09:01:41Z")

</div>

For this you will need to segment the structures and then export the closed surface to GLTF.

Here are two extensions that can do automatic segmentation. The TotalSegmentator video includes GLTF export as well towards the end.

> [@New extension: Fully automatic whole-body CT segmentation in 2 minutes using TotalSegmentator](https://discourse.slicer.org/t/new-extension-fully-automatic-whole-body-ct-segmentation-in-2-minutes-using-totalsegmentator/26710):
>
> The [TotalSegmentator AI model is now available as an extension for 3D Slicer](https://github.com/lassoan/SlicerTotalSegmentator#totalsegmentator) version 5.2 and above (see installation instructions [here](https://github.com/lassoan/SlicerTotalSegmentator#setup)). A large number of AI segmentation models have been developed over the past few years, but [TotalSegmentator](https://github.com/wasserth/TotalSegmentator) stands out in several aspects: it can segment many structures: 104 anatomical structures (all abdominal organs, bones, larger vessels, muscles) it is very robust: it can segment any whole-body, abdominal, chest CT images, regardless of image…

> [@New extension: MONAI Auto3DSeg - raise the bar in AI medical image segmentation](https://discourse.slicer.org/t/new-extension-monai-auto3dseg-raise-the-bar-in-ai-medical-image-segmentation/35680):
>
> New extension: MONAI Auto3DSeg - raise the bar in AI medical image segmentation MONAI Auto3DSeg extension is a collaboration between MONAI and 3D Slicer developer teams (led by Andres Diaz Pinto - NVIDIA and Andras Lasso - PerkLab) to improve on the state-of-the-art in fully automatic 3D medical image segmentation and make the results widely accessible. The extension comes with dozens of pre-trained segmentation models for specific clinical use cases, which are designed to be fast and run anywh…

---

<div class="post-metadata">

**Author:** ![anuragp2018](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/anuragp2018/32/77765_2.png) [@anuragp2018](https://discourse.slicer.org/u/anuragp2018)\
**Post date:** [August 29, 2024, 9:22am UTC](https://discourse.slicer.org/t/python-script-for-converting-nrrd-to-gltf/38101/5 "2024-08-29T09:22:56Z")

</div>

but i want to export gltf using python script

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [August 29, 2024, 9:25am UTC](https://discourse.slicer.org/t/python-script-for-converting-nrrd-to-gltf/38101/6 "2024-08-29T09:25:40Z")

</div>

The GLTF exporter module is written in python. See what functions it has and call them appropriately.

---

<div class="post-metadata">

**Author:** ![anuragp2018](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/anuragp2018/32/77765_2.png) [@anuragp2018](https://discourse.slicer.org/u/anuragp2018)\
**Post date:** [September 1, 2024, 6:11pm UTC](https://discourse.slicer.org/t/python-script-for-converting-nrrd-to-gltf/38101/7 "2024-09-01T18:11:50Z")

</div>

but it uses slicer i don’t want to use slicer.

---

<div class="post-metadata">

**Author:** ![chir.set](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chir.set/32/66982_2.png) [@chir.set](https://discourse.slicer.org/u/chir.set)\
**Post date:** [September 1, 2024, 6:18pm UTC](https://discourse.slicer.org/t/python-script-for-converting-nrrd-to-gltf/38101/8 "2024-09-01T18:18:35Z")

</div>

> [@anuragp2018](#):
>
> but it uses slicer i don’t want to use slicer

Are you serious? Please recall it’s a Slicer forum. Developers kindly offer free support here, but your demand will drive them in a confused state.

---

<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:** [September 2, 2024, 3:13am UTC](https://discourse.slicer.org/t/python-script-for-converting-nrrd-to-gltf/38101/9 "2024-09-02T03:13:29Z")

</div>

Yes, “i don’t want to use slicer” is indeed confusing, especially because it can mean so many things. Do you mean that you don’t want to use Slicer GUI, or don’t want to use Slicer’s Python environment, don’t want to use libraries that Slicer is using (mainly ITK and VTK), …?

In general, we give the simplest solution to the questions that users are asking, which uses the Slicer GUI or Python scripting within Slicer. However, since Slicer usually just adds a thin wrapper over pip-installable libraries, you can start from a script that runs in Slicer, and then step by step replace Slicer-specific parts (by looking at what Slicer does and replicate that with your own code).
