[Insight-developers] Re: [Insight-users] bad free() reading Signa images

Bill Lorensen bill.lorensen at gmail.com
Thu May 10 10:10:37 EDT 2007


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.

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


More information about the Insight-developers mailing list