Discussion:
[ITK-users] Access DICOM private tags using SimpleITK
Mathew Guilfoyle
2016-05-23 19:31:11 UTC
Permalink
In ITK the GDCMSeriesFileNames class (equivalently the ImageSeriesReader$GetGDCMSeriesFileNames method from Simple ITK) can both take arguments to read private DICOM tags (typically manufacturer specific info that does not follow the general standard.)

I cannot figure out how to use this function to actually read in a series of images or a volume with the hidden tags (I know they are there as I can see them in Osirix!)

The list of filenames that the two methods above return as no different whether the 'loadPrivateTags' attribute is set on or off.

Any ideas how I can access the private tags?

Cheers
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
Lowekamp, Bradley (NIH/NLM/LHC) [C]
2016-05-23 19:47:28 UTC
Permalink
Hello,

To get all the tags from the dicom files you need to load them individually. Something along these lines, but iterating over the list generated by GetGDCMSeriesFileNames:

from __future__ import print_function

import SimpleITK as sitk
import sys, os

if len ( sys.argv ) < 2:
print( "Usage: DicomImagePrintTags <input_file>" )
sys.exit ( 1 )

inputImage = sitk.ReadImage( sys.argv[1] )

for k in inputImage.GetMetaDataKeys():
v = inputImage.GetMetaData(k)
print("({0}) = = \"{2}\"".format(k,v))


HTH,
Brad
Post by Mathew Guilfoyle
In ITK the GDCMSeriesFileNames class (equivalently the ImageSeriesReader$GetGDCMSeriesFileNames method from Simple ITK) can both take arguments to read private DICOM tags (typically manufacturer specific info that does not follow the general standard.)
I cannot figure out how to use this function to actually read in a series of images or a volume with the hidden tags (I know they are there as I can see them in Osirix!)
The list of filenames that the two methods above return as no different whether the 'loadPrivateTags' attribute is set on or off.
Any ideas how I can access the private tags?
Cheers
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.kitware.com/products/protraining.php
http://www.itk.org/Wiki/ITK_FAQ
http://public.kitware.com/mailman/listinfo/insight-users
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
Mathew Guilfoyle
2016-05-23 19:59:43 UTC
Permalink
Thanks Brad - the trouble I'm having is that some of the keys are private/hidden.

For instance, in my images when I use the image.GetMetaDataKeys() method it returns a list of 107 keys but the one I need is a private manufacturer-specific timing tag that is not part of the standard meta-data dictionary. I know the tag I need because OsiriX viewer shows all the standard and private tags and it is in there with associated data. However, if I run image.HasMetaDataKey(my_private_key) it returns FALSE.

Reading various sources, including the ITK docs, it seems GDCM library has a setting that needs to be turned on to read private DICOM tags. However, the only reference I can see to this setting in SimpleITK is as an argument to the GetGDCMSeriesFileNames method and I'm not clear what function it serves there as the list of files is the same irrespective. What I need somehow is to tell ReadImage or ImageSeriesReader to parse the private tags...??

Thanks
Mat
Post by Lowekamp, Bradley (NIH/NLM/LHC) [C]
Hello,
from __future__ import print_function
import SimpleITK as sitk
import sys, os
print( "Usage: DicomImagePrintTags <input_file>" )
sys.exit ( 1 )
inputImage = sitk.ReadImage( sys.argv[1] )
v = inputImage.GetMetaData(k)
print("({0}) = = \"{2}\"".format(k,v))
HTH,
Brad
Post by Mathew Guilfoyle
In ITK the GDCMSeriesFileNames class (equivalently the ImageSeriesReader$GetGDCMSeriesFileNames method from Simple ITK) can both take arguments to read private DICOM tags (typically manufacturer specific info that does not follow the general standard.)
I cannot figure out how to use this function to actually read in a series of images or a volume with the hidden tags (I know they are there as I can see them in Osirix!)
The list of filenames that the two methods above return as no different whether the 'loadPrivateTags' attribute is set on or off.
Any ideas how I can access the private tags?
Cheers
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.kitware.com/products/protraining.php
http://www.itk.org/Wiki/ITK_FAQ
http://public.kitware.com/mailman/listinfo/insight-users
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
Lowekamp, Bradley (NIH/NLM/LHC) [C]
2016-05-24 13:44:09 UTC
Permalink
Hello,

Please find a patch here in Gerrit [1], which adds the option to load these private data tags. You should be able to download and compile to get the feature. Also note that itk::GDCMImageIO loads the private tags and encodes the with Base64 into strings [2]. I am working on finding some test data to verify behavior and write some tests and documentation.

