fix(Measurements): in MeasurementService keep a separate set of unmapped measurements (#3385)

* fix(Measurements): return {} instead of undefined for getSOPInstanceAttributes

* PR feedback:
- separated measurements from non-acquisition plane
- reverted to previous behaviour of returning undefined in getSOPInstanceAttributes

* Added unit tests for unmapped measurements.

* PR feedback: added comments to the unmappedMeasurement used in the unit tests.
This commit is contained in:
Joe Boccanfuso authored and GitHub committed 2023-05-12 16:24:00 -04:00
1 parent 4fd81b5cd2
commit 4172d0427b
3 files changed
+108 -46

No files matched your search

@@ -3,39 +3,16 @@ import * as cornerstone from '@cornerstonejs/core';
/**
* It checks if the imageId is provided then it uses it to query
* the metadata and get the SOPInstanceUID, SeriesInstanceUID and StudyInstanceUID.
* If the imageId is not provided then it uses the sceneUID to get the viewports
* inside the scene and then it checks each viewport to find the one that has
* acquisition plane view, and uses the currentImageId of the viewport to
* query the metadata and get UIDs.
* If the imageId is not provided then undefined is returned.
* @param {string} imageId The image id of the referenced image
* @param {string} sceneUID The scene UID of the measurement tool
* @returns
*/
export default function getSOPInstanceAttributes(
imageId,
cornerstoneViewportService = undefined,
viewportId = undefined
) {
export default function getSOPInstanceAttributes(imageId) {
if (imageId) {
return _getUIDFromImageID(imageId);
}
// Todo: implement for volume viewports and use the referencedSeriesInstanceUID
// if no imageId => measurement is not in the acquisition plane
// const metadata = getUIDFromScene(cornerstoneViewportService, viewportId);
// if (!metadata) {
// throw new Error('Not viewport with imageId found');
// }
// // Since the series and study UID is derived from another viewport in the
// // same scene, we cannot include the SOPInstanceUID
// return {
// SOPInstanceUID: null,
// SeriesInstanceUID: metadata.SeriesInstanceUID,
// StudyInstanceUID: metadata.StudyInstanceUID,
// };
}
function _getUIDFromImageID(imageId) {
@@ -48,23 +25,3 @@ function _getUIDFromImageID(imageId) {
frameNumber: instance.frameNumber || 1,
};
}
// function getUIDFromScene(cornerstoneViewportService) {
// const renderingEngine = cornerstoneViewportService.getRenderingEngine();
// const scene = renderingEngine.getScene(sceneUID);
// const viewportUIDs = scene.getViewportIds();
// if (viewportUIDs.length === 0) {
// throw new Error('No viewport found in scene');
// }
// for (let i = 0; i < viewportUIDs.length; i++) {
// const vp = renderingEngine.getViewport(viewportUIDs[i]);
// const imageId = vp.getCurrentImageId();
// if (imageId) {
// return _getUIDFromImageID(imageId);
// }
// }
// }