# Segementation mask file (.nii format) convert .stl format

**URL:** https://discourse.slicer.org/t/segementation-mask-file-nii-format-convert-stl-format/24971
**Category:** Support
**Tags:** segmentation, stl
**Created:** [August 29, 2022, 7:02am UTC](https://discourse.slicer.org/t/segementation-mask-file-nii-format-convert-stl-format/24971 "2022-08-29T07:02:23Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![wawa](https://avatars.discourse-cdn.com/v4/letter/w/f05b48/32.png) [@wawa](https://discourse.slicer.org/u/wawa)
#### Post date: [August 29, 2022, 7:02am UTC](https://discourse.slicer.org/t/segementation-mask-file-nii-format-convert-stl-format/24971/1 "2022-08-29T07:02:23Z")

</div>

Hi,  
I am able to convert my data ‘.nii’ Segementation mask files to Model ‘.stl’ files.  
Segementation mask files is for 3D medical images,which consists of multiple 2D slices.  
My Code

```auto
nii_pathname = ...   
seg = slicer.util.loadSegmentation(nii_pathname)
segmentationNode = slicer.mrmlScene.GetFirstNodeByClass("vtkMRMLSegmentationNode")
slicer.vtkSlicerSegmentationsModuleLogic.ExportSegmentsClosedSurfaceRepresentationToFiles(out, segmentationNode, None, "STL")

```

I think the conversion of mask to stl is a 3D reconstruction process, I would like to know what went through in the process and what functions were used?  
Looking forward to your reply.
