@cornerstonejs/core 0.33.0 → 0.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/RenderingEngine/BaseVolumeViewport.js.map +1 -1
- package/dist/cjs/RenderingEngine/StackViewport.d.ts +31 -22
- package/dist/cjs/RenderingEngine/StackViewport.js +246 -258
- package/dist/cjs/RenderingEngine/StackViewport.js.map +1 -1
- package/dist/cjs/RenderingEngine/helpers/cpuFallback/rendering/generateColorLUT.d.ts +1 -1
- package/dist/cjs/RenderingEngine/helpers/cpuFallback/rendering/generateColorLUT.js +2 -2
- package/dist/cjs/RenderingEngine/helpers/cpuFallback/rendering/generateColorLUT.js.map +1 -1
- package/dist/esm/RenderingEngine/BaseVolumeViewport.js.map +1 -1
- package/dist/esm/RenderingEngine/StackViewport.d.ts +31 -22
- package/dist/esm/RenderingEngine/StackViewport.js +244 -257
- package/dist/esm/RenderingEngine/StackViewport.js.map +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/generateColorLUT.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/generateColorLUT.js +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/generateColorLUT.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -70,9 +70,9 @@ const EPSILON = 1;
|
|
|
70
70
|
class StackViewport extends Viewport_1.default {
|
|
71
71
|
constructor(props) {
|
|
72
72
|
super(props);
|
|
73
|
+
this.voiUpdatedWithSetProperties = false;
|
|
73
74
|
this.invert = false;
|
|
74
75
|
this.stackInvalidated = false;
|
|
75
|
-
this.voiApplied = false;
|
|
76
76
|
this._publishCalibratedEvent = false;
|
|
77
77
|
this.resize = () => {
|
|
78
78
|
if (this.useCPURendering) {
|
|
@@ -106,22 +106,16 @@ class StackViewport extends Viewport_1.default {
|
|
|
106
106
|
return actor;
|
|
107
107
|
};
|
|
108
108
|
this.getProperties = () => {
|
|
109
|
+
const { voiRange, VOILUTFunction, interpolationType, invert } = this;
|
|
110
|
+
const rotation = this.getRotation();
|
|
109
111
|
return {
|
|
110
|
-
voiRange
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
voiRange,
|
|
113
|
+
VOILUTFunction,
|
|
114
|
+
interpolationType,
|
|
115
|
+
invert,
|
|
116
|
+
rotation,
|
|
115
117
|
};
|
|
116
118
|
};
|
|
117
|
-
this.getRotation = () => {
|
|
118
|
-
if (this.useCPURendering) {
|
|
119
|
-
return this.getRotationCPU();
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
return this.getRotationGPU();
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
119
|
this.getRotationCPU = () => {
|
|
126
120
|
const { viewport } = this._cpuFallbackEnabledElement;
|
|
127
121
|
return viewport.rotation;
|
|
@@ -138,18 +132,6 @@ class StackViewport extends Viewport_1.default {
|
|
|
138
132
|
? initialToCurrentViewUpAngle
|
|
139
133
|
: (360 - initialToCurrentViewUpAngle) % 360;
|
|
140
134
|
};
|
|
141
|
-
this.canvasToWorld = (canvasPos) => {
|
|
142
|
-
if (this.useCPURendering) {
|
|
143
|
-
return this.canvasToWorldCPU(canvasPos);
|
|
144
|
-
}
|
|
145
|
-
return this.canvasToWorldGPU(canvasPos);
|
|
146
|
-
};
|
|
147
|
-
this.worldToCanvas = (worldPos) => {
|
|
148
|
-
if (this.useCPURendering) {
|
|
149
|
-
return this.worldToCanvasCPU(worldPos);
|
|
150
|
-
}
|
|
151
|
-
return this.worldToCanvasGPU(worldPos);
|
|
152
|
-
};
|
|
153
135
|
this.canvasToWorldCPU = (canvasPos) => {
|
|
154
136
|
if (!this._cpuFallbackEnabledElement.image) {
|
|
155
137
|
return;
|
|
@@ -262,9 +244,98 @@ class StackViewport extends Viewport_1.default {
|
|
|
262
244
|
renderingEngineId: this.renderingEngineId,
|
|
263
245
|
};
|
|
264
246
|
};
|
|
247
|
+
this.renderingPipelineFunctions = {
|
|
248
|
+
getImageData: {
|
|
249
|
+
cpu: this.getImageDataCPU,
|
|
250
|
+
gpu: this.getImageDataGPU,
|
|
251
|
+
},
|
|
252
|
+
setColormap: {
|
|
253
|
+
cpu: this.setColormapCPU,
|
|
254
|
+
gpu: this.setColormapGPU,
|
|
255
|
+
},
|
|
256
|
+
getCamera: {
|
|
257
|
+
cpu: this.getCameraCPU,
|
|
258
|
+
gpu: super.getCamera,
|
|
259
|
+
},
|
|
260
|
+
setCamera: {
|
|
261
|
+
cpu: this.setCameraCPU,
|
|
262
|
+
gpu: super.setCamera,
|
|
263
|
+
},
|
|
264
|
+
setVOI: {
|
|
265
|
+
cpu: this.setVOICPU,
|
|
266
|
+
gpu: this.setVOIGPU,
|
|
267
|
+
},
|
|
268
|
+
getRotation: {
|
|
269
|
+
cpu: this.getRotationCPU,
|
|
270
|
+
gpu: this.getRotationGPU,
|
|
271
|
+
},
|
|
272
|
+
setInterpolationType: {
|
|
273
|
+
cpu: this.setInterpolationTypeCPU,
|
|
274
|
+
gpu: this.setInterpolationTypeGPU,
|
|
275
|
+
},
|
|
276
|
+
setInvertColor: {
|
|
277
|
+
cpu: this.setInvertColorCPU,
|
|
278
|
+
gpu: this.setInvertColorGPU,
|
|
279
|
+
},
|
|
280
|
+
resetCamera: {
|
|
281
|
+
cpu: (resetPan = true, resetZoom = true) => {
|
|
282
|
+
this.resetCameraCPU(resetPan, resetZoom);
|
|
283
|
+
return true;
|
|
284
|
+
},
|
|
285
|
+
gpu: (resetPan = true, resetZoom = true) => {
|
|
286
|
+
this.resetCameraGPU(resetPan, resetZoom);
|
|
287
|
+
return true;
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
canvasToWorld: {
|
|
291
|
+
cpu: this.canvasToWorldCPU,
|
|
292
|
+
gpu: this.canvasToWorldGPU,
|
|
293
|
+
},
|
|
294
|
+
worldToCanvas: {
|
|
295
|
+
cpu: this.worldToCanvasCPU,
|
|
296
|
+
gpu: this.worldToCanvasGPU,
|
|
297
|
+
},
|
|
298
|
+
getRenderer: {
|
|
299
|
+
cpu: () => this.getCPUFallbackError('getRenderer'),
|
|
300
|
+
gpu: super.getRenderer,
|
|
301
|
+
},
|
|
302
|
+
getDefaultActor: {
|
|
303
|
+
cpu: () => this.getCPUFallbackError('getDefaultActor'),
|
|
304
|
+
gpu: super.getDefaultActor,
|
|
305
|
+
},
|
|
306
|
+
getActors: {
|
|
307
|
+
cpu: () => this.getCPUFallbackError('getActors'),
|
|
308
|
+
gpu: super.getActors,
|
|
309
|
+
},
|
|
310
|
+
getActor: {
|
|
311
|
+
cpu: () => this.getCPUFallbackError('getActor'),
|
|
312
|
+
gpu: super.getActor,
|
|
313
|
+
},
|
|
314
|
+
setActors: {
|
|
315
|
+
cpu: () => this.getCPUFallbackError('setActors'),
|
|
316
|
+
gpu: super.setActors,
|
|
317
|
+
},
|
|
318
|
+
addActors: {
|
|
319
|
+
cpu: () => this.getCPUFallbackError('addActors'),
|
|
320
|
+
gpu: super.addActors,
|
|
321
|
+
},
|
|
322
|
+
addActor: {
|
|
323
|
+
cpu: () => this.getCPUFallbackError('addActor'),
|
|
324
|
+
gpu: super.addActor,
|
|
325
|
+
},
|
|
326
|
+
removeAllActors: {
|
|
327
|
+
cpu: () => this.getCPUFallbackError('removeAllActors'),
|
|
328
|
+
gpu: super.removeAllActors,
|
|
329
|
+
},
|
|
330
|
+
unsetColormap: {
|
|
331
|
+
cpu: this.unsetColormapCPU,
|
|
332
|
+
gpu: this.unsetColormapGPU,
|
|
333
|
+
},
|
|
334
|
+
};
|
|
265
335
|
this.scaling = {};
|
|
266
336
|
this.modality = null;
|
|
267
337
|
this.useCPURendering = (0, init_1.getShouldUseCPURendering)();
|
|
338
|
+
this._configureRenderingPipeline();
|
|
268
339
|
if (this.useCPURendering) {
|
|
269
340
|
this._cpuFallbackEnabledElement = {
|
|
270
341
|
canvas: this.canvas,
|
|
@@ -295,20 +366,21 @@ class StackViewport extends Viewport_1.default {
|
|
|
295
366
|
static get useCustomRenderingPipeline() {
|
|
296
367
|
return (0, init_1.getShouldUseCPURendering)();
|
|
297
368
|
}
|
|
369
|
+
setUseCPURendering(value) {
|
|
370
|
+
this.useCPURendering = value;
|
|
371
|
+
this._configureRenderingPipeline();
|
|
372
|
+
}
|
|
373
|
+
_configureRenderingPipeline() {
|
|
374
|
+
for (const [funcName, functions] of Object.entries(this.renderingPipelineFunctions)) {
|
|
375
|
+
this[funcName] = this.useCPURendering ? functions.cpu : functions.gpu;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
298
378
|
initializeElementDisabledHandler() {
|
|
299
379
|
eventTarget_1.default.addEventListener(Events_1.default.ELEMENT_DISABLED, function elementDisabledHandler() {
|
|
300
380
|
clearTimeout(this.debouncedTimeout);
|
|
301
381
|
eventTarget_1.default.removeEventListener(Events_1.default.ELEMENT_DISABLED, elementDisabledHandler);
|
|
302
382
|
});
|
|
303
383
|
}
|
|
304
|
-
getImageData() {
|
|
305
|
-
if (this.useCPURendering) {
|
|
306
|
-
return this.getImageDataCPU();
|
|
307
|
-
}
|
|
308
|
-
else {
|
|
309
|
-
return this.getImageDataGPU();
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
384
|
getImageDataGPU() {
|
|
313
385
|
const defaultActor = this.getDefaultActor();
|
|
314
386
|
if (!defaultActor) {
|
|
@@ -365,28 +437,18 @@ class StackViewport extends Viewport_1.default {
|
|
|
365
437
|
preScale: Object.assign({}, this.csImage.preScale),
|
|
366
438
|
};
|
|
367
439
|
}
|
|
368
|
-
buildMetadata(
|
|
440
|
+
buildMetadata(image) {
|
|
441
|
+
const imageId = image.imageId;
|
|
369
442
|
const { pixelRepresentation, bitsAllocated, bitsStored, highBit, photometricInterpretation, samplesPerPixel, } = metaData.get('imagePixelModule', imageId);
|
|
370
|
-
const
|
|
371
|
-
let windowWidth, windowCenter, voiLUTFunction;
|
|
372
|
-
if (voiLutModule) {
|
|
373
|
-
({ windowWidth, windowCenter, voiLUTFunction } = voiLutModule);
|
|
374
|
-
if (Array.isArray(windowWidth)) {
|
|
375
|
-
windowWidth = windowWidth[0];
|
|
376
|
-
}
|
|
377
|
-
if (Array.isArray(windowCenter)) {
|
|
378
|
-
windowCenter = windowCenter[0];
|
|
379
|
-
}
|
|
380
|
-
if (Object.values(VOILUTFunctionType_1.default).indexOf(voiLUTFunction) === -1) {
|
|
381
|
-
voiLUTFunction = VOILUTFunctionType_1.default.LINEAR;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
443
|
+
const { windowWidth, windowCenter, voiLUTFunction } = image;
|
|
384
444
|
const { modality } = metaData.get('generalSeriesModule', imageId);
|
|
385
445
|
const imageIdScalingFactor = metaData.get('scalingModule', imageId);
|
|
386
446
|
if (modality === 'PT' && imageIdScalingFactor) {
|
|
387
447
|
this._addScalingToViewport(imageIdScalingFactor);
|
|
388
448
|
}
|
|
389
449
|
this.modality = modality;
|
|
450
|
+
const voiLUTFunctionEnum = this._getValidVOILUTFunction(voiLUTFunction);
|
|
451
|
+
this.VOILUTFunction = voiLUTFunctionEnum;
|
|
390
452
|
let imagePlaneModule = this._getImagePlaneModule(imageId);
|
|
391
453
|
if (!this.useCPURendering) {
|
|
392
454
|
imagePlaneModule = this.calibrateIfNecessary(imageId, imagePlaneModule);
|
|
@@ -402,8 +464,8 @@ class StackViewport extends Viewport_1.default {
|
|
|
402
464
|
pixelRepresentation,
|
|
403
465
|
windowWidth,
|
|
404
466
|
windowCenter,
|
|
405
|
-
voiLUTFunction,
|
|
406
467
|
modality,
|
|
468
|
+
voiLUTFunction: voiLUTFunctionEnum,
|
|
407
469
|
},
|
|
408
470
|
};
|
|
409
471
|
}
|
|
@@ -451,8 +513,9 @@ class StackViewport extends Viewport_1.default {
|
|
|
451
513
|
return imagePlaneModule;
|
|
452
514
|
}
|
|
453
515
|
setProperties({ voiRange, VOILUTFunction, invert, interpolationType, rotation, } = {}, suppressEvents = false) {
|
|
454
|
-
if (typeof voiRange !== 'undefined'
|
|
455
|
-
|
|
516
|
+
if (typeof voiRange !== 'undefined') {
|
|
517
|
+
const voiUpdatedWithSetProperties = true;
|
|
518
|
+
this.setVOI(voiRange, { suppressEvents, voiUpdatedWithSetProperties });
|
|
456
519
|
}
|
|
457
520
|
if (typeof VOILUTFunction !== 'undefined') {
|
|
458
521
|
this.setVOILUTFunction(VOILUTFunction, suppressEvents);
|
|
@@ -471,6 +534,7 @@ class StackViewport extends Viewport_1.default {
|
|
|
471
534
|
}
|
|
472
535
|
resetProperties() {
|
|
473
536
|
this.cpuRenderingInvalidated = true;
|
|
537
|
+
this.voiUpdatedWithSetProperties = false;
|
|
474
538
|
this.fillWithBackgroundColor();
|
|
475
539
|
if (this.useCPURendering) {
|
|
476
540
|
this._cpuFallbackEnabledElement.renderingTools = {};
|
|
@@ -478,38 +542,37 @@ class StackViewport extends Viewport_1.default {
|
|
|
478
542
|
this._resetProperties();
|
|
479
543
|
this.render();
|
|
480
544
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
545
|
+
_resetProperties() {
|
|
546
|
+
let voiRange;
|
|
547
|
+
if (this._isCurrentImagePTPrescaled()) {
|
|
548
|
+
voiRange = this._getDefaultPTPrescaledVOIRange();
|
|
484
549
|
}
|
|
485
550
|
else {
|
|
486
|
-
|
|
551
|
+
voiRange = this._getVOIRangeForCurrentImage();
|
|
487
552
|
}
|
|
553
|
+
this.setVOI(voiRange);
|
|
554
|
+
if (this.getRotation() !== 0) {
|
|
555
|
+
this.setRotation(0);
|
|
556
|
+
}
|
|
557
|
+
this.setInterpolationType(InterpolationType_1.default.LINEAR);
|
|
558
|
+
this.setInvertColor(false);
|
|
488
559
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
560
|
+
_setPropertiesFromCache() {
|
|
561
|
+
var _a;
|
|
562
|
+
const { interpolationType, invert } = this;
|
|
563
|
+
let voiRange;
|
|
564
|
+
if (this.voiUpdatedWithSetProperties) {
|
|
565
|
+
voiRange = this.voiRange;
|
|
566
|
+
}
|
|
567
|
+
else if (this._isCurrentImagePTPrescaled()) {
|
|
568
|
+
voiRange = this._getDefaultPTPrescaledVOIRange();
|
|
492
569
|
}
|
|
493
570
|
else {
|
|
494
|
-
|
|
571
|
+
voiRange = (_a = this._getVOIRangeForCurrentImage()) !== null && _a !== void 0 ? _a : this.voiRange;
|
|
495
572
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
this.
|
|
499
|
-
this.setProperties({
|
|
500
|
-
voiRange: this.initialVOIRange,
|
|
501
|
-
rotation: 0,
|
|
502
|
-
interpolationType: InterpolationType_1.default.LINEAR,
|
|
503
|
-
invert: false,
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
|
-
_setPropertiesFromCache() {
|
|
507
|
-
const suppressEvents = true;
|
|
508
|
-
this.setProperties({
|
|
509
|
-
voiRange: this.voiRange,
|
|
510
|
-
interpolationType: this.interpolationType,
|
|
511
|
-
invert: this.invert,
|
|
512
|
-
}, suppressEvents);
|
|
573
|
+
this.setVOI(voiRange);
|
|
574
|
+
this.setInterpolationType(interpolationType);
|
|
575
|
+
this.setInvertColor(invert);
|
|
513
576
|
}
|
|
514
577
|
getCameraCPU() {
|
|
515
578
|
const { metadata, viewport } = this._cpuFallbackEnabledElement;
|
|
@@ -596,21 +659,11 @@ class StackViewport extends Viewport_1.default {
|
|
|
596
659
|
this.flipVertical = viewport.vflip;
|
|
597
660
|
}
|
|
598
661
|
}
|
|
599
|
-
setVOI(voiRange, suppressEvents) {
|
|
600
|
-
if (this.useCPURendering) {
|
|
601
|
-
this.setVOICPU(voiRange, suppressEvents);
|
|
602
|
-
return;
|
|
603
|
-
}
|
|
604
|
-
this.setVOIGPU(voiRange, suppressEvents);
|
|
605
|
-
}
|
|
606
662
|
setRotation(rotation) {
|
|
607
663
|
const previousCamera = this.getCamera();
|
|
608
|
-
|
|
609
|
-
this.setRotationCPU(rotation)
|
|
610
|
-
|
|
611
|
-
else {
|
|
612
|
-
this.setRotationGPU(rotation);
|
|
613
|
-
}
|
|
664
|
+
this.useCPURendering
|
|
665
|
+
? this.setRotationCPU(rotation)
|
|
666
|
+
: this.setRotationGPU(rotation);
|
|
614
667
|
const camera = this.getCamera();
|
|
615
668
|
const eventDetail = {
|
|
616
669
|
previousCamera,
|
|
@@ -626,26 +679,15 @@ class StackViewport extends Viewport_1.default {
|
|
|
626
679
|
if (this.useCPURendering) {
|
|
627
680
|
throw new Error('VOI LUT function is not supported in CPU rendering');
|
|
628
681
|
}
|
|
629
|
-
|
|
630
|
-
|
|
682
|
+
const newVOILUTFunction = this._getValidVOILUTFunction(voiLUTFunction);
|
|
683
|
+
let forceRecreateLUTFunction = false;
|
|
684
|
+
if (this.VOILUTFunction !== VOILUTFunctionType_1.default.LINEAR &&
|
|
685
|
+
newVOILUTFunction === VOILUTFunctionType_1.default.LINEAR) {
|
|
686
|
+
forceRecreateLUTFunction = true;
|
|
631
687
|
}
|
|
632
|
-
this.VOILUTFunction =
|
|
688
|
+
this.VOILUTFunction = newVOILUTFunction;
|
|
633
689
|
const { voiRange } = this.getProperties();
|
|
634
|
-
this.setVOI(voiRange, suppressEvents);
|
|
635
|
-
}
|
|
636
|
-
setInterpolationType(interpolationType) {
|
|
637
|
-
if (this.useCPURendering) {
|
|
638
|
-
this.setInterpolationTypeCPU(interpolationType);
|
|
639
|
-
return;
|
|
640
|
-
}
|
|
641
|
-
this.setInterpolationTypeGPU(interpolationType);
|
|
642
|
-
}
|
|
643
|
-
setInvertColor(invert) {
|
|
644
|
-
if (this.useCPURendering) {
|
|
645
|
-
this.setInvertColorCPU(invert);
|
|
646
|
-
return;
|
|
647
|
-
}
|
|
648
|
-
this.setInvertColorGPU(invert);
|
|
690
|
+
this.setVOI(voiRange, { suppressEvents, forceRecreateLUTFunction });
|
|
649
691
|
}
|
|
650
692
|
setRotationCPU(rotation) {
|
|
651
693
|
const { viewport } = this._cpuFallbackEnabledElement;
|
|
@@ -676,12 +718,8 @@ class StackViewport extends Viewport_1.default {
|
|
|
676
718
|
}
|
|
677
719
|
setInterpolationTypeCPU(interpolationType) {
|
|
678
720
|
const { viewport } = this._cpuFallbackEnabledElement;
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
}
|
|
682
|
-
else {
|
|
683
|
-
viewport.pixelReplication = true;
|
|
684
|
-
}
|
|
721
|
+
viewport.pixelReplication =
|
|
722
|
+
interpolationType === InterpolationType_1.default.LINEAR ? false : true;
|
|
685
723
|
this.interpolationType = interpolationType;
|
|
686
724
|
}
|
|
687
725
|
setInvertColorCPU(invert) {
|
|
@@ -717,7 +755,8 @@ class StackViewport extends Viewport_1.default {
|
|
|
717
755
|
this.invert = invert;
|
|
718
756
|
}
|
|
719
757
|
}
|
|
720
|
-
setVOICPU(voiRange,
|
|
758
|
+
setVOICPU(voiRange, options = {}) {
|
|
759
|
+
const { suppressEvents = false } = options;
|
|
721
760
|
const { viewport, image } = this._cpuFallbackEnabledElement;
|
|
722
761
|
if (!viewport || !image) {
|
|
723
762
|
return;
|
|
@@ -745,7 +784,6 @@ class StackViewport extends Viewport_1.default {
|
|
|
745
784
|
viewport.voi.windowWidth = windowWidth;
|
|
746
785
|
viewport.voi.windowCenter = windowCenter;
|
|
747
786
|
}
|
|
748
|
-
this.voiApplied = true;
|
|
749
787
|
this.voiRange = voiRange;
|
|
750
788
|
const eventDetail = {
|
|
751
789
|
viewportId: this.id,
|
|
@@ -755,7 +793,15 @@ class StackViewport extends Viewport_1.default {
|
|
|
755
793
|
(0, utilities_1.triggerEvent)(this.element, Events_1.default.VOI_MODIFIED, eventDetail);
|
|
756
794
|
}
|
|
757
795
|
}
|
|
758
|
-
setVOIGPU(voiRange,
|
|
796
|
+
setVOIGPU(voiRange, options = {}) {
|
|
797
|
+
const { suppressEvents = false, forceRecreateLUTFunction = false, voiUpdatedWithSetProperties = false, } = options;
|
|
798
|
+
if (voiRange &&
|
|
799
|
+
this.voiRange &&
|
|
800
|
+
this.voiRange.lower === voiRange.lower &&
|
|
801
|
+
this.voiRange.upper === voiRange.upper &&
|
|
802
|
+
!forceRecreateLUTFunction) {
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
759
805
|
const defaultActor = this.getDefaultActor();
|
|
760
806
|
if (!defaultActor) {
|
|
761
807
|
return;
|
|
@@ -763,8 +809,7 @@ class StackViewport extends Viewport_1.default {
|
|
|
763
809
|
if (!(0, utilities_1.isImageActor)(defaultActor)) {
|
|
764
810
|
return;
|
|
765
811
|
}
|
|
766
|
-
const
|
|
767
|
-
const imageActor = actor;
|
|
812
|
+
const imageActor = defaultActor.actor;
|
|
768
813
|
let voiRangeToUse = voiRange;
|
|
769
814
|
if (typeof voiRangeToUse === 'undefined') {
|
|
770
815
|
const imageData = imageActor.getMapper().getInputData();
|
|
@@ -773,43 +818,48 @@ class StackViewport extends Viewport_1.default {
|
|
|
773
818
|
voiRangeToUse = maxVoiRange;
|
|
774
819
|
}
|
|
775
820
|
imageActor.getProperty().setUseLookupTableScalarRange(true);
|
|
776
|
-
|
|
777
|
-
|
|
821
|
+
let transferFunction = imageActor.getProperty().getRGBTransferFunction(0);
|
|
822
|
+
const isSigmoidTFun = this.VOILUTFunction === VOILUTFunctionType_1.default.SAMPLED_SIGMOID;
|
|
823
|
+
if (isSigmoidTFun || !transferFunction || forceRecreateLUTFunction) {
|
|
824
|
+
const transferFunctionCreator = isSigmoidTFun
|
|
825
|
+
? utilities_1.createSigmoidRGBTransferFunction
|
|
826
|
+
: createLinearRGBTransferFunction_1.default;
|
|
827
|
+
transferFunction = transferFunctionCreator(voiRangeToUse);
|
|
778
828
|
if (this.invert) {
|
|
779
|
-
(0, utilities_1.invertRgbTransferFunction)(
|
|
829
|
+
(0, utilities_1.invertRgbTransferFunction)(transferFunction);
|
|
780
830
|
}
|
|
781
|
-
imageActor.getProperty().setRGBTransferFunction(0,
|
|
831
|
+
imageActor.getProperty().setRGBTransferFunction(0, transferFunction);
|
|
782
832
|
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
if (this.invert) {
|
|
786
|
-
(0, utilities_1.invertRgbTransferFunction)(cfun);
|
|
787
|
-
}
|
|
788
|
-
imageActor.getProperty().setRGBTransferFunction(0, cfun);
|
|
833
|
+
if (!isSigmoidTFun) {
|
|
834
|
+
transferFunction.setRange(voiRangeToUse.lower, voiRangeToUse.upper);
|
|
789
835
|
}
|
|
790
|
-
this.voiApplied = true;
|
|
791
836
|
this.voiRange = voiRangeToUse;
|
|
792
|
-
if (!
|
|
793
|
-
|
|
794
|
-
viewportId: this.id,
|
|
795
|
-
range: voiRangeToUse,
|
|
796
|
-
VOILUTFunction: this.VOILUTFunction,
|
|
797
|
-
};
|
|
798
|
-
(0, utilities_1.triggerEvent)(this.element, Events_1.default.VOI_MODIFIED, eventDetail);
|
|
837
|
+
if (!this.voiUpdatedWithSetProperties) {
|
|
838
|
+
this.voiUpdatedWithSetProperties = voiUpdatedWithSetProperties;
|
|
799
839
|
}
|
|
840
|
+
if (suppressEvents) {
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
const eventDetail = {
|
|
844
|
+
viewportId: this.id,
|
|
845
|
+
range: voiRangeToUse,
|
|
846
|
+
VOILUTFunction: this.VOILUTFunction,
|
|
847
|
+
};
|
|
848
|
+
(0, utilities_1.triggerEvent)(this.element, Events_1.default.VOI_MODIFIED, eventDetail);
|
|
800
849
|
}
|
|
801
850
|
_addScalingToViewport(imageIdScalingFactor) {
|
|
802
|
-
if (
|
|
803
|
-
|
|
804
|
-
const petScaling = {};
|
|
805
|
-
if (suvlbm) {
|
|
806
|
-
petScaling.suvbwToSuvlbm = suvlbm / suvbw;
|
|
807
|
-
}
|
|
808
|
-
if (suvbsa) {
|
|
809
|
-
petScaling.suvbwToSuvbsa = suvbsa / suvbw;
|
|
810
|
-
}
|
|
811
|
-
this.scaling.PET = petScaling;
|
|
851
|
+
if (this.scaling.PET) {
|
|
852
|
+
return;
|
|
812
853
|
}
|
|
854
|
+
const { suvbw, suvlbm, suvbsa } = imageIdScalingFactor;
|
|
855
|
+
const petScaling = {};
|
|
856
|
+
if (suvlbm) {
|
|
857
|
+
petScaling.suvbwToSuvlbm = suvlbm / suvbw;
|
|
858
|
+
}
|
|
859
|
+
if (suvbsa) {
|
|
860
|
+
petScaling.suvbwToSuvbsa = suvbsa / suvbw;
|
|
861
|
+
}
|
|
862
|
+
this.scaling.PET = petScaling;
|
|
813
863
|
}
|
|
814
864
|
_getNumCompsFromPhotometricInterpretation(photometricInterpretation) {
|
|
815
865
|
let numberOfComponents = 1;
|
|
@@ -821,7 +871,7 @@ class StackViewport extends Viewport_1.default {
|
|
|
821
871
|
return numberOfComponents;
|
|
822
872
|
}
|
|
823
873
|
_getImageDataMetadata(image) {
|
|
824
|
-
const { imagePlaneModule, imagePixelModule } = this.buildMetadata(image
|
|
874
|
+
const { imagePlaneModule, imagePixelModule } = this.buildMetadata(image);
|
|
825
875
|
let rowCosines, columnCosines;
|
|
826
876
|
rowCosines = imagePlaneModule.rowCosines;
|
|
827
877
|
columnCosines = imagePlaneModule.columnCosines;
|
|
@@ -904,8 +954,9 @@ class StackViewport extends Viewport_1.default {
|
|
|
904
954
|
this.stackInvalidated = true;
|
|
905
955
|
this.flipVertical = false;
|
|
906
956
|
this.flipHorizontal = false;
|
|
907
|
-
this.
|
|
908
|
-
this.
|
|
957
|
+
this.voiRange = null;
|
|
958
|
+
this.interpolationType = InterpolationType_1.default.LINEAR;
|
|
959
|
+
this.invert = false;
|
|
909
960
|
this.fillWithBackgroundColor();
|
|
910
961
|
if (this.useCPURendering) {
|
|
911
962
|
this._cpuFallbackEnabledElement.renderingTools = {};
|
|
@@ -972,12 +1023,9 @@ class StackViewport extends Viewport_1.default {
|
|
|
972
1023
|
}
|
|
973
1024
|
_loadAndDisplayImage(imageId, imageIdIndex) {
|
|
974
1025
|
return __awaiter(this, void 0, void 0, function* () {
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
else {
|
|
979
|
-
yield this._loadAndDisplayImageGPU(imageId, imageIdIndex);
|
|
980
|
-
}
|
|
1026
|
+
yield (this.useCPURendering
|
|
1027
|
+
? this._loadAndDisplayImageCPU(imageId, imageIdIndex)
|
|
1028
|
+
: this._loadAndDisplayImageGPU(imageId, imageIdIndex));
|
|
981
1029
|
return imageId;
|
|
982
1030
|
});
|
|
983
1031
|
}
|
|
@@ -988,6 +1036,7 @@ class StackViewport extends Viewport_1.default {
|
|
|
988
1036
|
if (this.currentImageIdIndex !== imageIdIndex) {
|
|
989
1037
|
return;
|
|
990
1038
|
}
|
|
1039
|
+
image.isPreScaled = (_a = image.preScale) === null || _a === void 0 ? void 0 : _a.scaled;
|
|
991
1040
|
this.csImage = image;
|
|
992
1041
|
const eventDetail = {
|
|
993
1042
|
image,
|
|
@@ -998,7 +1047,6 @@ class StackViewport extends Viewport_1.default {
|
|
|
998
1047
|
};
|
|
999
1048
|
(0, utilities_1.triggerEvent)(this.element, Events_1.default.STACK_NEW_IMAGE, eventDetail);
|
|
1000
1049
|
const metadata = this._getImageDataMetadata(image);
|
|
1001
|
-
image.isPreScaled = (_a = image.preScale) === null || _a === void 0 ? void 0 : _a.scaled;
|
|
1002
1050
|
const viewport = (0, getDefaultViewport_1.default)(this.canvas, image, this.modality, this._cpuFallbackEnabledElement.viewport.colormap);
|
|
1003
1051
|
this._cpuFallbackEnabledElement.image = image;
|
|
1004
1052
|
this._cpuFallbackEnabledElement.metadata = Object.assign({}, metadata);
|
|
@@ -1053,9 +1101,11 @@ class StackViewport extends Viewport_1.default {
|
|
|
1053
1101
|
_loadAndDisplayImageGPU(imageId, imageIdIndex) {
|
|
1054
1102
|
return new Promise((resolve, reject) => {
|
|
1055
1103
|
function successCallback(image, imageIdIndex, imageId) {
|
|
1104
|
+
var _a;
|
|
1056
1105
|
if (this.currentImageIdIndex !== imageIdIndex) {
|
|
1057
1106
|
return;
|
|
1058
1107
|
}
|
|
1108
|
+
image.isPreScaled = (_a = image.preScale) === null || _a === void 0 ? void 0 : _a.scaled;
|
|
1059
1109
|
this.csImage = image;
|
|
1060
1110
|
const eventDetail = {
|
|
1061
1111
|
image,
|
|
@@ -1112,7 +1162,6 @@ class StackViewport extends Viewport_1.default {
|
|
|
1112
1162
|
});
|
|
1113
1163
|
}
|
|
1114
1164
|
_updateActorToDisplayImageId(image) {
|
|
1115
|
-
var _a;
|
|
1116
1165
|
const sameImageData = this._checkVTKImageDataMatchesCornerstoneImage(image, this._imageData);
|
|
1117
1166
|
const activeCamera = this.getRenderer().getActiveCamera();
|
|
1118
1167
|
const previousCameraProps = (0, lodash_clonedeep_1.default)(this.getCamera());
|
|
@@ -1154,41 +1203,43 @@ class StackViewport extends Viewport_1.default {
|
|
|
1154
1203
|
this.resetCameraNoEvent();
|
|
1155
1204
|
this.triggerCameraEvent(this.getCamera(), previousCameraProps);
|
|
1156
1205
|
activeCamera.setFreezeFocalPoint(true);
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
: undefined;
|
|
1161
|
-
const isPreScaled = this.csImage.isPreScaled || ((_a = this.csImage.preScale) === null || _a === void 0 ? void 0 : _a.scaled);
|
|
1162
|
-
if (imagePixelModule.modality === 'PT' && isPreScaled) {
|
|
1163
|
-
voiRange = { lower: 0, upper: 5 };
|
|
1164
|
-
}
|
|
1165
|
-
this.initialVOIRange = voiRange;
|
|
1166
|
-
if (this.voiApplied && typeof voiRange === 'undefined') {
|
|
1167
|
-
voiRange = this.voiRange;
|
|
1168
|
-
}
|
|
1169
|
-
if (Object.values(VOILUTFunctionType_1.default).indexOf(voiLUTFunction) === -1) {
|
|
1170
|
-
this.VOILUTFunction = VOILUTFunctionType_1.default.LINEAR;
|
|
1171
|
-
}
|
|
1172
|
-
else {
|
|
1173
|
-
this.VOILUTFunction = voiLUTFunction;
|
|
1174
|
-
}
|
|
1175
|
-
this.setProperties({ voiRange });
|
|
1176
|
-
if (actor.getProperty().getRGBTransferFunction(0) === null) {
|
|
1177
|
-
const cfun = (0, createLinearRGBTransferFunction_1.default)(voiRange);
|
|
1178
|
-
actor.getProperty().setRGBTransferFunction(0, cfun);
|
|
1179
|
-
}
|
|
1180
|
-
let invert = false;
|
|
1181
|
-
if (imagePixelModule.photometricInterpretation === 'MONOCHROME1') {
|
|
1182
|
-
invert = true;
|
|
1183
|
-
}
|
|
1184
|
-
this.setProperties({ invert });
|
|
1185
|
-
const { focalPoint } = this.getCamera();
|
|
1186
|
-
this.cameraFocalPointOnRender = focalPoint;
|
|
1206
|
+
this.setVOI(this._getInitialVOIRange(image));
|
|
1207
|
+
this.setInvertColor(imagePixelModule.photometricInterpretation === 'MONOCHROME1');
|
|
1208
|
+
this.cameraFocalPointOnRender = this.getCamera().focalPoint;
|
|
1187
1209
|
this.stackInvalidated = false;
|
|
1188
1210
|
if (this._publishCalibratedEvent) {
|
|
1189
1211
|
this.triggerCalibrationEvent();
|
|
1190
1212
|
}
|
|
1191
1213
|
}
|
|
1214
|
+
_getInitialVOIRange(image) {
|
|
1215
|
+
if (this.voiRange && this.voiUpdatedWithSetProperties) {
|
|
1216
|
+
return this.voiRange;
|
|
1217
|
+
}
|
|
1218
|
+
const { windowCenter, windowWidth } = image;
|
|
1219
|
+
let voiRange = this._getVOIRangeFromWindowLevel(windowWidth, windowCenter);
|
|
1220
|
+
voiRange = this._getPTPreScaledRange() || voiRange;
|
|
1221
|
+
return voiRange;
|
|
1222
|
+
}
|
|
1223
|
+
_getPTPreScaledRange() {
|
|
1224
|
+
if (!this._isCurrentImagePTPrescaled()) {
|
|
1225
|
+
return undefined;
|
|
1226
|
+
}
|
|
1227
|
+
return this._getDefaultPTPrescaledVOIRange();
|
|
1228
|
+
}
|
|
1229
|
+
_isCurrentImagePTPrescaled() {
|
|
1230
|
+
if (this.modality !== 'PT' || !this.csImage.isPreScaled) {
|
|
1231
|
+
return false;
|
|
1232
|
+
}
|
|
1233
|
+
return true;
|
|
1234
|
+
}
|
|
1235
|
+
_getDefaultPTPrescaledVOIRange() {
|
|
1236
|
+
return { lower: 0, upper: 5 };
|
|
1237
|
+
}
|
|
1238
|
+
_getVOIRangeFromWindowLevel(windowWidth, windowCenter) {
|
|
1239
|
+
return typeof windowCenter === 'number' && typeof windowWidth === 'number'
|
|
1240
|
+
? utilities_1.windowLevel.toLowHighRange(windowWidth, windowCenter)
|
|
1241
|
+
: undefined;
|
|
1242
|
+
}
|
|
1192
1243
|
_setImageIdIndex(imageIdIndex) {
|
|
1193
1244
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1194
1245
|
if (imageIdIndex >= this.imageIds.length) {
|
|
@@ -1200,15 +1251,6 @@ class StackViewport extends Viewport_1.default {
|
|
|
1200
1251
|
return imageId;
|
|
1201
1252
|
});
|
|
1202
1253
|
}
|
|
1203
|
-
resetCamera(resetPan = true, resetZoom = true) {
|
|
1204
|
-
if (this.useCPURendering) {
|
|
1205
|
-
this.resetCameraCPU(resetPan, resetZoom);
|
|
1206
|
-
}
|
|
1207
|
-
else {
|
|
1208
|
-
this.resetCameraGPU(resetPan, resetZoom);
|
|
1209
|
-
}
|
|
1210
|
-
return true;
|
|
1211
|
-
}
|
|
1212
1254
|
resetCameraCPU(resetPan, resetZoom) {
|
|
1213
1255
|
const { image } = this._cpuFallbackEnabledElement;
|
|
1214
1256
|
if (!image) {
|
|
@@ -1318,53 +1360,15 @@ class StackViewport extends Viewport_1.default {
|
|
|
1318
1360
|
}
|
|
1319
1361
|
this._publishCalibratedEvent = false;
|
|
1320
1362
|
}
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
}
|
|
1325
|
-
return super.getRenderer();
|
|
1326
|
-
}
|
|
1327
|
-
getDefaultActor() {
|
|
1328
|
-
if (this.useCPURendering) {
|
|
1329
|
-
throw this.getCPUFallbackError('getDefaultActor');
|
|
1330
|
-
}
|
|
1331
|
-
return super.getDefaultActor();
|
|
1363
|
+
_getVOIRangeForCurrentImage() {
|
|
1364
|
+
const { windowCenter, windowWidth } = this.csImage;
|
|
1365
|
+
return this._getVOIRangeFromWindowLevel(windowWidth, windowCenter);
|
|
1332
1366
|
}
|
|
1333
|
-
|
|
1334
|
-
if (
|
|
1335
|
-
|
|
1336
|
-
}
|
|
1337
|
-
return super.getActors();
|
|
1338
|
-
}
|
|
1339
|
-
getActor(actorUID) {
|
|
1340
|
-
if (this.useCPURendering) {
|
|
1341
|
-
throw this.getCPUFallbackError('getActor');
|
|
1342
|
-
}
|
|
1343
|
-
return super.getActor(actorUID);
|
|
1344
|
-
}
|
|
1345
|
-
setActors(actors) {
|
|
1346
|
-
if (this.useCPURendering) {
|
|
1347
|
-
throw this.getCPUFallbackError('setActors');
|
|
1348
|
-
}
|
|
1349
|
-
return super.setActors(actors);
|
|
1350
|
-
}
|
|
1351
|
-
addActors(actors) {
|
|
1352
|
-
if (this.useCPURendering) {
|
|
1353
|
-
throw this.getCPUFallbackError('addActors');
|
|
1354
|
-
}
|
|
1355
|
-
return super.addActors(actors);
|
|
1356
|
-
}
|
|
1357
|
-
addActor(actorEntry) {
|
|
1358
|
-
if (this.useCPURendering) {
|
|
1359
|
-
throw this.getCPUFallbackError('addActor');
|
|
1360
|
-
}
|
|
1361
|
-
return super.addActor(actorEntry);
|
|
1362
|
-
}
|
|
1363
|
-
removeAllActors() {
|
|
1364
|
-
if (this.useCPURendering) {
|
|
1365
|
-
throw this.getCPUFallbackError('removeAllActors');
|
|
1367
|
+
_getValidVOILUTFunction(voiLUTFunction) {
|
|
1368
|
+
if (Object.values(VOILUTFunctionType_1.default).indexOf(voiLUTFunction) === -1) {
|
|
1369
|
+
voiLUTFunction = VOILUTFunctionType_1.default.LINEAR;
|
|
1366
1370
|
}
|
|
1367
|
-
return
|
|
1371
|
+
return voiLUTFunction;
|
|
1368
1372
|
}
|
|
1369
1373
|
getCPUFallbackError(method) {
|
|
1370
1374
|
return new Error(`method ${method} cannot be used during CPU Fallback mode`);
|
|
@@ -1375,22 +1379,6 @@ class StackViewport extends Viewport_1.default {
|
|
|
1375
1379
|
renderingEngine.fillCanvasWithBackgroundColor(this.canvas, this.options.background);
|
|
1376
1380
|
}
|
|
1377
1381
|
}
|
|
1378
|
-
setColormap(colormap) {
|
|
1379
|
-
if (this.useCPURendering) {
|
|
1380
|
-
this.setColormapCPU(colormap);
|
|
1381
|
-
}
|
|
1382
|
-
else {
|
|
1383
|
-
this.setColormapGPU(colormap);
|
|
1384
|
-
}
|
|
1385
|
-
}
|
|
1386
|
-
unsetColormap() {
|
|
1387
|
-
if (this.useCPURendering) {
|
|
1388
|
-
this.unsetColormapCPU();
|
|
1389
|
-
}
|
|
1390
|
-
else {
|
|
1391
|
-
this.unsetColormapGPU();
|
|
1392
|
-
}
|
|
1393
|
-
}
|
|
1394
1382
|
unsetColormapCPU() {
|
|
1395
1383
|
delete this._cpuFallbackEnabledElement.viewport.colormap;
|
|
1396
1384
|
this._cpuFallbackEnabledElement.renderingTools = {};
|