"Requested region is (at least partially) outside the largest possible region. Aborted (core dumped)" when calling Update/UpdateLargestPossibleRegion

Hello everyone!

I am new to ITK and I am trying to create a custom registration filter, but I keep running into following error message:

what(): /home/stefan/itk/Modules/Core/Common/src/itkDataObject.cxx:393:
Requested region is (at least partially) outside the largest possible region.
Aborted (core dumped)

Basically, code fails right after I call Update() method. I’ve tried to search for similar issues but nothing seems to be working. I’ve tried using UpdateLargestPossibleRegion() as well, and results (i.e. error) are still the same.

Whats funny is that for some cases my filter DOES work, and for some it DOES NOT. For example, here are baseline, baseline segmentation, follow-up and follow-up segmentation image information respectively, for which filter DOES work:

Image #1: dim = [71, 71, 68]; bb = {[-34.5 34.5 -128.5], [36.5 105.5 -60.5]}; vox = [1, 1, 1]; range = [-291.155, 7036.16]; orient = RPI

Image #1: dim = [71, 71, 68]; bb = {[-34.5 34.5 -128.5], [36.5 105.5 -60.5]}; vox = [1, 1, 1]; range = [0, 1]; orient = RPI

Image #1: dim = [71, 71, 68]; bb = {[-34.5 34.5 -128.5], [36.5 105.5 -60.5]}; vox = [1, 1, 1]; range = [-94.5187, 4305.86]; orient = RPI

Image #1: dim = [71, 71, 68]; bb = {[-34.5 34.5 -128.5], [36.5 105.5 -60.5]}; vox = [1, 1, 1]; range = [0, 1]; orient = RPI

Here are now baseline, baseline segmentation, follow-up and follow-up segmentation image information respectively, for which filter DOES NOT work and where produces error mentioned above:

Image #1: dim = [71, 71, 75]; bb = {[-34.5 34.5 -133.5], [36.5 105.5 -58.5]}; vox = [1, 1, 1]; range = [-113.235, 6368.84]; orient = RPI

Image #1: dim = [71, 71, 75]; bb = {[-34.5 34.5 -133.5], [36.5 105.5 -58.5]}; vox = [1, 1, 1]; range = [0, 1]; orient = RPI

Image #1: dim = [71, 71, 74]; bb = {[-34.5 34.5 -131.5], [36.5 105.5 -57.5]}; vox = [1, 1, 1]; range = [-125.684, 6891.19]; orient = RPI

Image #1: dim = [71, 71, 74]; bb = {[-34.5 34.5 -131.5], [36.5 105.5 -57.5]}; vox = [1, 1, 1]; range = [0, 1]; orient = RPI

To me image information seems pretty similar. What could be causing this issue? What am I missing?

Appreciate the help! Thanks!

You could step through this code using a debugger to see exactly what is happening. If the culprit is not here, use the debugger to figure out where does the problem arise.

1 Like

Hi @dzenanz, thanks for fast reply!

Couple of things I’ve forgot to mention:

  1. I am using ITK 4.6 version

  2. I’ve already tried debugging it, but not exactly sure how to interpret the problem. Basically, here are some interesting logs from debugger:

    at /home/stefan/itk-bctk-debug-install/usr/local/include/ITK-4.6/itkImageBase.hxx:241
    241 this->GetSource()->UpdateOutputInformation();
    (gdb) next
    262 if ( this->GetRequestedRegion().GetNumberOfPixels() == 0 )
    (gdb) list
    257
    258 // Now we should know what our largest possible region is. If our
    259 // requested region was not set yet, (or has been set to something
    260 // invalid - with no data in it ) then set it to the largest possible
    261 // region.
    262 if ( this->GetRequestedRegion().GetNumberOfPixels() == 0 )
    263 {
    264 this->SetRequestedRegionToLargestPossibleRegion();
    265 }
    266 }
    (gdb) next
    264 this->SetRequestedRegionToLargestPossibleRegion();
    (gdb) step
    itk::ImageBase<3u>::SetRequestedRegionToLargestPossibleRegion (
    this=0x55555755d870)
    at /home/stefan/itk-bctk-debug-install/usr/local/include/ITK-4.6/itkImageBase.hxx:294
    294 ImageBase< VImageDimension >
    (gdb) list
    289 }
    290
    291 //----------------------------------------------------------------------------
    292 template< unsigned int VImageDimension >
    293 void
    294 ImageBase< VImageDimension >
    295 ::SetRequestedRegionToLargestPossibleRegion()
    296 {
    297 this->SetRequestedRegion( this->GetLargestPossibleRegion() );
    298 }
    (gdb) next
    297 this->SetRequestedRegion( this->GetLargestPossibleRegion() );
    (gdb) next
    298 }
    (gdb) next
    itk::ImageBase<3u>::UpdateOutputInformation (this=0x55555755d600)
    at /home/stefan/itk-bctk-debug-install/usr/local/include/ITK-4.6/itkImageBase.hxx:266
    266 }
    (gdb) list
    261 // region.
    262 if ( this->GetRequestedRegion().GetNumberOfPixels() == 0 )
    263 {
    264 this->SetRequestedRegionToLargestPossibleRegion();
    265 }
    266 }
    267
    268 template< unsigned int VImageDimension >
    269 void
    270 ImageBase< VImageDimension >
    (gdb) next
    itk::DataObject::Update (this=0x55555755d600)
    at /home/stefan/itk/Modules/Core/Common/src/itkDataObject.cxx:340
    340 this->PropagateRequestedRegion();
    (gdb) next
    terminate called after throwing an instance of ‘itk::InvalidRequestedRegionError’
    what(): /home/stefan/itk/Modules/Core/Common/src/itkDataObject.cxx:393:
    Requested region is (at least partially) outside the largest possible region.

    Program received signal SIGABRT, Aborted.
    __GI_raise (sig=sig@entry=6) at …/sysdeps/unix/sysv/linux/raise.c:50
    50 …/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
    (gdb)

