[Insight-users] Re : Strange error when reading DICOM

Syrine Sahmim syrine.sahmim at yahoo.fr
Wed Jun 17 06:29:43 EDT 2009


itry to read a dicom series me too can you send me your cmakelists.txt file
i try to execute this program but i have this error when i debogue it:"DicomImageReadWrite.cxx
.\DicomImageReadWrite.cxx(8) : fatal error C1083: Impossible d'ouvrir le fichier include : 'itkImageFileReader.h' : No such file or directory" and i join my cmakefile 
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif

#ifdef __BORLANDC__
#define ITK_LEAN_AND_MEAN
#endif

#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkRescaleIntensityImageFilter.h"
#include "itkGDCMImageIO.h"
#include <list>
#include <fstream>

int main( int argc, char* argv[] )
{if( argc < 5 )
    {
    std::cerr << "Usage: " << std::endl;
    std::cerr << argv[0] << " DicomImage OutputDicomImage ";
    std::cerr << " OutputImage RescaleDicomImage\n";
    return EXIT_FAILURE;
    }
typedef signed short InputPixelType;
  const unsigned int   InputDimension = 2;

  typedef itk::Image< InputPixelType, InputDimension > InputImageType;
  typedef itk::ImageFileReader< InputImageType > ReaderType;

  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileName( argv[1] );
  typedef itk::GDCMImageIO           ImageIOType;

  ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
  
  reader->SetImageIO( gdcmImageIO );
  try
    {
    reader->Update();
    }
  catch (itk::ExceptionObject & e)
    {
    std::cerr << "exception in file reader " << std::endl;
    std::cerr << e << std::endl;
    return EXIT_FAILURE;
    }
  typedef itk::ImageFileWriter< InputImageType >  Writer1Type;

  Writer1Type::Pointer writer1 = Writer1Type::New();

  writer1->SetFileName( argv[2] );
  writer1->SetInput( reader->GetOutput() );
  writer1->SetImageIO( gdcmImageIO );
  try
    {
    writer1->Update();
    }
  catch (itk::ExceptionObject & e)
    {
    std::cerr << "exception in file writer " << std::endl;
    std::cerr << e << std::endl;
    return EXIT_FAILURE;
    }
  typedef unsigned char WritePixelType;
  
  typedef itk::Image< WritePixelType, 2 > WriteImageType;
  
  typedef itk::RescaleIntensityImageFilter< 
               InputImageType, WriteImageType > RescaleFilterType;

  RescaleFilterType::Pointer rescaler = RescaleFilterType::New();

  rescaler->SetOutputMinimum(   0 );
  rescaler->SetOutputMaximum( 255 );
  typedef itk::ImageFileWriter< WriteImageType >  Writer2Type;

  Writer2Type::Pointer writer2 = Writer2Type::New();

  writer2->SetFileName( argv[3] );
 
  rescaler->SetInput( reader->GetOutput() );
  writer2->SetInput( rescaler->GetOutput() );
  try
    {
    writer2->Update();
    }
  catch (itk::ExceptionObject & e)
    {
    std::cerr << "exception in file writer " << std::endl;
    std::cerr << e << std::endl;
    return EXIT_FAILURE;
    }
  typedef itk::ImageFileWriter< WriteImageType >  Writer3Type;
  
  Writer3Type::Pointer writer3 = Writer3Type::New();

  writer3->SetFileName( argv[4] );
  writer3->SetInput( rescaler->GetOutput() );
  writer3->UseInputMetaDataDictionaryOff ();
  writer3->SetImageIO( gdcmImageIO );
   try
    {
    writer3->Update();
    }
  catch (itk::ExceptionObject & e)
    {
    std::cerr << "Exception in file writer " << std::endl;
    std::cerr << e << std::endl;
    return EXIT_FAILURE;
     return EXIT_SUCCESS;

}




________________________________
De : Patrik.Br. <patrik.brynolfsson at gmail.com>
À : insight-users at itk.org
Envoyé le : Mardi, 16 Juin 2009, 10h43mn 41s
Objet : [Insight-users]  Strange error when reading DICOM


Hello,

I am trying to read DICOM series from a folder, much like in example
DicomSeriesReadImageWrite2.cxx. However, I modified the reader so that it
loops over all found series instead of just the first:

SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();
SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();
std::string seriesIdentifier;
typedef std::vector< std::string >   FileNamesContainer;
FileNamesContainer fileNames;

while( seriesItr != seriesEnd )
   {
    seriesIdentifier = seriesItr->c_str();
    fileNames = nameGenerator->GetFileNames( seriesIdentifier );
    reader->SetFileNames( fileNames );
        try{
            reader->Update();
            }
        catch (itk::ExceptionObject &ex)
            {
            std::cout << ex << std::endl;
            return EXIT_FAILURE;
            }
    
       {
        //Some code
       }

    seriesItr++;
   } 

However I sometimes get the error 
"Requested region is (at least partially) outside the largest possible
region."
I first thought this was due to one faulty DICOM series, but it happens for
many series, but not all of them. It only happens when I read multiple DICOM
series i.e. when I use the loop, never when I read just one series. Also,
depending on what other series have been read before, some series might or
might not be read correctly without error. What's going on?

-- 
View this message in context: http://n2.nabble.com/Strange-error-when-reading-DICOM-tp3085364p3085364.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.

_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090617/afb24084/attachment-0002.htm>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CMakeLists.txt
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090617/afb24084/attachment-0002.txt>


More information about the Insight-users mailing list