[Insight-users] Reading several slices into a volume - MetaImageIO
Lucas Lorenzo
lucas at cvrti . utah . edu
Sat, 8 Nov 2003 16:12:31 -0700
--Apple-Mail-27--168361447
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed
Hi all,
I have 136 slices stored in individual files. Each slice is 256 x 256.
I want to read them into a volume so I wrote the following meta header
file (B0.mhd) and code:
ObjectType = Image
NDims = 3
DimSize = 256 256 136
ElementSpacing = 1 1 1
Position = 0 0 0
ElementByteOrderMSB = True
ElementType = MET_USHORT
HeaderSize = -1
ElementDataFile = I.%03d 1 136 1
#include <itkImage.h>
#include <itkImageFileReader.h>
int main()
{
// Declare the image type
typedef itk::Image<unsigned short, 3> ImageType;
// Declare a reader
typedef itk::ImageFileReader< ImageType > VolumeReaderType;
VolumeReaderType::Pointer reader = VolumeReaderType::New();
// Set the name of the file to read
reader->SetFileName( "B0.mhd" );
// Set the image into which the results should be stored
ImageType::Pointer imOut;
imOut = reader->GetOutput();
// See if the file can be read - "try" otherwise program will
// mysteriously exit on failure in the Object factory
try
{
reader->Update();
}
catch(itk::ExceptionObject &e)
{
std::cout << "Problems reading file format" << std::endl;
std::cerr << e << std::endl;
return -1;
}
return 1;
}
And I have the problem that it reads the first file (I.001) but it
doesn't read the rest:
Using string 'I.%03d' with values 1 to 136 stepping 1
file = _I.001_
file = _I.002_
MetaImage: M_ReadElements: data not read completely
ideal = 131072 : actual = 0
*
*
*
file = _I.136_
MetaImage: M_ReadElements: data not read completely
ideal = 131072 : actual = 0
Could someone please help me to figure out what's wrong?
Thanks
Lucas Lorenzo
University of Utah
Nora Eccles Harrison CardioVascular Research and Training Institute
Fellows Room
95 South 2000 East
Salt Lake City, UT 84112-5000
e-mail: lucas at cvrti . utah . edu
telephone: 801-587-9536
--Apple-Mail-27--168361447
Content-Transfer-Encoding: 7bit
Content-Type: text/enriched;
charset=US-ASCII
Hi all,
I have 136 slices stored in individual files. Each slice is 256 x 256.
I want to read them into a volume so I wrote the following meta header
file (B0.mhd) and code:
<italic> ObjectType = Image
NDims = 3
DimSize = 256 256 136
ElementSpacing = 1 1 1
Position = 0 0 0
ElementByteOrderMSB = True
ElementType = MET_USHORT
HeaderSize = -1
ElementDataFile = I.%03d 1 136 1
#include <<itkImage.h>
#include <<itkImageFileReader.h>
int main()
{
// Declare the image type
typedef itk::Image<<unsigned short, 3> ImageType;
// Declare a reader
typedef itk::ImageFileReader<< ImageType > VolumeReaderType;
VolumeReaderType::Pointer reader = VolumeReaderType::New();
// Set the name of the file to read
reader->SetFileName( "B0.mhd" );
// Set the image into which the results should be stored
ImageType::Pointer imOut;
imOut = reader->GetOutput();
// See if the file can be read - "try" otherwise program will
// mysteriously exit on failure in the Object factory
try
{
reader->Update();
}
catch(itk::ExceptionObject &e)
{
std::cout <<<< "Problems reading file format" <<<< std::endl;
std::cerr <<<< e <<<< std::endl;
return -1;
}
return 1;
}</italic>
And I have the problem that it reads the first file (I.001) but it
doesn't read the rest:
<italic>Using string 'I.%03d' with values 1 to 136 stepping 1
file = _I.001_
file = _I.002_
MetaImage: M_ReadElements: data not read completely
ideal = 131072 : actual = 0
*
*
*
file = _I.136_
MetaImage: M_ReadElements: data not read completely
ideal = 131072 : actual = 0</italic>
Could someone please help me to figure out what's wrong?
Thanks
Lucas Lorenzo
University of Utah
Nora Eccles Harrison CardioVascular Research and Training Institute
Fellows Room
95 South 2000 East
Salt Lake City, UT 84112-5000
e-mail: lucas at cvrti . utah . edu
telephone: 801-587-9536
--Apple-Mail-27--168361447--