[Insight-users] GDCMImageIO object containing wrong(?) values when editing the DICOM header

Jon Haitz Legarreta Gorroño jhlegarreta at vicomtech.org
Thu Feb 17 12:38:34 EST 2011


Hi there,

I'm using ITK and GDCM to convert to DICOM format a stereolitography 
model I built.
I used a software to convert between .stl and DICOM. The thing is that 
the header I got is apparently lacking some fields that prevent the 
DICOM files from being correctly loaded by some DICOM viewers/workstations.

I was thinking that editing the DICOM header would allow me to solve the 
problem. I know editing the DICOM header is not desirable, but in this 
case my source is not a DICOM node (nobody to blame on exepct the 
software used to convert between STL and DICOM!) and it's just an 
artificial model I built.

What I basically do is this:

1. Let the user edit the source DICOM header
2. Try to save the edited header together with the original slices into 
a new dataset.

I'm puzzled when I check that the members of the itk::GDCMImageIO object 
I handle for the itk::ImageSeriesWriter do not reflect the changes in 
the dictionary after I've called the methods to change the original tags 
by the new values, that is, in short:


std::vector<itk::MetaDataDictionary *>  dictionaryArray = new 
std::vector<itk::MetaDataDictionary*>  ;
itk::GDCMImageIO::Pointer gdcmIO = itk::GDCMImageIO::New();
itk::ImageSeriesWriter< TInputImage, TOutputImage>::Pointer seriesWriter 
= itk::ImageSeriesWriter< TInputImage, TOutputImage>::New(); // 
TInputImage and TOutputImage are properly set somewhere above
itk::NumericSeriesFileNames::Pointer outputNames = 
itk::NumericSeriesFileNames::New();
itk::MetaDataDictionary *toDict= new itk::MetaDataDictionary ();

// Do for each tag of the DICOM Dictionary
itk::EncapsulateMetaData<std::string>( *toDict, tagKey, tagValue );
//

dictionaryArray->push_back( toDict );

seriesWriter->SetInput( PointerToITKImage );

// Generate output names
...

seriesWriter->SetImageIO( gdcmIO );
seriesWriter->SetFileNames( outputNames->GetFileNames() );
seriesWriter->SetMetaDataDictionaryArray( dictionaryArray );
seriesWriter->Update();

Even if at disk the written header tags are the user-edited ones, at 
this point of the program the gdcmIO object still contains the 
information related to the original dataset. Is that the expected behavior?

I had a look at some older posts concerning the DICOM header issue but 
didn't find an answer to this.
I also had a look at an (old) ITK example 
(DicomImageReadChangeHeaderWrite.cxx).


For sure, I am missing some concept.

Thank you,
JON HAITZ






More information about the Insight-users mailing list