[ITK-users] [ITK] Exception caught during extracting a volume, "Requested region is (at least partially) outside the largest possible region"
Bradley Lowekamp
blowekamp at mail.nih.gov
Thu Oct 8 12:30:29 EDT 2015
Hello,
What you need to look at is the "BufferedRegion". I also describe as InPlace as "stealing" the input's buffer. To add to the complexity, the ExtractImageFilter does not always run InPlace when the options is set. It depends to what the input's buffered region in, and that depends on if the filter that generates the input can stream it's requested region. The fact that you are getting this in the 2nd, or 3rd indicate that there are some funny pipeline behaviors happening with inputs and buffers. You likely want to disconnect the pipeline as some point, and take care not to modify that results with subsequent operations.
HTH,
Brad
On Oct 8, 2015, at 12:12 PM, Timothee Evain <tevain at telecom-paristech.fr> wrote:
> Well, by definition ( http://www.itk.org/Doxygen/html/classitk_1_1InPlaceImageFilter.html ) when you use in place, you are overwriting the same bulk of memory as input.
> I don't know how the region data is updated, and maybe if call UpdateLargestRegion() could show you the difference, but your initial fixed image is definitely modified if you process in place.
>
> Maybe you can try GetInput() after the first iteration on the extracter to see what do you have.
>
> HTH
>
> Tim
>
> ----- Mail original -----
> De: "Iyas Hamdan" <iyas.hamdan at gmail.com>
> À: "Timothee Evain" <tevain at telecom-paristech.fr>
> Cc: insight-users at itk.org, "Bradley Lowekamp" <blowekamp at mail.nih.gov>
> Envoyé: Jeudi 8 Octobre 2015 17:06:04
> Objet: Re: [ITK] [ITK-users] Exception caught during extracting a volume, "Requested region is (at least partially) outside the largest possible region"
>
> Thank you Brad and Tim for your replies.
>
> Brad, you're right I'm sorry I didnt include my whole pipeline because its
> a bit complicated.
>
> Actually what I'm trying to do is an application for image registration,
> and I'm using this volume extraction in the metric that I wrote for this
> purpose.
>
> My input is a Dicom series that I'm reading with VTK then transfering to
> ITK.
> I'm checking if the input is read correctly everytime I go inside the loop
> (before applying the ExtractFilter)
> And ( this->m_FixedImage->GetLargestPossibleRegion() ) always gives a valid
> result concerning the dimension, size and index.
> Thats why I thought the problem couldnt be caused by the input.
>
> I tried deleting the option extracter->InPlaceOn() as you suggested but
> I'm still getting the same error.
>
> What I do find weird though, is that I'm getting this exception in the
> second or third iteration of the registration! I mean, in the first
> iteration the extracter was able to go through all the pixels and extract a
> neighborhood around each pixel and everything was fine.
>
> But then again, I'm only applying this extracter on the fixed image which
> should be the same during the registration process so nothing should change
> from one iteration to another, right ?
>
> And in case I'm not missing anything, the ExtractFilter is kinda
> "seperated" from the rest of the pipeline as long as the input is read
> correctly and is staying the same throughout the whole process of the
> registration (and by staying the same I mean having the exact dimension,
> index and size). So I dont get why I would get an exception on the third
> iteration for example and not on the second pixel of the first iteration.
>
> And Tim, I didnt quiet get how I am "replacing the full image data (the
> input) with the small neighborhood', because my image ( this->m_FixedImage
> ) is staying always the same ( applying
> this->m_FixedImage->GetLargestPossibleRegion() gives always the right
> result ) and what I'm changing is just what I called F_Size and F_Start in
> my code which are used to creat another region (F_Region) and this is the
> region I'm changing.
>
> So could you please help me out here if I'm missing something ?
>
> Thanks in advance for your help.
>
> Iyas
>
>
>
>
> On Thu, Oct 8, 2015 at 3:26 PM, Timothee Evain <tevain at telecom-paristech.fr>
> wrote:
>
>> Hello Iyas
>>
>> I think you problem is coming from the fact you are using the filter in
>> place ("extracter->InPlaceOn();")
>> When you run your filter once, that's good, but you are replacing the full
>> image data (the input) with the small neighborhood.
>> So basically after your first iteration, you are requesting the next
>> neighborhood regarding the full image, which is outbound regarding the
>> previous neighborhood.
>>
>> HTH
>>
>> Tim
>>
>> ----- Mail original -----
>> De: "Iyas Hamdan" <iyas.hamdan at gmail.com>
>> À: insight-users at itk.org
>> Envoyé: Jeudi 8 Octobre 2015 13:07:49
>> Objet: [ITK] [ITK-users] Exception caught during extracting a volume,
>> "Requested region is (at least partially) outside the largest possible
>> region"
>>
>> Hello ITK users,
>>
>> I have a problem using the itk::ExtractImageFilter.
>>
>> What I'm trying to do is, from a 3D volume, I want to extract a small 3D
>> neighborhood around each pixel of this volume.
>>
>> So I'm using the ExtractImageFilter more than once and I guess that is
>> where it fails.
>>
>> The error I get is the following:
>>
>> itk::InvalidRequestedRegionError
>> Location: itk::DataObject::PropagateRequestedRegion(void)
>> File:itkDataObject.cxx
>> Line: 393
>> Description: Requested region is (at least partially) outside the largest
>> possible region.
>>
>>
>> I've looked on several answers to the same issue here in the mailing list
>> and what they propose is just to replace the Update() by an
>> UpdateLargestPossibleRegion(). And I did that but I'am still getting the
>> same error.
>>
>>
>> Here is the code I'm using:
>>
>> FixedImageType::RegionType RegionFixed =
>> this->m_FixedImage->GetLargestPossibleRegion();
>> FixedImageType::SizeType F_Size = RegionFixed.GetSize();
>> FixedImageType::IndexType F_Start = RegionFixed.GetIndex();
>>
>> /// here I set the F_Size and F_Start to the desired values
>> /// and I make sure that the region is always in the largest possible
>> region!
>> /// with Patch_Size being the size of the neighborhood to be extracted
>> around the pixel in each dimension
>>
>> for (int dim = 0; dim < 3; dim++)
>> {
>> if (FixedIndex[dim] < Patch_Size)
>> F_Start[dim] = 0;
>>
>> else
>> {
>> if (FixedIndex[dim] > (RegionFixed.GetSize()[dim] - Patch_Size - 1))
>> F_Start[dim] = RegionFixed.GetSize()[dim] - (2 * Patch_Size + 1);
>> else
>> F_Start[dim] = FixedIndex[dim] - Patch_Size;
>> }
>>
>> F_Size[dim] = 2 * Patch_Size + 1;
>> }
>>
>> FixedImageType::RegionType F_Region;
>> F_Region.SetSize(F_Size);
>> F_Region.SetIndex(F_Start);
>>
>> typedef itk::ExtractImageFilter< FixedImageType, FixedImageType >
>> FilterExtractType;
>> FilterExtractType::Pointer extracter = FilterExtractType::New();
>> extracter->InPlaceOn();
>> extracter->SetDirectionCollapseToSubmatrix();
>>
>> extracter->SetExtractionRegion(F_Region);
>> extracter->SetInput(this->m_FixedImage);
>>
>> try
>> {
>> extracter->UpdateLargestPossibleRegion();
>> }
>> catch (itk::ExceptionObject & err)
>> {
>> std::cout << "Exception caught during extracting the volume!" << std::endl;
>> std::cout << err << std::endl;
>> }
>>
>>
>>
>> Any help would be really appreciated.
>>
>> Thanks
>>
>> Iyas Hamdan
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.php
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/insight-users
>>
>> _______________________________________________
>> Community mailing list
>> Community at itk.org
>> http://public.kitware.com/mailman/listinfo/community
>>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-users
More information about the Insight-users
mailing list