# NRRD Segmentation To Numpy problem

**URL:** <https://discourse.slicer.org/t/nrrd-segmentation-to-numpy-problem/29122>\
**Category:** Support\
**Tags:** segmentation, dicom, python\
**Created:** [April 25, 2023, 11:40pm UTC](https://discourse.slicer.org/t/nrrd-segmentation-to-numpy-problem/29122 "2023-04-25T23:40:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thirawat](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/thirawat/32/65667_2.png) [@Thirawat](https://discourse.slicer.org/u/Thirawat)\
**Post date:** [April 25, 2023, 11:40pm UTC](https://discourse.slicer.org/t/nrrd-segmentation-to-numpy-problem/29122/1 "2023-04-25T23:40:26Z")

</div>

Hi, All  
I have .nrrd files of segmentations, so I only have 2 classes.  
but not all each file have 2 classes, I can say that most of them are one class for one file.

then let’s talk about my problem.  
I try to take segmentations to NumPy array in Python. but when it has one class in the file. It will assume that the class is value 1 by not caring class name or class color.  
then I try another way but it did not work.

## I try these ways.

1. try to read nrrd. But when it has on class on file. that class will be value 1.

* * *

1. try to convert nrrd to tiff images using Python. But the image has some transformation from the original.

* * *

1. try to convert nrrd to tif stack using 3D Slicer. But like no.1.

* * *

1. try to convert nrrd to dcm files using 3D Slicer. But like no.1.

Can someone help me, All I need is class A value is 1. Class B value is 2. even if it has one class on that file.  
So all 2 classes on files work as well.

Or I do something wrong ;-;.

thank you a lot.  
Thirawat.

---

<div class="post-metadata">

**Author:** ![Thirawat](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/thirawat/32/65667_2.png) [@Thirawat](https://discourse.slicer.org/u/Thirawat)\
**Post date:** [April 26, 2023, 9:55am UTC](https://discourse.slicer.org/t/nrrd-segmentation-to-numpy-problem/29122/2 "2023-04-26T09:55:18Z")

</div>

Should I do it manually?  
Map the file name and class on my csv then change its value.
