[Insight-users] Writing new DICOM files.
Mathieu Malaterre
mathieu.malaterre at gmail.com
Wed Nov 12 09:56:03 EST 2008
On Wed, Nov 12, 2008 at 3:33 PM, Mathieu Malaterre
<mathieu.malaterre at gmail.com> wrote:
> Todd,
>
> On Wed, Nov 12, 2008 at 2:01 PM, Todd Jensen <todd.jensen at ieee.org> wrote:
>> 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)
>
> +1
>
>> // 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)
>
> This is in fact the exact same issue, those info are linked to each
> other. I'll try to duplicate here and let you know what I found out.
>
> Thanks for your time and bug report,
Todd,
I cannot reproduce your issue. Here is the diff I used:
$ cvs di ImageReadDicomSeriesWrite.cxx
Index: ImageReadDicomSeriesWrite.cxx
===================================================================
RCS file: /cvsroot/Insight/Insight/Examples/IO/ImageReadDicomSeriesWrite.cxx,v
retrieving revision 1.1
diff -u -r1.1 ImageReadDicomSeriesWrite.cxx
--- ImageReadDicomSeriesWrite.cxx 21 Mar 2006 01:00:08 -0000 1.1
+++ ImageReadDicomSeriesWrite.cxx 12 Nov 2008 14:50:37 -0000
@@ -30,6 +30,7 @@
#include <vector>
#include <itksys/SystemTools.hxx>
+#include "gdcmUtil.h"
// Software Guide : BeginLatex
//
@@ -105,6 +106,7 @@
NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();
itk::MetaDataDictionary & dict = gdcmIO->GetMetaDataDictionary();
+ gdcmIO->KeepOriginalUIDOn();
std::string tagkey, value;
tagkey = "0008|0060"; // Modality
value = "MR";
@@ -116,6 +118,22 @@
value = "DV";
itk::EncapsulateMetaData<std::string>(dict, tagkey, value);
+ const char uidPrefix [] = "0.0.0.0.0";
+ tagkey = "0008|0016";
+ value = "1.2.840.10008.5.1.4.1.1.4";
+ itk::EncapsulateMetaData< std::string >( dict, tagkey, value);
+ tagkey = "0008|0018";
+ value = gdcm::Util::CreateUniqueUID( uidPrefix );
+ itk::EncapsulateMetaData< std::string >( dict, tagkey, value);
+ // (0020,000d) UI
[1.2.840.113619.2.5.1762386977.1328.985934491.590] # 48, 1
StudyInstanceUID
+ tagkey = "0020|000d";
+ value = gdcm::Util::CreateUniqueUID( uidPrefix );
+ itk::EncapsulateMetaData< std::string >( dict, tagkey, value);
+ // (0020,000e) UI
[1.2.840.113619.2.5.1762386977.1328.985934491.643] # 48, 1
SeriesInstanceUID
+ tagkey = "0020|000e";
+ value = gdcm::Util::CreateUniqueUID( uidPrefix );
+ itk::EncapsulateMetaData< std::string >( dict, tagkey, value);
+
SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();
Looking at the output I can see all my UIDs have indeed the illegal
root "0.0.0.0" ...
Please write up an example that exhibit the problem, create a bug
report and assign it to me. Please send complete example, that I can
compile here.
thank you.
--
Mathieu
More information about the Insight-users
mailing list