# Automate converting model to segmentation

**URL:** <https://discourse.slicer.org/t/automate-converting-model-to-segmentation/14305>\
**Category:** Support\
**Created:** [October 29, 2020, 1:27pm UTC](https://discourse.slicer.org/t/automate-converting-model-to-segmentation/14305 "2020-10-29T13:27:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon69961241](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@anon69961241](https://discourse.slicer.org/u/anon69961241)\
**Post date:** [October 29, 2020, 1:27pm UTC](https://discourse.slicer.org/t/automate-converting-model-to-segmentation/14305/1 "2020-10-29T13:27:26Z")

</div>

I have a set of MRI dicoms and STL model images, I am wanting to create binary segmentation maps from the models, which i can do fine manually using these steps:

- 

```
Go to Segmentations module

```

- 

```
Create new segmentation node

```

- 

```
Change master to Closed surface

```

- 

```
In Import/Export section import the model node to the segmentation node

```

- 

```
Export visible segments to binary labels map

```

But i have a lot of cases i need to do, so was wondering what is the actual code being executed to load in the STL files and convert them to a segmentation map? So i can automate the process

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:** [October 30, 2020, 4:34am UTC](https://discourse.slicer.org/t/automate-converting-model-to-segmentation/14305/2 "2020-10-30T04:34:24Z")

</div>

See several examples of how to automate these conversions in the script repository: [https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Segmentations](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Segmentations)

---

<div class="post-metadata">

**Author:** ![mohammed\_Chekroun](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mohammed_chekroun/32/76602_2.png) [@mohammed\_Chekroun](https://discourse.slicer.org/u/mohammed_Chekroun)\
**Post date:** [May 21, 2024, 11:23am UTC](https://discourse.slicer.org/t/automate-converting-model-to-segmentation/14305/3 "2024-05-21T11:23:33Z")

</div>

Did you please find the code for this automation, I tried it with slicer but it’s so slow
