[Insight-users] Writing new DICOM files.

Mathieu Malaterre mathieu.malaterre at gmail.com
Wed Nov 12 09:24:33 EST 2008


Robert,

On Wed, Nov 12, 2008 at 3:02 PM, Robert Haase <robert_haase at gmx.de> wrote:
> Hi Todd,
>
> I had the same problem like you using ITK 3.8. The source documentation in utilities/gdcm/src/gdcmFileHelper.cxx (at line 356) tells us:
>
> --------------------------------------------------------
> 4) When user *knows* he didn't modified the pixels, he may ask the writer to keep some
> informations unchanged :
> 'Media Storage SOP Class UID' (0x0002,0x0002)
> 'SOP Class UID'               (0x0008,0x0016)
> 'Image Type'                  (0x0008,0x0008)
> 'Conversion Type'             (0x0008,0x0064)
> He has to use gdcm::FileHelper::SetKeepMediaStorageSOPClassUID(true)
> (probabely name has to be changed)
> -------------------------------------------------------
>
> But this simply didn't work, because there is no function like SetKeepMediaStorageSOPClassUID.
> Worse than no comment in source code is a wrong one.

Where did you look for the function ?

$ grep KeepMediaStorageSOPClassUID *
...
gdcmFileHelper.h:   void SetKeepMediaStorageSOPClassUID (bool v)
...

It has been there for while now.

> I couldn't fix this problem in the itk/gdcm code because I'm a new ITK-user and not so familiar with coding rules.
>
> But I found a solution to get my program working (a dirty dirty workaround):
>
> I wrote my own MyFileHelper class, inheriting from gdcm::FileHelper.
>
> class GDCM_EXPORT MyFileHelper : public gdcm::FileHelper
> {...}
>
> It has an overwritten function  Write(std::string const &fileName), which does NOT call CheckMandatoryElements(). So in this function I'm doing my own mandatory-checks and there I'm absolutly free in defining which tags should be changed and which not.
>
> To get this work, I also had to implement an own DicomIO, which uses MyFileHelper, not the gdcm one
>
> class ITK_EXPORT myDicomImageIO : public itk::GDCMImageIO
> {...}
>
> Maybe this helps you. If you wish, I could send you my 'dirty' implementation of this.

CheckMandatoryElements is an important function to not try to bypass
it. It is defined in the standard when & where you are allowed to
preserve the UID. If you believe you found a case where you can
preserve the UID but GDCM will not let you do it, please fill in a bug
report.


-- 
Mathieu


More information about the Insight-users mailing list