forked from OHIF/Viewers
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from gradienthealth/gradienthealth/Segmentatio…
…n-modifications Gradienthealth/segmentation modifications
- Loading branch information
Showing
19 changed files
with
628 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
extensions/cornerstone-dicom-seg/src/utils/generateLabelmaps2DFromImageIdMap.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { cache } from '@cornerstonejs/core'; | ||
|
||
const generateLabelmaps2DFromImageIdMap = imageIdReferenceMap => { | ||
const labelmaps2D = [], | ||
referencedImages = [], | ||
segmentsOnLabelmap3D = new Set(); | ||
Array.from(imageIdReferenceMap.entries()).forEach((entry, index) => { | ||
referencedImages.push(cache.getImage(entry[0])); | ||
|
||
const segmentationImage = cache.getImage(entry[1]); | ||
const { rows, columns } = segmentationImage; | ||
const pixelData = segmentationImage.getPixelData(); | ||
const segmentsOnLabelmap = []; | ||
|
||
for (let i = 0; i < pixelData.length; i++) { | ||
const segment = pixelData[i]; | ||
if (!segmentsOnLabelmap.includes(segment) && segment !== 0) { | ||
segmentsOnLabelmap.push(segment); | ||
} | ||
} | ||
|
||
if (segmentsOnLabelmap.length) { | ||
labelmaps2D[index] = { | ||
segmentsOnLabelmap, | ||
pixelData, | ||
rows, | ||
columns, | ||
}; | ||
|
||
segmentsOnLabelmap.forEach(segmentIndex => { | ||
segmentsOnLabelmap3D.add(segmentIndex); | ||
}); | ||
} | ||
}); | ||
|
||
const labelmapObj = { | ||
segmentsOnLabelmap: Array.from(segmentsOnLabelmap3D), | ||
labelmaps2D, | ||
}; | ||
|
||
return { referencedImages, labelmapObj }; | ||
}; | ||
|
||
export default generateLabelmaps2DFromImageIdMap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.