# Export volume data in segment?

**URL:** <https://discourse.slicer.org/t/export-volume-data-in-segment/603>\
**Category:** Support\
**Tags:** segmentation\
**Created:** [June 30, 2017, 11:38am UTC](https://discourse.slicer.org/t/export-volume-data-in-segment/603 "2017-06-30T11:38:09Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![hherhold](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hherhold/32/12199_2.png) [@hherhold](https://discourse.slicer.org/u/hherhold)\
**Post date:** [June 30, 2017, 11:38am UTC](https://discourse.slicer.org/t/export-volume-data-in-segment/603/1 "2017-06-30T11:38:09Z")

</div>

Is it possible to export the volume data in a segment? Meaning, using the Segment Editor, you create a segment, then export a TIFF stack or NRRD with the same volume size as your original data set, but with just the data in your segment, all other voxels at 0?

Thanks!

-Hollister

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [June 30, 2017, 11:51am UTC](https://discourse.slicer.org/t/export-volume-data-in-segment/603/2 "2017-06-30T11:51:04Z")

</div>

In Segmentations module open the Import/Export section and export the segments into labelmap. If you have overlapping structures you need to export each to a different labelmap. Then you can click Save in the toolbar or main menu and export the labelmap to nrrd

---

<div class="post-metadata">

**Author:** ![hherhold](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hherhold/32/12199_2.png) [@hherhold](https://discourse.slicer.org/u/hherhold)\
**Post date:** [June 30, 2017, 12:07pm UTC](https://discourse.slicer.org/t/export-volume-data-in-segment/603/3 "2017-06-30T12:07:52Z")

</div>

Thanks for the reply Csaba.

This exports just the label map, with areas in the label as 1 and outside as zero. Is there a way to do the exact same thing, but exporting the volume data inside that label map? Meaning the greyscale values, not just the 1/0 inside/outside the label map.

Thanks!!!

-Hollister

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [June 30, 2017, 12:21pm UTC](https://discourse.slicer.org/t/export-volume-data-in-segment/603/4 "2017-06-30T12:21:30Z")

</div>

Ah I see. You can use the Mask Scalar Volume module

---

<div class="post-metadata">

**Author:** ![hherhold](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/hherhold/32/12199_2.png) [@hherhold](https://discourse.slicer.org/u/hherhold)\
**Post date:** [June 30, 2017, 1:44pm UTC](https://discourse.slicer.org/t/export-volume-data-in-segment/603/5 "2017-06-30T13:44:24Z")

</div>

Exactly what I was looking for. I _knew_ there had to be a way!

Thanks!!

-Hollister

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [November 21, 2019, 11:51pm UTC](https://discourse.slicer.org/t/export-volume-data-in-segment/603/6 "2019-11-21T23:51:31Z")

</div>

@cpinter is there an easy way to do this programmatically, is there a “recipe” somewhere?

If I understand correctly, this function is doing the export, but at this point I cannot quickly figure out how to get to it from python. I was also not sure if parameterizing the export through the widget is the only approach to do this.

> <https://github.com/Slicer/Slicer/blob/master/Modules/Loadable/Segmentations/qSlicerSegmentationsModuleWidget.cxx#L821-L941>

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [November 21, 2019, 11:53pm UTC](https://discourse.slicer.org/t/export-volume-data-in-segment/603/7 "2019-11-21T23:53:54Z")

</div>

Found this thread: [Get label map node from segmentation node](https://discourse.slicer.org/t/get-label-map-node-from-segmentation-node/1137/3) that also discusses programmatic use. Let me study that first!

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [November 29, 2019, 4:48pm UTC](https://discourse.slicer.org/t/export-volume-data-in-segment/603/8 "2019-11-29T16:48:42Z")

</div>

@fedorov Sounds good. Sorry for not reacting, I’m still in the process of moving continents. However, now the move itself is done and I’m gradually getting back to normal. Let me know if you need any guidance!

---

<div class="post-metadata">

**Author:** ![fedorov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/fedorov/32/14_2.png) [@fedorov](https://discourse.slicer.org/u/fedorov)\
**Post date:** [November 29, 2019, 5:30pm UTC](https://discourse.slicer.org/t/export-volume-data-in-segment/603/9 "2019-11-29T17:30:53Z")

</div>

No worries Csaba, I figured it out - Discourse search was very handy to locate that thread, and @lassoan helped with the bits I was missing. Good luck with the move, and settling down at the new place!