HTH,
Brad

[1] http://review.source.kitware.com/#/c/21160/
[2] https://github.com/InsightSoftwareConsortium/ITK/blob/bf3f02c6b75a26da3987afc296af140259215e85/Modules/IO/GDCM/src/itkGDCMImageIO.cxx#L567-L587
Post by Mathew Guilfoyle
Thanks Brad - the trouble I'm having is that some of the keys are private/hidden.
For instance, in my images when I use the image.GetMetaDataKeys() method it returns a list of 107 keys but the one I need is a private manufacturer-specific timing tag that is not part of the standard meta-data dictionary. I know the tag I need because OsiriX viewer shows all the standard and private tags and it is in there with associated data. However, if I run image.HasMetaDataKey(my_private_key) it returns FALSE.
Reading various sources, including the ITK docs, it seems GDCM library has a setting that needs to be turned on to read private DICOM tags. However, the only reference I can see to this setting in SimpleITK is as an argument to the GetGDCMSeriesFileNames method and I'm not clear what function it serves there as the list of files is the same irrespective. What I need somehow is to tell ReadImage or ImageSeriesReader to parse the private tags...??
Thanks
Mat
Post by Lowekamp, Bradley (NIH/NLM/LHC) [C]
Hello,
from __future__ import print_function
import SimpleITK as sitk
import sys, os
print( "Usage: DicomImagePrintTags <input_file>" )
sys.exit ( 1 )
inputImage = sitk.ReadImage( sys.argv[1] )
v = inputImage.GetMetaData(k)
print("({0}) = = \"{2}\"".format(k,v))
HTH,
Brad
Post by Mathew Guilfoyle
In ITK the GDCMSeriesFileNames class (equivalently the ImageSeriesReader$GetGDCMSeriesFileNames method from Simple ITK) can both take arguments to read private DICOM tags (typically manufacturer specific info that does not follow the general standard.)
I cannot figure out how to use this function to actually read in a series of images or a volume with the hidden tags (I know they are there as I can see them in Osirix!)
The list of filenames that the two methods above return as no different whether the 'loadPrivateTags' attribute is set on or off.
Any ideas how I can access the private tags?
Cheers
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.kitware.com/products/protraining.php
http://www.itk.org/Wiki/ITK_FAQ
http://public.kitware.com/mailman/listinfo/insight-users
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
Mathew Guilfoyle
2016-05-27 15:29:19 UTC
Permalink
Dear Brad

Thanks for the patch - I have successfully recompiled and the private tag functions are exposed in the R wrapping to SimpleITK. For instance I can do the following:

reader = ImageFileReader()
reader$LoadPrivateTagsOn()

or reader$SetLoadPrivateTags(TRUE)

However, neither of the above seem to have an effect i.e. a call to reader$GetLoadPrivateTags() returns FALSE after both of the above and the summary of my reader object has the 'loadPrivateTag' attribute at 0 irrespective. If I execute the reader I get an image with only the 107 public tags I had before. There are now errors reports with any of the commands.

Any ideas on how to get this working?

