@cornerstonejs/core 1.70.7 → 1.70.9
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.
- package/dist/cjs/RenderingEngine/StackViewport.d.ts +1 -0
- package/dist/cjs/RenderingEngine/StackViewport.js +1 -0
- package/dist/cjs/RenderingEngine/StackViewport.js.map +1 -1
- package/dist/cjs/RenderingEngine/helpers/setDefaultVolumeVOI.js +1 -0
- package/dist/cjs/RenderingEngine/helpers/setDefaultVolumeVOI.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/init.d.ts +2 -1
- package/dist/cjs/init.js +47 -3
- package/dist/cjs/init.js.map +1 -1
- package/dist/cjs/types/Cornerstone3DConfig.d.ts +1 -0
- package/dist/cjs/types/EventTypes.d.ts +2 -0
- package/dist/cjs/utilities/generateVolumePropsFromImageIds.js +4 -3
- package/dist/cjs/utilities/generateVolumePropsFromImageIds.js.map +1 -1
- package/dist/cjs/utilities/hasFloatScalingParameters.d.ts +2 -0
- package/dist/cjs/utilities/hasFloatScalingParameters.js +9 -0
- package/dist/cjs/utilities/hasFloatScalingParameters.js.map +1 -0
- package/dist/cjs/utilities/index.d.ts +2 -1
- package/dist/cjs/utilities/index.js +3 -1
- package/dist/cjs/utilities/index.js.map +1 -1
- package/dist/cjs/utilities/loadImageToCanvas.js +4 -2
- package/dist/cjs/utilities/loadImageToCanvas.js.map +1 -1
- package/dist/esm/RenderingEngine/StackViewport.js +1 -0
- package/dist/esm/RenderingEngine/StackViewport.js.map +1 -1
- package/dist/esm/RenderingEngine/helpers/setDefaultVolumeVOI.js +1 -0
- package/dist/esm/RenderingEngine/helpers/setDefaultVolumeVOI.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/init.js +44 -1
- package/dist/esm/init.js.map +1 -1
- package/dist/esm/utilities/generateVolumePropsFromImageIds.js +5 -4
- package/dist/esm/utilities/generateVolumePropsFromImageIds.js.map +1 -1
- package/dist/esm/utilities/hasFloatScalingParameters.js +5 -0
- package/dist/esm/utilities/hasFloatScalingParameters.js.map +1 -0
- package/dist/esm/utilities/index.js +2 -1
- package/dist/esm/utilities/index.js.map +1 -1
- package/dist/esm/utilities/loadImageToCanvas.js +4 -2
- package/dist/esm/utilities/loadImageToCanvas.js.map +1 -1
- package/dist/types/RenderingEngine/StackViewport.d.ts +1 -0
- package/dist/types/RenderingEngine/StackViewport.d.ts.map +1 -1
- package/dist/types/RenderingEngine/helpers/setDefaultVolumeVOI.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/init.d.ts +2 -1
- package/dist/types/init.d.ts.map +1 -1
- package/dist/types/types/Cornerstone3DConfig.d.ts +1 -0
- package/dist/types/types/Cornerstone3DConfig.d.ts.map +1 -1
- package/dist/types/types/EventTypes.d.ts +2 -0
- package/dist/types/types/EventTypes.d.ts.map +1 -1
- package/dist/types/utilities/generateVolumePropsFromImageIds.d.ts.map +1 -1
- package/dist/types/utilities/hasFloatScalingParameters.d.ts +3 -0
- package/dist/types/utilities/hasFloatScalingParameters.d.ts.map +1 -0
- package/dist/types/utilities/index.d.ts +2 -1
- package/dist/types/utilities/index.d.ts.map +1 -1
- package/dist/types/utilities/loadImageToCanvas.d.ts.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +2 -2
- package/src/RenderingEngine/StackViewport.ts +1 -0
- package/src/RenderingEngine/helpers/setDefaultVolumeVOI.ts +1 -0
- package/src/index.ts +2 -0
- package/src/init.ts +65 -16
- package/src/types/Cornerstone3DConfig.ts +5 -0
- package/src/types/EventTypes.ts +5 -1
- package/src/utilities/generateVolumePropsFromImageIds.ts +9 -5
- package/src/utilities/hasFloatScalingParameters.ts +15 -0
- package/src/utilities/index.ts +2 -0
- package/src/utilities/loadImageToCanvas.ts +5 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/core",
|
|
3
|
-
"version": "1.70.
|
|
3
|
+
"version": "1.70.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"type": "individual",
|
|
48
48
|
"url": "https://ohif.org/donate"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "4f49d65aab6456412e49d88c99ab6d4d3f760e8f"
|
|
51
51
|
}
|
|
@@ -2064,6 +2064,7 @@ class StackViewport extends Viewport implements IStackViewport, IImagesLoader {
|
|
|
2064
2064
|
},
|
|
2065
2065
|
useRGBA: false,
|
|
2066
2066
|
transferSyntaxUID,
|
|
2067
|
+
useNativeDataType: this.useNativeDataType,
|
|
2067
2068
|
priority: 5,
|
|
2068
2069
|
requestType: RequestType.Interaction,
|
|
2069
2070
|
additionalDetails,
|
package/src/index.ts
CHANGED
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
getConfiguration,
|
|
43
43
|
setConfiguration,
|
|
44
44
|
getWebWorkerManager,
|
|
45
|
+
canRenderFloatTextures,
|
|
45
46
|
} from './init';
|
|
46
47
|
|
|
47
48
|
// Classes
|
|
@@ -89,6 +90,7 @@ export {
|
|
|
89
90
|
getConfiguration,
|
|
90
91
|
setConfiguration,
|
|
91
92
|
getWebWorkerManager,
|
|
93
|
+
canRenderFloatTextures,
|
|
92
94
|
// enums
|
|
93
95
|
Enums,
|
|
94
96
|
CONSTANTS,
|
package/src/init.ts
CHANGED
|
@@ -13,11 +13,12 @@ import CentralizedWebWorkerManager from './webWorkerManager/webWorkerManager';
|
|
|
13
13
|
const defaultConfig: Cornerstone3DConfig = {
|
|
14
14
|
gpuTier: undefined,
|
|
15
15
|
detectGPUConfig: {},
|
|
16
|
+
isMobile: false, // is mobile device
|
|
16
17
|
rendering: {
|
|
17
18
|
useCPURendering: false,
|
|
18
19
|
// GPU rendering options
|
|
19
20
|
preferSizeOverAccuracy: false,
|
|
20
|
-
useNorm16Texture: false,
|
|
21
|
+
useNorm16Texture: false,
|
|
21
22
|
strictZSpacingForVolumeViewport: true,
|
|
22
23
|
},
|
|
23
24
|
// cache
|
|
@@ -27,11 +28,12 @@ const defaultConfig: Cornerstone3DConfig = {
|
|
|
27
28
|
let config: Cornerstone3DConfig = {
|
|
28
29
|
gpuTier: undefined,
|
|
29
30
|
detectGPUConfig: {},
|
|
31
|
+
isMobile: false, // is mobile device
|
|
30
32
|
rendering: {
|
|
31
33
|
useCPURendering: false,
|
|
32
34
|
// GPU rendering options
|
|
33
35
|
preferSizeOverAccuracy: false,
|
|
34
|
-
useNorm16Texture: false,
|
|
36
|
+
useNorm16Texture: false,
|
|
35
37
|
strictZSpacingForVolumeViewport: true,
|
|
36
38
|
},
|
|
37
39
|
// cache
|
|
@@ -77,23 +79,32 @@ function hasSharedArrayBuffer() {
|
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
function _hasNorm16TextureSupport() {
|
|
83
|
+
const gl = _getGLContext();
|
|
84
|
+
|
|
85
|
+
if (gl) {
|
|
86
|
+
const ext = (gl as WebGL2RenderingContext).getExtension(
|
|
87
|
+
'EXT_texture_norm16'
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
if (ext) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
84
94
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// 'EXT_texture_norm16'
|
|
88
|
-
// );
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
89
97
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
function isMobile() {
|
|
99
|
+
const ua = navigator.userAgent;
|
|
100
|
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
101
|
+
ua
|
|
102
|
+
);
|
|
103
|
+
}
|
|
94
104
|
|
|
95
|
-
|
|
96
|
-
|
|
105
|
+
function isMobileIOS() {
|
|
106
|
+
return /iPhone|iPod/.test(navigator.platform);
|
|
107
|
+
}
|
|
97
108
|
|
|
98
109
|
/**
|
|
99
110
|
* Initialize the cornerstone-core. If the browser has a webgl context and
|
|
@@ -112,6 +123,26 @@ async function init(configuration = config): Promise<boolean> {
|
|
|
112
123
|
// merge configs
|
|
113
124
|
config = deepMerge(defaultConfig, configuration);
|
|
114
125
|
|
|
126
|
+
config.isMobile = isMobile();
|
|
127
|
+
|
|
128
|
+
if (config.isMobile) {
|
|
129
|
+
// iOS devices don't have support for OES_texture_float_linear
|
|
130
|
+
// and thus we should use native data type if we are on iOS
|
|
131
|
+
if (isMobileIOS()) {
|
|
132
|
+
config.rendering.useNorm16Texture = _hasNorm16TextureSupport();
|
|
133
|
+
|
|
134
|
+
if (!config.rendering.useNorm16Texture) {
|
|
135
|
+
if (configuration.rendering?.preferSizeOverAccuracy) {
|
|
136
|
+
config.rendering.preferSizeOverAccuracy = true;
|
|
137
|
+
} else {
|
|
138
|
+
console.log(
|
|
139
|
+
'norm16 texture not supported, you can turn on the preferSizeOverAccuracy flag to use native data type, but be aware of the inaccuracy of the rendering in high bits'
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
115
146
|
// gpuTier
|
|
116
147
|
const hasWebGLContext = _hasActiveWebGLContext();
|
|
117
148
|
if (!hasWebGLContext) {
|
|
@@ -165,6 +196,23 @@ function setPreferSizeOverAccuracy(status: boolean): void {
|
|
|
165
196
|
_updateRenderingPipelinesForAllViewports();
|
|
166
197
|
}
|
|
167
198
|
|
|
199
|
+
/**
|
|
200
|
+
* Only IPhone IOS cannot render float textures right now due to the lack of support for OES_texture_float_linear.
|
|
201
|
+
* So we should not use float textures on IOS devices.
|
|
202
|
+
*/
|
|
203
|
+
function canRenderFloatTextures(): boolean {
|
|
204
|
+
const isMobile = config.isMobile;
|
|
205
|
+
if (!isMobile) {
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (isMobileIOS()) {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
|
|
168
216
|
/**
|
|
169
217
|
* Resets the cornerstone-core init state if it has been manually
|
|
170
218
|
* initialized to force use the cpu rendering (e.g., for tests)
|
|
@@ -286,4 +334,5 @@ export {
|
|
|
286
334
|
getConfiguration,
|
|
287
335
|
setConfiguration,
|
|
288
336
|
getWebWorkerManager,
|
|
337
|
+
canRenderFloatTextures,
|
|
289
338
|
};
|
|
@@ -8,6 +8,11 @@ type Cornerstone3DConfig = {
|
|
|
8
8
|
* https://github.com/pmndrs/detect-gpu/blob/master/src/index.ts#L82
|
|
9
9
|
*/
|
|
10
10
|
gpuTier?: TierResult;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Whether the device is mobile or not.
|
|
14
|
+
*/
|
|
15
|
+
isMobile: boolean;
|
|
11
16
|
/**
|
|
12
17
|
* When the `gpuTier` is not provided, the `detectGPUConfig` is passed as
|
|
13
18
|
* an argument to the `getGPUTier` method.
|
package/src/types/EventTypes.ts
CHANGED
|
@@ -56,7 +56,7 @@ type ColormapModifiedEventDetail = {
|
|
|
56
56
|
colormap: ColormapPublic;
|
|
57
57
|
/** Unique ID for the volume in the cache */
|
|
58
58
|
volumeId?: string;
|
|
59
|
-
}
|
|
59
|
+
};
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* DISPLAY_AREA_MODIFIED Event's data
|
|
@@ -119,6 +119,10 @@ type ImageVolumeModifiedEventDetail = {
|
|
|
119
119
|
imageVolume: IImageVolume;
|
|
120
120
|
/** FrameOfReferenceUID where the volume belongs to */
|
|
121
121
|
FrameOfReferenceUID: string;
|
|
122
|
+
/** number of frames */
|
|
123
|
+
numberOfFrames: number;
|
|
124
|
+
/** framesProcessed */
|
|
125
|
+
framesProcessed: number;
|
|
122
126
|
};
|
|
123
127
|
|
|
124
128
|
/**
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { vec3 } from 'gl-matrix';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
canRenderFloatTextures,
|
|
4
|
+
getConfiguration,
|
|
5
|
+
getShouldUseSharedArrayBuffer,
|
|
6
|
+
} from '../init';
|
|
3
7
|
import createFloat32SharedArray from './createFloat32SharedArray';
|
|
4
8
|
import createInt16SharedArray from './createInt16SharedArray';
|
|
5
9
|
import createUint16SharedArray from './createUInt16SharedArray';
|
|
@@ -7,6 +11,7 @@ import createUint8SharedArray from './createUint8SharedArray';
|
|
|
7
11
|
import getScalingParameters from './getScalingParameters';
|
|
8
12
|
import makeVolumeMetadata from './makeVolumeMetadata';
|
|
9
13
|
import sortImageIdsAndGetSpacing from './sortImageIdsAndGetSpacing';
|
|
14
|
+
import { hasFloatScalingParameters } from './hasFloatScalingParameters';
|
|
10
15
|
import { ImageVolumeProps, Mat3, Point3 } from '../types';
|
|
11
16
|
import cache from '../cache';
|
|
12
17
|
import { Events } from '../enums';
|
|
@@ -36,9 +41,8 @@ function generateVolumePropsFromImageIds(
|
|
|
36
41
|
|
|
37
42
|
// The prescale is ALWAYS used with modality LUT, so we can assume that
|
|
38
43
|
// if the rescale slope is not an integer, we need to use Float32
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
scalingParameters.rescaleSlope % 1 !== 0;
|
|
44
|
+
const floatAfterScale = hasFloatScalingParameters(scalingParameters);
|
|
45
|
+
const canRenderFloat = canRenderFloatTextures();
|
|
42
46
|
|
|
43
47
|
const {
|
|
44
48
|
BitsAllocated,
|
|
@@ -110,7 +114,7 @@ function generateVolumePropsFromImageIds(
|
|
|
110
114
|
// Temporary fix for 16 bit images to use Float32
|
|
111
115
|
// until the new dicom image loader handler the conversion
|
|
112
116
|
// correctly
|
|
113
|
-
if (!use16BitDataType ||
|
|
117
|
+
if (!use16BitDataType || (canRenderFloat && floatAfterScale)) {
|
|
114
118
|
sizeInBytes = length * 4;
|
|
115
119
|
scalarData = useSharedArrayBuffer
|
|
116
120
|
? createFloat32SharedArray(length)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ScalingParameters } from '../types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the scaling parameters contain a float rescale value.
|
|
5
|
+
* @param scalingParameters - The scaling parameters to check.
|
|
6
|
+
* @returns True if the scaling parameters contain a float rescale value, false otherwise.
|
|
7
|
+
*/
|
|
8
|
+
export const hasFloatScalingParameters = (
|
|
9
|
+
scalingParameters: ScalingParameters
|
|
10
|
+
): boolean => {
|
|
11
|
+
const hasFloatRescale = Object.values(scalingParameters).some(
|
|
12
|
+
(value) => typeof value === 'number' && !Number.isInteger(value)
|
|
13
|
+
);
|
|
14
|
+
return hasFloatRescale;
|
|
15
|
+
};
|
package/src/utilities/index.ts
CHANGED
|
@@ -71,6 +71,7 @@ import convertToGrayscale from './convertToGrayscale';
|
|
|
71
71
|
import getViewportImageIds from './getViewportImageIds';
|
|
72
72
|
import { getRandomSampleFromArray } from './getRandomSampleFromArray';
|
|
73
73
|
import { getVolumeId } from './getVolumeId';
|
|
74
|
+
import { hasFloatScalingParameters } from './hasFloatScalingParameters';
|
|
74
75
|
|
|
75
76
|
// name spaces
|
|
76
77
|
import * as planar from './planar';
|
|
@@ -162,4 +163,5 @@ export {
|
|
|
162
163
|
getRandomSampleFromArray,
|
|
163
164
|
getVolumeId,
|
|
164
165
|
color,
|
|
166
|
+
hasFloatScalingParameters,
|
|
165
167
|
};
|
|
@@ -113,17 +113,20 @@ export default function loadImageToCanvas(
|
|
|
113
113
|
);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
const { useNorm16Texture } =
|
|
116
|
+
const { useNorm16Texture, preferSizeOverAccuracy } =
|
|
117
|
+
getConfiguration().rendering;
|
|
118
|
+
const useNativeDataType = useNorm16Texture || preferSizeOverAccuracy;
|
|
117
119
|
|
|
118
120
|
// IMPORTANT: Request type should be passed if not the 'interaction'
|
|
119
121
|
// highest priority will be used for the request type in the imageRetrievalPool
|
|
120
122
|
const options = {
|
|
121
123
|
targetBuffer: {
|
|
122
|
-
type:
|
|
124
|
+
type: useNativeDataType ? undefined : 'Float32Array',
|
|
123
125
|
},
|
|
124
126
|
preScale: {
|
|
125
127
|
enabled: true,
|
|
126
128
|
},
|
|
129
|
+
useNativeDataType,
|
|
127
130
|
useRGBA: !!useCPURendering,
|
|
128
131
|
requestType,
|
|
129
132
|
};
|