Cryptic error message when failing to load frames of different sizes

We use itkImageFileReader in Slicer to read image stacks and it works well. However, time to time users report that the reader fails with this error:

Exception from vtkITK MegaMacro:
itk::InvalidRequestedRegionError (000000CC077682B8)
Location: “unknown”
File: d:\d\p\slicer-0-build\itk\modules\io\imagebase\include\itkImageFileReader.hxx
Line: 343
Description: ImageIO returns IO region that does not fully contain the requested regionRequested region: ImageRegion (000000CC07768280)
Dimension: 3
Index: [0, 0, 0]
Size: [1537, 2397, 1]
StreamableRegion region: ImageRegion (000000CC077682E0)
Dimension: 3
Index: [0, 0, 0]
Size: [2522, 1419, 1]

It turns out that this error is thrown when ITK (rightfully) refuses to load an image stack because not all files have the same shape (number of rows and columns).

Would it be possible to replace the error message with one that gives a better chance to users to understand and fix the error?

For example, something like “Image file reading failed: not all slices in the image have the same size (aaa-001.jpg size is 1000x1000, aaa-028.jpg size is 1010x1000)”.

On Friday I ran into a somewhat similar issue. I will look into this. @Andinet_Enquobahrie

1 Like

There is code already which attempts to provide such information. But if a single-file reader is invoked, it cannot know that there are other files. What does the stack trace look like in your case?

Problem I ran into is related but not really similar, see GDCM bug report. @mathieu.malaterre