[Insight-users] Reading Analyze 7.5 images
Luis Ibanez
luis.ibanez at kitware.com
Wed Nov 11 17:58:23 EST 2009
Hi Ahmet,
You are probably generating an incorrect list of filenames.
Please do the following:
1) Remove the line:
reader->SetImageIO( itk::AnalyzeImageIO::New() );
The image IO factory should be able to find the appropriate
ImageIO class for the file format that you are reading.
2) Before calling reader->Update() print out all the filenames
that result from the imageFileNameGenerator.
You need to insert code such as:
typedef std::vector<std::string> NamesContainerType;
NamesContainerType fileNames = nameGenerator->GetFileNames();
NamesContainerType::const_iterator fitr = fileNames.begin();
NamesContainerType::const_iterator fend = fileNames.fend();
while( fitr != fend )
{
std::cout << *fitr << std::endl;
++fitr;
}
3) Then you should verify that those names actually match existing files.
You could do that manually, or you could use the following lines:
#include <itksys/SystemTools.hxx>
if( ! SystemTools::FileExists( *fitr ) )
{
std::cerr << "File " << *fitr << " does not exist " << std::endl;
}
Please let us know what you find,
Luis
---------------------------------------------------------
On Wed, Nov 11, 2009 at 4:27 AM, A.Burak Yoldemir <yoldemir at gmail.com> wrote:
> Hello Luis,
>
> I formerly sent an e-mail to insight-users group about a problem of mine
> which is about reading Analyze 7.5 images with ITK, but could not get a
> response. I am trying to read a set of images but getting a segmentation
> fault. I am copying my code and the output below. Do you have any
> suggestions?
>
>
> Code:
> typedef unsigned char PixelType;
> const unsigned int Dimension = 3;
> typedef itk::Image< PixelType, Dimension > ImageType;
>
> typedef itk::ImageSeriesReader< ImageType > ReaderType;
>
> ReaderType::Pointer reader = ReaderType::New();
>
> typedef itk::NumericSeriesFileNames NameGeneratorType;
> NameGeneratorType::Pointer nameGenerator =
> NameGeneratorType::New();
>
>
> nameGenerator->SetSeriesFormat(
> "/root/Desktop/default_10-v1.0.3/default_10-v1.0.3/phantom_01/clean/dwi-%02d.hdr"
> );
>
> nameGenerator->SetStartIndex( 0 );
> nameGenerator->SetEndIndex( 66 );
> nameGenerator->SetIncrementIndex( 1 );
>
> reader->SetImageIO( itk::AnalyzeImageIO::New() );
>
> reader->SetFileNames( nameGenerator->GetFileNames() );
>
> cout << "Before try/catch" << endl;
> try
> {
> cout << "Try1" << endl;
> reader->Update();
> cout << "Try2" << endl;
> }
> catch (itk::ExceptionObject &e)
> {
> std::cerr << e << std::endl;
> return EXIT_FAILURE;
> }
>
>
> Output:
> Before try/catch
> Try1
> Segmentation fault
>
>
> Thanks in advance,
>
> Ahmet Burak Yoldemir
>
More information about the Insight-users
mailing list