How to input and output segments in mhd format in 3D slicers.

I currently have T1 data in nrrd format and annotated segmentation data in nrrd format. I hope to convert them into mhd format data. For volume, I can choose the mhd format when saving, but for files in seg.nrrd format, what should I do?

MetaImage (mha/mhd) file format cannot store information about image dimensions in a standard way, therefore we do not support saving segmentations into this format. If your segments are not overlapping then you can export the segmentation into a labelmap volume (e.g., by right-clicking on the segmentation in Data module) and you can save that labelmap volume in mhd format.

Why do you need to use mhd format? What software does not support nrrd format just mhd?

Thank you very much for your reply. I want to use it for deep learning training in the future because I only know how to read and train in mhd format. I tried the method you mentioned, which means that each label can only be saved as a binary lablemap. If there are 6 labels, I need to save them as 6 mhds. I will consider whether nrrd can be used for training.

Reading images from nrrd is just as easy as reading from mhd.

You can use slicerio Python package in your deep learning code to read segmentation files including metadata. It handles overlapping segments and identifies segments by name or terminology (and not based on label values, which can change, depending on what segments you had in the segmentation file in what order).

You may also use just pynrrd Python package but then you need to parse the segment metadata yourself.