Closed jmsmkn closed 1 year ago
I have emailed the user who created this file to try and find out more information.
I suspect it is a red herring for a multi-component image that has more than 3 components for a voxel. This is generally the case if a format has coded TIME in the components instead of dimensions.
Maybe! The user has not got back to me so we're none the wiser.
Hi, I met this problem when I save the output as a 4D mha (the shape is [D, W, H, C], C =45) file, where I want to save the segmentation of 45 organs of a patient into a 4D file but some organs have overlap. I can use SimleITK, ITK-SNAP, 3D Slicer to read or visualize the 4D mha file, but this package throughout an error about color space. I wonder if this package just supports C=1/3/4, according to this line. I think the 4D datatype can deal with the overlap segmentation problem well, but I don't know how to deal with the color space error! Could you give us some advice? Best, Xiangde Luo.
@Luoxd1996 , reference a quick solution on this gist.
The likely cause of seeing this error is because the naive way of creating 4D images would be something along the lines of:
output_arr = np.ones((100, 200, 300, 45), dtype=np.uint8)
image = SimpleITK.GetImageFromArray(output_arr)
SimpleITK.WriteImage(image, "output.mha", True)
However, this will create a 3D vector image and not a 4D image. Subtle difference. Adding isVector=False
as keyword arg to GetImageFromArray()
does produce a 4D image but for some unclear reason, it reverses the x, y, z, t
order.
To clarify the difference between a 3D vector image and a 4D image, this is getting the first voxel value:
three_d_vector_image[0, 0, 0][0]
four_d_image[0, 0, 0, 0]
@chrisvanrun, thanks a lot! I got it!!! Best.
@Luoxd1996 It is not acceptable to multi-channel requests, you already had a support thread going which I told you at 11am I was working on. Do not create extra work for my team like this, it slows everyone down.
We do not have any source images for this but on Grand Challenge we often see this error: