[Insight-users] modifying and writing dicom for 3D mri data set
Matthias Schabel
mschabel at ucair.med.utah.edu
Fri Sep 15 03:33:09 EDT 2006
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;
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060915/8b86dffd/attachment.htm
More information about the Insight-users
mailing list