Add workaround to load malformed 4D CTA DICOM files #128
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We have several datasets with poorly formatted DICOM images. These datasets come from the same source and have the same problem. The first file in the series slightly differs in several DICOM tags from the rest files.
Here is an example of differences between first and second files:
The difference between the second file and the third file is quite small:
As you can see, the main difference is the addition of trailing zeros only in the first file in the following tags:
SliceThickness,SpacingBetweenSlices,ReconstructionDiameter,GantryDetectorTilt,ImageOrientationPatientandRescaleSlope.Since ITK-SNAP uses tag
SliceThicknessfor computation of unique ID for image series, the whole dataset is split in two parts: the first sole file, and all remaining files. This behavior is acceptable when we work with a static 3D image, we can ignore the first slice and just work with slightly shorter image. However, it is impossible to open 4D images, since the first missing slice breaks the dimensions. A possible workaround is to manually delete all first slices from all time frames, which is not very user-friendly and quite tedious.I propose to add several workarounds to allow loading of such malformed 4D CTA DICOM files. At first, we remove the trailing zeros from fractional part of
SliceThicknesstag, thus combining all files in one dataset. Next, we add a fallback sorting toMFOrderByIPPStrategyin caseIPPSorterfails. The last change is needed sinceIPPSorterwill fail ifGantry/Detector Tilttag is not unique, resulting in wrong orientation of the first frame in the dynamic dataset.