From a6b92a4505b260bcfd64a2286ef10af0d0aca3a1 Mon Sep 17 00:00:00 2001 From: Erik Ziegler Date: Fri, 7 Feb 2020 17:09:37 +0100 Subject: [PATCH] Fix issues with isDisplaySetReconstructable when we have empty DICOM tags (closes #1280) (#1426) --- .../services/wado/retrieveMetadataLoader.js | 2 +- .../core/src/utils/isDisplaySetReconstructable.js | 15 +++++++++++++-- .../ViewerRetrieveStudyData.js | 3 +++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/platform/core/src/studies/services/wado/retrieveMetadataLoader.js b/platform/core/src/studies/services/wado/retrieveMetadataLoader.js index 4763f4bb0bd..2786f4cdf97 100644 --- a/platform/core/src/studies/services/wado/retrieveMetadataLoader.js +++ b/platform/core/src/studies/services/wado/retrieveMetadataLoader.js @@ -46,7 +46,7 @@ export default class RetrieveMetadataLoader { } if (loaders.next().done && !result) { - throw 'cant find data'; + throw new Error('RetrieveMetadataLoader failed'); } return result; diff --git a/platform/core/src/utils/isDisplaySetReconstructable.js b/platform/core/src/utils/isDisplaySetReconstructable.js index 95032054020..44783cb22da 100644 --- a/platform/core/src/utils/isDisplaySetReconstructable.js +++ b/platform/core/src/utils/isDisplaySetReconstructable.js @@ -67,6 +67,12 @@ function processSingleframe(instances) { if (instances.length > 2) { const firstIpp = _getImagePositionPatient(firstImage); const lastIpp = _getImagePositionPatient(instances[instances.length - 1]); + + // We can't reconstruct if we are missing imagePositionPatient values + if (!firstIpp || !lastIpp) { + return { value: false }; + } + const averageSpacingBetweenFrames = _getPerpendicularDistance(firstIpp, lastIpp) / (instances.length - 1); @@ -136,8 +142,13 @@ function _getSpacingIssue(spacing, averageSpacing) { } function _getImagePositionPatient(instance) { - return instance - .getTagValue('x00200032') + const tagValue = instance + .getTagValue('x00200032'); + if (!tagValue) { + return; + } + + return tagValue .split('\\') .map(element => Number(element)); } diff --git a/platform/viewer/src/connectedComponents/ViewerRetrieveStudyData.js b/platform/viewer/src/connectedComponents/ViewerRetrieveStudyData.js index 066357192c9..191157f171c 100644 --- a/platform/viewer/src/connectedComponents/ViewerRetrieveStudyData.js +++ b/platform/viewer/src/connectedComponents/ViewerRetrieveStudyData.js @@ -253,6 +253,7 @@ function ViewerRetrieveStudyData({ .catch(error => { if (error && !error.isCanceled) { setError(true); + log.error(error); } }); @@ -290,11 +291,13 @@ function ViewerRetrieveStudyData({ .catch(error => { if (error && !error.isCanceled) { setError(true); + log.error(error); } }); } catch (error) { if (error) { setError(true); + log.error(error); } } };