# save segmentation  

**URL:** <https://discourse.slicer.org/t/save-segmentation/13923>\
**Category:** Support\
**Tags:** segmentation\
**Created:** [October 7, 2020, 2:45pm UTC](https://discourse.slicer.org/t/save-segmentation/13923 "2020-10-07T14:45:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eslam\_Abdo](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/eslam_abdo/32/8356_2.png) [@Eslam\_Abdo](https://discourse.slicer.org/u/Eslam_Abdo)\
**Post date:** [October 7, 2020, 2:45pm UTC](https://discourse.slicer.org/t/save-segmentation/13923/1 "2020-10-07T14:45:09Z")

</div>

Operating system: MACOS  
Slicer version: 4.10.2

I saved my segmentation as labelmap and I read it from python  
and I need to know the structure of the data to use it in my deep learning model

---

<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 7, 2020, 7:59pm UTC](https://discourse.slicer.org/t/save-segmentation/13923/2 "2020-10-07T19:59:48Z")

</div>

There are two different approaches you can use.

A. Write your segmentation to numpy array directly in Slicer’s Python environment. You can use tools available in Slicer to preprocess, normalize, augment your data, using GUI, Python scripts, or [Jupyter Notebooks](https://github.com/Slicer/SlicerJupyter). There is an example script [here](https://discourse.slicer.org/t/generating-augmented-training-data-from-nrrd-file-using-random-translations-rotations-and-deformations/11810/8) that shows how to do 3D image augmentation with random deformations in Slicer.

B. You can load the segmentation (.seg.nrrd) file and process it using any tools (e.g., [torchio](https://pypi.org/project/torchio/)). Segmentation is stored in standard .nrrd file, so you can use any Python nrrd reader to read it as a numpy array. You can find specification of custom fields [here](http://apidocs.slicer.org/master/classvtkMRMLSegmentationStorageNode.html#details) and an example Python code snippet (that does not require Slicer’s Python environment) [here](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Get_information_from_segmentation_nrrd_file_header).
