@cornerstonejs/core 0.36.3 → 0.36.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 (223) hide show
  1. package/dist/cjs/utilities/getSliceRange.js +2 -1
  2. package/dist/cjs/utilities/getSliceRange.js.map +1 -1
  3. package/dist/esm/utilities/getSliceRange.js +2 -1
  4. package/dist/esm/utilities/getSliceRange.js.map +1 -1
  5. package/dist/umd/index.js +1 -1
  6. package/dist/umd/index.js.map +1 -1
  7. package/package.json +4 -3
  8. package/src/RenderingEngine/BaseVolumeViewport.ts +847 -0
  9. package/src/RenderingEngine/RenderingEngine.ts +1364 -0
  10. package/src/RenderingEngine/StackViewport.ts +2690 -0
  11. package/src/RenderingEngine/Viewport.ts +1244 -0
  12. package/src/RenderingEngine/VolumeViewport.ts +420 -0
  13. package/src/RenderingEngine/VolumeViewport3D.ts +42 -0
  14. package/src/RenderingEngine/getRenderingEngine.ts +34 -0
  15. package/src/RenderingEngine/helpers/addVolumesToViewports.ts +52 -0
  16. package/src/RenderingEngine/helpers/cpuFallback/colors/colormap.ts +343 -0
  17. package/src/RenderingEngine/helpers/cpuFallback/colors/index.ts +4 -0
  18. package/src/RenderingEngine/helpers/cpuFallback/colors/lookupTable.ts +469 -0
  19. package/src/RenderingEngine/helpers/cpuFallback/drawImageSync.ts +58 -0
  20. package/src/RenderingEngine/helpers/cpuFallback/rendering/calculateTransform.ts +136 -0
  21. package/src/RenderingEngine/helpers/cpuFallback/rendering/canvasToPixel.ts +25 -0
  22. package/src/RenderingEngine/helpers/cpuFallback/rendering/computeAutoVoi.ts +47 -0
  23. package/src/RenderingEngine/helpers/cpuFallback/rendering/correctShift.ts +38 -0
  24. package/src/RenderingEngine/helpers/cpuFallback/rendering/createViewport.ts +64 -0
  25. package/src/RenderingEngine/helpers/cpuFallback/rendering/doesImageNeedToBeRendered.ts +36 -0
  26. package/src/RenderingEngine/helpers/cpuFallback/rendering/fitToWindow.ts +22 -0
  27. package/src/RenderingEngine/helpers/cpuFallback/rendering/generateColorLUT.ts +60 -0
  28. package/src/RenderingEngine/helpers/cpuFallback/rendering/generateLut.ts +83 -0
  29. package/src/RenderingEngine/helpers/cpuFallback/rendering/getDefaultViewport.ts +88 -0
  30. package/src/RenderingEngine/helpers/cpuFallback/rendering/getImageFitScale.ts +52 -0
  31. package/src/RenderingEngine/helpers/cpuFallback/rendering/getImageSize.ts +55 -0
  32. package/src/RenderingEngine/helpers/cpuFallback/rendering/getLut.ts +53 -0
  33. package/src/RenderingEngine/helpers/cpuFallback/rendering/getModalityLut.ts +55 -0
  34. package/src/RenderingEngine/helpers/cpuFallback/rendering/getTransform.ts +17 -0
  35. package/src/RenderingEngine/helpers/cpuFallback/rendering/getVOILut.ts +74 -0
  36. package/src/RenderingEngine/helpers/cpuFallback/rendering/initializeRenderCanvas.ts +37 -0
  37. package/src/RenderingEngine/helpers/cpuFallback/rendering/lutMatches.ts +21 -0
  38. package/src/RenderingEngine/helpers/cpuFallback/rendering/now.ts +13 -0
  39. package/src/RenderingEngine/helpers/cpuFallback/rendering/pixelToCanvas.ts +22 -0
  40. package/src/RenderingEngine/helpers/cpuFallback/rendering/renderColorImage.ts +193 -0
  41. package/src/RenderingEngine/helpers/cpuFallback/rendering/renderGrayscaleImage.ts +166 -0
  42. package/src/RenderingEngine/helpers/cpuFallback/rendering/renderPseudoColorImage.ts +203 -0
  43. package/src/RenderingEngine/helpers/cpuFallback/rendering/resetCamera.ts +32 -0
  44. package/src/RenderingEngine/helpers/cpuFallback/rendering/resize.ts +109 -0
  45. package/src/RenderingEngine/helpers/cpuFallback/rendering/saveLastRendered.ts +36 -0
  46. package/src/RenderingEngine/helpers/cpuFallback/rendering/setDefaultViewport.ts +17 -0
  47. package/src/RenderingEngine/helpers/cpuFallback/rendering/setToPixelCoordinateSystem.ts +32 -0
  48. package/src/RenderingEngine/helpers/cpuFallback/rendering/storedColorPixelDataToCanvasImageData.ts +58 -0
  49. package/src/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageData.ts +76 -0
  50. package/src/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageDataColorLUT.ts +60 -0
  51. package/src/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageDataPET.ts +50 -0
  52. package/src/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageDataPseudocolorLUT.ts +66 -0
  53. package/src/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageDataPseudocolorLUTPET.ts +68 -0
  54. package/src/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageDataRGBA.ts +81 -0
  55. package/src/RenderingEngine/helpers/cpuFallback/rendering/storedRGBAPixelDataToCanvasImageData.ts +56 -0
  56. package/src/RenderingEngine/helpers/cpuFallback/rendering/transform.ts +126 -0
  57. package/src/RenderingEngine/helpers/cpuFallback/rendering/validator.ts +31 -0
  58. package/src/RenderingEngine/helpers/createVolumeActor.ts +103 -0
  59. package/src/RenderingEngine/helpers/createVolumeMapper.ts +37 -0
  60. package/src/RenderingEngine/helpers/getOrCreateCanvas.ts +58 -0
  61. package/src/RenderingEngine/helpers/index.ts +15 -0
  62. package/src/RenderingEngine/helpers/isRgbaSourceRgbDest.ts +1 -0
  63. package/src/RenderingEngine/helpers/setDefaultVolumeVOI.ts +227 -0
  64. package/src/RenderingEngine/helpers/setVolumesForViewports.ts +52 -0
  65. package/src/RenderingEngine/helpers/viewportTypeToViewportClass.ts +14 -0
  66. package/src/RenderingEngine/helpers/viewportTypeUsesCustomRenderingPipeline.ts +7 -0
  67. package/src/RenderingEngine/helpers/volumeNewImageEventDispatcher.ts +75 -0
  68. package/src/RenderingEngine/index.ts +23 -0
  69. package/src/RenderingEngine/renderingEngineCache.ts +43 -0
  70. package/src/RenderingEngine/vtkClasses/index.js +11 -0
  71. package/src/RenderingEngine/vtkClasses/vtkOffscreenMultiRenderWindow.js +149 -0
  72. package/src/RenderingEngine/vtkClasses/vtkSharedVolumeMapper.js +52 -0
  73. package/src/RenderingEngine/vtkClasses/vtkSlabCamera.d.ts +781 -0
  74. package/src/RenderingEngine/vtkClasses/vtkSlabCamera.js +155 -0
  75. package/src/RenderingEngine/vtkClasses/vtkStreamingOpenGLRenderWindow.js +47 -0
  76. package/src/RenderingEngine/vtkClasses/vtkStreamingOpenGLTexture.js +272 -0
  77. package/src/RenderingEngine/vtkClasses/vtkStreamingOpenGLViewNodeFactory.js +159 -0
  78. package/src/RenderingEngine/vtkClasses/vtkStreamingOpenGLVolumeMapper.js +319 -0
  79. package/src/Settings.ts +294 -0
  80. package/src/cache/cache.ts +854 -0
  81. package/src/cache/classes/Contour.ts +70 -0
  82. package/src/cache/classes/ContourSet.ts +151 -0
  83. package/src/cache/classes/ImageVolume.ts +155 -0
  84. package/src/cache/index.ts +5 -0
  85. package/src/constants/cpuColormaps.ts +1537 -0
  86. package/src/constants/epsilon.ts +3 -0
  87. package/src/constants/index.ts +13 -0
  88. package/src/constants/mprCameraValues.ts +20 -0
  89. package/src/constants/rendering.ts +8 -0
  90. package/src/constants/viewportPresets.ts +357 -0
  91. package/src/enums/BlendModes.ts +23 -0
  92. package/src/enums/ContourType.ts +6 -0
  93. package/src/enums/Events.ts +196 -0
  94. package/src/enums/GeometryType.ts +5 -0
  95. package/src/enums/InterpolationType.ts +13 -0
  96. package/src/enums/OrientationAxis.ts +8 -0
  97. package/src/enums/RequestType.ts +13 -0
  98. package/src/enums/SharedArrayBufferModes.ts +11 -0
  99. package/src/enums/VOILUTFunctionType.ts +10 -0
  100. package/src/enums/ViewportType.ts +21 -0
  101. package/src/enums/index.ts +23 -0
  102. package/src/eventTarget.ts +67 -0
  103. package/src/getEnabledElement.ts +105 -0
  104. package/src/global.ts +8 -0
  105. package/src/index.ts +123 -0
  106. package/src/init.ts +247 -0
  107. package/src/loaders/geometryLoader.ts +108 -0
  108. package/src/loaders/imageLoader.ts +298 -0
  109. package/src/loaders/volumeLoader.ts +477 -0
  110. package/src/metaData.ts +84 -0
  111. package/src/requestPool/imageLoadPoolManager.ts +43 -0
  112. package/src/requestPool/imageRetrievalPoolManager.ts +25 -0
  113. package/src/requestPool/requestPoolManager.ts +329 -0
  114. package/src/types/ActorSliceRange.ts +17 -0
  115. package/src/types/CPUFallbackColormap.ts +23 -0
  116. package/src/types/CPUFallbackColormapData.ts +12 -0
  117. package/src/types/CPUFallbackColormapsData.ts +7 -0
  118. package/src/types/CPUFallbackEnabledElement.ts +71 -0
  119. package/src/types/CPUFallbackLUT.ts +5 -0
  120. package/src/types/CPUFallbackLookupTable.ts +17 -0
  121. package/src/types/CPUFallbackRenderingTools.ts +25 -0
  122. package/src/types/CPUFallbackTransform.ts +16 -0
  123. package/src/types/CPUFallbackViewport.ts +29 -0
  124. package/src/types/CPUFallbackViewportDisplayedArea.ts +15 -0
  125. package/src/types/CPUIImageData.ts +47 -0
  126. package/src/types/ContourData.ts +19 -0
  127. package/src/types/Cornerstone3DConfig.ts +31 -0
  128. package/src/types/CustomEventType.ts +14 -0
  129. package/src/types/EventTypes.ts +403 -0
  130. package/src/types/FlipDirection.ts +9 -0
  131. package/src/types/IActor.ts +23 -0
  132. package/src/types/ICache.ts +28 -0
  133. package/src/types/ICachedGeometry.ts +13 -0
  134. package/src/types/ICachedImage.ts +13 -0
  135. package/src/types/ICachedVolume.ts +12 -0
  136. package/src/types/ICamera.ts +36 -0
  137. package/src/types/IContour.ts +18 -0
  138. package/src/types/IContourSet.ts +56 -0
  139. package/src/types/IDynamicImageVolume.ts +18 -0
  140. package/src/types/IEnabledElement.ts +21 -0
  141. package/src/types/IGeometry.ts +12 -0
  142. package/src/types/IImage.ts +113 -0
  143. package/src/types/IImageData.ts +45 -0
  144. package/src/types/IImageVolume.ts +78 -0
  145. package/src/types/ILoadObject.ts +36 -0
  146. package/src/types/IRegisterImageLoader.ts +10 -0
  147. package/src/types/IRenderingEngine.ts +28 -0
  148. package/src/types/IStackViewport.ts +138 -0
  149. package/src/types/IStreamingImageVolume.ts +13 -0
  150. package/src/types/IStreamingVolumeProperties.ts +14 -0
  151. package/src/types/IViewport.ts +149 -0
  152. package/src/types/IViewportId.ts +9 -0
  153. package/src/types/IVolume.ts +45 -0
  154. package/src/types/IVolumeInput.ts +36 -0
  155. package/src/types/IVolumeViewport.ts +141 -0
  156. package/src/types/ImageLoaderFn.ts +16 -0
  157. package/src/types/ImageSliceData.ts +6 -0
  158. package/src/types/Mat3.ts +16 -0
  159. package/src/types/Metadata.ts +39 -0
  160. package/src/types/OrientationVectors.ts +36 -0
  161. package/src/types/Plane.ts +6 -0
  162. package/src/types/Point2.ts +6 -0
  163. package/src/types/Point3.ts +6 -0
  164. package/src/types/Point4.ts +6 -0
  165. package/src/types/ScalingParameters.ts +27 -0
  166. package/src/types/StackViewportProperties.ts +25 -0
  167. package/src/types/TransformMatrix2D.ts +4 -0
  168. package/src/types/ViewportInputOptions.ts +21 -0
  169. package/src/types/ViewportPreset.ts +14 -0
  170. package/src/types/VolumeLoaderFn.ts +18 -0
  171. package/src/types/VolumeViewportProperties.ts +14 -0
  172. package/src/types/index.ts +157 -0
  173. package/src/types/voi.ts +15 -0
  174. package/src/utilities/actorCheck.ts +24 -0
  175. package/src/utilities/applyPreset.ts +132 -0
  176. package/src/utilities/calculateViewportsSpatialRegistration.ts +74 -0
  177. package/src/utilities/calibratedPixelSpacingMetadataProvider.ts +38 -0
  178. package/src/utilities/createFloat32SharedArray.ts +45 -0
  179. package/src/utilities/createInt16SharedArray.ts +43 -0
  180. package/src/utilities/createLinearRGBTransferFunction.ts +22 -0
  181. package/src/utilities/createSigmoidRGBTransferFunction.ts +63 -0
  182. package/src/utilities/createUInt16SharedArray.ts +43 -0
  183. package/src/utilities/createUint8SharedArray.ts +45 -0
  184. package/src/utilities/deepFreeze.ts +19 -0
  185. package/src/utilities/deepMerge.ts +81 -0
  186. package/src/utilities/getClosestImageId.ts +80 -0
  187. package/src/utilities/getClosestStackImageIndexForPoint.ts +116 -0
  188. package/src/utilities/getImageSliceDataForVolumeViewport.ts +61 -0
  189. package/src/utilities/getMinMax.ts +31 -0
  190. package/src/utilities/getRuntimeId.ts +54 -0
  191. package/src/utilities/getScalarDataType.ts +31 -0
  192. package/src/utilities/getScalingParameters.ts +35 -0
  193. package/src/utilities/getSliceRange.ts +86 -0
  194. package/src/utilities/getSpacingInNormalDirection.ts +44 -0
  195. package/src/utilities/getTargetVolumeAndSpacingInNormalDir.ts +126 -0
  196. package/src/utilities/getViewportImageCornersInWorld.ts +102 -0
  197. package/src/utilities/getViewportsWithImageURI.ts +46 -0
  198. package/src/utilities/getViewportsWithVolumeId.ts +38 -0
  199. package/src/utilities/getVoiFromSigmoidRGBTransferFunction.ts +23 -0
  200. package/src/utilities/getVolumeActorCorners.ts +24 -0
  201. package/src/utilities/getVolumeSliceRangeInfo.ts +52 -0
  202. package/src/utilities/getVolumeViewportScrollInfo.ts +32 -0
  203. package/src/utilities/getVolumeViewportsContainingSameVolumes.ts +58 -0
  204. package/src/utilities/hasNaNValues.ts +12 -0
  205. package/src/utilities/imageIdToURI.ts +10 -0
  206. package/src/utilities/imageToWorldCoords.ts +54 -0
  207. package/src/utilities/index.ts +100 -0
  208. package/src/utilities/indexWithinDimensions.ts +27 -0
  209. package/src/utilities/invertRgbTransferFunction.ts +36 -0
  210. package/src/utilities/isEqual.ts +27 -0
  211. package/src/utilities/isOpposite.ts +23 -0
  212. package/src/utilities/isTypedArray.ts +20 -0
  213. package/src/utilities/loadImageToCanvas.ts +80 -0
  214. package/src/utilities/planar.ts +91 -0
  215. package/src/utilities/renderToCanvas.ts +32 -0
  216. package/src/utilities/scaleRgbTransferFunction.ts +37 -0
  217. package/src/utilities/snapFocalPointToSlice.ts +78 -0
  218. package/src/utilities/spatialRegistrationMetadataProvider.ts +50 -0
  219. package/src/utilities/transformWorldToIndex.ts +16 -0
  220. package/src/utilities/triggerEvent.ts +38 -0
  221. package/src/utilities/uuidv4.ts +13 -0
  222. package/src/utilities/windowLevel.ts +39 -0
  223. package/src/utilities/worldToImageCoords.ts +64 -0
