<div dir="ltr"><div><div><div><div><div><div><div><div><div><div>Thank you Brad and Tim for your replies. <br><br></div>Brad, you're right I'm sorry I didnt include my whole pipeline because its a bit complicated. <br><br></div>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. <br><br></div>My input is a Dicom series that I'm reading with VTK then transfering to ITK. <br></div>I'm checking if the input is read correctly everytime I go inside the loop (before applying the ExtractFilter) <br></div>And ( this->m_FixedImage->GetLargestPossibleRegion() ) always gives a valid result concerning the dimension, size and index. <br></div>Thats why I thought the problem couldnt be caused by the input. <br></div><div><br></div>I tried deleting the option extracter->InPlaceOn() as you suggested but I'm still getting the same error. <br><br></div>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. <br><br></div>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 ? <br><br></div>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. <br><div><div><div><br></div><div>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. <br><br></div><div>So could you please help me out here if I'm missing something ? <br><br></div><div>Thanks in advance for your help. <br><br></div><div>Iyas<br></div><div><div><div><div><div><div><div><div><div><br><h3 class=""><br></h3><br></div></div></div></div></div></div></div></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 8, 2015 at 3:26 PM, Timothee Evain <span dir="ltr"><<a href="mailto:tevain@telecom-paristech.fr" target="_blank">tevain@telecom-paristech.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello Iyas<br>
<br>
I think you problem is coming from the fact you are using the filter in place ("extracter->InPlaceOn();")<br>
When you run your filter once, that's good, but you are replacing the full image data (the input) with the small neighborhood.<br>
So basically after your first iteration, you are requesting the next neighborhood regarding the full image, which is outbound regarding the previous neighborhood.<br>
<br>
HTH<br>
<br>
Tim<br>
<br>
----- Mail original -----<br>
De: "Iyas Hamdan" <<a href="mailto:iyas.hamdan@gmail.com">iyas.hamdan@gmail.com</a>><br>
À: <a href="mailto:insight-users@itk.org">insight-users@itk.org</a><br>
Envoyé: Jeudi 8 Octobre 2015 13:07:49<br>
Objet: [ITK] [ITK-users] Exception caught during extracting a volume, "Requested region is (at least partially) outside the largest possible region"<br>
<div><div class="h5"><br>
Hello ITK users,<br>
<br>
I have a problem using the itk::ExtractImageFilter.<br>
<br>
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.<br>
<br>
So I'm using the ExtractImageFilter more than once and I guess that is where it fails.<br>
<br>
The error I get is the following:<br>
<br>
itk::InvalidRequestedRegionError<br>
Location: itk::DataObject::PropagateRequestedRegion(void)<br>
File:itkDataObject.cxx<br>
Line: 393<br>
Description: Requested region is (at least partially) outside the largest possible region.<br>
<br>
<br>
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.<br>
<br>
<br>
Here is the code I'm using:<br>
<br>
FixedImageType::RegionType RegionFixed = this->m_FixedImage->GetLargestPossibleRegion();<br>
FixedImageType::SizeType F_Size = RegionFixed.GetSize();<br>
FixedImageType::IndexType F_Start = RegionFixed.GetIndex();<br>
<br>
/// here I set the F_Size and F_Start to the desired values<br>
/// and I make sure that the region is always in the largest possible region!<br>
/// with Patch_Size being the size of the neighborhood to be extracted around the pixel in each dimension<br>
<br>
for (int dim = 0; dim < 3; dim++)<br>
{<br>
if (FixedIndex[dim] < Patch_Size)<br>
F_Start[dim] = 0;<br>
<br>
else<br>
{<br>
if (FixedIndex[dim] > (RegionFixed.GetSize()[dim] - Patch_Size - 1))<br>
F_Start[dim] = RegionFixed.GetSize()[dim] - (2 * Patch_Size + 1);<br>
else<br>
F_Start[dim] = FixedIndex[dim] - Patch_Size;<br>
}<br>
<br>
F_Size[dim] = 2 * Patch_Size + 1;<br>
}<br>
<br>
FixedImageType::RegionType F_Region;<br>
F_Region.SetSize(F_Size);<br>
F_Region.SetIndex(F_Start);<br>
<br>
typedef itk::ExtractImageFilter< FixedImageType, FixedImageType > FilterExtractType;<br>
FilterExtractType::Pointer extracter = FilterExtractType::New();<br>
extracter->InPlaceOn();<br>
extracter->SetDirectionCollapseToSubmatrix();<br>
<br>
extracter->SetExtractionRegion(F_Region);<br>
extracter->SetInput(this->m_FixedImage);<br>
<br>
try<br>
{<br>
extracter->UpdateLargestPossibleRegion();<br>
}<br>
catch (itk::ExceptionObject & err)<br>
{<br>
std::cout << "Exception caught during extracting the volume!" << std::endl;<br>
std::cout << err << std::endl;<br>
}<br>
<br>
<br>
<br>
Any help would be really appreciated.<br>
<br>
Thanks<br>
<br>
Iyas Hamdan<br>
<br>
</div></div><span class="">_____________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" rel="noreferrer" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/insight-users</a><br>
<br>
</span>_______________________________________________<br>
Community mailing list<br>
<a href="mailto:Community@itk.org">Community@itk.org</a><br>
<a href="http://public.kitware.com/mailman/listinfo/community" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/community</a><br>
</blockquote></div><br></div>