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