# Cryptic error message when failing to load frames of different sizes

**URL:** <https://discourse.itk.org/t/cryptic-error-message-when-failing-to-load-frames-of-different-sizes/2463>\
**Category:** Engineering\
**Created:** [December 2, 2019, 3:52am UTC](https://discourse.itk.org/t/cryptic-error-message-when-failing-to-load-frames-of-different-sizes/2463 "2019-12-02T03:52:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lassoan](https://discourse.itk.org/user_avatar/discourse.itk.org/lassoan/32/27_2.png) [@lassoan](https://discourse.itk.org/u/lassoan)\
**Post date:** [December 2, 2019, 3:52am UTC](https://discourse.itk.org/t/cryptic-error-message-when-failing-to-load-frames-of-different-sizes/2463/1 "2019-12-02T03:52:06Z")

</div>

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)”_.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [December 2, 2019, 4:34pm UTC](https://discourse.itk.org/t/cryptic-error-message-when-failing-to-load-frames-of-different-sizes/2463/2 "2019-12-02T16:34:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [December 3, 2019, 7:53pm UTC](https://discourse.itk.org/t/cryptic-error-message-when-failing-to-load-frames-of-different-sizes/2463/3 "2019-12-03T19:53:26Z")

</div>

There is [code](https://github.com/InsightSoftwareConsortium/ITK/blob/1fae733ea63a106883fd9f0c02db770ae01c4cb8/Modules/IO/ImageBase/include/itkImageSeriesReader.hxx#L350-L353) already which attempts to provide such information. But if a [single-file reader](https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/IO/ImageBase/include/itkImageFileReader.hxx) is invoked, it cannot know that there are other files. What does the stack trace look like in your case?

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [December 3, 2019, 8:27pm UTC](https://discourse.itk.org/t/cryptic-error-message-when-failing-to-load-frames-of-different-sizes/2463/4 "2019-12-03T20:27:04Z")

</div>

Problem I ran into is related but not really similar, see [GDCM bug report](https://sourceforge.net/p/gdcm/bugs/494/). @mathieu.malaterre