Cheers
Mathew
Post by Lowekamp, Bradley (NIH/NLM/LHC) [C]
Hello,
Please find a patch here in Gerrit [1], which adds the option to load these private data tags. You should be able to download and compile to get the feature. Also note that itk::GDCMImageIO loads the private tags and encodes the with Base64 into strings [2]. I am working on finding some test data to verify behavior and write some tests and documentation.
HTH,
Brad
[1] http://review.source.kitware.com/#/c/21160/
[2] https://github.com/InsightSoftwareConsortium/ITK/blob/bf3f02c6b75a26da3987afc296af140259215e85/Modules/IO/GDCM/src/itkGDCMImageIO.cxx#L567-L587
Post by Mathew Guilfoyle
Thanks Brad - the trouble I'm having is that some of the keys are private/hidden.
For instance, in my images when I use the image.GetMetaDataKeys() method it returns a list of 107 keys but the one I need is a private manufacturer-specific timing tag that is not part of the standard meta-data dictionary. I know the tag I need because OsiriX viewer shows all the standard and private tags and it is in there with associated data. However, if I run image.HasMetaDataKey(my_private_key) it returns FALSE.
Reading various sources, including the ITK docs, it seems GDCM library has a setting that needs to be turned on to read private DICOM tags. However, the only reference I can see to this setting in SimpleITK is as an argument to the GetGDCMSeriesFileNames method and I'm not clear what function it serves there as the list of files is the same irrespective. What I need somehow is to tell ReadImage or ImageSeriesReader to parse the private tags...??
Thanks
Mat
Post by Lowekamp, Bradley (NIH/NLM/LHC) [C]
Hello,
from __future__ import print_function
import SimpleITK as sitk
import sys, os
print( "Usage: DicomImagePrintTags <input_file>" )
sys.exit ( 1 )
inputImage = sitk.ReadImage( sys.argv[1] )
v = inputImage.GetMetaData(k)
print("({0}) = = \"{2}\"".format(k,v))
HTH,
Brad
Post by Mathew Guilfoyle
In ITK the GDCMSeriesFileNames class (equivalently the ImageSeriesReader$GetGDCMSeriesFileNames method from Simple ITK) can both take arguments to read private DICOM tags (typically manufacturer specific info that does not follow the general standard.)
I cannot figure out how to use this function to actually read in a series of images or a volume with the hidden tags (I know they are there as I can see them in Osirix!)
The list of filenames that the two methods above return as no different whether the 'loadPrivateTags' attribute is set on or off.
Any ideas how I can access the private tags?
Cheers
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.kitware.com/products/protraining.php
http://www.itk.org/Wiki/ITK_FAQ
http://public.kitware.com/mailman/listinfo/insight-users
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
Lowekamp, Bradley (NIH/NLM/LHC) [C]
2016-05-27 20:08:31 UTC
Permalink
Hi,

Sorry that didn’t work. I was able to get some dicom data with private tags. I have updated the patch with more commits in the topic:

http://review.source.kitware.com/#/q/status:open+project:SimpleITK+branch:master+topic:AddLoadPrivateTagsOptions

Now that I have tested it with data, I have merged it into the “next” branch.

What are these “error reports” with any command?

Brad
Post by Mathew Guilfoyle
Dear Brad
reader = ImageFileReader()
reader$LoadPrivateTagsOn()
or reader$SetLoadPrivateTags(TRUE)
However, neither of the above seem to have an effect i.e. a call to reader$GetLoadPrivateTags() returns FALSE after both of the above and the summary of my reader object has the 'loadPrivateTag' attribute at 0 irrespective. If I execute the reader I get an image with only the 107 public tags I had before. There are now errors reports with any of the commands.
Any ideas on how to get this working?
Cheers
Mathew
Post by Lowekamp, Bradley (NIH/NLM/LHC) [C]
Hello,
Please find a patch here in Gerrit [1], which adds the option to load these private data tags. You should be able to download and compile to get the feature. Also note that itk::GDCMImageIO loads the private tags and encodes the with Base64 into strings [2]. I am working on finding some test data to verify behavior and write some tests and documentation.
HTH,
Brad
[1] http://review.source.kitware.com/#/c/21160/
[2] https://github.com/InsightSoftwareConsortium/ITK/blob/bf3f02c6b75a26da3987afc296af140259215e85/Modules/IO/GDCM/src/itkGDCMImageIO.cxx#L567-L587
Post by Mathew Guilfoyle
Thanks Brad - the trouble I'm having is that some of the keys are private/hidden.
For instance, in my images when I use the image.GetMetaDataKeys() method it returns a list of 107 keys but the one I need is a private manufacturer-specific timing tag that is not part of the standard meta-data dictionary. I know the tag I need because OsiriX viewer shows all the standard and private tags and it is in there with associated data. However, if I run image.HasMetaDataKey(my_private_key) it returns FALSE.
Reading various sources, including the ITK docs, it seems GDCM library has a setting that needs to be turned on to read private DICOM tags. However, the only reference I can see to this setting in SimpleITK is as an argument to the GetGDCMSeriesFileNames method and I'm not clear what function it serves there as the list of files is the same irrespective. What I need somehow is to tell ReadImage or ImageSeriesReader to parse the private tags...??
Thanks
Mat
Post by Lowekamp, Bradley (NIH/NLM/LHC) [C]
Hello,
from __future__ import print_function
import SimpleITK as sitk
import sys, os
print( "Usage: DicomImagePrintTags <input_file>" )
sys.exit ( 1 )
inputImage = sitk.ReadImage( sys.argv[1] )
v = inputImage.GetMetaData(k)
print("({0}) = = \"{2}\"".format(k,v))
HTH,
Brad
Post by Mathew Guilfoyle
In ITK the GDCMSeriesFileNames class (equivalently the ImageSeriesReader$GetGDCMSeriesFileNames method from Simple ITK) can both take arguments to read private DICOM tags (typically manufacturer specific info that does not follow the general standard.)
I cannot figure out how to use this function to actually read in a series of images or a volume with the hidden tags (I know they are there as I can see them in Osirix!)
The list of filenames that the two methods above return as no different whether the 'loadPrivateTags' attribute is set on or off.
Any ideas how I can access the private tags?
Cheers
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.kitware.com/products/protraining.php
http://www.itk.org/Wiki/ITK_FAQ
http://public.kitware.com/mailman/listinfo/insight-users
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insigh
Mathew Guilfoyle
2016-05-29 12:50:20 UTC
Permalink
This works perfectly now: I can extract the time stamp I need.

