<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I've written a python script that takes in a volume and tries to extract a Y slice using the ExtractImageFilter via WrapITK. It keeps giving me a region error and I cannot figure out why.<div><br></div><div>Can anyone take a look at my script and its output and tell me what I'm doing wrong?</div><div><br></div><div>Here's the script:</div><div><br></div><div><div></div><blockquote type="cite"><div>#!/usr/bin/env python</div><div><br></div><div>import itk</div><div>from sys import argv</div><div><br></div><div>imageType = itk.Image[itk.UC, 3]</div><div>readerType = itk.ImageFileReader[imageType]</div><div>reader = readerType.New()</div><div>reader.SetFileName( argv[1] )</div><div><br></div><div>size = itk.size(reader)</div><div>print "\nInput image size: ", size</div><div><br></div><div>reader.UpdateOutputInformation()</div><div>reader.UpdateLargestPossibleRegion()</div><div>coronal = reader.GetOutput().GetLargestPossibleRegion()</div><div><br></div><div>ycut = size.GetElement(1)/2</div><div>coronal.SetIndex(1, ycut)</div><div>coronal.SetSize(1, 0);</div><div><br></div><div>extract = itk.ExtractImageFilter[itk.Image.UC3, itk.Image.UC2].New()</div><div>extract.SetInput(reader.GetOutput())</div><div><br></div><div><br></div><div>extract.SetDirectionCollapseToIdentity()</div><div>extract.SetExtractionRegion(coronal)</div><div>extract.UpdateOutputInformation()</div><div><br></div><div>print "\nExtract's input image: ", extract.GetOutput()</div><div>print "\nThe ExtractImageFilter: ", extract</div><div>print "\nExtract's region: ", extract.GetExtractionRegion()</div><div>print "\nSize of the extract's output: ", itk.size(extract.GetOutput())</div><div><br></div><div>print "\nReader's region: ", reader.GetOutput().GetLargestPossibleRegion()</div><div><br></div><div>print "\n"</div><div><br></div><div>extract.Update()</div><div>itk.write(extract.GetOutput(), "extract.png")</div></blockquote><div><br></div><div><br></div><div>And here is its output:</div><div><br></div><div><div></div><blockquote type="cite"><div>puget => ./itkextract.py ../Public/teapot.vtk</div><div>Warning: Unknown parameter 'std::string' in template 'itk::MetaDataObject'</div><div><br></div><div>Input image size: itkSize3 ([256, 256, 256])</div><div><br></div><div>Extract's input image: Image (0x108d3f010)</div><div> RTTI typeinfo: itk::Image<unsigned char, 2u></div><div> Reference Count: 2</div><div> Modified Time: 203</div><div> Debug: Off</div><div> Observers: </div><div> none</div><div> Source: (0x108db78c0) </div><div> Source output index: 0</div><div> Release Data: Off</div><div> Data Released: False</div><div> Global Release Data: Off</div><div> PipelineMTime: 200</div><div> UpdateMTime: 0</div><div> RealTimeStamp: 0 seconds </div><div> LargestPossibleRegion: </div><div> Dimension: 2</div><div> Index: [0, 0]</div><div> Size: [256, 256]</div><div> BufferedRegion: </div><div> Dimension: 2</div><div> Index: [0, 0]</div><div> Size: [0, 0]</div><div> RequestedRegion: </div><div> Dimension: 2</div><div> Index: [0, 0]</div><div> Size: [0, 0]</div><div> Spacing: [1, 1.3095]</div><div> Origin: [0, 0]</div><div> Direction: </div><div>1 0</div><div>0 1</div><div><br></div><div> IndexToPointMatrix: </div><div> 1 0</div><div>0 1.3095</div><div><br></div><div> PointToIndexMatrix: </div><div> 1 0</div><div>0 0.76365</div><div><br></div><div> PixelContainer: </div><div> ImportImageContainer (0x10cc2bbc0)</div><div> RTTI typeinfo: itk::ImportImageContainer<unsigned long, unsigned char></div><div> Reference Count: 1</div><div> Modified Time: 190</div><div> Debug: Off</div><div> Observers: </div><div> none</div><div> Pointer: 0</div><div> Container manages memory: true</div><div> Size: 0</div><div> Capacity: 0</div><div><br></div><div><br></div><div>The ExtractImageFilter: ExtractImageFilter (0x108db78c0)</div><div> RTTI typeinfo: itk::ExtractImageFilter<itk::Image<unsigned char, 3u>, itk::Image<unsigned char, 2u> ></div><div> Reference Count: 1</div><div> Modified Time: 200</div><div> Debug: Off</div><div> Observers: </div><div> none</div><div> Number Of Required Inputs: 1</div><div> Number Of Required Outputs: 1</div><div> Number Of Threads: 24</div><div> ReleaseDataFlag: Off</div><div> ReleaseDataBeforeUpdateFlag: Off</div><div> Input 0: (0x108d1a090)</div><div> Output 0: (0x108d3f010)</div><div> AbortGenerateData: Off</div><div> Progress: 0</div><div> Multithreader: </div><div> RTTI typeinfo: itk::MultiThreader</div><div> Reference Count: 1</div><div> Modified Time: 188</div><div> Debug: Off</div><div> Observers: </div><div> none</div><div> Thread Count: 24</div><div> Global Maximum Number Of Threads: 128</div><div> Global Default Number Of Threads: 24</div><div> ExtractionRegion: ImageRegion (0x108db79c0)</div><div> Dimension: 3</div><div> Index: [0, 128, 0]</div><div> Size: [256, 0, 256]</div><div><br></div><div> OutputImageRegion: ImageRegion (0x108db79f8)</div><div> Dimension: 2</div><div> Index: [0, 0]</div><div> Size: [256, 256]</div><div><br></div><div> DirectionCollaspeStrategy: 1</div><div><br></div><div><br></div><div>Extract's region: itkImageRegion3([0, 128, 0], [256, 0, 256])</div><div><br></div><div>Size of the extract's output: itkSize2 ([256, 256])</div><div><br></div><div>Reader's region: itkImageRegion3([0, 128, 0], [256, 0, 256])</div><div><br></div><div><br></div><div>Traceback (most recent call last):</div><div> File "./itkextract.py", line 39, in <module></div><div> extract.Update()</div><div>RuntimeError: /nfs/Users/dave/pkg/sitk-build/ITK/Modules/Core/Common/src/itkDataObject.cxx:387:</div></blockquote><div></div></div><blockquote type="cite"><div><div>Requested region is (at least partially) outside the largest possible region.</div></div></blockquote><div><br></div><div><br></div><div>Thank you for any help.</div><div>Dave</div><div><br></div><div><br></div><div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 16px; "><div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px; ">David T. Chen, PhD [Lockheed Martin contractor]</span></font></div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px; "><a href="mailto:dchen@mail.nih.gov">mailto:dchen@mail.nih.gov</a> <a href="http://erie.nlm.nih.gov/~dave">http://erie.nlm.nih.gov/~dave</a></span></font></div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px; ">phone:301.435.3264 iphone:301.524.3174</span></font></div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px; ">Office of High Performance Computing and Communications</span></font></div><div><font class="Apple-style-span" face="Monaco" size="3"><span class="Apple-style-span" style="font-size: 12px; ">National Library of Medicine</span></font></div></div></div>
</div>
<br></div></body></html>