[Insight-users] creating a volume from separate slices

Luis Ibanez luis . ibanez at kitware . com
Tue, 11 Nov 2003 23:17:52 -0500


Hi Lucas,

The message from the reader seems to be pretty clear:

" Using string 'I.%03d' with values 1 to 136 stepping 1  "

If 137 slices are being generated in the volume, this
looks like a bug.

Could you please send us the following, attached to
an email:

1) The source code that you are using for reading
    the data

2) The MetaImage Header that you are using when you
    get 137 slices instead of 136

3) The test printed out by the program while it is
     running

and very important

4) The list of files in the directory where you have
    I.001, I.002.... etc.


Also, let us know if you are working on Unix and/or
Linux and the compiler you are using.


Thanks


   Luis



-------------------
Lucas Lorenzo wrote:
> Thanks Luis,
> 
> I've tried option A but as I said, it seems to be reading 137 slices  
> instead of 136.This is the results from  reader->GetOutput()->Print(  
> std::cout ):
> 
> 
> Image (0x265d40)
>   RTTI typeinfo:   N3itk5ImageItLj3EEE
>   Reference Count: 1
>   Modified Time: 24
>   Debug: Off
>   Observers:
>     none
>   Source: (0x263e50)
>   Source output index: 0
>   Release Data: Off
>   Data Released: False
>   Global Release Data: Off
>   PipelineMTime: 13
>   UpdateTime: 27
>   LastRequestedRegionWasOutsideOfTheBufferedRegion: 1
>   LargestPossibleRegion:
>     Dimension: 3
>     Index: [0, 0, 0]
>     Size: [256, 256, 137]
>   BufferedRegion:
>     Dimension: 3
>     Index: [0, 0, 0]
>     Size: [256, 256, 137]
>   RequestedRegion:
>     Dimension: 3
>     Index: [0, 0, 0]
>     Size: [256, 256, 137]
>   Origin: [0, 0, 0]
>   Spacing: [0.390625, 0.390625, 1]
>   PixelContainer: ImportImageContainer (0x265e50)
>   RTTI typeinfo:   N3itk20ImportImageContainerImtEE
>   Reference Count: 2
>   Modified Time: 25
>   Debug: Off
>   Observers:
>     none
>   Pointer: 0x265e94
>   Container manages memory: true
>   Size: 8978432
>   Capacity: 8978432
> 
> I can't understand what's wrong. Do you ?
> Thanks again,
> 
> Lucas
> 
> On Monday, November 10, 2003, at 08:08 PM, Luis Ibanez wrote:
> 
>> Hi Lucas,
>>
>> The DICOMImageIO class will only read
>> DICOM files, not write them.
>>
>> About the number of slices.  You could
>> easily verify the reading by doing:
>>
>> A) In your code, call Update in the reader
>>    and print out the details of the image.
>>
>>    something like:
>>
>>    reader->Update();
>>    reader->GetOutput()->Print( std::cout );
>>
>> or
>>
>>
>> B) Saving your image as a MetaImage,
>>    simply provide the writer with a filename
>>    with extension ".mhd".
>>
>>    The MetaImage header will show you how
>>    many pixels your dataset has along each
>>    dimension.
>>
>>
>> Please let us know what you find.
>>
>>
>> Thanks,
>>
>>
>>   Luis
>>
>>
>> ---------------------
>> Lucas Lorenzo wrote:
>>
>>> 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
>>> _______________________________________________
>>> 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
> 
>