[Insight-users] now my dicom series reader seg faults with the changes

Bill Lorensen bill.lorensen at gmail.com
Thu Dec 3 16:46:22 EST 2009


I'll take a look, but it won't be for a few days... Can you clarify
what version of itk you are referring to? Is it 3.16? If not, is it
the current cvs? There was a bug introduced in the current cvs
yesterday. It has been removed. That's why we must know clearly which
version you are talking about.

Bill

On Thu, Dec 3, 2009 at 3:35 PM, John Drozd <john.drozd at gmail.com> wrote:
> Hi Bill,
>
> Sorry, but it's getting more complicated with itkGDCMIMageIO.cxx.
>
> With the previous ITK (the version prior to the rev 1.162 change that you
> did to itkGDCMIMageIO.cxx so my outputted 3d dicom volume would be in the
> correct orientation):
>
> With this previous ITK, I had code working that read two dicom series and
> wrote them to a 3d dicom single file volume.
>
> Now with the revised ITK (the version with the re 1.162 change that you did
> to itkGDCMIMageIO.cxx so my outputted 3d dicom volume would be in the
> correct orientation):
>
> With this revised ITK, my code that reads two dicom series and writes them
> to a 3d dicom single file volume.
> seg faults.
>
> Could you check this for me please.
>
> Ideally, I would like my previous segmentation code to output the correct
> dicom orientation, and my code that reads dicom series to both work with the
> same version of ITK.
>
> Thanks,
> john
>
> You can download my dicom series data as compressed tar.gz from the
> following links:
>
> http://www.apmaths.uwo.ca/~jdrozd/datasubject.tar.gz
>
> and
>
> http://www.apmaths.uwo.ca/~jdrozd/datasubject4.tar.gz
>
> (Prior to running the below code, untar and unzip these two compressed files
> and have them in the same directory as the code executable)
>
> Below is my code:
>
> /* to run ReadAtlasDicomSeriesAndReadSubjectDicomSeries.cxx, compile and
> type:
> ./ReadAtlasDicomSeriesAndReadSubjectDicomSeries "datasubject"
> "datasubject4/136_S_0429/MPR__GradWarp__B1_Correction__N3__Scaled/2007-06-18_13_28_06.0/S33724/70809234826766_S33724_I66806_Dicom"
> */
>
> #if defined(_MSC_VER)
> #pragma warning ( disable : 4786 )
> #endif
>
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include "itkOrientedImage.h"
> #include "itkGDCMImageIO.h"
> #include "itkGDCMSeriesFileNames.h"
> #include "itkImageSeriesReader.h"
>
> int main(int argc, char *argv[])
> {
>
>   typedef short InputPixelType;
>   const unsigned int   InputDimension = 3;
>
>   typedef itk::Image< InputPixelType, InputDimension > InputImageType;
>
>   typedef itk::ImageSeriesReader< InputImageType > AtlasReaderSeriesType;
>
>   typedef itk::ImageSeriesReader< InputImageType > SubjectReaderSeriesType;
>
>   AtlasReaderSeriesType::Pointer movingatlasfilter =
> AtlasReaderSeriesType::New();
>
>   SubjectReaderSeriesType::Pointer fixedsubjectfilter =
> SubjectReaderSeriesType::New();
>
>  typedef itk::GDCMImageIO           ImageIOType;
>
>   ImageIOType::Pointer gdcmImageIOAtlas = ImageIOType::New();
>
>   ImageIOType::Pointer gdcmImageIOSubject = ImageIOType::New();
>
>   fixedsubjectfilter->SetImageIO( gdcmImageIOSubject );
>
>   movingatlasfilter->SetImageIO( gdcmImageIOAtlas );
>
> typedef itk::GDCMSeriesFileNames AtlasNamesGeneratorType;
>   AtlasNamesGeneratorType::Pointer AtlasnameGenerator =
> AtlasNamesGeneratorType::New();
>
> typedef itk::GDCMSeriesFileNames SubjectNamesGeneratorType;
>   SubjectNamesGeneratorType::Pointer SubjectnameGenerator =
> SubjectNamesGeneratorType::New();
>
>   SubjectnameGenerator->SetUseSeriesDetails( true );
>   SubjectnameGenerator->AddSeriesRestriction("0008|0021" );
>
>   SubjectnameGenerator->SetDirectory( argv[2] );
>
>   AtlasnameGenerator->SetUseSeriesDetails( true );
>   AtlasnameGenerator->AddSeriesRestriction("0008|0021" );
>
>   AtlasnameGenerator->SetDirectory( argv[1] );
>
> try
>     {
>     std::cout << std::endl << "The directory: " << std::endl;
>     std::cout << std::endl << argv[1] << std::endl << std::endl;
>     std::cout << "Contains the following Atlas DICOM Series: ";
>     std::cout << std::endl << std::endl;
>
> typedef std::vector< std::string >    AtlasSeriesIdContainer;
>
>     const AtlasSeriesIdContainer & AtlasseriesUID =
> AtlasnameGenerator->GetSeriesUIDs();
>
>     AtlasSeriesIdContainer::const_iterator AtlasseriesItr =
> AtlasseriesUID.begin();
>     AtlasSeriesIdContainer::const_iterator AtlasseriesEnd =
> AtlasseriesUID.end();
>     while( AtlasseriesItr != AtlasseriesEnd )
>       {
>       std::cout << AtlasseriesItr->c_str() << std::endl;
>       AtlasseriesItr++;
>       }
>
> std::string AtlasseriesIdentifier;
>
>     if( argc > 4 ) // If no optional series identifier
>       {
>       AtlasseriesIdentifier = argv[3];
>       }
>     else
>       {
>       AtlasseriesIdentifier = AtlasseriesUID.begin()->c_str();
>       }
>
> std::cout << std::endl << std::endl;
>     std::cout << "Now reading Atlas series: " << std::endl << std::endl;
>     std::cout << AtlasseriesIdentifier << std::endl;
>     std::cout << std::endl << std::endl;
>
> typedef std::vector< std::string >   AtlasFileNamesContainer;
>     AtlasFileNamesContainer AtlasfileNames;
>
>     AtlasfileNames = AtlasnameGenerator->GetFileNames( AtlasseriesIdentifier
> );
>
>     movingatlasfilter->SetFileNames( AtlasfileNames );
>
>
>     try
>       {
>       movingatlasfilter->Update();
>       std::cout << "Atlas read successfully"  << std::endl;
>       }
>     catch (itk::ExceptionObject &ex)
>       {
>       std::cout << ex << std::endl;
>       return EXIT_FAILURE;
>       }
>
>       typedef itk::ImageFileWriter< InputImageType > AtlasWriterSubjectType;
>
>   AtlasWriterSubjectType::Pointer movingatlasfilterwriter =
> AtlasWriterSubjectType::New();
>
>
>   movingatlasfilterwriter->UseInputMetaDataDictionaryOff();
>   movingatlasfilterwriter->SetImageIO( gdcmImageIOAtlas );
>
>
> movingatlasfilterwriter->SetFileName( "atlasout.dcm" );
>
> movingatlasfilterwriter->SetInput( movingatlasfilter->GetOutput() );
>
>
> try
>       {
>       movingatlasfilterwriter->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;
>     }
>
>     try
>     {
>     std::cout << std::endl << "The directory: " << std::endl;
>     std::cout << std::endl << argv[2] << std::endl << std::endl;
>     std::cout << "Contains the following Subject DICOM Series: ";
>     std::cout << std::endl << std::endl;
>
> typedef std::vector< std::string >    SubjectSeriesIdContainer;
>
>     const SubjectSeriesIdContainer & SubjectseriesUID =
> SubjectnameGenerator->GetSeriesUIDs();
>
>     SubjectSeriesIdContainer::const_iterator SubjectseriesItr =
> SubjectseriesUID.begin();
>     SubjectSeriesIdContainer::const_iterator SubjectseriesEnd =
> SubjectseriesUID.end();
>     while( SubjectseriesItr != SubjectseriesEnd )
>       {
>       std::cout << SubjectseriesItr->c_str() << std::endl;
>       SubjectseriesItr++;
>       }
>
> std::string SubjectseriesIdentifier;
>
>     if( argc > 4 ) // If no optional series identifier
>       {
>       SubjectseriesIdentifier = argv[2];
>       }
>     else
>       {
>       SubjectseriesIdentifier = SubjectseriesUID.begin()->c_str();
>       }
>
> std::cout << std::endl << std::endl;
>     std::cout << "Now reading Subject series: " << std::endl << std::endl;
>     std::cout << SubjectseriesIdentifier << std::endl;
>     std::cout << std::endl << std::endl;
>
> typedef std::vector< std::string >   SubjectFileNamesContainer;
>     SubjectFileNamesContainer SubjectfileNames;
>
>     SubjectfileNames = SubjectnameGenerator->GetFileNames(
> SubjectseriesIdentifier );
>
>     fixedsubjectfilter->SetFileNames( SubjectfileNames );
>
>     try
>       {
>       fixedsubjectfilter->Update();
>       std::cout << "Subject read successfully"  << std::endl;
>       }
>     catch (itk::ExceptionObject &ex)
>       {
>       std::cout << ex << std::endl;
>       return EXIT_FAILURE;
>       }
>
>       typedef itk::ImageFileWriter< InputImageType >
> SubjectWriterSubjectType;
>
>   SubjectWriterSubjectType::Pointer fixedsubjectfilterwriter =
> SubjectWriterSubjectType::New();
>
>   fixedsubjectfilterwriter->UseInputMetaDataDictionaryOff();
>   fixedsubjectfilterwriter->SetImageIO( gdcmImageIOSubject );
>
>   fixedsubjectfilterwriter->SetFileName( "subjectout.dcm" );
>
>   fixedsubjectfilterwriter->SetInput( fixedsubjectfilter->GetOutput() );
>
>
> try
>       {
>       fixedsubjectfilterwriter->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;
> }
>
>


More information about the Insight-users mailing list