From c1a0d3c662d143b62dfbf1c01f6ce394af3756ca Mon Sep 17 00:00:00 2001 From: Erik Ziegler Date: Wed, 25 Mar 2020 17:55:39 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20Add=20support=20for=20single=20entries?= =?UTF-8?q?=20in=20SequenceOfUltrasoundRegions.=20M=E2=80=A6=20(#1559)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: Add support for single entries in SequenceOfUltrasoundRegions. More than one region will need lower-level changes * Update platform/core/src/utils/metadataProvider/getPixelSpacingInformation.js Co-authored-by: Danny Brown --- .../getPixelSpacingInformation.js | 80 ++++++++++++++----- 1 file changed, 60 insertions(+), 20 deletions(-) diff --git a/platform/core/src/utils/metadataProvider/getPixelSpacingInformation.js b/platform/core/src/utils/metadataProvider/getPixelSpacingInformation.js index b8e674109..7d76c39f7 100644 --- a/platform/core/src/utils/metadataProvider/getPixelSpacingInformation.js +++ b/platform/core/src/utils/metadataProvider/getPixelSpacingInformation.js @@ -19,45 +19,53 @@ export default function getPixelSpacingInformation(instance) { '1.2.840.10008.5.1.4.1.1.12.1.1', // Enhanced XA Image Storage '1.2.840.10008.5.1.4.1.1.12.2', // X-Ray Radiofluoroscopic Image Storage '1.2.840.10008.5.1.4.1.1.12.2.1', // Enhanced XRF Image Storage - '1.2.840.10008.5.1.4.1.1.12.3' // X-Ray Angiographic Bi-plane Image Storage Retired + '1.2.840.10008.5.1.4.1.1.12.3', // X-Ray Angiographic Bi-plane Image Storage Retired ]; - const { PixelSpacing, ImagerPixelSpacing, SOPClassUID, PixelSpacingCalibrationType, PixelSpacingCalibrationDescription, EstimatedRadiographicMagnificationFactor } = instance; + const { + PixelSpacing, + ImagerPixelSpacing, + SOPClassUID, + PixelSpacingCalibrationType, + PixelSpacingCalibrationDescription, + EstimatedRadiographicMagnificationFactor, + SequenceOfUltrasoundRegions, + } = instance; const isProjection = projectionRadiographSOPClassUIDs.includes(SOPClassUID); const TYPES = { NOT_APPLICABLE: 'NOT_APPLICABLE', UNKNOWN: 'UNKNOWN', CALIBRATED: 'CALIBRATED', - DETECTOR: 'DETECTOR' + DETECTOR: 'DETECTOR', }; - if (isProjection === false && !ImagerPixelSpacing) { - // If only Pixel Spacing is present, and this is not a projection radiograph, - // we can stop here - return { - PixelSpacing, - type: TYPES.NOT_APPLICABLE, - isProjection - }; - } else if (isProjection && !ImagerPixelSpacing) { + if (isProjection && !ImagerPixelSpacing) { // If only Pixel Spacing is present, and this is a projection radiograph, // PixelSpacing should be used, but the user should be informed that // what it means is unknown return { PixelSpacing, type: TYPES.UNKNOWN, - isProjection + isProjection, }; - } else if (PixelSpacing && ImagerPixelSpacing && PixelSpacing === ImagerPixelSpacing) { + } else if ( + PixelSpacing && + ImagerPixelSpacing && + PixelSpacing === ImagerPixelSpacing + ) { // If Imager Pixel Spacing and Pixel Spacing are present and they have the same values, // then the user should be informed that the measurements are at the detector plane return { PixelSpacing, type: TYPES.DETECTOR, - isProjection + isProjection, }; - } else if (PixelSpacing && ImagerPixelSpacing && PixelSpacing !== ImagerPixelSpacing) { + } else if ( + PixelSpacing && + ImagerPixelSpacing && + PixelSpacing !== ImagerPixelSpacing + ) { // If Imager Pixel Spacing and Pixel Spacing are present and they have different values, // then the user should be informed that these are "calibrated" // (in some unknown manner if Pixel Spacing Calibration Type and/or @@ -67,7 +75,7 @@ export default function getPixelSpacingInformation(instance) { type: TYPES.CALIBRATED, isProjection, PixelSpacingCalibrationType, - PixelSpacingCalibrationDescription + PixelSpacingCalibrationDescription, }; } else if (!PixelSpacing && ImagerPixelSpacing) { let CorrectedImagerPixelSpacing = ImagerPixelSpacing; @@ -75,16 +83,48 @@ export default function getPixelSpacingInformation(instance) { // Note that in IHE Mammo profile compliant displays, the value of Imager Pixel Spacing is required to be corrected by // Estimated Radiographic Magnification Factor and the user informed of that. // TODO: should this correction be done before all of this logic? - CorrectedImagerPixelSpacing = ImagerPixelSpacing.map(pixelSpacing => pixelSpacing / EstimatedRadiographicMagnificationFactor); + CorrectedImagerPixelSpacing = ImagerPixelSpacing.map( + pixelSpacing => pixelSpacing / EstimatedRadiographicMagnificationFactor + ); } else { - log.info('EstimatedRadiographicMagnificationFactor was not present. Unable to correct ImagerPixelSpacing.'); + log.info( + 'EstimatedRadiographicMagnificationFactor was not present. Unable to correct ImagerPixelSpacing.' + ); } return { PixelSpacing: CorrectedImagerPixelSpacing, isProjection, }; + } else if ( + SequenceOfUltrasoundRegions && + typeof SequenceOfUltrasoundRegions === 'object' + ) { + const { PhysicalDeltaX, PhysicalDeltaY } = SequenceOfUltrasoundRegions; + const USPixelSpacing = [PhysicalDeltaX * 10, PhysicalDeltaY * 10]; + + return { + PixelSpacing: USPixelSpacing, + }; + } else if ( + SequenceOfUltrasoundRegions && + Array.isArray(SequenceOfUltrasoundRegions) && + SequenceOfUltrasoundRegions.length > 1 + ) { + log.warn( + 'Sequence of Ultrasound Regions > one entry. This is not yet implemented, all measurements will be shown in pixels.' + ); + } else if (isProjection === false && !ImagerPixelSpacing) { + // If only Pixel Spacing is present, and this is not a projection radiograph, + // we can stop here + return { + PixelSpacing, + type: TYPES.NOT_APPLICABLE, + isProjection, + }; } - log.info('Unknown combination of PixelSpacing and ImagerPixelSpacing identified. Unable to determine spacing.'); + log.info( + 'Unknown combination of PixelSpacing and ImagerPixelSpacing identified. Unable to determine spacing.' + ); }