@dzenanz Hi Dzenan! Sorry to bother you, but after further debugging. I’ve deduced the following:

First of all. I would like to mention that I am subclassing ImageToImage filter in order to make a Registration filter (which takes multiple inputs: Baseline image, Baseline Mask, Follow up image, Follow up mask). Now, my filter raises

“Requested region is (at least partially) outside the largest possible region”

If and only if Baseline image has bigger dimensions (in my case specifically Z-axis) than Follow-up image. Error is being raised in ITK’s function VerifyInputRegion() during Update() method (Note that I’ve tried UpdateLargestInputRegion instead, same thing). Here is the code where error is raised:

template< unsigned int VImageDimension >
bool
ImageBase< VImageDimension >
::VerifyRequestedRegion()
{
  bool         retval = true;
  unsigned int i;

  // Is the requested region within the LargestPossibleRegion?
  // Note that the test is indeed against the largest possible region
  // rather than the buffered region; see DataObject::VerifyRequestedRegion.
  const IndexType & requestedRegionIndex = this->GetRequestedRegion().GetIndex();
  const IndexType & largestPossibleRegionIndex =
    this->GetLargestPossibleRegion().GetIndex();

  const SizeType & requestedRegionSize = this->GetRequestedRegion().GetSize();
  const SizeType & largestPossibleRegionSize =
    this->GetLargestPossibleRegion().GetSize();

  for ( i = 0; i < VImageDimension; i++ )
    {
    if ( ( requestedRegionIndex[i] < largestPossibleRegionIndex[i] )
         || ( ( requestedRegionIndex[i] + static_cast< OffsetValueType >( requestedRegionSize[i] ) )
              > ( largestPossibleRegionIndex[i] + static_cast< OffsetValueType >( largestPossibleRegionSize[i] ) ) ) )
      {
      retval = false;
      }
    }

  return retval;
}

Here are now baseline, baseline segmentation, follow-up and follow-up segmentation image information respectively,

Image #1: dim = [71, 71, 75]; bb = {[-34.5 34.5 -133.5], [36.5 105.5 -58.5]}; vox = [1, 1, 1]; range = [-113.235, 6368.84]; orient = RPI

Image #1: dim = [71, 71, 75]; bb = {[-34.5 34.5 -133.5], [36.5 105.5 -58.5]}; vox = [1, 1, 1]; range = [0, 1]; orient = RPI

Image #1: dim = [71, 71, 74]; bb = {[-34.5 34.5 -131.5], [36.5 105.5 -57.5]}; vox = [1, 1, 1]; range = [-125.684, 6891.19]; orient = RPI

Image #1: dim = [71, 71, 74]; bb = {[-34.5 34.5 -131.5], [36.5 105.5 -57.5]}; vox = [1, 1, 1]; range = [0, 1]; orient = RPI

This is because for some reason when calling Update (or UpdateLargestPossibleRegion) method on the filter, it treats follow up image as the LARGEST POSSIBLE REGION at one point, and BL as REQUESTED REGION. Since BL has bigger dimension than FU image, error is raised.

How can I make sure that from all inputs to the filter, Update method chooses the input with biggest dimensions as the one for Largest Possible region?

Hope you understand what I mean. Thanks in advance!

I think you need to familiarize yourself better with the image processing pipeline, more concretely How To Write A Filter. You probably need to override PropagateRequestedRegion() or something similar.

1 Like

Alright! Thanks for reply. I will give it a try :slight_smile:

I’ve managed to solve my issue by overriding GetRequestedInputRegion() method from itk::ImageToImage class. Thanks for the help!

1 Like