@cornerstonejs/core 5.8.1 → 5.10.2
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/esm/RenderingEngine/BaseRenderingEngine.js +4 -2
- package/dist/esm/RenderingEngine/BaseVolumeViewport.d.ts +1 -0
- package/dist/esm/RenderingEngine/BaseVolumeViewport.js +13 -3
- package/dist/esm/RenderingEngine/ContextPoolRenderingEngine.js +3 -1
- package/dist/esm/RenderingEngine/GenericViewport/DefaultRenderPathResolver.js +3 -1
- package/dist/esm/RenderingEngine/GenericViewport/Planar/DefaultPlanarDataProvider.js +3 -1
- package/dist/esm/RenderingEngine/GenericViewport/Planar/PlanarViewport.js +3 -1
- package/dist/esm/RenderingEngine/GenericViewport/Planar/PlanarViewportLegacyAdapter.js +3 -1
- package/dist/esm/RenderingEngine/GenericViewport/Planar/planarViewReference.js +1 -1
- package/dist/esm/RenderingEngine/GenericViewport/genericViewportReferenceCompatibility.js +3 -2
- package/dist/esm/RenderingEngine/RenderingEngine.js +3 -1
- package/dist/esm/RenderingEngine/StackViewport.js +8 -4
- package/dist/esm/RenderingEngine/TiledRenderingEngine.js +3 -1
- package/dist/esm/RenderingEngine/VideoViewport.d.ts +1 -0
- package/dist/esm/RenderingEngine/VideoViewport.js +18 -12
- package/dist/esm/RenderingEngine/Viewport.d.ts +1 -0
- package/dist/esm/RenderingEngine/Viewport.js +17 -10
- package/dist/esm/RenderingEngine/VolumeViewport.js +4 -2
- package/dist/esm/RenderingEngine/WSIViewport.js +1 -2
- package/dist/esm/RenderingEngine/helpers/addImageSlicesToViewports.js +3 -1
- package/dist/esm/RenderingEngine/helpers/addVolumesToViewports.js +3 -1
- package/dist/esm/RenderingEngine/helpers/attachWebGLContextEvents.js +3 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/renderPseudoColorImage.js +3 -1
- package/dist/esm/RenderingEngine/helpers/getCameraVectors.js +3 -1
- package/dist/esm/RenderingEngine/helpers/stats/StatsOverlay.js +3 -1
- package/dist/esm/RenderingEngine/helpers/volumeNewImageEventDispatcher.js +3 -1
- package/dist/esm/RenderingEngine/vtkClasses/vtkStreamingOpenGLVolumeMapper.js +3 -1
- package/dist/esm/cache/cache.js +16 -14
- package/dist/esm/cache/classes/BaseStreamingImageVolume.js +4 -2
- package/dist/esm/eventTarget.js +3 -1
- package/dist/esm/init.js +7 -5
- package/dist/esm/loaders/ProgressiveRetrieveImages.js +3 -1
- package/dist/esm/loaders/cornerstoneStreamingImageVolumeLoader.js +4 -2
- package/dist/esm/loaders/fillNearbyFrames.js +3 -1
- package/dist/esm/requestPool/requestPoolManager.js +3 -1
- package/dist/esm/types/IViewport.d.ts +2 -0
- package/dist/esm/utilities/ProgressiveIterator.js +4 -2
- package/dist/esm/utilities/VoxelManager.js +12 -10
- package/dist/esm/utilities/calculateSpacingBetweenImageIds.js +5 -3
- package/dist/esm/utilities/calculateViewportsSpatialRegistration.js +4 -2
- package/dist/esm/utilities/deepEqual.js +3 -1
- package/dist/esm/utilities/eventListener/TargetEventListeners.js +3 -1
- package/dist/esm/utilities/getBufferConfiguration.js +3 -1
- package/dist/esm/utilities/getEffectiveSpacingAlongDirection.d.ts +6 -0
- package/dist/esm/utilities/getEffectiveSpacingAlongDirection.js +11 -0
- package/dist/esm/utilities/getImageSliceDataForVolumeViewport.js +3 -1
- package/dist/esm/utilities/getVolumeSliceRangeInfo.js +3 -1
- package/dist/esm/utilities/index.d.ts +5 -1
- package/dist/esm/utilities/index.js +5 -1
- package/dist/esm/utilities/loadImageToCanvas.js +3 -1
- package/dist/esm/utilities/logger.d.ts +2 -1
- package/dist/esm/utilities/logger.js +2 -1
- package/dist/esm/utilities/resolveApplicationUrl.d.ts +3 -0
- package/dist/esm/utilities/resolveApplicationUrl.js +31 -0
- package/dist/esm/utilities/snapFocalPointToSlice.js +7 -1
- package/dist/esm/utilities/updatePlaneRestriction.d.ts +2 -2
- package/dist/esm/utilities/updatePlaneRestriction.js +47 -19
- package/dist/esm/utilities/voxelSlab/getVoxelThicknessAlongNormal.d.ts +6 -0
- package/dist/esm/utilities/voxelSlab/getVoxelThicknessAlongNormal.js +10 -0
- package/dist/esm/utilities/voxelSlab/index.d.ts +10 -0
- package/dist/esm/utilities/voxelSlab/index.js +7 -0
- package/dist/esm/utilities/voxelSlab/indexSpaceSlab.d.ts +29 -0
- package/dist/esm/utilities/voxelSlab/indexSpaceSlab.js +121 -0
- package/dist/esm/utilities/voxelSlab/isPlaneDepthViewable.d.ts +2 -0
- package/dist/esm/utilities/voxelSlab/isPlaneDepthViewable.js +12 -0
- package/dist/esm/utilities/voxelSlab/iterateVoxelsInShape.d.ts +20 -0
- package/dist/esm/utilities/voxelSlab/iterateVoxelsInShape.js +91 -0
- package/dist/esm/utilities/voxelSlab/sampleVoxelsInShape.d.ts +16 -0
- package/dist/esm/utilities/voxelSlab/sampleVoxelsInShape.js +24 -0
- package/dist/esm/utilities/voxelSlab/shapes/createEllipseShape.d.ts +22 -0
- package/dist/esm/utilities/voxelSlab/shapes/createEllipseShape.js +90 -0
- package/dist/esm/utilities/voxelSlab/shapes/createPolylineShape.d.ts +10 -0
- package/dist/esm/utilities/voxelSlab/shapes/createPolylineShape.js +170 -0
- package/dist/esm/utilities/voxelSlab/shapes/createRectangleShape.d.ts +14 -0
- package/dist/esm/utilities/voxelSlab/shapes/createRectangleShape.js +69 -0
- package/dist/esm/utilities/voxelSlab/shapes/index.d.ts +8 -0
- package/dist/esm/utilities/voxelSlab/shapes/index.js +4 -0
- package/dist/esm/utilities/voxelSlab/shapes/shapeGeometry.d.ts +28 -0
- package/dist/esm/utilities/voxelSlab/shapes/shapeGeometry.js +99 -0
- package/dist/esm/utilities/voxelSlab/slabMembership.d.ts +11 -0
- package/dist/esm/utilities/voxelSlab/slabMembership.js +42 -0
- package/dist/esm/utilities/wasmBasePath.d.ts +3 -0
- package/dist/esm/utilities/wasmBasePath.js +12 -0
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/webWorkerManager/webWorkerManager.js +6 -6
- package/package.json +6 -7
- package/LICENSE +0 -21
|
@@ -2,6 +2,8 @@ import getImageSliceDataForVolumeViewport from '../../utilities/getImageSliceDat
|
|
|
2
2
|
import triggerEvent from '../../utilities/triggerEvent.js';
|
|
3
3
|
import { Events } from '../../enums/index.js';
|
|
4
4
|
import { getRenderingEngine } from '../getRenderingEngine.js';
|
|
5
|
+
import { coreLog } from '../../utilities/logger.js';
|
|
6
|
+
const log = coreLog.getLogger('RenderingEngine', 'volumeNewImageEventDispatcher');
|
|
5
7
|
const state = {};
|
|
6
8
|
export function resetVolumeNewImageState(viewportId) {
|
|
7
9
|
if (state[viewportId] !== undefined) {
|
|
@@ -20,7 +22,7 @@ function volumeNewImageEventDispatcher(cameraEvent) {
|
|
|
20
22
|
}
|
|
21
23
|
const sliceData = getImageSliceDataForVolumeViewport(viewport);
|
|
22
24
|
if (!sliceData) {
|
|
23
|
-
|
|
25
|
+
log.warn(`volumeNewImageEventDispatcher: sliceData is undefined for viewport ${viewport.id}`);
|
|
24
26
|
return;
|
|
25
27
|
}
|
|
26
28
|
const { numberOfSlices, imageIndex } = sliceData;
|
|
@@ -9,6 +9,8 @@ import { Representation } from '@kitware/vtk.js/Rendering/Core/Property/Constant
|
|
|
9
9
|
import { BlendMode } from '@kitware/vtk.js/Rendering/Core/VolumeMapper/Constants.js';
|
|
10
10
|
import { getCanUseNorm16Texture } from '../../init.js';
|
|
11
11
|
import canUseFloatOpacityTexture from './canUseFloatOpacityTexture.js';
|
|
12
|
+
import { coreLog } from '../../utilities/logger.js';
|
|
13
|
+
const log = coreLog.getLogger('RenderingEngine', 'vtkStreamingOpenGLVolumeMapper');
|
|
12
14
|
function vtkStreamingOpenGLVolumeMapper(publicAPI, model) {
|
|
13
15
|
model.classHierarchy.push('vtkStreamingOpenGLVolumeMapper');
|
|
14
16
|
const graphicsResourceReferenceCount = new Map();
|
|
@@ -232,7 +234,7 @@ function vtkStreamingOpenGLVolumeMapper(publicAPI, model) {
|
|
|
232
234
|
model.scalarTextures = [];
|
|
233
235
|
}
|
|
234
236
|
if (!model.scalarTextures[component]) {
|
|
235
|
-
|
|
237
|
+
log.warn(`ScalarTexture for component ${component} not initialized, skipping.`);
|
|
236
238
|
return;
|
|
237
239
|
}
|
|
238
240
|
const currentTexture = model.scalarTextures[component];
|
package/dist/esm/cache/cache.js
CHANGED
|
@@ -4,6 +4,8 @@ import eventTarget from '../eventTarget.js';
|
|
|
4
4
|
import Events from '../enums/Events.js';
|
|
5
5
|
import { ImageQualityStatus } from '../enums/index.js';
|
|
6
6
|
import fnv1aHash from '../utilities/fnv1aHash.js';
|
|
7
|
+
import { coreLog } from '../utilities/logger.js';
|
|
8
|
+
const log = coreLog.getLogger('cache');
|
|
7
9
|
const ONE_GB = 1073741824;
|
|
8
10
|
class Cache {
|
|
9
11
|
constructor() {
|
|
@@ -147,12 +149,12 @@ class Cache {
|
|
|
147
149
|
this._putGeometryCommon(geometryId, geometry, cachedGeometry);
|
|
148
150
|
}
|
|
149
151
|
catch (error) {
|
|
150
|
-
|
|
152
|
+
log.debug(`Error in _putGeometryCommon for geometry ${geometryId}:`, error);
|
|
151
153
|
throw error;
|
|
152
154
|
}
|
|
153
155
|
})
|
|
154
156
|
.catch((error) => {
|
|
155
|
-
|
|
157
|
+
log.debug(`Error caching geometry ${geometryId}:`, error);
|
|
156
158
|
this._geometryCache.delete(geometryId);
|
|
157
159
|
throw error;
|
|
158
160
|
});
|
|
@@ -362,11 +364,11 @@ class Cache {
|
|
|
362
364
|
}
|
|
363
365
|
_putImageCommon(imageId, image, cachedImage) {
|
|
364
366
|
if (!this._imageCache.has(imageId)) {
|
|
365
|
-
|
|
367
|
+
log.warn('The image was purged from the cache before it completed loading.');
|
|
366
368
|
return;
|
|
367
369
|
}
|
|
368
370
|
if (!image) {
|
|
369
|
-
|
|
371
|
+
log.warn('Image is undefined');
|
|
370
372
|
return;
|
|
371
373
|
}
|
|
372
374
|
if (image.sizeInBytes === undefined || Number.isNaN(image.sizeInBytes)) {
|
|
@@ -394,21 +396,21 @@ class Cache {
|
|
|
394
396
|
}
|
|
395
397
|
async putImageLoadObject(imageId, imageLoadObject) {
|
|
396
398
|
if (imageId === undefined) {
|
|
397
|
-
|
|
399
|
+
log.error('putImageLoadObject: imageId must not be undefined');
|
|
398
400
|
throw new Error('putImageLoadObject: imageId must not be undefined');
|
|
399
401
|
}
|
|
400
402
|
if (imageLoadObject.promise === undefined) {
|
|
401
|
-
|
|
403
|
+
log.error('putImageLoadObject: imageLoadObject.promise must not be undefined');
|
|
402
404
|
throw new Error('putImageLoadObject: imageLoadObject.promise must not be undefined');
|
|
403
405
|
}
|
|
404
406
|
const alreadyCached = this._imageCache.get(imageId);
|
|
405
407
|
if (alreadyCached?.imageLoadObject) {
|
|
406
|
-
|
|
408
|
+
log.warn(`putImageLoadObject: imageId ${imageId} already in cache`);
|
|
407
409
|
throw new Error('putImageLoadObject: imageId already in cache');
|
|
408
410
|
}
|
|
409
411
|
if (imageLoadObject.cancelFn &&
|
|
410
412
|
typeof imageLoadObject.cancelFn !== 'function') {
|
|
411
|
-
|
|
413
|
+
log.error('putImageLoadObject: imageLoadObject.cancel must be a function');
|
|
412
414
|
throw new Error('putImageLoadObject: imageLoadObject.cancel must be a function');
|
|
413
415
|
}
|
|
414
416
|
const cachedImage = {
|
|
@@ -427,12 +429,12 @@ class Cache {
|
|
|
427
429
|
this._putImageCommon(imageId, image, cachedImage);
|
|
428
430
|
}
|
|
429
431
|
catch (error) {
|
|
430
|
-
|
|
432
|
+
log.debug(`Error in _putImageCommon for image ${imageId}:`, error);
|
|
431
433
|
throw error;
|
|
432
434
|
}
|
|
433
435
|
})
|
|
434
436
|
.catch((error) => {
|
|
435
|
-
|
|
437
|
+
log.debug(`Error caching image ${imageId}:`, error);
|
|
436
438
|
this._imageCache.delete(imageId);
|
|
437
439
|
throw error;
|
|
438
440
|
});
|
|
@@ -512,7 +514,7 @@ class Cache {
|
|
|
512
514
|
}
|
|
513
515
|
_putVolumeCommon(volumeId, volume, cachedVolume) {
|
|
514
516
|
if (!this._volumeCache.get(volumeId)) {
|
|
515
|
-
|
|
517
|
+
log.warn('The volume was purged from the cache before it completed loading.');
|
|
516
518
|
return;
|
|
517
519
|
}
|
|
518
520
|
cachedVolume.loaded = true;
|
|
@@ -581,7 +583,7 @@ class Cache {
|
|
|
581
583
|
this._putVolumeCommon(volumeId, volume, cachedVolume);
|
|
582
584
|
}
|
|
583
585
|
catch (error) {
|
|
584
|
-
|
|
586
|
+
log.error(`Error in _putVolumeCommon for volume ${volumeId}:`, error);
|
|
585
587
|
this._volumeCache.delete(volumeId);
|
|
586
588
|
throw error;
|
|
587
589
|
}
|
|
@@ -593,11 +595,11 @@ class Cache {
|
|
|
593
595
|
}
|
|
594
596
|
_putGeometryCommon(geometryId, geometry, cachedGeometry) {
|
|
595
597
|
if (!this._geometryCache.get(geometryId)) {
|
|
596
|
-
|
|
598
|
+
log.warn('The geometry was purged from the cache before it completed loading.');
|
|
597
599
|
return;
|
|
598
600
|
}
|
|
599
601
|
if (!geometry) {
|
|
600
|
-
|
|
602
|
+
log.warn('Geometry is undefined');
|
|
601
603
|
return;
|
|
602
604
|
}
|
|
603
605
|
if (geometry.sizeInBytes === undefined ||
|
|
@@ -11,6 +11,8 @@ import ImageVolume from './ImageVolume.js';
|
|
|
11
11
|
import ProgressiveRetrieveImages from '../../loaders/ProgressiveRetrieveImages.js';
|
|
12
12
|
import { canRenderFloatTextures } from '../../init.js';
|
|
13
13
|
import { loadAndCacheImage } from '../../loaders/imageLoader.js';
|
|
14
|
+
import { coreLog } from '../../utilities/logger.js';
|
|
15
|
+
const log = coreLog.getLogger('cache', 'BaseStreamingImageVolume');
|
|
14
16
|
const requestTypeDefault = RequestType.Prefetch;
|
|
15
17
|
export class BaseStreamingImageVolume extends ImageVolume {
|
|
16
18
|
constructor(imageVolumeProperties, streamingProperties) {
|
|
@@ -122,7 +124,7 @@ export class BaseStreamingImageVolume extends ImageVolume {
|
|
|
122
124
|
const imageIdIndex = this.getImageIdIndex(imageId);
|
|
123
125
|
const { imageQualityStatus } = image;
|
|
124
126
|
if (this.loadStatus.cancelled) {
|
|
125
|
-
|
|
127
|
+
log.warn('volume load cancelled, returning for imageIdIndex: ', imageIdIndex);
|
|
126
128
|
return;
|
|
127
129
|
}
|
|
128
130
|
this.updateTextureAndTriggerEvents(imageIdIndex, imageId, imageQualityStatus);
|
|
@@ -332,7 +334,7 @@ export class BaseStreamingImageVolume extends ImageVolume {
|
|
|
332
334
|
this.reRenderTarget = this.reRenderFraction;
|
|
333
335
|
}
|
|
334
336
|
return this.imagesLoader.loadImages(imageIds, this).catch((e) => {
|
|
335
|
-
|
|
337
|
+
log.debug('progressive loading failed to complete', e);
|
|
336
338
|
});
|
|
337
339
|
}
|
|
338
340
|
_addScalingToVolume(suvFactor) {
|
package/dist/esm/eventTarget.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { coreLog } from './utilities/logger.js';
|
|
2
|
+
const log = coreLog.getLogger('eventTarget');
|
|
1
3
|
class CornerstoneEventTarget {
|
|
2
4
|
constructor() {
|
|
3
5
|
this.listeners = {};
|
|
@@ -75,7 +77,7 @@ class CornerstoneEventTarget {
|
|
|
75
77
|
stack[i].call(this, event);
|
|
76
78
|
}
|
|
77
79
|
catch (error) {
|
|
78
|
-
|
|
80
|
+
log.error(`error in event listener of type: ${event.type}`, error);
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
83
|
return !event.defaultPrevented;
|
package/dist/esm/init.js
CHANGED
|
@@ -7,6 +7,8 @@ import triggerEvent from './utilities/triggerEvent.js';
|
|
|
7
7
|
import eventTarget from './eventTarget.js';
|
|
8
8
|
import { Events, RenderBackends, RenderingEngineModeEnum } from './enums/index.js';
|
|
9
9
|
import { isRegisteredRenderBackend } from './RenderingEngine/helpers/renderBackendRegistry.js';
|
|
10
|
+
import { coreLog } from './utilities/logger.js';
|
|
11
|
+
const log = coreLog.getLogger('init');
|
|
10
12
|
const defaultConfig = {
|
|
11
13
|
isMobile: false,
|
|
12
14
|
rendering: {
|
|
@@ -64,18 +66,18 @@ function init(configuration = config) {
|
|
|
64
66
|
config.rendering.preferSizeOverAccuracy = true;
|
|
65
67
|
}
|
|
66
68
|
else if (!_hasNorm16TextureSupport()) {
|
|
67
|
-
|
|
69
|
+
log.info('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');
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
const capabilities = getRenderingCapabilities();
|
|
71
73
|
if (!capabilities.webgl) {
|
|
72
|
-
|
|
74
|
+
log.info('CornerstoneRender: GPU not detected, using CPU rendering');
|
|
73
75
|
config.rendering.useCPURendering = true;
|
|
74
76
|
}
|
|
75
77
|
else {
|
|
76
|
-
|
|
78
|
+
log.info('CornerstoneRender: using GPU rendering');
|
|
77
79
|
if (capabilities.softwareRasterizer) {
|
|
78
|
-
|
|
80
|
+
log.info(`CornerstoneRender: software rasterizer detected (${capabilities.renderer}), GPU rendering may be slow`);
|
|
79
81
|
}
|
|
80
82
|
}
|
|
81
83
|
csRenderInitialized = true;
|
|
@@ -104,7 +106,7 @@ function getEffectiveRenderBackend(override) {
|
|
|
104
106
|
}
|
|
105
107
|
if (!warnedUnregisteredBackends.has(backend)) {
|
|
106
108
|
warnedUnregisteredBackends.add(backend);
|
|
107
|
-
|
|
109
|
+
log.warn(`[getEffectiveRenderBackend] Unregistered render backend "${backend}"; ` +
|
|
108
110
|
`falling back to 'auto'. Register custom backends with registerRenderBackend().`);
|
|
109
111
|
}
|
|
110
112
|
}
|
|
@@ -10,6 +10,8 @@ import { ImageQualityStatus, RequestType, Events } from '../enums/index.js';
|
|
|
10
10
|
import cache from '../cache/cache.js';
|
|
11
11
|
import eventTarget from '../eventTarget.js';
|
|
12
12
|
import { fillNearbyFrames } from './fillNearbyFrames.js';
|
|
13
|
+
import { coreLog } from '../utilities/logger.js';
|
|
14
|
+
const log = coreLog.getLogger('loaders', 'ProgressiveRetrieveImages');
|
|
13
15
|
export { sequentialRetrieveStages, interleavedRetrieveStages, singleRetrieveStages, };
|
|
14
16
|
export class ProgressiveRetrieveImages {
|
|
15
17
|
constructor(imageRetrieveConfiguration) {
|
|
@@ -67,7 +69,7 @@ class ProgressiveRetrieveImagesInstance {
|
|
|
67
69
|
.forEach(async (image, done) => {
|
|
68
70
|
const oldStatus = cache.getImageQuality(imageId);
|
|
69
71
|
if (!image) {
|
|
70
|
-
|
|
72
|
+
log.warn('No image retrieved', imageId);
|
|
71
73
|
return;
|
|
72
74
|
}
|
|
73
75
|
const { imageQualityStatus } = image;
|
|
@@ -4,6 +4,8 @@ import { RequestType } from '../enums/index.js';
|
|
|
4
4
|
import imageLoadPoolManager from '../requestPool/imageLoadPoolManager.js';
|
|
5
5
|
import { generateVolumePropsFromImageIds } from '../utilities/generateVolumePropsFromImageIds.js';
|
|
6
6
|
import { loadImage } from './imageLoader.js';
|
|
7
|
+
import { coreLog } from '../utilities/logger.js';
|
|
8
|
+
const log = coreLog.getLogger('loaders', 'cornerstoneStreamingImageVolumeLoader');
|
|
7
9
|
function cornerstoneStreamingImageVolumeLoader(volumeId, options) {
|
|
8
10
|
if (!options || !options.imageIds || !options.imageIds.length) {
|
|
9
11
|
throw new Error('ImageIds must be provided to create a streaming image volume');
|
|
@@ -24,7 +26,7 @@ function cornerstoneStreamingImageVolumeLoader(volumeId, options) {
|
|
|
24
26
|
imageLoadPoolManager.addRequest(async () => {
|
|
25
27
|
loadImage(imageId)
|
|
26
28
|
.then(() => {
|
|
27
|
-
|
|
29
|
+
log.info(`Prefetched imageId: ${imageId}`);
|
|
28
30
|
resolve(true);
|
|
29
31
|
})
|
|
30
32
|
.catch((err) => {
|
|
@@ -32,7 +34,7 @@ function cornerstoneStreamingImageVolumeLoader(volumeId, options) {
|
|
|
32
34
|
});
|
|
33
35
|
}, RequestType.Prefetch, { volumeId }, 1);
|
|
34
36
|
});
|
|
35
|
-
})).catch(
|
|
37
|
+
})).catch((error) => log.error(error));
|
|
36
38
|
}
|
|
37
39
|
const volumeProps = generateVolumePropsFromImageIds(options.imageIds, volumeId);
|
|
38
40
|
const { dimensions, spacing, origin, direction, metadata, imageIds, dataType, numberOfComponents, } = volumeProps;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import cache from '../cache/cache.js';
|
|
2
|
+
import { coreLog } from '../utilities/logger.js';
|
|
3
|
+
const log = coreLog.getLogger('loaders', 'fillNearbyFrames');
|
|
2
4
|
export function fillNearbyFrames(listener, request, image) {
|
|
3
5
|
if (!request?.nearbyRequests?.length) {
|
|
4
6
|
return;
|
|
@@ -19,7 +21,7 @@ export function fillNearbyFrames(listener, request, image) {
|
|
|
19
21
|
listener.successCallback(targetId, nearbyImage);
|
|
20
22
|
}
|
|
21
23
|
catch (e) {
|
|
22
|
-
|
|
24
|
+
log.warn("Couldn't fill nearby item ", nearbyItem.itemId, e);
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import RequestType from '../enums/RequestType.js';
|
|
2
2
|
import uuidv4 from '../utilities/uuidv4.js';
|
|
3
|
+
import { coreLog } from '../utilities/logger.js';
|
|
4
|
+
const log = coreLog.getLogger('requestPool', 'requestPoolManager');
|
|
3
5
|
class RequestPoolManager {
|
|
4
6
|
constructor(id) {
|
|
5
7
|
this.numRequests = {
|
|
@@ -85,7 +87,7 @@ class RequestPoolManager {
|
|
|
85
87
|
requestResult = requestDetails.requestFn();
|
|
86
88
|
}
|
|
87
89
|
catch (e) {
|
|
88
|
-
|
|
90
|
+
log.warn('sendRequest failed', e);
|
|
89
91
|
}
|
|
90
92
|
if (requestResult?.finally) {
|
|
91
93
|
requestResult.finally(() => {
|
|
@@ -11,6 +11,7 @@ export type ViewReferenceSpecifier = {
|
|
|
11
11
|
frameNumber?: number;
|
|
12
12
|
forFrameOfReference?: boolean;
|
|
13
13
|
points?: Point3[];
|
|
14
|
+
forceInPlaneVectors?: boolean;
|
|
14
15
|
volumeId?: string;
|
|
15
16
|
};
|
|
16
17
|
export interface ReferenceCompatibleOptions {
|
|
@@ -29,6 +30,7 @@ export type PlaneRestriction = {
|
|
|
29
30
|
point: Point3;
|
|
30
31
|
inPlaneVector1?: Point3;
|
|
31
32
|
inPlaneVector2?: Point3;
|
|
33
|
+
referencePlaneThickness?: number;
|
|
32
34
|
};
|
|
33
35
|
export interface ViewReference {
|
|
34
36
|
FrameOfReferenceUID?: string;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { coreLog } from './logger.js';
|
|
2
|
+
const log = coreLog.getLogger('utilities', 'ProgressiveIterator');
|
|
1
3
|
export class PromiseIterator extends Promise {
|
|
2
4
|
}
|
|
3
5
|
export default class ProgressiveIterator {
|
|
@@ -79,7 +81,7 @@ export default class ProgressiveIterator {
|
|
|
79
81
|
}
|
|
80
82
|
catch (e) {
|
|
81
83
|
if (!done) {
|
|
82
|
-
|
|
84
|
+
log.warn('Caught exception in intermediate value', e);
|
|
83
85
|
continue;
|
|
84
86
|
}
|
|
85
87
|
if (errorCallback) {
|
|
@@ -111,7 +113,7 @@ export default class ProgressiveIterator {
|
|
|
111
113
|
errorCallback(reason);
|
|
112
114
|
}
|
|
113
115
|
else {
|
|
114
|
-
|
|
116
|
+
log.warn("Couldn't process because", reason);
|
|
115
117
|
}
|
|
116
118
|
});
|
|
117
119
|
}
|
|
@@ -4,6 +4,8 @@ import { mat3, vec3 } from 'gl-matrix';
|
|
|
4
4
|
import RLEVoxelMap from './RLEVoxelMap.js';
|
|
5
5
|
import isEqual from './isEqual.js';
|
|
6
6
|
import { iterateOverPointsInShapeVoxelManager } from './pointInShapeCallback.js';
|
|
7
|
+
import { coreLog } from './logger.js';
|
|
8
|
+
const log = coreLog.getLogger('utilities', 'VoxelManager');
|
|
7
9
|
const DEFAULT_RLE_SIZE = 5 * 1024;
|
|
8
10
|
const worldToIndexDeltaScratch = [0, 0, 0];
|
|
9
11
|
const worldToIndexResultScratch = [0, 0, 0];
|
|
@@ -242,7 +244,7 @@ export default class VoxelManager {
|
|
|
242
244
|
const { isWithinObject } = options || {};
|
|
243
245
|
const map = this.map;
|
|
244
246
|
if (!map) {
|
|
245
|
-
|
|
247
|
+
log.warn('No map found, you need to use a map voxel manager to use rleForEach');
|
|
246
248
|
return;
|
|
247
249
|
}
|
|
248
250
|
map.defaultValue = undefined;
|
|
@@ -327,7 +329,7 @@ export default class VoxelManager {
|
|
|
327
329
|
if (this._getConstructor) {
|
|
328
330
|
return this._getConstructor();
|
|
329
331
|
}
|
|
330
|
-
|
|
332
|
+
log.warn('No scalar data available or can be used to get the constructor');
|
|
331
333
|
return Float32Array;
|
|
332
334
|
}
|
|
333
335
|
getArrayOfModifiedSlices() {
|
|
@@ -522,7 +524,7 @@ export default class VoxelManager {
|
|
|
522
524
|
if (!imageId) {
|
|
523
525
|
if (!warnedMissingImageIds.has(sliceIndex)) {
|
|
524
526
|
warnedMissingImageIds.add(sliceIndex);
|
|
525
|
-
|
|
527
|
+
log.warn(`ImageId not found for sliceIndex: ${sliceIndex}`);
|
|
526
528
|
}
|
|
527
529
|
sliceVoxelManagers[sliceIndex] = null;
|
|
528
530
|
return null;
|
|
@@ -531,7 +533,7 @@ export default class VoxelManager {
|
|
|
531
533
|
if (!image?.voxelManager) {
|
|
532
534
|
if (!warnedMissingImages.has(imageId)) {
|
|
533
535
|
warnedMissingImages.add(imageId);
|
|
534
|
-
|
|
536
|
+
log.warn(`Image not found for imageId: ${imageId}`);
|
|
535
537
|
}
|
|
536
538
|
return null;
|
|
537
539
|
}
|
|
@@ -745,7 +747,7 @@ export default class VoxelManager {
|
|
|
745
747
|
activeDimensionGroup = dimensionGroupNumber - 1;
|
|
746
748
|
}
|
|
747
749
|
else if (timePoint !== undefined) {
|
|
748
|
-
|
|
750
|
+
log.warn('Warning: timePoint parameter is deprecated. Please use dimensionGroupNumber instead. timePoint is zero-based while dimensionGroupNumber starts at 1.');
|
|
749
751
|
activeDimensionGroup = timePoint;
|
|
750
752
|
}
|
|
751
753
|
if (!numberOfComponents) {
|
|
@@ -788,7 +790,7 @@ export default class VoxelManager {
|
|
|
788
790
|
return voxelGroups[activeDimensionGroup].getMiddleSliceData();
|
|
789
791
|
};
|
|
790
792
|
voxelManager.setTimePoint = (newTimePoint) => {
|
|
791
|
-
|
|
793
|
+
log.warn('Warning: setTimePoint is deprecated. Please use setDimensionGroupNumber instead. Note that timePoint is zero-based while dimensionGroupNumber starts at 1.');
|
|
792
794
|
voxelManager.setDimensionGroupNumber(newTimePoint + 1);
|
|
793
795
|
};
|
|
794
796
|
voxelManager.setDimensionGroupNumber = (newDimensionGroupNumber) => {
|
|
@@ -797,21 +799,21 @@ export default class VoxelManager {
|
|
|
797
799
|
voxelManager._set = (index, v) => voxelGroups[activeDimensionGroup]._set(index, v);
|
|
798
800
|
};
|
|
799
801
|
voxelManager.getAtIndexAndTimePoint = (index, tp) => {
|
|
800
|
-
|
|
802
|
+
log.warn('Warning: getAtIndexAndTimePoint is deprecated. Please use getAtIndexAndDimensionGroup instead. Note that timePoint is zero-based while dimensionGroupNumber starts at 1.');
|
|
801
803
|
return voxelManager.getAtIndexAndDimensionGroup(index, tp + 1);
|
|
802
804
|
};
|
|
803
805
|
voxelManager.getAtIndexAndDimensionGroup = (index, dimensionGroupNumber) => {
|
|
804
806
|
return voxelGroups[dimensionGroupNumber - 1]._get(index);
|
|
805
807
|
};
|
|
806
808
|
voxelManager.getTimePointScalarData = (tp) => {
|
|
807
|
-
|
|
809
|
+
log.warn('Warning: getTimePointScalarData is deprecated. Please use getDimensionGroupScalarData instead. Note that timePoint is zero-based while dimensionGroupNumber starts at 1.');
|
|
808
810
|
return voxelManager.getDimensionGroupScalarData(tp + 1);
|
|
809
811
|
};
|
|
810
812
|
voxelManager.getDimensionGroupScalarData = (dimensionGroupNumber) => {
|
|
811
813
|
return voxelGroups[dimensionGroupNumber - 1].getCompleteScalarDataArray();
|
|
812
814
|
};
|
|
813
815
|
voxelManager.getCurrentTimePointScalarData = () => {
|
|
814
|
-
|
|
816
|
+
log.warn('Warning: getCurrentTimePointScalarData is deprecated. Please use getCurrentDimensionGroupScalarData instead.');
|
|
815
817
|
return voxelManager.getCurrentDimensionGroupScalarData();
|
|
816
818
|
};
|
|
817
819
|
voxelManager.getCurrentDimensionGroupScalarData = () => {
|
|
@@ -821,7 +823,7 @@ export default class VoxelManager {
|
|
|
821
823
|
return voxelGroups[activeDimensionGroup].getCompleteScalarDataArray();
|
|
822
824
|
};
|
|
823
825
|
voxelManager.getCurrentTimePoint = () => {
|
|
824
|
-
|
|
826
|
+
log.warn('Warning: getCurrentTimePoint is deprecated. Please use getCurrentDimensionGroupNumber instead. Note that timePoint is zero-based while dimensionGroupNumber starts at 1.');
|
|
825
827
|
return activeDimensionGroup;
|
|
826
828
|
};
|
|
827
829
|
voxelManager.getCurrentDimensionGroupNumber = () => {
|
|
@@ -2,6 +2,8 @@ import { vec3 } from 'gl-matrix';
|
|
|
2
2
|
import * as metaData from '../metaData.js';
|
|
3
3
|
import { MetadataModules } from '../enums/index.js';
|
|
4
4
|
import { getConfiguration } from '../init.js';
|
|
5
|
+
import { coreLog } from './logger.js';
|
|
6
|
+
const log = coreLog.getLogger('utilities', 'calculateSpacingBetweenImageIds');
|
|
5
7
|
const DEFAULT_THICKNESS_SINGLE_SLICE = 1;
|
|
6
8
|
function getPixelSpacingForCubicVoxel(metadata) {
|
|
7
9
|
if (metadata.columnPixelSpacing !== undefined) {
|
|
@@ -86,11 +88,11 @@ export default function calculateSpacingBetweenImageIds(imageIds) {
|
|
|
86
88
|
const { strictZSpacingForVolumeViewport } = getConfiguration().rendering;
|
|
87
89
|
if ((spacing === 0 || isNaN(spacing)) && !strictZSpacingForVolumeViewport) {
|
|
88
90
|
if (spacingBetweenSlices) {
|
|
89
|
-
|
|
91
|
+
log.debug('Could not calculate spacing. Using spacingBetweenSlices');
|
|
90
92
|
spacing = spacingBetweenSlices;
|
|
91
93
|
}
|
|
92
94
|
else if (sliceThickness) {
|
|
93
|
-
|
|
95
|
+
log.debug('Could not calculate spacing and no spacingBetweenSlices. Using sliceThickness');
|
|
94
96
|
spacing = sliceThickness;
|
|
95
97
|
}
|
|
96
98
|
else {
|
|
@@ -103,7 +105,7 @@ export default function calculateSpacingBetweenImageIds(imageIds) {
|
|
|
103
105
|
spacing = pixelSpacingValue;
|
|
104
106
|
}
|
|
105
107
|
else {
|
|
106
|
-
|
|
108
|
+
log.debug(`Could not calculate spacing and no pixel spacing found. Using default thickness (${DEFAULT_THICKNESS_SINGLE_SLICE} mm)`);
|
|
107
109
|
spacing = DEFAULT_THICKNESS_SINGLE_SLICE;
|
|
108
110
|
}
|
|
109
111
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { vec3, mat4 } from 'gl-matrix';
|
|
2
2
|
import spatialRegistrationMetadataProvider from './spatialRegistrationMetadataProvider.js';
|
|
3
3
|
import { get } from '../metaData.js';
|
|
4
|
+
import { coreLog } from './logger.js';
|
|
5
|
+
const log = coreLog.getLogger('utilities', 'calculateViewportsSpatialRegistration');
|
|
4
6
|
const ALLOWED_DELTA = 0.05;
|
|
5
7
|
function calculateViewportsSpatialRegistration(viewport1, viewport2) {
|
|
6
8
|
const imageId1 = viewport1.getSliceIndex();
|
|
@@ -8,13 +10,13 @@ function calculateViewportsSpatialRegistration(viewport1, viewport2) {
|
|
|
8
10
|
const imagePlaneModule1 = get('imagePlaneModule', imageId1.toString());
|
|
9
11
|
const imagePlaneModule2 = get('imagePlaneModule', imageId2.toString());
|
|
10
12
|
if (!imagePlaneModule1 || !imagePlaneModule2) {
|
|
11
|
-
|
|
13
|
+
log.info('Viewport spatial registration requires image plane module');
|
|
12
14
|
return;
|
|
13
15
|
}
|
|
14
16
|
const { imageOrientationPatient: iop2 } = imagePlaneModule2;
|
|
15
17
|
const isSameImagePlane = imagePlaneModule1.imageOrientationPatient.every((v, i) => Math.abs(v - iop2[i]) < ALLOWED_DELTA);
|
|
16
18
|
if (!isSameImagePlane) {
|
|
17
|
-
|
|
19
|
+
log.info('Viewport spatial registration only supported for same orientation (hence translation only) for now', imagePlaneModule1?.imageOrientationPatient, imagePlaneModule2?.imageOrientationPatient);
|
|
18
20
|
return;
|
|
19
21
|
}
|
|
20
22
|
const imagePositionPatient1 = imagePlaneModule1.imagePositionPatient;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { coreLog } from './logger.js';
|
|
2
|
+
const log = coreLog.getLogger('utilities', 'deepEqual');
|
|
1
3
|
export function deepEqual(obj1, obj2) {
|
|
2
4
|
if (obj1 === obj2) {
|
|
3
5
|
return true;
|
|
@@ -9,7 +11,7 @@ export function deepEqual(obj1, obj2) {
|
|
|
9
11
|
return JSON.stringify(obj1) === JSON.stringify(obj2);
|
|
10
12
|
}
|
|
11
13
|
catch (error) {
|
|
12
|
-
|
|
14
|
+
log.debug('Error in JSON.stringify during deep comparison:', error);
|
|
13
15
|
return obj1 === obj2;
|
|
14
16
|
}
|
|
15
17
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { coreLog } from '../logger.js';
|
|
2
|
+
const log = coreLog.getLogger('utilities', 'TargetEventListeners');
|
|
1
3
|
var EventListenerPhases;
|
|
2
4
|
(function (EventListenerPhases) {
|
|
3
5
|
EventListenerPhases[EventListenerPhases["None"] = 0] = "None";
|
|
@@ -73,7 +75,7 @@ class TargetEventListeners {
|
|
|
73
75
|
: EventListenerPhases.Bubble;
|
|
74
76
|
const registeredPhases = listenersMap.get(callback) ?? EventListenerPhases.None;
|
|
75
77
|
if (registeredPhases & listenerPhase) {
|
|
76
|
-
|
|
78
|
+
log.warn('A listener is already registered for this phase');
|
|
77
79
|
return;
|
|
78
80
|
}
|
|
79
81
|
listenersMap.set(callback, registeredPhases | listenerPhase);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { coreLog } from './logger.js';
|
|
2
|
+
const log = coreLog.getLogger('utilities', 'getBufferConfiguration');
|
|
1
3
|
function getConstructorFromType(bufferType, isVolumeBuffer) {
|
|
2
4
|
switch (bufferType) {
|
|
3
5
|
case 'Float32Array':
|
|
@@ -12,7 +14,7 @@ function getConstructorFromType(bufferType, isVolumeBuffer) {
|
|
|
12
14
|
return bufferType === 'Uint16Array' ? Uint16Array : Int16Array;
|
|
13
15
|
}
|
|
14
16
|
else {
|
|
15
|
-
|
|
17
|
+
log.debug(`${bufferType} is not supported for volume rendering, switching back to Float32Array`);
|
|
16
18
|
return Float32Array;
|
|
17
19
|
}
|
|
18
20
|
default:
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { mat3 } from 'gl-matrix';
|
|
2
|
+
import type { IImageVolume, Point3 } from '../types/index.js';
|
|
3
|
+
export default function getEffectiveSpacingAlongDirection(volume: IImageVolume | {
|
|
4
|
+
direction: mat3 | number[];
|
|
5
|
+
spacing: Point3;
|
|
6
|
+
}, direction: Point3): number;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { vec3 } from 'gl-matrix';
|
|
2
|
+
export default function getEffectiveSpacingAlongDirection(volume, direction) {
|
|
3
|
+
const { direction: volumeDirection, spacing } = volume;
|
|
4
|
+
const iVector = volumeDirection.slice(0, 3);
|
|
5
|
+
const jVector = volumeDirection.slice(3, 6);
|
|
6
|
+
const kVector = volumeDirection.slice(6, 9);
|
|
7
|
+
const dotI = vec3.dot(iVector, direction) / spacing[0];
|
|
8
|
+
const dotJ = vec3.dot(jVector, direction) / spacing[1];
|
|
9
|
+
const dotK = vec3.dot(kVector, direction) / spacing[2];
|
|
10
|
+
return 1 / Math.sqrt(dotI * dotI + dotJ * dotJ + dotK * dotK);
|
|
11
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import getSliceRange from './getSliceRange.js';
|
|
2
2
|
import getTargetVolumeAndSpacingInNormalDir from './getTargetVolumeAndSpacingInNormalDir.js';
|
|
3
|
+
import { coreLog } from './logger.js';
|
|
4
|
+
const log = coreLog.getLogger('utilities', 'getImageSliceDataForVolumeViewport');
|
|
3
5
|
function getImageSliceDataForVolumeViewport(viewport) {
|
|
4
6
|
const camera = viewport.getCamera();
|
|
5
7
|
const { spacingInNormalDirection, imageVolume } = getTargetVolumeAndSpacingInNormalDir(viewport, camera);
|
|
@@ -12,7 +14,7 @@ function getImageSliceDataForVolumeViewport(viewport) {
|
|
|
12
14
|
.find((a) => a.referencedId === imageVolume.volumeId ||
|
|
13
15
|
a.uid === imageVolume.volumeId);
|
|
14
16
|
if (!actorEntry) {
|
|
15
|
-
|
|
17
|
+
log.warn('No actor found for with actorUID of', imageVolume.volumeId);
|
|
16
18
|
}
|
|
17
19
|
const volumeActor = actorEntry.actor;
|
|
18
20
|
const sliceRange = getSliceRange(volumeActor, viewPlaneNormal, focalPoint);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import getSliceRange from './getSliceRange.js';
|
|
2
2
|
import getTargetVolumeAndSpacingInNormalDir from './getTargetVolumeAndSpacingInNormalDir.js';
|
|
3
|
+
import { coreLog } from './logger.js';
|
|
4
|
+
const log = coreLog.getLogger('utilities', 'getVolumeSliceRangeInfo');
|
|
3
5
|
function getVolumeSliceRangeInfo(viewport, volumeId, useSlabThickness = false) {
|
|
4
6
|
const camera = viewport.getCamera();
|
|
5
7
|
const { focalPoint, viewPlaneNormal } = camera;
|
|
@@ -9,7 +11,7 @@ function getVolumeSliceRangeInfo(viewport, volumeId, useSlabThickness = false) {
|
|
|
9
11
|
}
|
|
10
12
|
const actorEntry = viewport.getActor(actorUID);
|
|
11
13
|
if (!actorEntry) {
|
|
12
|
-
|
|
14
|
+
log.warn('No actor found for with actorUID of', actorUID);
|
|
13
15
|
return null;
|
|
14
16
|
}
|
|
15
17
|
const volumeActor = actorEntry.actor;
|