Skip to content

Commit

Permalink
update generate segmentation to handle cornerstone metadata objects
Browse files Browse the repository at this point in the history
  • Loading branch information
emelalkim committed Jul 17, 2023
1 parent eddc951 commit e2b8c69
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/adapters/Cornerstone/Segmentation_4X.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,34 @@ const generateSegmentationDefaultOptions = {
* imageIds, images and the cornerstoneTools brushData.
*
* @param {object[]} images An array of cornerstone images that contain the source
* data under `image.data.byteArray.buffer` or an array of DICOM JSON Objects.
* data under `image.data.byteArray.buffer` or an array of image metadata objects
* from CornerstoneWadoImageLoader's MetadataProvider.
* @param {Object|Object[]} inputLabelmaps3D The cornerstone `Labelmap3D` object, or an array of objects.
* @param {Object} userOptions Options to pass to the segmentation derivation and `fillSegmentation`.
* @returns {Blob}
*/
function generateSegmentation(images, inputLabelmaps3D, userOptions = {}) {
const isMultiframe = images[0].imageId.includes("?frame");
const isDataAvailable = images[0] && !!images[0].data;
const segmentation = isDataAvailable
? _createSegFromImages(images, isMultiframe, userOptions)
: _createSegFromJSONObjects(images, isMultiframe, userOptions);
return fillSegmentation(segmentation, inputLabelmaps3D, userOptions);
if (isDataAvailable) {
// Cornerstone image object
const isMultiframe = images[0].imageId.includes("?frame");
const segmentation = _createSegFromImages(
images,
isMultiframe,
userOptions
);
return fillSegmentation(segmentation, inputLabelmaps3D, userOptions);
} else {
// Cornerstone metadata objects
const isMultiframe = images[0].isMultiframe;
images.forEach(image => delete image.isMultiframe);
const segmentation = _createSegFromJSONObjects(
images,
isMultiframe,
userOptions
);
return fillSegmentation(segmentation, inputLabelmaps3D, userOptions);
}
}

/**
Expand Down

0 comments on commit e2b8c69

Please sign in to comment.