@cornerstonejs/core 1.3.0 → 1.4.1

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 (38) hide show
  1. package/dist/cjs/RenderingEngine/StackViewport.js +5 -5
  2. package/dist/cjs/RenderingEngine/StackViewport.js.map +1 -1
  3. package/dist/cjs/RenderingEngine/VolumeViewport.js.map +1 -1
  4. package/dist/cjs/cache/classes/ImageVolume.d.ts +2 -2
  5. package/dist/cjs/cache/classes/ImageVolume.js +1 -1
  6. package/dist/cjs/cache/classes/ImageVolume.js.map +1 -1
  7. package/dist/cjs/init.js +8 -6
  8. package/dist/cjs/init.js.map +1 -1
  9. package/dist/cjs/types/Cornerstone3DConfig.d.ts +3 -1
  10. package/dist/cjs/types/IImage.d.ts +1 -1
  11. package/dist/cjs/types/IImageVolume.d.ts +2 -2
  12. package/dist/cjs/types/IVolume.d.ts +1 -1
  13. package/dist/cjs/types/ScalingParameters.d.ts +1 -1
  14. package/dist/esm/RenderingEngine/StackViewport.js +5 -5
  15. package/dist/esm/RenderingEngine/StackViewport.js.map +1 -1
  16. package/dist/esm/RenderingEngine/VolumeViewport.js.map +1 -1
  17. package/dist/esm/cache/classes/ImageVolume.d.ts +2 -2
  18. package/dist/esm/cache/classes/ImageVolume.js +1 -1
  19. package/dist/esm/cache/classes/ImageVolume.js.map +1 -1
  20. package/dist/esm/init.js +8 -6
  21. package/dist/esm/init.js.map +1 -1
  22. package/dist/esm/types/Cornerstone3DConfig.d.ts +3 -1
  23. package/dist/esm/types/IImage.d.ts +1 -1
  24. package/dist/esm/types/IImageVolume.d.ts +2 -2
  25. package/dist/esm/types/IVolume.d.ts +1 -1
  26. package/dist/esm/types/ScalingParameters.d.ts +1 -1
  27. package/dist/umd/index.js +1 -1
  28. package/dist/umd/index.js.map +1 -1
  29. package/package.json +2 -2
  30. package/src/RenderingEngine/StackViewport.ts +5 -5
  31. package/src/RenderingEngine/VolumeViewport.ts +1 -1
  32. package/src/cache/classes/ImageVolume.ts +4 -2
  33. package/src/init.ts +11 -9
  34. package/src/types/Cornerstone3DConfig.ts +16 -1
  35. package/src/types/IImage.ts +1 -1
  36. package/src/types/IImageVolume.ts +2 -2
  37. package/src/types/IVolume.ts +1 -1
  38. package/src/types/ScalingParameters.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/core",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "description": "",
5
5
  "main": "dist/umd/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -44,5 +44,5 @@
44
44
  "type": "individual",
45
45
  "url": "https://ohif.org/donate"
46
46
  },
47
- "gitHead": "2d2a16d47deaee1ad6d6c5b15e84626ae6ecfdf5"
47
+ "gitHead": "13e9e13e8445e84ac0ef70e4214c0c74b324cce3"
48
48
  }
