Python script for converting nrrd to gltf

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

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

yes in gltf or glb format

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.

but i want to export gltf using python script

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

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.

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).