I added the try/catch block. It gives a segmentation fault, however does not throw an exception. Here is the code and the output:<br><br><b>Code:</b><br> typedef unsigned char PixelType;<br> const unsigned int Dimension = 3;<br>
typedef itk::Image< PixelType, Dimension > ImageType;<br> <br> typedef itk::ImageSeriesReader< ImageType > ReaderType;<br> <br> ReaderType::Pointer reader = ReaderType::New();<br>
<br> typedef itk::NumericSeriesFileNames NameGeneratorType;<br> NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();<br><br><br> nameGenerator->SetSeriesFormat( "/root/Desktop/default_10-v1.0.3/default_10-v1.0.3/phantom_01/clean/dwi-%02d.hdr" );<br>
<br> nameGenerator->SetStartIndex( 0 );<br> nameGenerator->SetEndIndex( 66 );<br> nameGenerator->SetIncrementIndex( 1 );<br> <br> reader->SetImageIO( itk::AnalyzeImageIO::New() );<br>
<br> reader->SetFileNames( nameGenerator->GetFileNames() );<br> <br> cout << "Before try/catch" << endl;<br> try<br> {<br> cout << "Try1" << endl;<br>
reader->Update();<br> cout << "Try2" << endl;<br> }<br> catch (itk::ExceptionObject &e)<br> {<br> std::cerr << e << std::endl;<br>
return EXIT_FAILURE;<br> }<br><br><br><b>Output:</b><br>Before try/catch<br>Try1<br>Segmentation fault<br><br><br clear="all">Ahmet Burak Yoldemir<br>
<br><br><div class="gmail_quote">On Sun, Nov 8, 2009 at 11:23 PM, Bill Lorensen <span dir="ltr"><<a href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">Place a try/catch block around the reader->Update() and print the<br>
exception if one is thrown.<br>
<br>
try<br>
{<br>
reader->Update();<br>
}<br>
catch (itk::ExceptionObject &e)<br>
{<br>
std::cerr << e << std::endl;<br>
return EXIT_FAILURE;<br>
}<br>
<br>
<br>
On Sun, Nov 8, 2009 at 3:40 PM, A.Burak Yoldemir <<a href="mailto:yoldemir@gmail.com">yoldemir@gmail.com</a>> wrote:<br>
</div><div><div></div><div class="h5">> Hello,<br>
><br>
> I am trying to read Analyze 7.5 images using ITK, however I am getting<br>
> segfault. Here is the relevant code:<br>
><br>
> typedef unsigned char PixelType;<br>
> const unsigned int Dimension = 3;<br>
> typedef itk::Image< PixelType, Dimension > ImageType;<br>
><br>
> typedef itk::ImageSeriesReader< ImageType > ReaderType;<br>
><br>
> ReaderType::Pointer reader = ReaderType::New();<br>
><br>
> typedef itk::NumericSeriesFileNames NameGeneratorType;<br>
> NameGeneratorType::Pointer nameGenerator =<br>
> NameGeneratorType::New();<br>
><br>
> nameGenerator->SetSeriesFormat(<br>
> "/root/Desktop/default_10-v1.0.3/default_10-v1.0.3/phantom_01/clean/dwi-%02d.hdr"<br>
> );<br>
><br>
> nameGenerator->SetStartIndex( 0 );<br>
> nameGenerator->SetEndIndex( 66 );<br>
> nameGenerator->SetIncrementIndex( 1 );<br>
><br>
> reader->SetImageIO( itk::AnalyzeImageIO::New() );<br>
><br>
> reader->SetFileNames( nameGenerator->GetFileNames() );<br>
> reader->Update();<br>
><br>
> I am getting a segmentation fault when the update method is called. Any<br>
> ideas?<br>
><br>
> Thanks in advance,<br>
><br>
><br>
> Ahmet Burak Yoldemi<br>
</div></div><div><div></div><div class="h5">> _____________________________________<br>
> Powered by <a href="http://www.kitware.com" 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" 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.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
><br>
> Please keep messages on-topic and check the ITK FAQ at:<br>
> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
><br>
><br>
</div></div></blockquote></div><br>