[Insight-users] dicom series read

G G greenlander1986 at gmail.com
Tue Mar 29 08:27:36 EDT 2011


Thanks a lot... :) It works

2011/3/29 Abayiz <abayiz at yahoo.com>

> Hi,
>
> For try the following partial code for reading your dicom series:
> *********************************************************************
>  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" );
>   nameGenerator->SetDirectory( argv[1] );
>   try
>     {
>
>     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();
>            }
>
>     typedef std::vector< std::string >   FileNamesContainer;
>     FileNamesContainer fileNames;
>     fileNames = nameGenerator->GetFileNames( seriesIdentifier );
>     reader->SetFileNames( fileNames );
>    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;
>     }
>
> --- On *Tue, 3/29/11, G G <greenlander1986 at gmail.com>* wrote:
>
>
> From: G G <greenlander1986 at gmail.com>
> Subject: Re: [Insight-users] dicom series read
> To: "John Drescher" <drescherjm at gmail.com>
> Cc: "insight-users" <insight-users at itk.org>
> Date: Tuesday, March 29, 2011, 4:12 AM
>
>
> I think yes, I open this dicom series in ITK-SNAP without problems
> When I use only \Examples\IO\DicomSeriesReadSeriesWrite.cxx
> everything works fine, but when I use in my code it is wrong...
>
> 2011/3/29 John Drescher <drescherjm at gmail.com<http://mc/compose?to=drescherjm@gmail.com>
> >
>
> On Tue, Mar 29, 2011 at 3:21 AM, G G <greenlander1986 at gmail.com<http://mc/compose?to=greenlander1986@gmail.com>>
> wrote:
> > Hi I have so problem with dicom series read...
> >
> > I have this code for reading... I used this from
> > \Examples\IO\DicomSeriesReadSeriesWrite.cxx
> >
> >     typedef unsigned char /*signed short*/     PixelType;
> >     const unsigned int      InputDimension = 3;
> >
> >     typedef itk::Image< PixelType, InputDimension >      ImageType;
> >     typedef itk::ImageSeriesReader< ImageType >             ReaderType;
> >
> >     typedef itk::GDCMImageIO                        ImageIOType;
> >     typedef itk::GDCMSeriesFileNames                NamesGeneratorType;
> >
> >     ImageIOType::Pointer gdcmIO = ImageIOType::New();
> >     NamesGeneratorType::Pointer namesGenerator =
> NamesGeneratorType::New();
> >
> >     size_t found = path.find_last_of("/\\");
> >     std::string str = path.substr(0,found);
> >
> >     namesGenerator->SetInputDirectory( str.c_str() );
> >     const ReaderType::FileNamesContainer & filenames =
> > namesGenerator->GetInputFileNames();
> >
> >     ReaderType::Pointer reader = ReaderType::New();
> >     reader->SetImageIO( gdcmIO );
> >     reader->SetFileNames( filenames );
> >
> >     try
> >     {
> >         reader->Update();
> >     }
> >     catch (itk::ExceptionObject &e)
> >     {
> >         cerr << e << endl;
> >         return;
> >     }
> >
> >     typedef unsigned char /*signed short*/ /*float*/
> > PixelType2;
> >     const   unsigned int                      OutputDimension = 3;
> >     typedef itk::Image< PixelType2, OutputDimension >  OutputImageType;
> >
> >
> >
> >     typedef itk::ImageToVTKImageFilter< OutputImageType > ConnectorType;
> >
> >
> >     ConnectorType::Pointer connector = ConnectorType::New();
> >
> >     connector->SetInput(reader->GetOutput());
> >     // ... continue and display image in QvtkWidget
> >
> > but when I am trying load dicom series I get this
> >
> > WARNING: In ..\..\..\..\src\Insight\Code\IO\itkGDCMImageIO.cxx, line 348
> > GDCMImageIO (02B4A198): The DICOM file:
> > C:/InsightApplications-3.20.0/src/muj_test4/Release/neco2/image004.dcm
> does
> > not have a preamble.
> >
> > Could someone help me please?
> > Thanks a lot
> >
>
> Does that file have 128 bytes before the DICM header?
>
> http://www.leadtools.com/SDK/medical/dicom-spec1.htm
>
> John
>
>
>
> -----Inline Attachment Follows-----
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.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/20110329/8c7fd6d0/attachment.htm>


More information about the Insight-users mailing list