Fwd: [Insight-users] Analyze_Series

Luis Ibanez luis.ibanez at kitware.com
Tue Nov 30 22:59:52 EST 2004


Hi Yasser,


Please *NEVER* assign values to the component of the "argv[]" array.

These strings are read from the command line, they actually should be
treated as "const".


It is unfortunate that the compiler allowed you to do something like:

 > argv[1]="C:/YASCOPY/ImageData/126_1/126_1_1.img";
 > argv[2]="C:/YASCOPY/ImageData/126_1/126_1_28.img";
 > argv[3]="C:/YASCOPY/ImageData/126_1/Out";



Please post the exact error message that you get. You are probably
getting also the filename of the file that cannot be read.

It is a common mistake to provide a wrongly constructed printf format
to the filenames generator.

For double checking the names that you are generating, you can get
the container returned by the GetFileNames() method of the filename
generator, and print all of them.  Please look at the Doxigen
documentation of the NumericSeriesFileNames class:

http://www.itk.org/Insight/Doxygen/html/classitk_1_1NumericSeriesFileNames.html



   Regards,



      Luis



----------------------
yasser salman wrote:

> oops , i forgot the File, sorry, i attached it now
> Note: forwarded message attached.
> 
> 
> 
> 		
> __________________________________ 
> Do you Yahoo!? 
> The all-new My Yahoo! - What will yours do?
> http://my.yahoo.com 
> 
> 
> ------------------------------------------------------------------------
> 
> Subject:
> [Insight-users] Analyze_Series
> From:
> yasser salman <yass71 at yahoo.com>
> Date:
> Mon, 29 Nov 2004 12:32:52 -0800 (PST)
> To:
> insight-users at itk.org
> 
> 
> hi all..,
> i modified the attachment file to read Analyze image ,
> the following Error message appeared " File cannot be
> read"
> i'm using Example found in IO directory, but i think i
> have a problem
> in specify my series location also the output image
> location (and name) can if u plz help me to fix the
> problem.
> Note: my seires from ISBR and have no header,
> start slice 126_1_1.img End slice 126_1_28.img 
> i read it correctly (*without header*) when i convert
> it to DICOM but i need to read it as its original
> format..,
> thanks .., 
> Yasser..,
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 
> 
> ------------------------------------------------------------------------
> 
> /*=========================================================================
> 
>   Program:   Insight Segmentation & Registration Toolkit
>   Module:    $RCSfile: ImageSeriesReadWrite.cxx,v $
>   Language:  C++
>   Date:      $Date: 2003/12/29 15:27:22 $
>   Version:   $Revision: 1.1 $
> 
>   Copyright (c) Insight Software Consortium. All rights reserved.
>   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
> 
>      This software is distributed WITHOUT ANY WARRANTY; without even 
>      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
>      PURPOSE.  See the above copyright notices for more information.
> 
> =========================================================================*/
> 
> //  Software Guide : BeginLatex
> //
> //  This example illustrates how to read a series of 2D slices from independent
> //  files in order to compose a volume. The class \doxygen{ImageSeriesReader}
> //  is used for this purpose. This class works in combination with a generator
> //  of filenames that will provide a list of files to be read. In this
> //  particular example we use the \doxygen{NumericSeriesFileNames} class as
> //  filename generator. This generator uses a \code{printf} style of string format
> //  with a ``\%d'' field that will be succesively replaced by a number specified
> //  by the user. Here we will use a format like ``file\%04d.png'' for reading 
> //  PNG files named file0001.png, file0002.png, file0003.png... and so on.
> //
> //  This requires the following headers as shown.
> //
> //  \index{itk::ImageSeriesReader!header}
> //  \index{itk::NumericSeriesFileNames!header}
> //
> //  Software Guide : EndLatex 
> 
> // Software Guide : BeginCodeSnippet
> #include "itkImage.h"
> #include "itkImageSeriesReader.h"
> #include "itkImageFileWriter.h"
> #include "itkNumericSeriesFileNames.h"
> #include "itkAnalyzeImageIO.h"
> // Software Guide : EndCodeSnippet
> 
> 
> int main( int argc, char ** argv )
> {
>   // Verify the number of parameters in the command line
> 
> 
>   // Software Guide : BeginLatex
>   //
>   // We start by defining the \code{PixelType} and \code{ImageType}.
>   //
>   //
>   // Software Guide : EndLatex 
> 
>   // Software Guide : BeginCodeSnippet
>   typedef unsigned char                       PixelType;
>   const unsigned int Dimension = 3;
> 
>   typedef itk::Image< PixelType, Dimension >  ImageType;
>   // Software Guide : EndCodeSnippet
> 
> 
>   // Software Guide : BeginLatex
>   //
>   // The image type is used as a template parameter to instantiate
>   // the reader and writer.
>   //
>   // \index{itk::ImageSeriesReader!Instantiation}
>   // \index{itk::ImageFileWriter!Instantiation}
>   //
>   // Software Guide : EndLatex 
> 
>   // Software Guide : BeginCodeSnippet
>   typedef itk::ImageSeriesReader< ImageType >  ReaderType;
>   typedef itk::ImageFileWriter<   ImageType >  WriterType;
> 
>   ReaderType::Pointer reader = ReaderType::New();
>   WriterType::Pointer writer = WriterType::New();
>   // Software Guide : EndCodeSnippet
> 
> argv[1]="C:/YASCOPY/ImageData/126_1/126_1_1.img";
> argv[2]="C:/YASCOPY/ImageData/126_1/126_1_28.img";
> argv[3]="C:/YASCOPY/ImageData/126_1/Out";
>   const unsigned int first =0;// atoi( argv[1] );
>   const unsigned int last  = 27;//atoi( argv[2] );
> 
>   const char * outputFilename = argv[3];
> 
>   // Software Guide : BeginCodeSnippet
>   typedef itk::NumericSeriesFileNames    NameGeneratorType;
> 
>   NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
>    
>   nameGenerator->SetStartIndex( first );
>   nameGenerator->SetEndIndex( last );
>   nameGenerator->SetIncrementIndex( 1 );
> 
>   nameGenerator->SetSeriesFormat( "C:/YASCOPY/ImageData/126_1/126_1_%d.img" );
>   // Software Guide : EndCodeSnippet
> 
> 
> 
>   //  Software Guide : BeginLatex
>   //
>   //  The ImageIO object that actually performs the read process
>   //  is now connected to the ImageSeriesReader.
>   //
>   //  Software Guide : EndLatex 
> 
>   // Software Guide : BeginCodeSnippet
>   reader->SetImageIO( itk::AnalyzeImageIO::New() );
>   // Software Guide : EndCodeSnippet
> 
> 
> 
> 
>   //  Software Guide : BeginLatex
>   //
>   //  The filenames of the input and output files must be provided to the
>   //  reader and writer respectively.
>   //
>   //  Software Guide : EndLatex 
> 
>   // Software Guide : BeginCodeSnippet
>   reader->SetFileNames( nameGenerator->GetFileNames()  );
> 
>   writer->SetFileName( outputFilename );
>   // Software Guide : EndCodeSnippet
> 
>   try
>     { 
>     reader->Update();
>     }
>   catch( itk::ExceptionObject & excp )
>     {
>     std::cerr << "Error reading the series " << std::endl;
>     std::cerr << excp << std::endl;
>     }
> 
>   ImageType::Pointer image = reader->GetOutput();
>   writer->SetInput( image );
> 
> 
>   //  Software Guide : BeginLatex
>   //
>   //  Finally, execution of the pipeline can be triggered by invoking the
>   //  Update() method in the writer.
>   //
>   //  Software Guide : EndLatex 
> 
>   // Software Guide : BeginCodeSnippet
>   writer->Update();
>   // Software Guide : EndCodeSnippet
> 
> 
>   return 0;
> }
> 
> 
> 





More information about the Insight-users mailing list