Sorry for the typo in the previous message, should have read 'There are no error reports...'

Many thanks
Post by Lowekamp, Bradley (NIH/NLM/LHC) [C]
Hi,
http://review.source.kitware.com/#/q/status:open+project:SimpleITK+branch:master+topic:AddLoadPrivateTagsOptions
Now that I have tested it with data, I have merged it into the “next” branch.
What are these “error reports” with any command?
Brad
Post by Mathew Guilfoyle
Dear Brad
reader = ImageFileReader()
reader$LoadPrivateTagsOn()
or reader$SetLoadPrivateTags(TRUE)
However, neither of the above seem to have an effect i.e. a call to reader$GetLoadPrivateTags() returns FALSE after both of the above and the summary of my reader object has the 'loadPrivateTag' attribute at 0 irrespective. If I execute the reader I get an image with only the 107 public tags I had before. There are now errors reports with any of the commands.
Any ideas on how to get this working?
Cheers
Mathew
Post by Lowekamp, Bradley (NIH/NLM/LHC) [C]
Hello,
Please find a patch here in Gerrit [1], which adds the option to load these private data tags. You should be able to download and compile to get the feature. Also note that itk::GDCMImageIO loads the private tags and encodes the with Base64 into strings [2]. I am working on finding some test data to verify behavior and write some tests and documentation.
HTH,
Brad
[1] http://review.source.kitware.com/#/c/21160/
[2] https://github.com/InsightSoftwareConsortium/ITK/blob/bf3f02c6b75a26da3987afc296af140259215e85/Modules/IO/GDCM/src/itkGDCMImageIO.cxx#L567-L587
Post by Mathew Guilfoyle
Thanks Brad - the trouble I'm having is that some of the keys are private/hidden.
For instance, in my images when I use the image.GetMetaDataKeys() method it returns a list of 107 keys but the one I need is a private manufacturer-specific timing tag that is not part of the standard meta-data dictionary. I know the tag I need because OsiriX viewer shows all the standard and private tags and it is in there with associated data. However, if I run image.HasMetaDataKey(my_private_key) it returns FALSE.
Reading various sources, including the ITK docs, it seems GDCM library has a setting that needs to be turned on to read private DICOM tags. However, the only reference I can see to this setting in SimpleITK is as an argument to the GetGDCMSeriesFileNames method and I'm not clear what function it serves there as the list of files is the same irrespective. What I need somehow is to tell ReadImage or ImageSeriesReader to parse the private tags...??
Thanks
Mat
Post by Lowekamp, Bradley (NIH/NLM/LHC) [C]
Hello,
from __future__ import print_function
import SimpleITK as sitk
import sys, os
print( "Usage: DicomImagePrintTags <input_file>" )
sys.exit ( 1 )
inputImage = sitk.ReadImage( sys.argv[1] )
v = inputImage.GetMetaData(k)
print("({0}) = = \"{2}\"".format(k,v))
HTH,
Brad
Post by Mathew Guilfoyle
In ITK the GDCMSeriesFileNames class (equivalently the ImageSeriesReader$GetGDCMSeriesFileNames method from Simple ITK) can both take arguments to read private DICOM tags (typically manufacturer specific info that does not follow the general standard.)
I cannot figure out how to use this function to actually read in a series of images or a volume with the hidden tags (I know they are there as I can see them in Osirix!)
The list of filenames that the two methods above return as no different whether the 'loadPrivateTags' attribute is set on or off.
Any ideas how I can access the private tags?
Cheers
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
http://www.kitware.com/products/protraining.php
http://www.itk.org/Wiki/ITK_FAQ
http://public.kitware.com/mailman/listinfo/insight-users
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/ins

Loading...