[Insight-users] Writing new DICOM files.
Todd Jensen
todd.jensen at ieee.org
Wed Nov 12 08:01:44 EST 2008
Hello, Mathieu,
> > Media Storage SOP Instance UID (0002,0003) is set to a newly generated UID
> > Image Type is set to DERIVED\PRIMARY
>
> I think what you are looking for is: itk::GDCMImageIO::KeepOriginalUID( true )
I am using this.
> > And since the 0002,0003 element is set to a new unique UID, it never matches
> the SOP Instance UID which is an error.
>
> what ? 0002,0003 should match the value from the dataset. If you found
> an issue, please report, a simple way to reproduce it. Thank you.
Here is how to reproduce, using ITK 3.6:
1) Set the SOP Instance UID in meta data:
itk::MetaDataDictionary outMetaData;
// Assign values to required DICOM elements for SC SOP class UID in meta data...
//
[...removed for brevity...] (I have verified the requirement elements are all set using the standard documentation and David Clunie's verification tools)
// Assign SOP Instance UID with a defined prefix...
//
vcl_string instanceUID = gdcm::Util::CreateUniqueUID( uidPrefix );
itk::EncapsulateMetaData< vcl_string >( outMetaData, "0008|0018", instanceUID );
itk::EncapsulateMetaData< vcl_string >( outMetaData, "0002|0003", instanceUID );
2) Attach meta data to GDCM:
itk::GDCMImageIO::Pointer dicomIO = itk::GDCMImageIO::New();
typedef itk::ImageFileWriter< ImageType2D > WriterType;
WriterType::Pointer dcmWriter = WriterType::New();
outputImage->SetMetaDataDictionary( outMetaData );
dicomIO->SetKeepOriginalUID( true );
dcmWriter->SetFileName( outputFile.str() );
dcmWriter->SetInput( outputImage );
dcmWriter->SetImageIO( dicomIO );
dcmWriter->Update();
gdcm::FileHelper::CheckMandatoryElements() will regenerate the media storage SOP instance UID even though KeepOriginalUID is set to true.
I hope this helps explain the issue. Also, it would be nice if I could keep the image type I set (it is forced to DERIVED\\PRIMARY)
Regards,
Todd Jensen
More information about the Insight-users
mailing list