[Insight-users] creating a volume from separate slices
Lucas Lorenzo
lucas at cvrti . utah . edu
Thu, 6 Nov 2003 18:01:06 -0700
--Apple-Mail-8--334646375
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
format=flowed
Thanks Josh,
I'm using the ImageSeriesReader.
The files are GE 5x (as far as I know the pixel type is unsigned int 16
bit) so my understanding is that the IO factory mechanism should make
it transparent for me the reading process. What I'd like to do is to
generate the volume in Analyze format. I checked the generated list of
file names and it's ok.
So, this is the code:
#include "itkNumericSeriesFileNames.h"
#include "itkImageSeriesReader.h"
#include "itkImageFileWriter.h"
#include "itkImage.h"
#include "itkAnalyzeImageIO.h"
#include <iostream>
int main(int argc, char * argv[])
{
typedef itk::Image<unsigned int,3> Image3DType;
typedef itk::AnalyzeImageIO ImageIOType;
ImageIOType::Pointer analyzeIO = ImageIOType::New();
//
// Here we generate filenames: I.001 I.002 ------ I.136
itk::NumericSeriesFileNames::Pointer fileIter =
itk::NumericSeriesFileNames::New();
fileIter->SetStartIndex( 1 );
fileIter->SetEndIndex( 136 );
fileIter->SetIncrementIndex( 1 );
fileIter->SetSeriesFormat("I.%03d");
itk::ImageSeriesReader<Image3DType>::Pointer reader =
itk::ImageSeriesReader<Image3DType>::New();
reader->SetFileNames( fileIter->GetFileNames() );
try
{
reader->Update();
}
catch( itk::ExceptionObject & err )
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return -1;
}
itk::ImageFileWriter< Image3DType >::Pointer writer =
itk::ImageFileWriter< Image3DType >::New();
writer->SetInput( reader->GetOutput() );
writer->SetFileName("test");
writer->SetImageIO(analyzeIO);
try
{
writer->Update();
}
catch( itk::ExceptionObject & err )
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return -1;
}
return 0;
}
but when doing the "reader->Update()" I have a run time error:
ExceptionObject caught !
itk::ExceptionObject (0x225c90)
Location: "Unknown"
File: /usr/local/include/InsightToolkit/IO/itkImageFileReader.txx
Line: 101
Description: Could not create IO object for file I.002
So, it seems to be that it is reading the first file in the list
("I.001") but it can't read the second.
Could anyone help me with this ?
Thanks
Lucas
On Thursday, November 6, 2003, at 11:07 AM, Joshua Cates wrote:
> Hi Lucas,
>
> To read slices into a volume, you can either create a MetaImageHeader
> for
> it with the MetaImageImporter application, or use the
> itk::ImageSeriesReader.
>
> (if these are raw files, another trick is to 'cat' them into to a
> single
> file)
>
> Josh.
> ______________________________
> Josh Cates
> Scientific Computing and Imaging Institute
> University of Utah
> Email: cates at sci . utah . edu
> Phone: (801) 587-7697
> URL: http://www . sci . utah . edu/~cates
>
>
> On Thu, 6 Nov 2003, Lucas Lorenzo wrote:
>
>> Hi,
>>
>> I have many slices (from a volume) stored in separate files.
>> How can I create the volume to save it to a file?
>> 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
>>
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk . org
>> http://www . itk . org/mailman/listinfo/insight-users
>>
>
>
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-8--334646375
Content-Transfer-Encoding: 7bit
Content-Type: text/enriched;
charset=US-ASCII
Thanks Josh,
I'm using the ImageSeriesReader.
The files are GE 5x (as far as I know the pixel type is unsigned int
16 bit) so my understanding is that the IO factory mechanism should
make it transparent for me the reading process. What I'd like to do is
to generate the volume in Analyze format. I checked the generated list
of file names and it's ok.
So, this is the code:
<italic> #include "itkNumericSeriesFileNames.h"
#include "itkImageSeriesReader.h"
#include "itkImageFileWriter.h"
#include "itkImage.h"
#include "itkAnalyzeImageIO.h"
#include <<iostream>
int main(int argc, char * argv[])
{
typedef itk::Image<<unsigned int,3> Image3DType;
typedef itk::AnalyzeImageIO ImageIOType;
ImageIOType::Pointer analyzeIO = ImageIOType::New();
//
// Here we generate filenames: I.001 I.002 ------ I.136
itk::NumericSeriesFileNames::Pointer fileIter =
itk::NumericSeriesFileNames::New();
fileIter->SetStartIndex( 1 );
fileIter->SetEndIndex( 136 );
fileIter->SetIncrementIndex( 1 );
fileIter->SetSeriesFormat("I.%03d");
itk::ImageSeriesReader<<Image3DType>::Pointer reader =
itk::ImageSeriesReader<<Image3DType>::New();
reader->SetFileNames( fileIter->GetFileNames() );
try
{
reader->Update();
}
catch( itk::ExceptionObject & err )
{
std::cout <<<< "ExceptionObject caught !" <<<< std::endl;
std::cout <<<< err <<<< std::endl;
return -1;
}
itk::ImageFileWriter<< Image3DType >::Pointer writer =
itk::ImageFileWriter<< Image3DType >::New();
writer->SetInput( reader->GetOutput() );
writer->SetFileName("test");
writer->SetImageIO(analyzeIO);
try
{
writer->Update();
}
catch( itk::ExceptionObject & err )
{
std::cout <<<< "ExceptionObject caught !" <<<< std::endl;
std::cout <<<< err <<<< std::endl;
return -1;
}
return 0;
}
</italic>
but when doing the "reader->Update()" I have a run time error:
<italic> ExceptionObject caught !
itk::ExceptionObject (0x225c90)
Location: "Unknown"
File: /usr/local/include/InsightToolkit/IO/itkImageFileReader.txx
Line: 101
Description: Could not create IO object for file I.002</italic>
So, it seems to be that it is reading the first file in the list
("I.001") but it can't read the second.
Could anyone help me with this ?
Thanks
Lucas
On Thursday, November 6, 2003, at 11:07 AM, Joshua Cates wrote:
<excerpt>Hi Lucas,
To read slices into a volume, you can either create a MetaImageHeader
for
it with the MetaImageImporter application, or use the
itk::ImageSeriesReader.
(if these are raw files, another trick is to 'cat' them into to a
single
file)
Josh.
______________________________
Josh Cates
Scientific Computing and Imaging Institute
University of Utah
Email: cates at sci . utah . edu
Phone: (801) 587-7697
URL: http://www . sci . utah . edu/~cates
On Thu, 6 Nov 2003, Lucas Lorenzo wrote:
<excerpt>Hi,
I have many slices (from a volume) stored in separate files.
How can I create the volume to save it to a file?
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
_______________________________________________
Insight-users mailing list
Insight-users at itk . org
http://www . itk . org/mailman/listinfo/insight-users
</excerpt>
</excerpt>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-8--334646375--