[Insight-users] Reading Analyze 7.5 images with ITK

kent williams nkwmailinglists at gmail.com
Mon Nov 9 10:11:25 EST 2009


Err shouldnt' edit code in GMAIL -- remove the curly brace before
"return image;"

On Mon, Nov 9, 2009 at 9:10 AM, kent williams <nkwmailinglists at gmail.com> wrote:
> Why are you using the Image Series Reader? Analyze images comprise a
> header file + a raw image data file.  Here's what we use in our code:
>
>  template <typename TImage>
>  typename TImage::Pointer ReadImage( const std::string &fileName)
>  {
>    typename TImage::Pointer image;
>
>    typedef itk::ImageFileReader<TImage> ReaderType;
>    typename ReaderType::Pointer reader = ReaderType::New();
>    reader->SetFileName( fileName.c_str() );
>    try
>      {
>      reader->Update();
>      }
>    catch( itk::ExceptionObject & err )
>      {
>      std::cout << "Caught an exception reading" << fileName << ": "
> << std::endl;
>      std::cout << err << " " << __FILE__ << " " << __LINE__ << std::endl;
>      throw err;
>      }
>    catch(...)
>      {
>      std::cout << "Error while reading image " << fileName << std::endl;
>      throw;
>      }
>     image = reader->GetOutput();
>    }
>    return image;
>  }
>
>
>
> On Sun, Nov 8, 2009 at 2:40 PM, A.Burak Yoldemir <yoldemir at gmail.com> wrote:
>> Hello,
>>
>> I am trying to read Analyze 7.5 images using ITK, however I am getting
>> segfault. Here is the relevant 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() );
>>             reader->Update();
>>
>> I am getting a segmentation fault when the update method is called. Any
>> ideas?
>>
>> Thanks in advance,
>>
>>
>> Ahmet Burak Yoldemi
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>>
>


More information about the Insight-users mailing list