[Insight-users] modifying and writing dicom for 3D mri data set
Luis Ibanez
luis.ibanez at kitware.com
Sun Sep 24 10:57:44 EDT 2006
Hi Matthias,
The ITK pipeline does not propagate the MetaDataDictionaries.
The reason is that we cannot guarantee that the values in
the dictionaries are still valid after passing one image through
a filter. [e.g. a regions of interest filter should edit also
the meta data dictionary in order to reflect the new number of
pixels in the image].
As a result, it is upto you to pass the MetaDataDictionaries to
the ImageIO class used for writing.
You may want to look at the example:
Insight/Examples/IO/
ImageReadDicomSeriesWrite.cxx
Regards,
Luis
------------------------
Matthias Schabel wrote:
> I am trying to output post-processed data that preserves most of the
> DICOM metadata from the input DICOM files, but with a few fields
> modified. Unfortunately, while the data itself is output and appears
> correct, I can't seem to get ITK to include anything but what I guess is
> the default GDCM DICOM stuff. A snippet of the code that I'm using
> (InputType is Image<float,3>, OutputType is Image<short,3>) is below.
> The dumpITKMetadata function just prints all the tag/value pairs to
> std::cout - in this case, the first call includes altered/added fields,
> so my changes are propagating correctly into the gdcmImageIO variable,
> but don't seem to make it the rest of the way through the pipeline. Any
> suggestions on what I may be doing wrong?
>
> Regards,
>
> Matthias
>
>
>
> // set up ITK DICOM image series writer
> typedef itk::ImageFileWriter<OutputType> WriterType;
>
> WriterType::Pointer writer = WriterType::New();
>
> static const std::string output_name =
> "/Users/matthiasschabel/Temporary/Ktrans.dcm";
>
> typedef itk::GDCMImageIO ImageIOType;
>
> ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
>
> metadata_type& dict = gdcmImageIO->GetMetaDataDictionary();
>
> copyITKMetadata(metadata(0),dict);
>
> // DICOM dictionary values
> static const std::string modalityTag = "0008|0060",
> seriesDescriptionTag = "0008|103e",
> seriesNumberTag = "0020|0011",
> windowCenterTag = "0028|1050",
> windowWidthTag = "0028|1051",
> rescaleInterceptTag = "0028|1052",
> rescaleSlopeTag = "0028|1053";
>
> itk::EncapsulateMetaData<std::string>(dict,modalityTag,"MR");
>
> itk::EncapsulateMetaData<std::string>(dict,seriesDescriptionTag,"Ktrans");
> itk::EncapsulateMetaData<std::string>(dict,windowCenterTag,"500.0");
> itk::EncapsulateMetaData<std::string>(dict,windowWidthTag,"1000.0");
> itk::EncapsulateMetaData<std::string>(dict,rescaleInterceptTag,"0.0");
> itk::EncapsulateMetaData<std::string>(dict,rescaleSlopeTag,"1000.0");
>
> dumpITKMetadata(dict,std::cout);
> dumpITKMetadata(metadata(0),std::cout);
>
> writer->SetInput(rescaler->GetOutput());
> writer->SetFileName(output_name.c_str());
> writer->SetImageIO(gdcmImageIO);
>
> try
> {
> writer->Update();
> }
> catch (itk::ExceptionObject& e)
> {
> std::cerr << "exception in file reader " << std::endl;
> std::cerr << e << std::endl;
>
> throw;
> }
> }
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
More information about the Insight-users
mailing list