[Insight-users] Dicom

Syrine Sahmim syrine.sahmim at yahoo.fr
Tue Jun 23 03:44:10 EDT 2009


Hi luis,
yesterday i send a mail to know what's wrong on it since i had read the software kit  . i change as i said before the installation. now i have itk 3.12 with visual studio 8 (2005) and cmake2.6.My system is windows xp.
all right,when i read the kit i find that if we need to give a dicom serie as input ,this will be possible if i use setFileName() method.
My questions are:
1.if i have a directory of dicom serie 2D or 3D how can i put him in the code.
2.as i understood, the argv[] is an array. what he will contain exactly?
3. if the reading is done. how can i know that is correct or false .in other words, the system must give me some indicaton or no if the reading is done.
4.where can i put the directory to have the image after writing it.

May be my questions are so stupid but those points are important to understand to can progress.i will send my code again and please can you indicate to me where is the error and where i must mention the input and out put directories.
Excuse-me again
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif

#ifdef __BORLANDC__
#define ITK_LEAN_AND_MEAN
#endif


#include "itkOrientedImage.h"
#include "itkGDCMImageIO.h"
#include "itkGDCMSeriesFileNames.h"
#include "itkImageSeriesReader.h"
#include "itkImageFileWriter.h"
int main( int argc, char* argv[] )
{

  if( argc < 3 )
    {
    std::cerr << "Usage: " << std::endl;
    std::cerr << argv[0] << " DicomDirectory  outputFileName  [seriesName]" << std::endl;
    return EXIT_FAILURE;
    }

  typedef signed short    PixelType;
  const unsigned int      Dimension = 3;

  typedef itk::OrientedImage< PixelType, Dimension >         ImageType;

  typedef itk::ImageSeriesReader< ImageType >        ReaderType;
  ReaderType::Pointer reader = ReaderType::New();

  typedef itk::GDCMImageIO       ImageIOType;
  ImageIOType::Pointer dicomIO = ImageIOType::New();
  
  reader->SetImageIO( dicomIO );

  typedef itk::GDCMSeriesFileNames NamesGeneratorType;
  NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();

  nameGenerator->SetUseSeriesDetails( true );
  nameGenerator->AddSeriesRestriction("0008|0021" );
  //argv[1]="C:/Documents and Settings/Sirouna/Mes documents/Master/imgdicom/DICOM/09033118/07230000";
  nameGenerator->SetDirectory( "C:/Documents and Settings/Sirouna/Mes documents/Master/imgdicom/DICOM/09033118/07230000" );


  try
    {
    std::cout << std::endl << "The directory: " << std::endl;
    std::cout << std::endl << argv[1] << std::endl ;
    std::cout << "Contains the following DICOM Series: ";
    std::cout << std::endl << std::endl;


    typedef std::vector< std::string >    SeriesIdContainer;
    
    const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();
    
    SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();
    SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();
    while( seriesItr != seriesEnd )
      {
      std::cout << seriesItr->c_str() << std::endl;
      seriesItr++;
      }

    std::string seriesIdentifier;

    if( argc > 3 ) 
      {
      seriesIdentifier = argv[3];
      }
    else
      {
      seriesIdentifier = seriesUID.begin()->c_str();
      }

    std::cout << std::endl << std::endl;
    std::cout << "Now reading series: " << std::endl << std::endl;
    std::cout << seriesIdentifier << std::endl;
    std::cout << std::endl << std::endl;

    typedef std::vector< std::string >   FileNamesContainer;
    FileNamesContainer fileNames;

    fileNames = nameGenerator->GetFileNames( seriesIdentifier );

    reader->SetFileNames( "c:/ );

    try
      {
      reader->Update();
      }
    catch (itk::ExceptionObject &ex)
      {
      std::cout << ex << std::endl;
      return EXIT_FAILURE;
      }


}
  catch (itk::ExceptionObject &ex)
    {
    std::cout << ex << std::endl;
    return EXIT_FAILURE;
    }


  return EXIT_SUCCESS;

}


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090623/f11abeed/attachment.htm>


More information about the Insight-users mailing list