@@ -0,0 +1,36 @@
1
+ import { VolumeActor } from './IActor';
2
+ import BlendModes from '../enums/BlendModes';
3
+
4
+ /**
5
+ * Volume input callback type, used to perform operations on the volume data
6
+ * after it has been loaded.
7
+ */
8
+ type VolumeInputCallback = (params: {
9
+ /** vtk volume actor */
10
+ volumeActor: VolumeActor;
11
+ /** unique volume Id in the cache */
12
+ volumeId: string;
13
+ }) => unknown;
14
+
15
+ /**
16
+ * VolumeInput that can be used to add a volume to a viewport. It includes
17
+ * mandatory `volumeId` but other options such as `visibility`, `blendMode`,
18
+ * `slabThickness` and `callback` can also be provided
19
+ */
20
+ interface IVolumeInput {
21
+ /** Volume ID of the volume in the cache */
22
+ volumeId: string;
23
+ // actorUID for segmentations, since two segmentations with the same volumeId
24
+ // can have different representations
25
+ actorUID?: string;
26
+ /** Visibility of the volume - by default it is true */
27
+ visibility?: boolean;
28
+ /** Callback to be called when the volume is added to the viewport */
29
+ callback?: VolumeInputCallback;
30
+ /** Blend mode of the volume - by default it is `additive` */
31
+ blendMode?: BlendModes;
32
+ /** Slab thickness of the volume - by default it is 0.05*/
33
+ slabThickness?: number;
34
+ }
35
+
36
+ export type { IVolumeInput, VolumeInputCallback };
@@ -0,0 +1,141 @@
1
+ import Point2 from './Point2';
2
+ import Point3 from './Point3';
3
+ import { IViewport } from './IViewport';
4
+ import { IVolumeInput } from './IVolumeInput';
5
+ import FlipDirection from './FlipDirection';
6
+ import IImageData from './IImageData';
7
+ import { BlendModes, OrientationAxis } from '../enums';
8
+ import { VolumeViewportProperties } from '.';
9
+
10
+ /**
11
+ * Interface for the Volume Viewport
12
+ */
13
+ export default interface IVolumeViewport extends IViewport {
14
+ useCPURendering: boolean;
15
+ getFrameOfReferenceUID: () => string;
16
+ /**
17
+ * Retrieve the viewport properties
18
+ */
19
+ getProperties: () => VolumeViewportProperties;
20
+ /**
21
+ * canvasToWorld Returns the world coordinates of the given `canvasPos`
22
+ * projected onto the plane defined by the `Viewport`'s `vtkCamera`'s focal point
23
+ * and the direction of projection.
24
+ */
25
+ canvasToWorld: (canvasPos: Point2) => Point3;
26
+ /**
27
+ * Returns the canvas coordinates of the given `worldPos`
28
+ * projected onto the `Viewport`'s `canvas`.
29
+ */
30
+ worldToCanvas: (worldPos: Point3) => Point2;
31
+ /**
32
+ * Uses viewport camera and volume actor to decide if the viewport
33
+ * is looking at the volume in the direction of acquisition (imageIds).
34
+ * If so, it uses the origin and focalPoint to calculate the slice index.
35
+ */
36
+ getCurrentImageIdIndex: () => number;
37
+
38
+ /**
39
+ * Checks if the viewport has a volume actor with the given volumeId
40
+ */
41
+ hasVolumeId: (volumeId: string) => boolean;
42
+
43
+ /**
44
+ * if the volume viewport has imageURI (no loader schema)
45
+ * in one of its volume actors
46
+ */
47
+ hasImageURI: (imageURI: string) => boolean;
48
+
49
+ /**
50
+ * Uses viewport camera and volume actor to decide if the viewport
51
+ * is looking at the volume in the direction of acquisition (imageIds).
52
+ * If so, it uses the origin and focalPoint to find which imageId is
53
+ * currently being viewed.
54
+ */
55
+ getCurrentImageId: () => string;
56
+ /**
57
+ * Sets the properties for the viewport. If no volumeId is provided
58
+ * it applies the properties to the default volume actor (first volume)
59
+ */
60
+ setProperties(
61
+ { voiRange }: VolumeViewportProperties,
62
+ volumeId?: string,
63
+ suppressEvents?: boolean
64
+ ): void;
65
+ /**
66
+ * Creates volume actors for all volumes defined in the `volumeInputArray`.
67
+ * For each entry, if a `callback` is supplied, it will be called with the new volume actor as input.
68
+ * For each entry, if a `blendMode` and/or `slabThickness` is defined, this will be set on the actor's
69
+ * `VolumeMapper`.
70
+ */
71
+ setVolumes(
72
+ volumeInputArray: Array<IVolumeInput>,
73
+ immediate?: boolean,
74
+ suppressEvents?: boolean
75
+ ): Promise<void>;
76
+ /**
77
+ * Creates and adds volume actors for all volumes defined in the `volumeInputArray`.
78
+ * For each entry, if a `callback` is supplied, it will be called with the new volume actor as input.
79
+ */
80
+ addVolumes(
81
+ volumeInputArray: Array<IVolumeInput>,
82
+ immediate?: boolean,
83
+ suppressEvents?: boolean
84
+ ): Promise<void>;
85
+ /**
86
+ * It removes the volume actor from the Viewport. If the volume actor is not in
87
+ * the viewport, it does nothing.
88
+ */
89
+ removeVolumeActors(actorUIDs: Array<string>, immediate?: boolean): void;
90
+
91
+ /**
92
+ * Given a point in world coordinates, return the intensity at that point
93
+ */
94
+ getIntensityFromWorld(point: Point3): number;
95
+ /**
96
+ * getBounds gets the visible bounds of the viewport
97
+ */
98
+ getBounds(): any;
99
+ /**
100
+ * Flip the viewport along the desired axis
101
+ */
102
+ flip(flipDirection: FlipDirection): void;
103
+ /**
104
+ * Reset the camera for the volume viewport
105
+ */
106
+ resetCamera(
107
+ resetPan?: boolean,
108
+ resetZoom?: boolean,
109
+ resetToCenter?: boolean
110
+ ): boolean;
111
+ /**
112
+ * Sets the blendMode for actors of the viewport.
113
+ */
114
+ setBlendMode(
115
+ blendMode: BlendModes,
116
+ filterActorUIDs?: Array<string>,
117
+ immediate?: boolean
118
+ ): void;
119
+ /**
120
+ * Sets the slab thickness for actors of the viewport.
121
+ */
122
+ setSlabThickness(
123
+ slabThickness: number,
124
+ filterActorUIDs?: Array<string>
125
+ ): void;
126
+ /**
127
+ * Gets the slab thickness option in the `Viewport`'s `options`.
128
+ */
129
+ getSlabThickness(): number;
130
+ /**
131
+ * Returns the image and its properties that is being shown inside the
132
+ * stack viewport. It returns, the image dimensions, image direction,
133
+ * image scalar data, vtkImageData object, metadata, and scaling (e.g., PET suvbw)
134
+ * Note: since the volume viewport supports fusion, to get the
135
+ * image data for a specific volume, use the optional volumeId
136
+ * argument.
137
+ */
138
+ getImageData(volumeId?: string): IImageData | undefined;
139
+
140
+ setOrientation(orientation: OrientationAxis): void;
141
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Any imageLoader function should implement a loading given the imageId
3
+ * and returns a mandatory promise which will resolve to the loaded image object.
4
+ * Additional `cancelFn` and `decache` can be implemented.
5
+ */
6
+ type ImageLoaderFn = (
7
+ imageId: string,
8
+ options?: Record<string, any>
9
+ ) => {
10
+ /** Promise that resolves to the image object */
11
+ promise: Promise<Record<string, any>>;
12
+ cancelFn?: () => void | undefined;
13
+ decache?: () => void | undefined;
14
+ };
15
+
16
+ export default ImageLoaderFn;
@@ -0,0 +1,6 @@
1
+ type ImageSliceData = {
2
+ numberOfSlices: number;
3
+ imageIndex: number;
4
+ };
5
+
6
+ export default ImageSliceData;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * This represents a 3x3 matrix of numbers
3
+ */
4
+ type Mat3 = [
5
+ number,
6
+ number,
7
+ number,
8
+ number,
9
+ number,
10
+ number,
11
+ number,
12
+ number,
13
+ number
14
+ ];
15
+
16
+ export default Mat3;
@@ -0,0 +1,39 @@
1
+ import type { VOI } from './voi';
2
+
3
+ /**
4
+ * Metadata for images, More information can be found in the
5
+ * {@link https://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.7.6.3.html#table_C.7-11c}
6
+ */
7
+ type Metadata = {
8
+ /** Number of bits allocated for each pixel sample. Each sample shall have the same number of bits allocated */
9
+ BitsAllocated: number;
10
+ /** Number of bits stored for each pixel sample */
11
+ BitsStored: number;
12
+ SamplesPerPixel: number;
13
+ /** Most significant bit for pixel sample data */
14
+ HighBit: number;
15
+ /** Specifies the intended interpretation of the pixel data */
16
+ PhotometricInterpretation: string;
17
+ /** Data representation of the pixel samples. */
18
+ PixelRepresentation: number;
19
+ /** Image Modality */
20
+ Modality: string;
21
+ /** SeriesInstanceUID of the volume */
22
+ SeriesInstanceUID?: string;
23
+ /** The direction cosines of the first row and the first column with respect to the patient */
24
+ ImageOrientationPatient: Array<number>;
25
+ /** Physical distance in the patient between the center of each pixel */
26
+ PixelSpacing: Array<number>;
27
+ /** Uniquely identifies the Frame of Reference for a Series */
28
+ FrameOfReferenceUID: string;
29
+ /** Number of columns in the image. */
30
+ Columns: number;
31
+ /** Number of rows in the image. */
32
+ Rows: number;
33
+ /** Window Level/Center for the image */
34
+ voiLut: Array<VOI>;
35
+ /** VOILUTFunction for the image which is LINEAR or SAMPLED_SIGMOID */
36
+ VOILUTFunction: string;
37
+ };
38
+
39
+ export default Metadata;
@@ -0,0 +1,36 @@
1
+ import { Point3 } from '../types';
2
+
3
+ /**
4
+ * - `viewUp` - An array of three floating point numbers describing a vector
5
+ * that represents the up direction for the view.
6
+ * - `viewPlaneNormal` - The direction of the projection
7
+ *
8
+ * see [Axial vs Sagittal vs Coronal](https://faculty.washington.edu/chudler/slice.html)
9
+ * see {@link https://kitware.github.io/vtk-js/api/Rendering_Core_Camera.html | VTK.js: Rendering_Core_Camera}
10
+ *
11
+ * @example
12
+ *
13
+ * ```javascript
14
+ * renderingEngine.setViewports([
15
+ * {
16
+ * viewportId: 'a-viewport-uid',
17
+ * type: ViewportType.ORTHOGRAPHIC,
18
+ * element: document.querySelector('div'),
19
+ * defaultOptions: {
20
+ * orientation: {
21
+ * viewUp: [0, 0, 1],
22
+ * viewPlaneNormal: [1, 0, 0],
23
+ * },
24
+ * background: [1, 0, 0],
25
+ * },
26
+ * }]);
27
+ * ```
28
+ */
29
+ type OrientationVectors = {
30
+ /** Slice Normal for the viewport - the normal that points in the opposite direction of the slice normal out of screen and is negative of direction of projection */
31
+ viewPlaneNormal: Point3;
32
+ /** viewUp direction for the viewport - the vector that points from bottom to top of the viewport */
33
+ viewUp: Point3;
34
+ };
35
+
36
+ export default OrientationVectors;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Plane equation Ax+By+Cz=D, plane is defined by [A, B, C, D]
3
+ */
4
+ type Plane = [number, number, number, number];
5
+
6
+ export default Plane;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This duplicates the typing established in gl-matrix for a vec2
3
+ */
4
+ type Point2 = [number, number];
5
+
6
+ export default Point2;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This duplicates the typing established in gl-matrix for a vec3
3
+ */
4
+ type Point3 = [number, number, number];
5
+
6
+ export default Point3;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This represents a 4-vector or RGBA value.
3
+ */
4
+ type Point4 = [number, number, number, number];
5
+
6
+ export default Point4;
@@ -0,0 +1,27 @@
1
+ type ScalingParameters = {
2
+ /** m in m*p+b which specifies the linear transformation from stored pixels to memory value */
3
+ rescaleSlope: number;
4
+ /** b in m*p+b which specifies the offset of the transformation */
5
+ rescaleIntercept: number;
6
+ /** modality */
7
+ modality: string;
8
+ /** SUV body weight */
9
+ suvbw?: number;
10
+ /** SUV lean body mass */
11
+ suvlbm?: number;
12
+ /** SUV body surface area */
13
+ suvbsa?: number;
14
+ };
15
+
16
+ type PTScaling = {
17
+ /** suv body weight to suv lean body mass */
18
+ suvbwToSuvlbm?: number;
19
+ /** suv body weight to suv body surface area */
20
+ suvbwToSuvbsa?: number;
21
+ };
22
+
23
+ type Scaling = {
24
+ PET?: PTScaling;
25
+ };
26
+
27
+ export { PTScaling, Scaling, ScalingParameters };
@@ -0,0 +1,25 @@
1
+ import InterpolationType from '../enums/InterpolationType';
2
+ import VOILUTFunctionType from '../enums/VOILUTFunctionType';
3
+ import { VOIRange } from './voi';
4
+
5
+ /**
6
+ * Stack Viewport Properties
7
+ */
8
+ type StackViewportProperties = {
9
+ /** voi range (upper, lower) for the viewport */
10
+ voiRange?: VOIRange;
11
+ /** VOILUTFunction type which is LINEAR or SAMPLED_SIGMOID */
12
+ VOILUTFunction?: VOILUTFunctionType;
13
+ /** invert flag - whether the image is inverted */
14
+ invert?: boolean;
15
+ /** interpolation type - linear or nearest neighbor */
16
+ interpolationType?: InterpolationType;
17
+ /** image rotation */
18
+ rotation?: number;
19
+ /** suppress events (optional) */
20
+ suppressEvents?: boolean;
21
+ /** Indicates if the voi is a computed VOI (not user set) */
22
+ isComputedVOI?: boolean;
23
+ };
24
+
25
+ export default StackViewportProperties;
@@ -0,0 +1,4 @@
1
+ /** used for CPU rendering */
2
+ type TransformMatrix2D = [number, number, number, number, number, number];
3
+
4
+ export default TransformMatrix2D;
@@ -0,0 +1,21 @@
1
+ import { OrientationAxis } from '../enums';
2
+ import OrientationVectors from './OrientationVectors';
3
+
4
+ /**
5
+ * This type defines the shape of viewport input options, so we can throw when it is incorrect.
6
+ */
7
+ type ViewportInputOptions = {
8
+ /** background color */
9
+ background?: [number, number, number];
10
+ /** orientation of the viewport which can be either an Enum for axis Enums.OrientationAxis.[AXIAL|SAGITTAL|CORONAL|DEFAULT] or an object with viewPlaneNormal and viewUp */
11
+ orientation?: OrientationAxis | OrientationVectors;
12
+ /** whether the events should be suppressed and not fired*/
13
+ suppressEvents?: boolean;
14
+ /**
15
+ * parallel projection settings, Note that this will only be used for VOLUME_3D viewport. You can't modify the
16
+ * parallel projection of a stack viewport or volume viewport using viewport input options.
17
+ */
18
+ parallelProjection?: boolean;
19
+ };
20
+
21
+ export default ViewportInputOptions;
@@ -0,0 +1,14 @@
1
+ interface ViewportPreset {
2
+ name: string;
3
+ gradientOpacity: string;
4
+ specularPower: string;
5
+ scalarOpacity: string;
6
+ specular: string;
7
+ shade: string;
8
+ ambient: string;
9
+ colorTransfer: string;
10
+ diffuse: string;
11
+ interpolation: string;
12
+ }
13
+
14
+ export default ViewportPreset;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Any volumeLoader function should implement a loading given the volumeId
3
+ * and returns a mandatory promise which will resolve to the loaded volume object.
4
+ * Additional `cancelFn` and `decache` can be implemented.
5
+ */
6
+ type VolumeLoaderFn = (
7
+ volumeId: string,
8
+ options?: Record<string, any>
9
+ ) => {
10
+ /** promise that resolves to the volume object */
11
+ promise: Promise<Record<string, any>>;
12
+ /** cancel function */
13
+ cancelFn?: () => void | undefined;
14
+ /** decache function */
15
+ decache?: () => void | undefined;
16
+ };
17
+
18
+ export default VolumeLoaderFn;
@@ -0,0 +1,14 @@
1
+ import { VOIRange } from './voi';
2
+ import VOILUTFunctionType from '../enums/VOILUTFunctionType';
3
+
4
+ /**
5
+ * Stack Viewport Properties
6
+ */
7
+ type VolumeViewportProperties = {
8
+ /** voi range (upper, lower) for the viewport */
9
+ voiRange?: VOIRange;
10
+ /** VOILUTFunction type which is LINEAR or SAMPLED_SIGMOID */
11
+ VOILUTFunction?: VOILUTFunctionType;
12
+ };
13
+
14
+ export default VolumeViewportProperties;
@@ -0,0 +1,157 @@
1
+ // @see: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#-type-only-imports-and-export
2
+ import type Cornerstone3DConfig from './Cornerstone3DConfig';
3
+ import type ICamera from './ICamera';
4
+ import type IEnabledElement from './IEnabledElement';
5
+ import type ICache from './ICache';
6
+ import type { IVolume, VolumeScalarData } from './IVolume';
7
+ import type { VOI, VOIRange } from './voi';
8
+ import type ImageLoaderFn from './ImageLoaderFn';
9
+ import type IImageVolume from './IImageVolume';
10
+ import type IDynamicImageVolume from './IDynamicImageVolume';
11
+ import type VolumeLoaderFn from './VolumeLoaderFn';
12
+ import type IRegisterImageLoader from './IRegisterImageLoader';
13
+ import type IStreamingVolumeProperties from './IStreamingVolumeProperties';
14
+ import type CustomEventType from './CustomEventType';
15
+ import type { IViewport, PublicViewportInput } from './IViewport';
16
+ import type { VolumeActor, Actor, ActorEntry } from './IActor';
17
+ import type {
18
+ IImageLoadObject,
19
+ IVolumeLoadObject,
20
+ IGeometryLoadObject,
21
+ } from './ILoadObject';
22
+ import type Metadata from './Metadata';
23
+ import type OrientationVectors from './OrientationVectors';
24
+ import type Point2 from './Point2';
25
+ import type Point3 from './Point3';
26
+ import type Point4 from './Point4';
27
+ import type Mat3 from './Mat3';
28
+ import type Plane from './Plane';
29
+ import type IStreamingImageVolume from './IStreamingImageVolume';
30
+ import type ViewportInputOptions from './ViewportInputOptions';
31
+ import type IImageData from './IImageData';
32
+ import type CPUIImageData from './CPUIImageData';
33
+ import type { CPUImageData } from './CPUIImageData';
34
+ import type IImage from './IImage';
35
+ import type {
36
+ PTScaling,
37
+ Scaling,
38
+ ScalingParameters,
39
+ } from './ScalingParameters';
40
+ import type StackViewportProperties from './StackViewportProperties';
41
+ import type VolumeViewportProperties from './VolumeViewportProperties';
42
+ import type IViewportId from './IViewportId';
43
+ import type FlipDirection from './FlipDirection';
44
+ import type ICachedImage from './ICachedImage';
45
+ import type ICachedVolume from './ICachedVolume';
46
+ import type IStackViewport from './IStackViewport';
47
+ import type IVolumeViewport from './IVolumeViewport';
48
+ import type ViewportPreset from './ViewportPreset';
49
+
50
+ // CPU types
51
+ import type CPUFallbackEnabledElement from './CPUFallbackEnabledElement';
52
+ import type CPUFallbackViewport from './CPUFallbackViewport';
53
+ import type CPUFallbackTransform from './CPUFallbackTransform';
54
+ import type CPUFallbackColormapData from './CPUFallbackColormapData';
55
+ import type CPUFallbackViewportDisplayedArea from './CPUFallbackViewportDisplayedArea';
56
+ import type CPUFallbackColormapsData from './CPUFallbackColormapsData';
57
+ import type CPUFallbackColormap from './CPUFallbackColormap';
58
+ import type TransformMatrix2D from './TransformMatrix2D';
59
+ import type CPUFallbackLookupTable from './CPUFallbackLookupTable';
60
+ import type CPUFallbackLUT from './CPUFallbackLUT';
61
+ import type CPUFallbackRenderingTools from './CPUFallbackRenderingTools';
62
+ import type { IVolumeInput, VolumeInputCallback } from './IVolumeInput';
63
+ import type * as EventTypes from './EventTypes';
64
+ import type IRenderingEngine from './IRenderingEngine';
65
+ import type ActorSliceRange from './ActorSliceRange';
66
+ import type ImageSliceData from './ImageSliceData';
67
+ import type IGeometry from './IGeometry';
68
+ import type {
69
+ PublicContourSetData,
70
+ ContourSetData,
71
+ ContourData,
72
+ } from './ContourData';
73
+ import type ICachedGeometry from './ICachedGeometry';
74
+ import type { IContourSet } from './IContourSet';
75
+ import type { IContour } from './IContour';
76
+
77
+ export type {
78
+ // config
79
+ Cornerstone3DConfig,
80
+ //
81
+ ICamera,
82
+ IStackViewport,
83
+ IVolumeViewport,
84
+ IEnabledElement,
85
+ ICache,
86
+ IVolume,
87
+ VolumeScalarData,
88
+ IViewportId,
89
+ IImageVolume,
90
+ IDynamicImageVolume,
91
+ IRenderingEngine,
92
+ ScalingParameters,
93
+ PTScaling,
94
+ Scaling,
95
+ IStreamingImageVolume,
96
+ IImage,
97
+ IImageData,
98
+ CPUIImageData,
99
+ CPUImageData,
100
+ EventTypes,
101
+ ImageLoaderFn,
102
+ VolumeLoaderFn,
103
+ IRegisterImageLoader,
104
+ IStreamingVolumeProperties,
105
+ IViewport,
106
+ StackViewportProperties,
107
+ VolumeViewportProperties,
108
+ PublicViewportInput,
109
+ VolumeActor,
110
+ Actor,
111
+ ActorEntry,
112
+ IImageLoadObject,
113
+ IVolumeLoadObject,
114
+ IVolumeInput,
115
+ VolumeInputCallback,
116
+ ViewportPreset,
117
+ //
118
+ Metadata,
119
+ OrientationVectors,
120
+ Point2,
121
+ Point3,
122
+ Point4,
123
+ Mat3,
124
+ Plane,
125
+ ViewportInputOptions,
126
+ VOIRange,
127
+ VOI,
128
+ FlipDirection,
129
+ ICachedImage,
130
+ ICachedVolume,
131
+ // CPU fallback types
132
+ CPUFallbackEnabledElement,
133
+ CPUFallbackViewport,
134
+ CPUFallbackTransform,
135
+ CPUFallbackColormapData,
136
+ CPUFallbackViewportDisplayedArea,
137
+ CPUFallbackColormapsData,
138
+ CPUFallbackColormap,
139
+ TransformMatrix2D,
140
+ CPUFallbackLookupTable,
141
+ CPUFallbackLUT,
142
+ CPUFallbackRenderingTools,
143
+ //
144
+ CustomEventType,
145
+ ActorSliceRange,
146
+ ImageSliceData,
147
+ // Geometry
148
+ IGeometry,
149
+ IGeometryLoadObject,
150
+ ICachedGeometry,
151
+ // Contour
152
+ PublicContourSetData,
153
+ ContourSetData,
154
+ ContourData,
155
+ IContourSet,
156
+ IContour,
157
+ };
@@ -0,0 +1,15 @@
1
+ type VOI = {
2
+ /** Window Width for display */
3
+ windowWidth: number;
4
+ /** Window Center for display */
5
+ windowCenter: number;
6
+ };
7
+
8
+ type VOIRange = {
9
+ /** upper value for display */
10
+ upper: number;
11
+ /** lower value for display */
12
+ lower: number;
13
+ };
14
+
15
+ export type { VOI, VOIRange };
@@ -0,0 +1,24 @@
1
+ import { Types } from '..';
2
+
3
+ type actorTypes = 'vtkActor' | 'vtkVolume' | 'vtkImageSlice';
4
+
5
+ /**
6
+ * Checks if a vtk Actor is an image actor (vtkVolume or vtkImageSlice) otherwise returns false.
7
+ *
8
+ * @param actor - actor
9
+ * @returns A boolean value.
10
+ */
11
+ export function isImageActor(actorEntry: Types.ActorEntry): boolean {
12
+ return (
13
+ actorIsA(actorEntry, 'vtkVolume') || actorIsA(actorEntry, 'vtkImageSlice')
14
+ );
15
+ }
16
+
17
+ export function actorIsA(
18
+ actorEntry: Types.ActorEntry,
19
+ actorType: actorTypes
20
+ ): boolean {
21
+ const actor = actorEntry.actor;
22
+
23
+ return !!actor.isA(actorType);
24
+ }