Skip to content

Commit

Permalink
ENH: Make DICOM variable spacing warning more informative
Browse files Browse the repository at this point in the history
Before:

Images are not equally spaced (a difference of -0.476013 vs 1.90399 in spacings was detected).

After:

Image slices are not equally spaced (1.90399 spacing was expected, 1.42798 spacing was found between .../I6000001 and .../I6100000).
  • Loading branch information
lassoan authored and pieper committed Nov 3, 2023
1 parent 0d226ab commit ef38f69
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Modules/Scripted/DICOMLib/DICOMUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,22 +695,22 @@ def getSortedImageFiles(filePaths, epsilon=0.01):
dist1 = distances[file1]
spacing0 = dist1 - dist0
n = 1
for fileN in files[1:]:
for n in range(1, len(files)):
fileN = files[n]
fileNminus1 = files[n - 1]
distN = distances[fileN]
distNminus1 = distances[fileNminus1]
spacingN = distN - distNminus1
spaceError = spacingN - spacing0
if abs(spaceError) > epsilon:
spaceWarnings += 1
warningText += f"Images are not equally spaced (a difference of {spaceError:g} vs {spacing0:g} in spacings was detected)."
warningText += f"Image slices are not equally spaced ({spacing0:g} spacing was expected, {spacingN:g} spacing was found between files {fileN} and {fileNminus1})."
if acquisitionGeometryRegularizationEnabled:
warningText += " Slicer will apply a transform to this series trying to regularize the volume. Please use caution.\n"
else:
warningText += (" If loaded image appears distorted, enable 'Acquisition geometry regularization'"
" in Application settings / DICOM / DICOMScalarVolumePlugin. Please use caution.\n")
break
n += 1

if spaceWarnings != 0:
logging.warning("Geometric issues were found with %d of the series. Please use caution.\n" % spaceWarnings)
Expand Down

0 comments on commit ef38f69

Please sign in to comment.