@cornerstonejs/tools 0.53.1 → 0.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/cjs/utilities/segmentation/index.d.ts +2 -1
  2. package/dist/cjs/utilities/segmentation/index.js +3 -1
  3. package/dist/cjs/utilities/segmentation/index.js.map +1 -1
  4. package/dist/cjs/utilities/segmentation/rectangleROIThresholdVolumeByRange.d.ts +1 -5
  5. package/dist/cjs/utilities/segmentation/rectangleROIThresholdVolumeByRange.js.map +1 -1
  6. package/dist/cjs/utilities/segmentation/thresholdSegmentationByRange.d.ts +4 -0
  7. package/dist/cjs/utilities/segmentation/thresholdSegmentationByRange.js +54 -0
  8. package/dist/cjs/utilities/segmentation/thresholdSegmentationByRange.js.map +1 -0
  9. package/dist/cjs/utilities/segmentation/thresholdVolumeByRange.d.ts +1 -5
  10. package/dist/cjs/utilities/segmentation/thresholdVolumeByRange.js +4 -49
  11. package/dist/cjs/utilities/segmentation/thresholdVolumeByRange.js.map +1 -1
  12. package/dist/cjs/utilities/segmentation/utilities.d.ts +11 -0
  13. package/dist/cjs/utilities/segmentation/utilities.js +55 -0
  14. package/dist/cjs/utilities/segmentation/utilities.js.map +1 -1
  15. package/dist/esm/utilities/segmentation/index.d.ts +2 -1
  16. package/dist/esm/utilities/segmentation/index.js +2 -1
  17. package/dist/esm/utilities/segmentation/index.js.map +1 -1
  18. package/dist/esm/utilities/segmentation/rectangleROIThresholdVolumeByRange.d.ts +1 -5
  19. package/dist/esm/utilities/segmentation/rectangleROIThresholdVolumeByRange.js.map +1 -1
  20. package/dist/esm/utilities/segmentation/thresholdSegmentationByRange.d.ts +4 -0
  21. package/dist/esm/utilities/segmentation/thresholdSegmentationByRange.js +52 -0
  22. package/dist/esm/utilities/segmentation/thresholdSegmentationByRange.js.map +1 -0
  23. package/dist/esm/utilities/segmentation/thresholdVolumeByRange.d.ts +1 -5
  24. package/dist/esm/utilities/segmentation/thresholdVolumeByRange.js +3 -45
  25. package/dist/esm/utilities/segmentation/thresholdVolumeByRange.js.map +1 -1
  26. package/dist/esm/utilities/segmentation/utilities.d.ts +11 -0
  27. package/dist/esm/utilities/segmentation/utilities.js +52 -0
  28. package/dist/esm/utilities/segmentation/utilities.js.map +1 -1
  29. package/dist/umd/index.js +1 -2
  30. package/dist/umd/index.js.map +1 -1
  31. package/package.json +2 -2
  32. package/dist/umd/index.js.LICENSE.txt +0 -6
@@ -1,5 +1,7 @@
1
+ import { utilities as csUtils } from '@cornerstonejs/core';
1
2
  import { getToolGroup } from '../../store/ToolGroupManager';
2
3
  import BrushTool from '../../tools/segmentation/BrushTool';
4
+ import getBoundingBoxAroundShape from '../boundingBox/getBoundingBoxAroundShape';
3
5
  export default function getBrushToolInstances(toolGroupId) {
4
6
  const toolGroup = getToolGroup(toolGroupId);
5
7
  if (toolGroup === undefined) {
@@ -12,4 +14,54 @@ export default function getBrushToolInstances(toolGroupId) {
12
14
  const brushBasedToolInstances = Object.values(toolInstances).filter((toolInstance) => toolInstance instanceof BrushTool);
13
15
  return brushBasedToolInstances;
14
16
  }
17
+ const equalsCheck = (a, b) => {
18
+ return JSON.stringify(a) === JSON.stringify(b);
19
+ };
20
+ export function getVoxelOverlap(imageData, dimensions, voxelSpacing, voxelCenter) {
21
+ const voxelCornersWorld = [];
22
+ for (let i = 0; i < 2; i++) {
23
+ for (let j = 0; j < 2; j++) {
24
+ for (let k = 0; k < 2; k++) {
25
+ const point = voxelCenter;
26
+ point[0] = point[0] + ((i * 2 - 1) * voxelSpacing[0]) / 2;
27
+ point[1] = point[1] + ((j * 2 - 1) * voxelSpacing[1]) / 2;
28
+ point[2] = point[2] + ((k * 2 - 1) * voxelSpacing[2]) / 2;
29
+ voxelCornersWorld.push(point);
30
+ }
31
+ }
32
+ }
33
+ const voxelCornersIJK = voxelCornersWorld.map((world) => csUtils.transformWorldToIndex(imageData, world));
34
+ const overlapBounds = getBoundingBoxAroundShape(voxelCornersIJK, dimensions);
35
+ return overlapBounds;
36
+ }
37
+ export function processVolumes(segmentationVolume, thresholdVolumeInformation) {
38
+ const { spacing: segmentationSpacing, imageData: segmentationImageData } = segmentationVolume;
39
+ const scalarData = segmentationVolume.getScalarData();
40
+ const volumeInfoList = [];
41
+ let baseVolumeIdx = 0;
42
+ for (let i = 0; i < thresholdVolumeInformation.length; i++) {
43
+ const { imageData, spacing, dimensions } = thresholdVolumeInformation[i].volume;
44
+ const volumeSize = thresholdVolumeInformation[i].volume.getScalarData().length;
45
+ if (volumeSize === scalarData.length &&
46
+ equalsCheck(spacing, segmentationSpacing)) {
47
+ baseVolumeIdx = i;
48
+ }
49
+ const referenceValues = imageData.getPointData().getScalars().getData();
50
+ const lower = thresholdVolumeInformation[i].lower;
51
+ const upper = thresholdVolumeInformation[i].upper;
52
+ volumeInfoList.push({
53
+ imageData,
54
+ referenceValues,
55
+ lower,
56
+ upper,
57
+ spacing,
58
+ dimensions,
59
+ volumeSize,
60
+ });
61
+ }
62
+ return {
63
+ volumeInfoList,
64
+ baseVolumeIdx,
65
+ };
66
+ }
15
67
  //# sourceMappingURL=utilities.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../../src/utilities/segmentation/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,SAAS,MAAM,oCAAoC,CAAC;AAE3D,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,WAAW;IACvD,MAAM,SAAS,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC;IAE5C,IAAI,SAAS,KAAK,SAAS,EAAE;QAC3B,OAAO;KACR;IAED,MAAM,aAAa,GAAG,SAAS,CAAC,cAAc,CAAC;IAE/C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,EAAE;QACtC,OAAO;KACR;IAGD,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM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