# Batch Processing Stl files into binary images for Radiomics

**URL:** <https://discourse.slicer.org/t/batch-processing-stl-files-into-binary-images-for-radiomics/37285>\
**Category:** Support\
**Tags:** python, 3d-model\
**Created:** [July 9, 2024, 3:02pm UTC](https://discourse.slicer.org/t/batch-processing-stl-files-into-binary-images-for-radiomics/37285 "2024-07-09T15:02:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven\_A](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/steven_a/32/14596_2.png) [@Steven\_A](https://discourse.slicer.org/u/Steven_A)\
**Post date:** [July 9, 2024, 3:02pm UTC](https://discourse.slicer.org/t/batch-processing-stl-files-into-binary-images-for-radiomics/37285/1 "2024-07-09T15:02:22Z")

</div>

Hi, is there a way to batch process the discretization of stl files into binary images to be loaded into either slicerradiomics or into pyradiomics for feature extraction? Or maybe there is a way to simply load in the stl file with trimesh or numpy-stl and discretize it in order to use pyradiomics?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 9, 2024, 3:17pm UTC](https://discourse.slicer.org/t/batch-processing-stl-files-into-binary-images-for-radiomics/37285/2 "2024-07-09T15:17:17Z")

</div>

Yes, you can do that with a small python script. See [these examples](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#segmentations)

---

<div class="post-metadata">

**Author:** ![Steven\_A](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/steven_a/32/14596_2.png) [@Steven\_A](https://discourse.slicer.org/u/Steven_A)\
**Post date:** [July 9, 2024, 3:25pm UTC](https://discourse.slicer.org/t/batch-processing-stl-files-into-binary-images-for-radiomics/37285/3 "2024-07-09T15:25:23Z")

</div>

How do you go about batch importing files into a MRML scene and then accessing each node in order to use the example code you provided?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [July 9, 2024, 3:53pm UTC](https://discourse.slicer.org/t/batch-processing-stl-files-into-binary-images-for-radiomics/37285/4 "2024-07-09T15:53:04Z")

</div>

Generally you probably want to load each one, convert it, save it, and delete it. Just do that in a loop over all your file names. I don’t think we have a canned example of that but it’s something a chatbot should be good at generating for you.
