@cornerstonejs/core 0.47.3 → 0.101.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.
- package/dist/cjs/RenderingEngine/StackViewport.d.ts +1 -0
- package/dist/cjs/RenderingEngine/StackViewport.js +21 -15
- package/dist/cjs/RenderingEngine/StackViewport.js.map +1 -1
- package/dist/cjs/types/CPUFallbackEnabledElement.d.ts +4 -34
- package/dist/cjs/types/CPUIImageData.d.ts +3 -3
- package/dist/cjs/types/IImage.d.ts +1 -1
- package/dist/cjs/types/ImagePixelModule.d.ts +13 -0
- package/dist/cjs/types/ImagePixelModule.js +3 -0
- package/dist/cjs/types/ImagePixelModule.js.map +1 -0
- package/dist/cjs/types/ImagePlaneModule.d.ts +16 -0
- package/dist/cjs/types/ImagePlaneModule.js +3 -0
- package/dist/cjs/types/ImagePlaneModule.js.map +1 -0
- package/dist/cjs/types/PixelDataTypedArray.d.ts +1 -0
- package/dist/cjs/types/PixelDataTypedArray.js +3 -0
- package/dist/cjs/types/PixelDataTypedArray.js.map +1 -0
- package/dist/cjs/types/index.d.ts +4 -1
- package/dist/esm/RenderingEngine/StackViewport.d.ts +1 -0
- package/dist/esm/RenderingEngine/StackViewport.js +23 -17
- package/dist/esm/RenderingEngine/StackViewport.js.map +1 -1
- package/dist/esm/types/CPUFallbackEnabledElement.d.ts +4 -34
- package/dist/esm/types/CPUIImageData.d.ts +3 -3
- package/dist/esm/types/IImage.d.ts +1 -1
- package/dist/esm/types/ImagePixelModule.d.ts +13 -0
- package/dist/esm/types/ImagePixelModule.js +2 -0
- package/dist/esm/types/ImagePixelModule.js.map +1 -0
- package/dist/esm/types/ImagePlaneModule.d.ts +16 -0
- package/dist/esm/types/ImagePlaneModule.js +2 -0
- package/dist/esm/types/ImagePlaneModule.js.map +1 -0
- package/dist/esm/types/PixelDataTypedArray.d.ts +1 -0
- package/dist/esm/types/PixelDataTypedArray.js +2 -0
- package/dist/esm/types/PixelDataTypedArray.js.map +1 -0
- package/dist/esm/types/index.d.ts +4 -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 +57 -75
- package/src/types/CPUFallbackEnabledElement.ts +4 -34
- package/src/types/CPUIImageData.ts +3 -3
- package/src/types/IImage.ts +1 -8
- package/src/types/ImagePixelModule.ts +14 -0
- package/src/types/ImagePlaneModule.ts +17 -0
- package/src/types/PixelDataTypedArray.ts +7 -0
- package/src/types/index.ts +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.101.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/umd/index.js",
|
|
6
6
|
"types": "dist/esm/index.d.ts",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"type": "individual",
|
|
44
44
|
"url": "https://ohif.org/donate"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "186364d5ecda841550ca4928715a988ddf585c7e"
|
|
47
47
|
}
|
|
@@ -69,22 +69,14 @@ import cache from '../cache';
|
|
|
69
69
|
import correctShift from './helpers/cpuFallback/rendering/correctShift';
|
|
70
70
|
import { ImageActor } from '../types/IActor';
|
|
71
71
|
import createLinearRGBTransferFunction from '../utilities/createLinearRGBTransferFunction';
|
|
72
|
+
import {
|
|
73
|
+
PixelDataTypedArray,
|
|
74
|
+
ImagePixelModule,
|
|
75
|
+
ImagePlaneModule,
|
|
76
|
+
} from '../types';
|
|
72
77
|
|
|
73
78
|
const EPSILON = 1; // Slice Thickness
|
|
74
79
|
|
|
75
|
-
interface ImagePixelModule {
|
|
76
|
-
bitsAllocated: number;
|
|
77
|
-
bitsStored: number;
|
|
78
|
-
samplesPerPixel: number;
|
|
79
|
-
highBit: number;
|
|
80
|
-
photometricInterpretation: string;
|
|
81
|
-
pixelRepresentation: string;
|
|
82
|
-
windowWidth: number | number[];
|
|
83
|
-
windowCenter: number | number[];
|
|
84
|
-
voiLUTFunction: VOILUTFunctionType;
|
|
85
|
-
modality: string;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
80
|
interface ImageDataMetaData {
|
|
89
81
|
bitsAllocated: number;
|
|
90
82
|
numComps: number;
|
|
@@ -93,25 +85,9 @@ interface ImageDataMetaData {
|
|
|
93
85
|
dimensions: Point3;
|
|
94
86
|
spacing: Point3;
|
|
95
87
|
numVoxels: number;
|
|
96
|
-
imagePlaneModule:
|
|
88
|
+
imagePlaneModule: ImagePlaneModule;
|
|
97
89
|
imagePixelModule: ImagePixelModule;
|
|
98
90
|
}
|
|
99
|
-
|
|
100
|
-
interface ImagePlaneModule {
|
|
101
|
-
columnCosines?: Point3;
|
|
102
|
-
columnPixelSpacing?: number;
|
|
103
|
-
imageOrientationPatient?: Float32Array;
|
|
104
|
-
imagePositionPatient?: Point3;
|
|
105
|
-
pixelSpacing?: Point2;
|
|
106
|
-
rowCosines?: Point3;
|
|
107
|
-
rowPixelSpacing?: number;
|
|
108
|
-
sliceLocation?: number;
|
|
109
|
-
sliceThickness?: number;
|
|
110
|
-
frameOfReferenceUID: string;
|
|
111
|
-
columns: number;
|
|
112
|
-
rows: number;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
91
|
// TODO This needs to be exposed as its published to consumers.
|
|
116
92
|
type CalibrationEvent = {
|
|
117
93
|
rowScale: number;
|
|
@@ -164,7 +140,7 @@ class StackViewport extends Viewport implements IStackViewport {
|
|
|
164
140
|
// yet widely supported in all hardwares. This feature can be turned on
|
|
165
141
|
// by setting useNorm16Texture or preferSizeOverAccuracy in the configuration
|
|
166
142
|
private useNativeDataType = false;
|
|
167
|
-
private cpuImagePixelData:
|
|
143
|
+
private cpuImagePixelData: PixelDataTypedArray;
|
|
168
144
|
private cpuRenderingInvalidated: boolean;
|
|
169
145
|
private csImage: IImage;
|
|
170
146
|
|
|
@@ -1750,49 +1726,7 @@ class StackViewport extends Viewport implements IStackViewport {
|
|
|
1750
1726
|
|
|
1751
1727
|
triggerEvent(this.element, Events.STACK_NEW_IMAGE, eventDetail);
|
|
1752
1728
|
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
const viewport = getDefaultViewport(
|
|
1756
|
-
this.canvas,
|
|
1757
|
-
image,
|
|
1758
|
-
this.modality,
|
|
1759
|
-
this._cpuFallbackEnabledElement.viewport.colormap
|
|
1760
|
-
);
|
|
1761
|
-
|
|
1762
|
-
const { windowCenter, windowWidth } = viewport.voi;
|
|
1763
|
-
this.voiRange = windowLevelUtil.toLowHighRange(
|
|
1764
|
-
windowWidth,
|
|
1765
|
-
windowCenter
|
|
1766
|
-
);
|
|
1767
|
-
|
|
1768
|
-
this._cpuFallbackEnabledElement.image = image;
|
|
1769
|
-
this._cpuFallbackEnabledElement.metadata = {
|
|
1770
|
-
...metadata,
|
|
1771
|
-
};
|
|
1772
|
-
this.cpuImagePixelData = image.getPixelData();
|
|
1773
|
-
|
|
1774
|
-
const viewportSettingToUse = Object.assign(
|
|
1775
|
-
{},
|
|
1776
|
-
viewport,
|
|
1777
|
-
this._cpuFallbackEnabledElement.viewport
|
|
1778
|
-
);
|
|
1779
|
-
|
|
1780
|
-
// Important: this.stackInvalidated is different than cpuRenderingInvalidated. The
|
|
1781
|
-
// former is being used to maintain the previous state of the viewport
|
|
1782
|
-
// in the same stack, the latter is used to trigger drawImageSync
|
|
1783
|
-
this._cpuFallbackEnabledElement.viewport = this.stackInvalidated
|
|
1784
|
-
? viewport
|
|
1785
|
-
: viewportSettingToUse;
|
|
1786
|
-
|
|
1787
|
-
// used the previous state of the viewport, then stackInvalidated is set to false
|
|
1788
|
-
this.stackInvalidated = false;
|
|
1789
|
-
|
|
1790
|
-
// new viewport is set to the current viewport, then cpuRenderingInvalidated is set to true
|
|
1791
|
-
this.cpuRenderingInvalidated = true;
|
|
1792
|
-
|
|
1793
|
-
this._cpuFallbackEnabledElement.transform = calculateTransform(
|
|
1794
|
-
this._cpuFallbackEnabledElement
|
|
1795
|
-
);
|
|
1729
|
+
this._updateToDisplayImageCPU(image);
|
|
1796
1730
|
|
|
1797
1731
|
// Todo: trigger an event to allow applications to hook into END of loading state
|
|
1798
1732
|
// Currently we use loadHandlerManagers for this
|
|
@@ -1975,7 +1909,12 @@ class StackViewport extends Viewport implements IStackViewport {
|
|
|
1975
1909
|
*/
|
|
1976
1910
|
public renderImageObject = (image) => {
|
|
1977
1911
|
this._setCSImage(image);
|
|
1978
|
-
|
|
1912
|
+
|
|
1913
|
+
const renderFn = this.useCPURendering
|
|
1914
|
+
? this._updateToDisplayImageCPU
|
|
1915
|
+
: this._updateActorToDisplayImageId;
|
|
1916
|
+
|
|
1917
|
+
renderFn.call(this, image);
|
|
1979
1918
|
};
|
|
1980
1919
|
|
|
1981
1920
|
private _setCSImage = (image) => {
|
|
@@ -1983,6 +1922,49 @@ class StackViewport extends Viewport implements IStackViewport {
|
|
|
1983
1922
|
this.csImage = image;
|
|
1984
1923
|
};
|
|
1985
1924
|
|
|
1925
|
+
private _updateToDisplayImageCPU(image: IImage) {
|
|
1926
|
+
const metadata = this._getImageDataMetadata(image) as ImageDataMetaData;
|
|
1927
|
+
|
|
1928
|
+
const viewport = getDefaultViewport(
|
|
1929
|
+
this.canvas,
|
|
1930
|
+
image,
|
|
1931
|
+
this.modality,
|
|
1932
|
+
this._cpuFallbackEnabledElement.viewport.colormap
|
|
1933
|
+
);
|
|
1934
|
+
|
|
1935
|
+
const { windowCenter, windowWidth } = viewport.voi;
|
|
1936
|
+
this.voiRange = windowLevelUtil.toLowHighRange(windowWidth, windowCenter);
|
|
1937
|
+
|
|
1938
|
+
this._cpuFallbackEnabledElement.image = image;
|
|
1939
|
+
this._cpuFallbackEnabledElement.metadata = {
|
|
1940
|
+
...metadata,
|
|
1941
|
+
};
|
|
1942
|
+
this.cpuImagePixelData = image.getPixelData();
|
|
1943
|
+
|
|
1944
|
+
const viewportSettingToUse = Object.assign(
|
|
1945
|
+
{},
|
|
1946
|
+
viewport,
|
|
1947
|
+
this._cpuFallbackEnabledElement.viewport
|
|
1948
|
+
);
|
|
1949
|
+
|
|
1950
|
+
// Important: this.stackInvalidated is different than cpuRenderingInvalidated. The
|
|
1951
|
+
// former is being used to maintain the previous state of the viewport
|
|
1952
|
+
// in the same stack, the latter is used to trigger drawImageSync
|
|
1953
|
+
this._cpuFallbackEnabledElement.viewport = this.stackInvalidated
|
|
1954
|
+
? viewport
|
|
1955
|
+
: viewportSettingToUse;
|
|
1956
|
+
|
|
1957
|
+
// used the previous state of the viewport, then stackInvalidated is set to false
|
|
1958
|
+
this.stackInvalidated = false;
|
|
1959
|
+
|
|
1960
|
+
// new viewport is set to the current viewport, then cpuRenderingInvalidated is set to true
|
|
1961
|
+
this.cpuRenderingInvalidated = true;
|
|
1962
|
+
|
|
1963
|
+
this._cpuFallbackEnabledElement.transform = calculateTransform(
|
|
1964
|
+
this._cpuFallbackEnabledElement
|
|
1965
|
+
);
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1986
1968
|
/**
|
|
1987
1969
|
* It updates the volume actor with the retrieved cornerstone image.
|
|
1988
1970
|
* It first checks if the new image has the same dimensions, spacings, and
|
|
@@ -6,6 +6,8 @@ import CPUFallbackViewport from './CPUFallbackViewport';
|
|
|
6
6
|
import CPUFallbackTransform from './CPUFallbackTransform';
|
|
7
7
|
import CPUFallbackColormap from './CPUFallbackColormap';
|
|
8
8
|
import CPUFallbackRenderingTools from './CPUFallbackRenderingTools';
|
|
9
|
+
import { ImagePlaneModule } from './ImagePlaneModule';
|
|
10
|
+
import { ImagePixelModule } from './ImagePixelModule';
|
|
9
11
|
|
|
10
12
|
interface CPUFallbackEnabledElement {
|
|
11
13
|
scale?: number;
|
|
@@ -31,40 +33,8 @@ interface CPUFallbackEnabledElement {
|
|
|
31
33
|
/** Last spacing is always EPSILON for CPU */
|
|
32
34
|
spacing?: Point3;
|
|
33
35
|
origin?: Point3;
|
|
34
|
-
imagePlaneModule?:
|
|
35
|
-
|
|
36
|
-
rows: number;
|
|
37
|
-
columns: number;
|
|
38
|
-
imageOrientationPatient: number[];
|
|
39
|
-
rowCosines: Point3;
|
|
40
|
-
columnCosines: Point3;
|
|
41
|
-
imagePositionPatient: number[];
|
|
42
|
-
sliceThickness?: number;
|
|
43
|
-
sliceLocation?: number;
|
|
44
|
-
pixelSpacing: Point2;
|
|
45
|
-
rowPixelSpacing: number;
|
|
46
|
-
columnPixelSpacing: number;
|
|
47
|
-
};
|
|
48
|
-
imagePixelModule?: {
|
|
49
|
-
samplesPerPixel: number;
|
|
50
|
-
photometricInterpretation: string;
|
|
51
|
-
rows: number;
|
|
52
|
-
columns: number;
|
|
53
|
-
bitsAllocated: number;
|
|
54
|
-
bitsStored: number;
|
|
55
|
-
highBit: number;
|
|
56
|
-
pixelRepresentation: number;
|
|
57
|
-
planarConfiguration?: number;
|
|
58
|
-
pixelAspectRatio?: number;
|
|
59
|
-
smallestPixelValue?: number;
|
|
60
|
-
largestPixelValue?: number;
|
|
61
|
-
redPaletteColorLookupTableDescriptor?: number[];
|
|
62
|
-
greenPaletteColorLookupTableDescriptor?: number[];
|
|
63
|
-
bluePaletteColorLookupTableDescriptor?: number[];
|
|
64
|
-
redPaletteColorLookupTableData: number[];
|
|
65
|
-
greenPaletteColorLookupTableData: number[];
|
|
66
|
-
bluePaletteColorLookupTableData: number[];
|
|
67
|
-
};
|
|
36
|
+
imagePlaneModule?: ImagePlaneModule;
|
|
37
|
+
imagePixelModule?: ImagePixelModule;
|
|
68
38
|
};
|
|
69
39
|
}
|
|
70
40
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Point3, Scaling, Mat3 } from '../types';
|
|
1
|
+
import { Point3, Scaling, Mat3, PixelDataTypedArray } from '../types';
|
|
2
2
|
|
|
3
3
|
type CPUImageData = {
|
|
4
4
|
worldToIndex?: (point: Point3) => Point3;
|
|
@@ -8,7 +8,7 @@ type CPUImageData = {
|
|
|
8
8
|
/** Last spacing is always EPSILON */
|
|
9
9
|
getSpacing?: () => Point3;
|
|
10
10
|
getDirection?: () => Mat3;
|
|
11
|
-
getScalarData?: () =>
|
|
11
|
+
getScalarData?: () => PixelDataTypedArray;
|
|
12
12
|
/** Last index is always 1 */
|
|
13
13
|
getDimensions?: () => Point3;
|
|
14
14
|
};
|
|
@@ -20,7 +20,7 @@ type CPUIImageData = {
|
|
|
20
20
|
origin: Point3;
|
|
21
21
|
imageData: CPUImageData;
|
|
22
22
|
metadata: { Modality: string };
|
|
23
|
-
scalarData:
|
|
23
|
+
scalarData: PixelDataTypedArray;
|
|
24
24
|
scaling: Scaling;
|
|
25
25
|
/** whether the image has pixel spacing and it is not undefined */
|
|
26
26
|
hasPixelSpacing?: boolean;
|
package/src/types/IImage.ts
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import CPUFallbackLUT from './CPUFallbackLUT';
|
|
2
2
|
import CPUFallbackColormap from './CPUFallbackColormap';
|
|
3
3
|
import CPUFallbackEnabledElement from './CPUFallbackEnabledElement';
|
|
4
|
-
|
|
5
|
-
type PixelDataTypedArray =
|
|
6
|
-
| Float32Array
|
|
7
|
-
| Int16Array
|
|
8
|
-
| Uint16Array
|
|
9
|
-
| Uint8Array
|
|
10
|
-
| Int8Array
|
|
11
|
-
| Uint8ClampedArray;
|
|
4
|
+
import { PixelDataTypedArray } from './PixelDataTypedArray';
|
|
12
5
|
|
|
13
6
|
/**
|
|
14
7
|
* Cornerstone Image interface, it is used for both CPU and GPU rendering
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { VOILUTFunctionType } from '../enums';
|
|
2
|
+
|
|
3
|
+
export interface ImagePixelModule {
|
|
4
|
+
bitsAllocated: number;
|
|
5
|
+
bitsStored: number;
|
|
6
|
+
samplesPerPixel: number;
|
|
7
|
+
highBit: number;
|
|
8
|
+
photometricInterpretation: string;
|
|
9
|
+
pixelRepresentation: string;
|
|
10
|
+
windowWidth: number | number[];
|
|
11
|
+
windowCenter: number | number[];
|
|
12
|
+
voiLUTFunction: VOILUTFunctionType;
|
|
13
|
+
modality: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Point2 from './Point2';
|
|
2
|
+
import Point3 from './Point3';
|
|
3
|
+
|
|
4
|
+
export interface ImagePlaneModule {
|
|
5
|
+
columnCosines?: Point3;
|
|
6
|
+
columnPixelSpacing?: number;
|
|
7
|
+
imageOrientationPatient?: Float32Array;
|
|
8
|
+
imagePositionPatient?: Point3;
|
|
9
|
+
pixelSpacing?: Point2;
|
|
10
|
+
rowCosines?: Point3;
|
|
11
|
+
rowPixelSpacing?: number;
|
|
12
|
+
sliceLocation?: number;
|
|
13
|
+
sliceThickness?: number;
|
|
14
|
+
frameOfReferenceUID: string;
|
|
15
|
+
columns: number;
|
|
16
|
+
rows: number;
|
|
17
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -77,6 +77,9 @@ import type { IContour } from './IContour';
|
|
|
77
77
|
import type RGB from './RGB';
|
|
78
78
|
import { ColormapPublic, ColormapRegistration } from './Colormap';
|
|
79
79
|
import type { ViewportProperties } from './ViewportProperties';
|
|
80
|
+
import type { PixelDataTypedArray } from './PixelDataTypedArray';
|
|
81
|
+
import type { ImagePixelModule } from './ImagePixelModule';
|
|
82
|
+
import type { ImagePlaneModule } from './ImagePlaneModule';
|
|
80
83
|
|
|
81
84
|
export type {
|
|
82
85
|
// config
|
|
@@ -164,4 +167,8 @@ export type {
|
|
|
164
167
|
RGB,
|
|
165
168
|
ColormapPublic,
|
|
166
169
|
ColormapRegistration,
|
|
170
|
+
// PixelData
|
|
171
|
+
PixelDataTypedArray,
|
|
172
|
+
ImagePixelModule,
|
|
173
|
+
ImagePlaneModule,
|
|
167
174
|
};
|