How to deal with .mha files ¶
By: vertin on Aug. 21, 2024, 4:15 p.m.
In Docker, .mha is read as a numpy array and then placed into the model for segmentation, but the AI I trained divides .jpg and outputs .png format images, which is different from what is in Docker. I have an idea now, but I don't know if it's feasible:
First, convert the .mha format file to a .jpg image, perform AI segmentation, and then convert the output image to .mha format.
I also have two more questions:
-
When saving the. mha file in Docker, only the numpy array was written, but I found there is a header describing the data in the .mha file. I don't know if the absence of this header will affect the entire file.
-
I only found tutorials on converting .png to .mhd (similar to .mha, but it separate the header and image data in two files), but I couldn't find how to save it as .mha. Can I directly change .mhd to .mha in the code to save files that meet the requirements? However, this may result in errors or lack of headers describing the data.