@cornerstonejs/core 1.10.2 → 1.10.4

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 (23) hide show
  1. package/dist/cjs/RenderingEngine/helpers/cpuFallback/rendering/getVOILut.js +3 -1
  2. package/dist/cjs/RenderingEngine/helpers/cpuFallback/rendering/getVOILut.js.map +1 -1
  3. package/dist/cjs/RenderingEngine/helpers/cpuFallback/rendering/renderColorImage.js +3 -2
  4. package/dist/cjs/RenderingEngine/helpers/cpuFallback/rendering/renderColorImage.js.map +1 -1
  5. package/dist/cjs/requestPool/requestPoolManager.js +1 -1
  6. package/dist/cjs/requestPool/requestPoolManager.js.map +1 -1
  7. package/dist/cjs/utilities/windowLevel.js +4 -4
  8. package/dist/cjs/utilities/windowLevel.js.map +1 -1
  9. package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/getVOILut.js +3 -1
  10. package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/getVOILut.js.map +1 -1
  11. package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/renderColorImage.js +3 -2
  12. package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/renderColorImage.js.map +1 -1
  13. package/dist/esm/requestPool/requestPoolManager.js +1 -1
  14. package/dist/esm/requestPool/requestPoolManager.js.map +1 -1
  15. package/dist/esm/utilities/windowLevel.js +4 -4
  16. package/dist/esm/utilities/windowLevel.js.map +1 -1
  17. package/dist/umd/index.js +1 -1
  18. package/dist/umd/index.js.map +1 -1
  19. package/package.json +2 -2
  20. package/src/RenderingEngine/helpers/cpuFallback/rendering/getVOILut.ts +9 -1
  21. package/src/RenderingEngine/helpers/cpuFallback/rendering/renderColorImage.ts +5 -3
  22. package/src/requestPool/requestPoolManager.ts +1 -1
  23. package/src/utilities/windowLevel.ts +13 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/core",
3
- "version": "1.10.2",
3
+ "version": "1.10.4",
4
4
  "description": "",
5
5
  "main": "dist/umd/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -46,5 +46,5 @@
46
46
  "type": "individual",
47
47
  "url": "https://ohif.org/donate"
48
48
  },
49
- "gitHead": "7700f91b8d72db5808a68056645792d184bf5436"
49
+ "gitHead": "0468aa978beba2b216674c2876d4bc4d1a9938a0"
50
50
  }
@@ -15,6 +15,11 @@
15
15
  */
16
16
 
17
17
  /**
18
+ * Generates the linear VOI LUT function.
19
+ * From the DICOM standard:
20
+ * https://dicom.nema.org/medical/dicom/current/output/html/part03.html#sect_C.11.2.1.2.1
21
+ * ((x - (c - 0.5)) / (w-1) + 0.5) * (ymax- ymin) + ymin
22
+ * clipped to the ymin...ymax range
18
23
  *
19
24
  * @param {Number} windowWidth Window Width
20
25
  * @param {Number} windowCenter Window Center
@@ -23,7 +28,10 @@
23
28
  */
24
29
  function generateLinearVOILUT(windowWidth: number, windowCenter: number) {
25
30
  return function (modalityLutValue) {
26
- return ((modalityLutValue - windowCenter) / windowWidth + 0.5) * 255.0;
31
+ const value =
32
+ ((modalityLutValue - (windowCenter - 0.5)) / (windowWidth - 1) + 0.5) *
33
+ 255.0;
34
+ return Math.min(Math.max(value, 0), 255);
27
35
  };
28
36
  }
29
37
 
@@ -72,10 +72,12 @@ function getRenderCanvas(
72
72
  const renderCanvas = enabledElement.renderingTools.renderCanvas;
73
73
 
74
74
  // The ww/wc is identity and not inverted - get a canvas with the image rendered into it for
75
- // Fast drawing
75
+ // Fast drawing. Note that this is 256/128, and NOT 255/127, per the DICOM
76
+ // standard, but allow either.
77
+ const { windowWidth, windowCenter } = enabledElement.viewport.voi;
76
78
  if (
77
- enabledElement.viewport.voi.windowWidth === 255 &&
78
- enabledElement.viewport.voi.windowCenter === 127 &&
79
+ (windowWidth === 256 || windowWidth === 255) &&
80
+ (windowCenter === 128 || windowCenter === 127) &&
79
81
  enabledElement.viewport.invert === false &&
80
82
  image.getCanvas &&
81
83
  image.getCanvas()
@@ -307,7 +307,7 @@ class RequestPoolManager {
307
307
  const priorities = Object.keys(this.requestPool[type])
308
308
  .map(Number)
309
309
  .filter((priority) => this.requestPool[type][priority].length)
310
- .sort();
310
+ .sort((a, b) => a - b);
311
311
  return priorities;
312
312
  }
313
313
 
@@ -1,5 +1,8 @@
1
1
  /**
2
2
  * Given a low and high window level, return the window width and window center
3
+ * Formulas from note 4 in
4
+ * https://dicom.nema.org/medical/dicom/current/output/html/part03.html#sect_C.11.2.1.2.1
5
+ * extended to allow for low/high swapping
3
6
  * @param low - The low window level.
4
7
  * @param high - The high window level.
5
8
  * @returns a JavaScript object with two properties: windowWidth and windowCenter.
@@ -11,14 +14,20 @@ function toWindowLevel(
11
14
  windowWidth: number;
12
15
  windowCenter: number;
13
16
  } {
14
- const windowWidth = Math.abs(low - high);
15
- const windowCenter = low + windowWidth / 2;
17
+ // Allow for swapping high/low
18
+ const windowWidth = Math.abs(high - low) + 1;
19
+ const windowCenter = (low + high + 1) / 2;
16
20
 
17
21
  return { windowWidth, windowCenter };
18
22
  }
19
23
 
20
24
  /**
21
25
  * Given a window width and center, return the lower and upper bounds of the window
26
+ * The formulas for the calculation are specified in
27
+ * https://dicom.nema.org/medical/dicom/current/output/html/part03.html#sect_C.11.2.1.2.1
28
+ * if (x <= c - 0.5 - (w-1) /2), then y = ymin
29
+ * else if (x > c - 0.5 + (w-1) /2), then y = ymax
30
+ * else y = ((x - (c - 0.5)) / (w-1) + 0.5) * (ymax- ymin) + ymin
22
31
  * @param windowWidth - the width of the window in HU
23
32
  * @param windowCenter - The center of the window.
24
33
  * @returns a JavaScript object with two properties: lower and upper.
@@ -30,8 +39,8 @@ function toLowHighRange(
30
39
  lower: number;
31
40
  upper: number;
32
41
  } {
33
- const lower = windowCenter - windowWidth / 2.0;
34
- const upper = windowCenter + windowWidth / 2.0;
42
+ const lower = windowCenter - 0.5 - (windowWidth - 1) / 2;
43
+ const upper = windowCenter - 0.5 + (windowWidth - 1) / 2;
35
44
 
36
45
  return { lower, upper };
37
46
  }