Skip to content

Commit

Permalink
Fix issues with isDisplaySetReconstructable when we have empty DICOM …
Browse files Browse the repository at this point in the history
…tags (closes OHIF#1280) (OHIF#1426)
  • Loading branch information
swederik authored Feb 7, 2020
1 parent a4c9a86 commit a6b92a4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default class RetrieveMetadataLoader {
}

if (loaders.next().done && !result) {
throw 'cant find data';
throw new Error('RetrieveMetadataLoader failed');
}

return result;
Expand Down
15 changes: 13 additions & 2 deletions platform/core/src/utils/isDisplaySetReconstructable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ function ViewerRetrieveStudyData({
.catch(error => {
if (error && !error.isCanceled) {
setError(true);
log.error(error);
}
});

Expand Down Expand Up @@ -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);
}
}
};
Expand Down

0 comments on commit a6b92a4

Please sign in to comment.