We do the same thing in Slicer. The vtkITKArchetypeImageSeriesReader deduces what to do from a single representative file. An earlier version exists ion InsightApplications/vtkITK.<br><br><div><span class="gmail_quote">On 5/10/07, 
<b class="gmail_sendername">kent williams</b> &lt;<a href="mailto:norman-k-williams@uiowa.edu">norman-k-williams@uiowa.edu</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
This behavior is my fault, since GE4ImageIO was a conversion of code from<br>the BRAINS2 application, which worked this way. I can understand how that<br>would interact poorly with the ImageSeriesReader.<br><br>It brings up an issue that has bothered me about how Image IO works in ITK:
<br>While it promises and delivers a fair amount of image format independence,<br>it exposes the difference between monolithic image file formats and image<br>formats that are built from a series of 2D image files.<br><br>
What I&#39;ve started for brains2 is a separate layer of abstraction that takes<br>a path (a filename, a directory name), deduces how that can be translated<br>into an image volume, and then loads it.<br><br>In most ITK-based research software, the developer knows the incoming image
<br>format, and can choose whether to use an image series reader or an image<br>reader.&nbsp;&nbsp;That&#39;s all well and good, but in the case of more general image<br>processing applications, you want to be able to &#39;take all comers.&#39;
<br><br>And really, there&#39;s no good reason for using the same 10 or 15 lines of<br>boilerplate code every time you want to open a file.&nbsp;&nbsp;Much better to write<br>it once and re-use it everywhere.&nbsp;&nbsp;For novices, knowing which 10 or 15 lines
<br>of boilerplate code to drop in is part of the learning curve to using ITK --<br>one that isn&#39;t strictly necessary.<br><br><br>On 5/9/07 5:05 PM, &quot;Neil Weisenfeld&quot; &lt;<a href="mailto:neil@bwh.harvard.edu">
neil@bwh.harvard.edu</a>&gt; wrote:<br><br>&gt; Hi all,<br>&gt;<br>&gt; (devs maybe read the last paragraph)<br>&gt;<br>&gt; Here&#39;s why using GE4ImageIO with itkImageSeriesReader causes core-dumps:<br>&gt;<br>&gt; itkImageSeriesReader reader attempts to read in an image slice by
<br>&gt; slice, however GE4ImageIO, when given the filename of a single slice,<br>&gt; ***actually reads in the whole volume***<br>&gt;<br>&gt; So while itkImageSeriesReader correctly allocates an output volume<br>&gt; for the slice dimensions x #slices, it then reads the entire volume
<br>&gt; #slices many times obviously (well, not obviously, but see below)<br>&gt; trampling over unallocated memory.<br>&gt;<br>&gt; One solution is to use GE4ImageIO with itkImageReader, rather than<br>&gt; itkImageSeriesReader, supply only the *first* filename in the series,
<br>&gt; and then let the internal magic pick up all of the slices.<br>&gt;<br>&gt; Maybe stylistically, it would be good if the loop in<br>&gt; itkImageSeriesReader that actually copies pixels checked both the<br>&gt; input AND output arrays for IsAtEnd().&nbsp;&nbsp;That would, at least, avoid
<br>&gt; the core dump.<br>&gt;<br>&gt;<br>&gt; Regards,<br>&gt; Neil<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; On May 8, 2007, at 2:29 PM, Neil Weisenfeld wrote:<br>&gt;<br>&gt;&gt;<br>&gt;&gt; Hi all,
<br>&gt;&gt;<br>&gt;&gt; I&#39;m trying to read some Signa 4.x images using the GE4ImageIO and<br>&gt;&gt; this seems to result in:<br>&gt;&gt;<br>&gt;&gt; *** glibc detected *** free(): invalid pointer: 0x0000002a98ab1010 ***
<br>&gt;&gt;<br>&gt;&gt; which is coming from the destruction of itkImportImageContainer.<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt; An e-mail that someone sent to this list in January about reading<br>&gt;&gt; Signa 5.x images yielded the response that the Insight Applications
<br>&gt;&gt; program ConvertBetweenFileFormats does this, however it seems to me<br>&gt;&gt; that ConvertBetweenFileFormats uses GDCM to read DICOM series<br>&gt;&gt; images, but not Signa(?)<br>&gt;&gt;<br>&gt;&gt; Furthermore, the tests included for GE4ImageIO only test reading of
<br>&gt;&gt; a single slice, not a series, so I&#39;m wondering if there is actually<br>&gt;&gt; a bug.<br>&gt;&gt;<br>&gt;&gt; Here&#39;s the code excerpt.&nbsp;&nbsp;***NOTE: I&#39;ve tried this both via factory<br>&gt;&gt; traversal and by specifying a GE4ImageIO &quot;manually&quot; and both
<br>&gt;&gt; produce the same results.<br>&gt;&gt;<br>&gt;&gt; I&#39;d appreciate any suggestions and apologise if I did something<br>&gt;&gt; incredibly stupid.<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt; Regards,<br>
&gt;&gt; Neil<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt;&nbsp;&nbsp; itk::ObjectFactoryBase::RegisterFactory<br>&gt;&gt; ( itk::GEAdwImageIOFactory::New() );<br>&gt;&gt;&nbsp;&nbsp; itk::ObjectFactoryBase::RegisterFactory<br>
&gt;&gt; ( itk::GE4ImageIOFactory::New() );<br>&gt;&gt;&nbsp;&nbsp; itk::ObjectFactoryBase::RegisterFactory<br>&gt;&gt; ( itk::GE5ImageIOFactory::New() );<br>&gt;&gt;<br>&gt;&gt;&nbsp;&nbsp; typedef unsigned short PixelType;<br>&gt;&gt;&nbsp;&nbsp; typedef itk::Image&lt; PixelType, 3&gt; ImageType;
<br>&gt;&gt;&nbsp;&nbsp; typedef itk::NumericSeriesFileNames GeneratorType;<br>&gt;&gt;&nbsp;&nbsp; typedef itk::ImageSeriesReader&lt; ImageType &gt; SeriesReaderType;<br>&gt;&gt;<br>&gt;&gt;&nbsp;&nbsp; GeneratorType::Pointer names = GeneratorType::New();
<br>&gt;&gt;&nbsp;&nbsp; names-&gt;SetStartIndex( start );<br>&gt;&gt;&nbsp;&nbsp; names-&gt;SetIncrementIndex( inc ) ;<br>&gt;&gt;&nbsp;&nbsp; names-&gt;SetEndIndex( end );<br>&gt;&gt;&nbsp;&nbsp; names-&gt;SetSeriesFormat( inpPat.c_str() );<br>&gt;&gt;<br>&gt;&gt;&nbsp;&nbsp; SeriesReaderType::Pointer reader = SeriesReaderType::New();
<br>&gt;&gt;&nbsp;&nbsp; reader-&gt;SetFileNames( names-&gt;GetFileNames() );<br>&gt;&gt;<br>&gt;&gt;&nbsp;&nbsp; try<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; reader-&gt;SetDebug(true);<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; reader-&gt;Update();<br>&gt;&gt;<br>&gt;&gt;<br>
&gt;&gt; code trace:<br>&gt;&gt;<br>&gt;&gt; #0&nbsp;&nbsp;0x000000329cf2e21d in raise () from /lib64/tls/libc.so.6<br>&gt;&gt; (gdb) bt<br>&gt;&gt; #0&nbsp;&nbsp;0x000000329cf2e21d in raise () from /lib64/tls/libc.so.6<br>&gt;&gt; #1&nbsp;&nbsp;0x000000329cf2fa1e in abort () from /lib64/tls/libc.so.6
<br>&gt;&gt; #2&nbsp;&nbsp;0x000000329cf63291 in __libc_message () from /lib64/tls/libc.so.6<br>&gt;&gt; #3&nbsp;&nbsp;0x000000329cf68eae in _int_free () from /lib64/tls/libc.so.6<br>&gt;&gt; #4&nbsp;&nbsp;0x000000329cf691f6 in free () from /lib64/tls/libc.so.6
<br>&gt;&gt; #5&nbsp;&nbsp;0x000000329fcae20e in operator delete () from /usr/lib64/libstdc<br>&gt;&gt; ++.so.6<br>&gt;&gt; #6&nbsp;&nbsp;0x0000000000441e15 in ~ImportImageContainer (this=0x659f70)<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; at /opt/x86_64/pkgs/itk/3.2.0/gcc-release/include/
<br>&gt;&gt; InsightToolkit/Common/itkImportImageContainer.txx:45<br>&gt;&gt; #7&nbsp;&nbsp;0x0000002a967ecf29 in itk::Object::UnRegister ()<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/x86_64/pkgs/itk/3.2.0/gcc-release/lib/InsightToolkit/<br>&gt;&gt; 
libITKCommon.so.3.2<br>&gt;&gt; #8&nbsp;&nbsp;0x00000000004324e4 in<br>&gt;&gt; itk::SmartPointer&lt;itk::ImportImageContainer&lt;unsigned long, unsigned<br>&gt;&gt; short&gt;<br>&gt;&gt;&gt; ::UnRegister (this=0x65bc20)<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; at /opt/x86_64/pkgs/itk/3.2.0/gcc-release/include/
<br>&gt;&gt; InsightToolkit/Common/itkSmartPointer.h:148<br>&gt;&gt; #9&nbsp;&nbsp;0x0000000000432109 in ~SmartPointer (this=0x65bc20)<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; at /opt/x86_64/pkgs/itk/3.2.0/gcc-release/include/<br>&gt;&gt; InsightToolkit/Common/itkSmartPointer.h:65
<br>&gt;&gt; #10 0x0000000000440373 in ~Image (this=0x65ba60)<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; at /opt/x86_64/pkgs/itk/3.2.0/gcc-release/include/<br>&gt;&gt; InsightToolkit/Common/itkImage.h:365<br>&gt;&gt; #11 0x0000002a967ecf29 in itk::Object::UnRegister ()
<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/x86_64/pkgs/itk/3.2.0/gcc-release/lib/InsightToolkit/<br>&gt;&gt; libITKCommon.so.3.2<br>&gt;&gt; #12 0x0000002a967f8143 in itk::ProcessObject::~ProcessObject$base ()<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/x86_64/pkgs/itk/3.2.0/gcc-release/lib/InsightToolkit/
<br>&gt;&gt; libITKCommon.so.3.2<br>&gt;&gt; #13 0x0000000000430351 in ~ImageSource (this=0x659db0)<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; at /opt/x86_64/pkgs/itk/3.2.0/gcc-release/include/<br>&gt;&gt; InsightToolkit/Common/itkImageSource.h:178
<br>&gt;&gt; #14 0x0000000000448e74 in ~ImageFileReader (this=0x659db0)<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; at /opt/x86_64/pkgs/itk/3.2.0/gcc-release/include/<br>&gt;&gt; InsightToolkit/IO/itkImageFileReader.txx:46<br>&gt;&gt; #15 0x0000002a967ecf29 in itk::Object::UnRegister ()
<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/x86_64/pkgs/itk/3.2.0/gcc-release/lib/InsightToolkit/<br>&gt;&gt; libITKCommon.so.3.2<br>&gt;&gt; #16 0x00000000004462b0 in<br>&gt;&gt; itk::SmartPointer&lt;itk::ImageFileReader&lt;itk::Image&lt;unsigned short,
<br>&gt;&gt; 3u&gt;, itk::DefaultConvertPixelTraits&lt;unsigned short&gt; &gt; &gt;::UnRegister<br>&gt;&gt; (this=0x7fbfffecc0)<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; at /opt/x86_64/pkgs/itk/3.2.0/gcc-release/include/<br>&gt;&gt; InsightToolkit/Common/itkSmartPointer.h:148
<br>&gt;&gt; #17 0x0000000000444069 in ~SmartPointer (this=0x7fbfffecc0)<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; at /opt/x86_64/pkgs/itk/3.2.0/gcc-release/include/<br>&gt;&gt; InsightToolkit/Common/itkSmartPointer.h:65<br>&gt;&gt; #18 0x000000000043e928 in
<br>&gt;&gt; itk::ImageSeriesReader&lt;itk::Image&lt;unsigned short, 3u&gt;<br>&gt;&gt;&gt; ::GenerateData (this=0x6428a0)<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; at /opt/x86_64/pkgs/itk/3.2.0/gcc-release/include/<br>&gt;&gt; InsightToolkit/IO/itkImageSeriesReader.txx:290
<br>&gt;&gt; #19 0x0000002a967f9516 in itk::ProcessObject::UpdateOutputData ()<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp;from /opt/x86_64/pkgs/itk/3.2.0/gcc-release/lib/InsightToolkit/<br>&gt;&gt; libITKCommon.so.3.2<br>&gt;&gt; #20 0x0000000000428421 in main (argc=6, argv=0x7fbffff518)
<br>&gt;&gt;&nbsp;&nbsp;&nbsp;&nbsp; at /home/ch116471/projects/svnwrk/crkit.org/trunk/tools/code/<br>&gt;&gt; crlSlicesToVolume.cxx:80<br>&gt;&gt;<br>&gt;&gt; _______________________________________________<br>&gt;&gt; Insight-users mailing list
<br>&gt;&gt; <a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br>&gt;&gt; <a href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a><br>&gt;<br>&gt; _______________________________________________
<br>&gt; Insight-developers mailing list<br>&gt; <a href="mailto:Insight-developers@itk.org">Insight-developers@itk.org</a><br>&gt; <a href="http://www.itk.org/mailman/listinfo/insight-developers">http://www.itk.org/mailman/listinfo/insight-developers
</a><br><br>_______________________________________________<br>Insight-developers mailing list<br><a href="mailto:Insight-developers@itk.org">Insight-developers@itk.org</a><br><a href="http://www.itk.org/mailman/listinfo/insight-developers">
http://www.itk.org/mailman/listinfo/insight-developers</a><br></blockquote></div><br>