[Insight-users] Error even after fixing ITK bug / Combining
ImageSeriesReader and RawImageIO
Andreas Keil
andreas.keil at cs.tum.edu
Fri Mar 9 11:00:05 EST 2007
Hello,
I'd like to read image data from a series of raw files containing a 2D
slice each, e.g. a 620x480x191 voxel volume in the files "data.001" to
"data.191". Therefore, I set up an ImageSeriesReader and a RawImageIO in
the following way:
-------------------------------------------------------------------------
#include "itkImage.h"
#include "itkImageSeriesReader.h"
#include "itkRawImageIO.h"
#include "itkNumericSeriesFileNames.h"
typedef float PixelType;
const int Dimension = 3;
typedef itk::Image<PixelType, Dimension> ImageType;
ImageType::Pointer itkImg = ImageType::New();
typedef itk::ImageSeriesReader<ImageType> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
typedef itk::RawImageIO<PixelType, Dimension> ImageIOType;
ImageIOType::Pointer io = ImageIOType::New();
io->SetDimensions(0, 620);
io->SetDimensions(1, 480);
io->SetDimensions(2, 191);
io->SetSpacing(0, 1.0);
io->SetSpacing(1, 1.0);
io->SetSpacing(2, 1.0);
io->SetOrigin(0, 0.0);
io->SetOrigin(1, 0.0);
io->SetOrigin(2, 0.0);
io->SetHeaderSize(0);
io->SetByteOrderToLittleEndian();
io->SetFileTypeToBinary();
io->SetFileDimensionality(Dimension);
io->SetPixelType(itk::ImageIOBase::SCALAR);
io->SetNumberOfComponents(1);
typedef itk::NumericSeriesFileNames NameGeneratorType;
NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
nameGenerator->SetSeriesFormat("data.%03d");
nameGenerator->SetStartIndex(1);
nameGenerator->SetEndIndex(191);
reader->SetImageIO(io);
reader->SetFileNames(nameGenerator->GetFileNames());
// read image into ITK image
reader->Update();
itkImg = reader->GetOutput();
-------------------------------------------------------------------------
However, even after fixing a bug (which I'll report asap) in
itkImageSeriesReader.txx where the two lines
dimSize[m_NumberOfDimensionsInImage] = m_FileNames.size();
spacing[m_NumberOfDimensionsInImage] = interSliceSpacing;
had to be fixed by adding -1 in the index, I still can't read an image
series with RawImageIO. I get an ITK exception telling me that only one
1190400 bytes could be read (which is the size of one slice) instead of
227366400 bytes (which is the whole volume's size). It seems to me that
the RawImageIO object wants to read all data from the first file, which
is, of course, impossible. How can I tell the ImageSeriesReader/RawImageIO
that I want to read the input from all 191 files?
Thank you,
Andreas.
More information about the Insight-users
mailing list