@@ -1289,7 +1289,7 @@ class StackViewport extends Viewport implements IStackViewport {
1289
1289
  * @param imageIdScalingFactor - suvbw, suvlbm, suvbsa
1290
1290
  */
1291
1291
  private _addScalingToViewport(imageIdScalingFactor) {
1292
- if (this.scaling.PET) {
1292
+ if (this.scaling.PT) {
1293
1293
  return;
1294
1294
  }
1295
1295
 
@@ -1297,17 +1297,17 @@ class StackViewport extends Viewport implements IStackViewport {
1297
1297
  // These ratios are constant across all frames, so only need one.
1298
1298
  const { suvbw, suvlbm, suvbsa } = imageIdScalingFactor;
1299
1299
 
1300
- const petScaling = <PTScaling>{};
1300
+ const ptScaling = <PTScaling>{};
1301
1301
 
1302
1302
  if (suvlbm) {
1303
- petScaling.suvbwToSuvlbm = suvlbm / suvbw;
1303
+ ptScaling.suvbwToSuvlbm = suvlbm / suvbw;
1304
1304
  }
1305
1305
 
1306
1306
  if (suvbsa) {
1307
- petScaling.suvbwToSuvbsa = suvbsa / suvbw;
1307
+ ptScaling.suvbwToSuvbsa = suvbsa / suvbw;
1308
1308
  }
1309
1309
 
1310
- this.scaling.PET = petScaling;
1310
+ this.scaling.PT = ptScaling;
1311
1311
  }
1312
1312
 
1313
1313
  /**
@@ -2,7 +2,7 @@ import vtkPlane from '@kitware/vtk.js/Common/DataModel/Plane';
2
2
  import { vec3 } from 'gl-matrix';
3
3
 
4
4
  import cache from '../cache';
5
- import { EPSILON, MPR_CAMERA_VALUES, RENDERING_DEFAULTS } from '../constants';
5
+ import { MPR_CAMERA_VALUES, RENDERING_DEFAULTS } from '../constants';
6
6
  import { BlendModes, OrientationAxis } from '../enums';
7
7
  import type {
8
8
  ActorEntry,
@@ -23,6 +23,9 @@ export class ImageVolume implements IImageVolume {
23
23
 
24
24
  /** Read-only unique identifier for the volume */
25
25
  readonly volumeId: string;
26
+
27
+ isPreScaled = false;
28
+
26
29
  /** Dimensions of the volume */
27
30
  dimensions: Point3;
28
31
  /** volume direction in world space */
@@ -32,10 +35,9 @@ export class ImageVolume implements IImageVolume {
32
35
  /** volume origin, Note this is an opinionated origin for the volume */
33
36
  origin: Point3;
34
37
  /** Whether preScaling has been performed on the volume */
35
- isPrescaled = false;
36
38
  /** volume scaling parameters if it contains scaled data */
37
39
  scaling?: {
38
- PET?: {
40
+ PT?: {
39
41
  // @TODO: Do these values exist?
40
42
  SUVlbmFactor?: number;
41
43
  SUVbsaFactor?: number;
package/src/init.ts CHANGED
@@ -8,8 +8,9 @@ import { deepMerge } from './utilities';
8
8
  import { Cornerstone3DConfig } from './types';
9
9
  // TODO: move sharedArrayBuffer into config.
10
10
  // TODO: change config into a class with methods to better control get/set
11
- const defaultConfig = {
12
- detectGPU: {},
11
+ const defaultConfig: Cornerstone3DConfig = {
12
+ gpuTier: undefined,
13
+ detectGPUConfig: {},
13
14
  rendering: {
14
15
  useCPURendering: false,
15
16
  // GPU rendering options
@@ -21,8 +22,9 @@ const defaultConfig = {
21
22
  // ...
22
23
  };
23
24
 
24
- let config = {
25
- detectGPU: {},
25
+ let config: Cornerstone3DConfig = {
26
+ gpuTier: undefined,
27
+ detectGPUConfig: {},
26
28
  rendering: {
27
29
  useCPURendering: false,
28
30
  // GPU rendering options
@@ -106,19 +108,19 @@ async function init(configuration = {}): Promise<boolean> {
106
108
  // merge configs
107
109
  config = deepMerge(defaultConfig, configuration);
108
110
 
109
- // detectGPU
111
+ // gpuTier
110
112
  const hasWebGLContext = _hasActiveWebGLContext();
111
113
  if (!hasWebGLContext) {
112
114
  console.log('CornerstoneRender: GPU not detected, using CPU rendering');
113
115
  config.rendering.useCPURendering = true;
114
116
  } else {
115
- const gpuTier = await getGPUTier();
116
- config.detectGPU = gpuTier;
117
+ config.gpuTier =
118
+ config.gpuTier || (await getGPUTier(config.detectGPUConfig));
117
119
  console.log(
118
120
  'CornerstoneRender: Using detect-gpu to get the GPU benchmark:',
119
- gpuTier
121
+ config.gpuTier
120
122
  );
121
- if (gpuTier.tier < 1) {
123
+ if (config.gpuTier.tier < 1) {
122
124
  console.log(
123
125
  'CornerstoneRender: GPU is not powerful enough, using CPU rendering'
124
126
  );
@@ -1,5 +1,20 @@
1
+ import type { TierResult, GetGPUTier } from 'detect-gpu';
2
+
1
3
  type Cornerstone3DConfig = {
2
- detectGPU: any;
4
+ /**
5
+ * It is used to store the device information,
6
+ * we use it if provided if not a network call is performed.
7
+ * Its type is the `TierResult` in the `detect-gpu` library.
8
+ * https://github.com/pmndrs/detect-gpu/blob/master/src/index.ts#L82
9
+ */
10
+ gpuTier?: TierResult;
11
+ /**
12
+ * When the `gpuTier` is not provided, the `detectGPUConfig` is passed as
13
+ * an argument to the `getGPUTier` method.
14
+ * Its type is the `GetGPUTier` in the `detect-gpu` library.
15
+ * https://github.com/pmndrs/detect-gpu/blob/master/src/index.ts#L20
16
+ */
17
+ detectGPUConfig: GetGPUTier;
3
18
  rendering: {
4
19
  // vtk.js supports 8bit integer textures and 32bit float textures.
5
20
  // However, if the client has norm16 textures (it can be seen by visiting
@@ -82,7 +82,7 @@ interface IImage {
82
82
  colormap?: CPUFallbackColormap;
83
83
  /** image scaling metadata - including PT suv values */
84
84
  scaling?: {
85
- PET?: {
85
+ PT?: {
86
86
  // @TODO: Do these values exist?
87
87
  SUVlbmFactor?: number;
88
88
  SUVbsaFactor?: number;
@@ -23,10 +23,10 @@ interface IImageVolume {
23
23
  /** volume origin - set to the imagePositionPatient of the last image in the volume */
24
24
  origin: Point3;
25
25
  /** Whether preScaling has been performed on the volume */
26
- isPrescaled: boolean;
26
+ isPreScaled: boolean;
27
27
  /** volume scaling metadata */
28
28
  scaling?: {
29
- PET?: {
29
+ PT?: {
30
30
  SUVlbmFactor?: number;
31
31
  SUVbsaFactor?: number;
32
32
  suvbwToSuvlbm?: number;
@@ -31,7 +31,7 @@ interface IVolume {
31
31
  referencedVolumeId?: string;
32
32
  /** volume scaling metadata */
33
33
  scaling?: {
34
- PET?: {
34
+ PT?: {
35
35
  // @TODO: Do these values exist?
36
36
  SUVlbmFactor?: number;
37
37
  SUVbsaFactor?: number;
@@ -27,7 +27,7 @@ type PTScaling = {
27
27
  };
28
28
 
29
29
  type Scaling = {
30
- PET?: PTScaling;
30
+ PT?: PTScaling;
31
31
  };
32
32
 
33
33
  export { PTScaling, Scaling, ScalingParameters };