Create labelmap nrrd file from numpy array

Hi,

I’m interested in converting a numpy array into a .nrrd file that functions as a label map in 3D slicer.

This numpy array represents the output of a custom semantic segmentation model, containing 33 distinct classes by integer values.

I wonder if I could transform this prediction mask into a label map file format that is compatible with 3D slicer.

I would really appreciate some help. Thank you.

See this:

slicer.util.addVolumeFromArray