[Insight-users] creating a volume from separate slices

Lucas Lorenzo lucas at cvrti . utah . edu
Sat, 8 Nov 2003 13:07:57 -0700


Thanks a lot Mr. Johnson,

now I'm able to read all the slices. To  check it I'm writing the  
volume to a vtk file and there's something I can't understand: I have  
136 slices (files I.001 to I.136) but when I read the vtk file header  
it says that the volume has 137 slabs.
I'm also trying to write this volume as a dicom file but I'm having  
this problem:

	itk::ERROR: ImageFileWriter(0x26a6f0): No ImageIO set, or none could  
be created.

By the way, I'm inserting both types into the IO factory at the  
beginning of my program:

   	static bool firstTime = true;
  	 if(firstTime)
  	   {
   	     
	itk::ObjectFactoryBase::RegisterFactory(itk::GE5ImageIOFactory::New()  
);
    	   
	 
itk::ObjectFactoryBase::RegisterFactory(itk::DICOMImageIO2Factory::New() 
);
    	  	firstTime = false;
   	  }

Regards,

Lucas

On Thursday, November 6, 2003, at 07:14 PM, Hans Johnson wrote:

> Lucas,
>
> The IO factory mechanism does not have support for the GE4x or GE5x
> files by default.  This was a decision made since very few people  
> needed
> this support.  You will need to call the RegisterOnce() call once at  
> the
> beging of your main function to insert this filetype into the IO  
> factory
> list of known file types (see the Testing/Code/IO/*GE*.cxx file for the
> exact syntax).
>
> Since ITK has no concept of image orientation
> (Coronal/Sagittal/Transverse) this information was not originally taken
> into account.  You're current program will output Analyze images with a
> transverse coding no matter what the actual orientation was in the GE
> image.    I am happy to announce that we are currently working very  
> hard
> to remedy this situation in a manner that will be useful across most
> image types that have an orientation specification.
>
> In addition, you will not need to use the ImageSeriesFilter as the GE
> filter implementations reads through all the files in the directory and
> choose the ones that belong in the volume based on scan
> characteristics.  For example if you have a scan sequence where PD and
> T2 images are acquired simultaneously as interleaved slices, then
> choosing I.001(or any odd numbered slice) will read all the odd images
> and produce the PD volume, and choosing I.002 (or any even numbered
> slice) will read all the even images and produce the T2 image volume.
>
> Regards,
> Hans J. Johnson
>
> PS:  the pixel type is unsigned short int (16 bits).
>
>
>
> Lucas Lorenzo wrote:
>
>> 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
>>
>
>
>
> _______________________________________________
> 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