MetaImage: M_ReadElementsROI: data not read completely

Hi

I am using SimpleITK 2.0.2 and Python 3.7.9 to read a 3D CT image in the compressed mhd format (ct.mhd, ct.zraw). When I run the code below, I am getting the following message. “data not read completely”. So, I saved the read image back to file, opened in a viewer and I got the correct image. So, it seems like there is no issue for the code… Anyone has any clue why I am getting this message?

Thanks.
JK

[message]
MetaImage: M_ReadElementsROI: data not read completely
ideal = 1069833 : actual = 633067

[code]
file_reader = sitk.ImageFileReader()
file_reader.SetFileName(img_path)
file_reader.SetExtractIndex(start_index)
file_reader.SetExtractSize(extract_size)
img = file_reader.Execute()

1 Like

That might be true for an image that is mostly zero, so the last 40% of it which was not read only contained zeroes. This is practically possible with label images.

1 Like

I can’t quite imaging that being the case for a CT image though. Can you share your image?

Did you manage to find a resoluton to this issue?, I am having the same one as well.

True for me. I have experienced the same “MetaImage: M_ReadElementsROI: data not read completely” issue and figured the 3D image is a label, where 28,295,732 pixels are 0 and 15,820 pixels are labels.

I’m experiencing similar issues with (non-binary) CT images.
As an experiment I tried reading a CT image with a purposely corrupted .raw file.
when doing so, I see the console message:

MetaImage: M_ReadElementsData: data not read completely
   ideal = 203948032 : actual = 16384

What is concerning is that with ITK 4.13, attempting to read this image with the standard itk::ImageFileReader would throw an itk::ExceptionObject. However, after updating to ITK 5.2 reading fails silently.

2 Likes

This is a bug! Great catch!

The M_ReadElementsROI() function correctly returns false in this condition:

but that return value is now being lost within the M_ReadROIStream() function

and also in lines 2661, 2767, and 2832 in that file.

I’ll create a pull request to fix these errors in the MetaIO library. I’ll need to work with the other ITK devs to determine how to update that library in ITK.

Thanks!
Stephen

3 Likes

Once the PR is merged in MetaIO repository, invoking UpdateFromUpstream.sh script in ITK should update it appropriately.

Actually, ignoring the return value is a now systemic problem in the metaImage.cxx file - happens with writing and reading. It is going to take some hunting to fix all of them. git blame…

Here is the MetaIO pull request:

3 Likes

ITK PR is now open:

1 Like

Merged!

1 Like