-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reading Legacy Converted Enhanced Images #105
Comments
I have created a patch which updates ITK's GDCM to the latest: Would you be able to build ITK with this patch and check to see if it adds support for your particular file? xref: SimpleITK/SimpleITK#440 |
Thanks @blowekamp! It worked! These are the steps to reproduce:
Where the content of import itk
import sys
if __name__ == '__main__':
input_filename = sys.args[1]
image = itk.imread(input_filename)
metadata = image.GetMetaDataDictionary()
print(metadata['0008|0016']) # expected: '1.2.840.10008.5.1.4.1.1.4.4' |
You can build SimpleITK against this ITK to get this support too, if you prefer that interface. |
I've run a few tests to compare ITK Image objects resulting from reading the original series of legacy MR Image and Legacy Converted Enhanced MR Image instances. The actual pixel data are identical: import itk
import numpy as np
ImageType = itk.Image[itk.ctype('signed short'), 3]
series_reader = itk.ImageSeriesReader[ImageType].New(FileNames=legacy_filenames)
legacy_image = series_reader.GetOutput()
legacy_array = itk.GetArrayFromImage(legacy_image)
file_reader = itk.ImageFileReader[ImageType].New(FileName=enhanced_filename)
enhanced_image = file_reader.GetOutput()
enhanced_array = itk.GetArrayFromImage(enhanced_image)
np.testing.assert_array_equal(legacy_array, enhanced_array) However, the spacing is different: assert legacy_image.GetImageDimension() == enhanced_image.GetImageDimension()
for i in range(legacy_image.GetImageDimensions()):
assert legacy_image.GetSpacing().GetElement(i) == enhanced_image.GetSpacing().GetElement(i), \
"spacing along image dimension {} is not identical".format(i) This is because the legacy_metadata = series_reader.GetMetaDataDictionaryArray()
legacy_metadata[0]['0028|0030'] # Pixel Spacing
legacy_metadata[0]['0018|0088'] # Spacing Between Slices
enhanced_metadata = enhanced_image.GetMetaDataDictionary()
enhanced_metadata['5200|9229'] # Shared Functional Group Sequence The problem is that in case of the Legacy Converted Enhanced MR Image information object definition class the Pixel Spacing and Spacing Between Slices attributes are contained in the Pixel Measures Sequence attribute within the Shared Functional Group Sequence attribute (see PS3.3 A.71.4 Legacy Converted Enhanced MR Image Functional Group Macros and PS3.3 C.7.6.16.2.1 Pixel Measures Macro). This is the output of the GDCM program
Key |
The relevant attributes may also end up in the Unassigned Per-Frame Converted Attributes Sequence attributes (see PS3.3 C.7.6.16.2.25.2 Unassigned Per-Frame Converted Attributes Macro). |
The return value of To me, it seems this problem originates in GDCM. It appears GDCM looks for the Pixel Spacing and Spacing Between Slices attributes only at the root level of the dataset, but not in the Pixel Measures Sequence of the Shared Functional Groups Sequence (see gdcmSpacing.h). If GDCM cannot determine the spacing, it returns ones as default values (see gdcmImage.h). @blowekamp Do you think this evaluation is accurate? |
This is worrying, because it probably also affects multi-frame images of other SOP classes, such as Enhanced MR Image (see Enhanced MR Image Functional Group Macros) and Enhanced CT Image (see Enhanced CT Image Functional Group Macros). |
@hackermd I am one of the main author of GDCM and I can guarantee that GDCM is reading the Pixel Spacing from the correct location (esp. Per-Frame or Shared Function Groups Sequence). Please add a link to your generated DICOM DataSet? |
@hackermd If you cannot redistribute your DICOM DataSet, please include the output from |
@malaterre thanks for your feedback. Please find below the output of
I will determine whether I can share the DICOM object. |
@malaterre See this comment on the corresponding SimpleITK github issue on how to generate the enhanced image object. |
Reading multi-frame images now works with the 5.0 Beta 1 release. However, the values of the spacing, origin and direction attributes are not set correctly but represent the defaults. |
@hackermd please try the 5.0 Beta 3 release where this should be addressed per: InsightSoftwareConsortium/ITK#315
|
@thewtex thanks for your follow up. I just tested with version import itk
enhanced_image = itk.imread(enhanced_filename)
enhanced_image.GetSpacing() This returns However, it does not work with the import itk
file_reader = itk.ImageFileReader.New(FileName=enhanced_filename)
enhanced_image = file_reader.GetOutput()
enhanced_image.GetSpacing() This returns Notably, the output of import itk
series_reader = itk.ImageSeriesReader.New(FileNames=legacy_filenames)
legacy_image = series_reader.GetOutput()
legacy_image.GetSpacing() This returns The series is read correctly with SimpleITK version import SimpleITK as sitk
series_reader = sitk.ImageSeriesReader()
series_reader.SetFileNames(legacy_filenames)
legacy_image = series_reader.Execute()
legacy_image.GetSpacing() This returns |
@hackermd thanks for the update. I am glad to hear it is working with Is there a a series that we can use to reproduce the legacy filenames issue and create a regression test? |
@thewtex please see this comment on issue #440 of SimpleITK repository on how to reproduce |
I tested with series Expected spacing: |
::jumps from Tardis ☎️ :: @hackermd Can you please try the recent
and let us know how it goes? These include: InsightSoftwareConsortium/ITK#4521 |
More improvements made in ITK 5.4 RC 4. Available in the |
I've converted a DICOM Series of Single-Frame MR Images to a Legacy Converted Enhanced MR Image using MultiFrameImageFactory. When I try to load the generated multi-frame image using ITK's
imread
function, I get the following error:Support for Legacy Converted Enhanced Image Storage classes has only recently been added to GDCM:
https://github.com/malaterre/GDCM/blob/513a75c2f4dc704549223b831879c4a5fab00076/Source/DataStructureAndEncodingDefinition/gdcmMediaStorage.cxx#L144
This functionality is not yet in the GDCM code that comes with ITK:
https://github.com/InsightSoftwareConsortium/ITK/blob/6dffe29eb245f77ac27a17d0398fa3073cb6bf4c/Modules/ThirdParty/GDCM/src/gdcm/Source/DataStructureAndEncodingDefinition/gdcmMediaStorage.cxx#L143
Is there a change that the GDCM source code will be updated for the 5.0 release?
See also related SimpleITK issue
The text was updated successfully, but these errors were encountered: