Export Segmentation as Labeled LabelMap

Because labelmap format does not have a field to store actual labels, only indices. The labels are preserved in the color table that was saved during the export.

See this thread on how to correctly load the labelmap as a segmentation using the color table from the UI. Copying segment names/colors from one segmentation to another - #7 by lassoan

The example I sent you is the programmatic approach to the same thing.

This may or may not be relevant for you, but we encountered an issue when using a labelmaps with non-contiguous numbers, and not starting from 1. We were training a multilabel model, and the source we used had for training had labelmaps that go from 1-50 (with couple gaps) and then 101-103. Monai didn’t like that so we ended having to reorder the labels in a continuous fashion from 1-50. So if your first label has an index of 8, you may or may not encounter the same issue. FYI.