@cornerstonejs/core 0.45.1 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/RenderingEngine/BaseVolumeViewport.d.ts +7 -1
- package/dist/cjs/RenderingEngine/BaseVolumeViewport.js +124 -16
- package/dist/cjs/RenderingEngine/BaseVolumeViewport.js.map +1 -1
- package/dist/cjs/RenderingEngine/helpers/createVolumeActor.js.map +1 -1
- package/dist/cjs/RenderingEngine/helpers/setDefaultVolumeVOI.js +11 -1
- package/dist/cjs/RenderingEngine/helpers/setDefaultVolumeVOI.js.map +1 -1
- package/dist/cjs/types/Colormap.d.ts +15 -0
- package/dist/cjs/types/Colormap.js +3 -0
- package/dist/cjs/types/Colormap.js.map +1 -0
- package/dist/cjs/types/EventTypes.d.ts +1 -0
- package/dist/cjs/types/ScalingParameters.d.ts +3 -0
- package/dist/cjs/types/StackViewportProperties.d.ts +2 -6
- package/dist/cjs/types/ViewportProperties.d.ts +8 -0
- package/dist/cjs/types/ViewportProperties.js +3 -0
- package/dist/cjs/types/ViewportProperties.js.map +1 -0
- package/dist/cjs/types/VolumeViewportProperties.d.ts +5 -5
- package/dist/cjs/types/index.d.ts +3 -1
- package/dist/cjs/utilities/applyPreset.js.map +1 -1
- package/dist/cjs/utilities/colormap.d.ts +5 -0
- package/dist/cjs/utilities/colormap.js +17 -0
- package/dist/cjs/utilities/colormap.js.map +1 -0
- package/dist/cjs/utilities/index.d.ts +2 -1
- package/dist/cjs/utilities/index.js +3 -1
- package/dist/cjs/utilities/index.js.map +1 -1
- package/dist/esm/RenderingEngine/BaseVolumeViewport.d.ts +7 -1
- package/dist/esm/RenderingEngine/BaseVolumeViewport.js +125 -17
- package/dist/esm/RenderingEngine/BaseVolumeViewport.js.map +1 -1
- package/dist/esm/RenderingEngine/helpers/createVolumeActor.js.map +1 -1
- package/dist/esm/RenderingEngine/helpers/setDefaultVolumeVOI.js +10 -1
- package/dist/esm/RenderingEngine/helpers/setDefaultVolumeVOI.js.map +1 -1
- package/dist/esm/types/Colormap.d.ts +15 -0
- package/dist/esm/types/Colormap.js +2 -0
- package/dist/esm/types/Colormap.js.map +1 -0
- package/dist/esm/types/EventTypes.d.ts +1 -0
- package/dist/esm/types/ScalingParameters.d.ts +3 -0
- package/dist/esm/types/StackViewportProperties.d.ts +2 -6
- package/dist/esm/types/ViewportProperties.d.ts +8 -0
- package/dist/esm/types/ViewportProperties.js +2 -0
- package/dist/esm/types/ViewportProperties.js.map +1 -0
- package/dist/esm/types/VolumeViewportProperties.d.ts +5 -5
- package/dist/esm/types/index.d.ts +3 -1
- package/dist/esm/utilities/applyPreset.js.map +1 -1
- package/dist/esm/utilities/colormap.d.ts +5 -0
- package/dist/esm/utilities/colormap.js +12 -0
- package/dist/esm/utilities/colormap.js.map +1 -0
- package/dist/esm/utilities/index.d.ts +2 -1
- package/dist/esm/utilities/index.js +2 -1
- package/dist/esm/utilities/index.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +2 -2
- package/src/RenderingEngine/BaseVolumeViewport.ts +232 -25
- package/src/RenderingEngine/helpers/createVolumeActor.ts +0 -1
- package/src/RenderingEngine/helpers/setDefaultVolumeVOI.ts +13 -1
- package/src/types/Colormap.ts +31 -0
- package/src/types/EventTypes.ts +2 -0
- package/src/types/ScalingParameters.ts +6 -0
- package/src/types/StackViewportProperties.ts +2 -9
- package/src/types/ViewportProperties.ts +16 -0
- package/src/types/VolumeViewportProperties.ts +7 -7
- package/src/types/index.ts +5 -0
- package/src/utilities/applyPreset.ts +4 -1
- package/src/utilities/colormap.ts +32 -0
- package/src/utilities/index.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/umd/index.js",
|
|
6
6
|
"types": "dist/esm/index.d.ts",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"type": "individual",
|
|
44
44
|
"url": "https://ohif.org/donate"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "5856c935d5879c1efa3a50930044d6526ed5c2c2"
|
|
47
47
|
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import vtkVolume from '@kitware/vtk.js/Rendering/Core/Volume';
|
|
2
|
+
import vtkColorTransferFunction from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction';
|
|
3
|
+
import vtkColorMaps from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps';
|
|
2
4
|
|
|
3
5
|
import cache from '../cache';
|
|
4
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
MPR_CAMERA_VALUES,
|
|
8
|
+
RENDERING_DEFAULTS,
|
|
9
|
+
VIEWPORT_PRESETS,
|
|
10
|
+
} from '../constants';
|
|
5
11
|
import {
|
|
6
12
|
BlendModes,
|
|
7
13
|
Events,
|
|
@@ -14,6 +20,7 @@ import { getShouldUseCPURendering } from '../init';
|
|
|
14
20
|
import { loadVolume } from '../loaders/volumeLoader';
|
|
15
21
|
import type {
|
|
16
22
|
ActorEntry,
|
|
23
|
+
ColormapPublic,
|
|
17
24
|
FlipDirection,
|
|
18
25
|
IImageData,
|
|
19
26
|
IVolumeInput,
|
|
@@ -28,10 +35,13 @@ import type { ViewportInput } from '../types/IViewport';
|
|
|
28
35
|
import type IVolumeViewport from '../types/IVolumeViewport';
|
|
29
36
|
import {
|
|
30
37
|
actorIsA,
|
|
38
|
+
applyPreset,
|
|
31
39
|
createSigmoidRGBTransferFunction,
|
|
32
40
|
getVoiFromSigmoidRGBTransferFunction,
|
|
33
41
|
imageIdToURI,
|
|
42
|
+
invertRgbTransferFunction,
|
|
34
43
|
triggerEvent,
|
|
44
|
+
colormap as colormapUtils,
|
|
35
45
|
} from '../utilities';
|
|
36
46
|
import { createVolumeActor } from './helpers';
|
|
37
47
|
import volumeNewImageEventDispatcher, {
|
|
@@ -40,6 +50,7 @@ import volumeNewImageEventDispatcher, {
|
|
|
40
50
|
import Viewport from './Viewport';
|
|
41
51
|
import type { vtkSlabCamera as vtkSlabCameraType } from './vtkClasses/vtkSlabCamera';
|
|
42
52
|
import vtkSlabCamera from './vtkClasses/vtkSlabCamera';
|
|
53
|
+
import vtkPiecewiseFunction from '@kitware/vtk.js/Common/DataModel/PiecewiseFunction';
|
|
43
54
|
|
|
44
55
|
/**
|
|
45
56
|
* Abstract base class for volume viewports. VolumeViewports are used to render
|
|
@@ -54,6 +65,7 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
|
|
|
54
65
|
useCPURendering = false;
|
|
55
66
|
use16BitTexture = false;
|
|
56
67
|
private _FrameOfReferenceUID: string;
|
|
68
|
+
private inverted = false;
|
|
57
69
|
|
|
58
70
|
// Viewport Properties
|
|
59
71
|
// TODO: similar to setVoi, this is only applicable to first volume
|
|
@@ -206,6 +218,135 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
|
|
|
206
218
|
this.setVOI(voiRange, volumeId, suppressEvents);
|
|
207
219
|
}
|
|
208
220
|
|
|
221
|
+
/**
|
|
222
|
+
* Sets the colormap for the volume with the given ID and optionally suppresses events.
|
|
223
|
+
*
|
|
224
|
+
* @param colormap - The colormap to apply (e.g., "hsv").
|
|
225
|
+
* @param volumeId - The ID of the volume to set the colormap for.
|
|
226
|
+
* @param suppressEvents - If `true`, events will not be emitted during the colormap a
|
|
227
|
+
*
|
|
228
|
+
* @returns void
|
|
229
|
+
*/
|
|
230
|
+
private setColormap(
|
|
231
|
+
colormap: ColormapPublic,
|
|
232
|
+
volumeId: string,
|
|
233
|
+
suppressEvents?: boolean
|
|
234
|
+
) {
|
|
235
|
+
const applicableVolumeActorInfo = this._getApplicableVolumeActor(volumeId);
|
|
236
|
+
|
|
237
|
+
if (!applicableVolumeActorInfo) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const { volumeActor } = applicableVolumeActorInfo;
|
|
242
|
+
|
|
243
|
+
const mapper = volumeActor.getMapper();
|
|
244
|
+
mapper.setSampleDistance(1.0);
|
|
245
|
+
|
|
246
|
+
const cfun = vtkColorTransferFunction.newInstance();
|
|
247
|
+
let colormapObj = colormapUtils.getColormap(colormap);
|
|
248
|
+
|
|
249
|
+
const { name, opacityMapping } = colormap;
|
|
250
|
+
|
|
251
|
+
if (!colormapObj) {
|
|
252
|
+
colormapObj = vtkColorMaps.getPresetByName(name);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
if (!colormapObj) {
|
|
256
|
+
throw new Error(`Colormap ${colormap} not found`);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const range = volumeActor
|
|
260
|
+
.getProperty()
|
|
261
|
+
.getRGBTransferFunction(0)
|
|
262
|
+
.getRange();
|
|
263
|
+
|
|
264
|
+
cfun.applyColorMap(colormapObj);
|
|
265
|
+
cfun.setMappingRange(range[0], range[1]);
|
|
266
|
+
volumeActor.getProperty().setRGBTransferFunction(0, cfun);
|
|
267
|
+
|
|
268
|
+
const ofun = vtkPiecewiseFunction.newInstance();
|
|
269
|
+
ofun.addPoint(range[0], 0.0);
|
|
270
|
+
ofun.addPoint(range[1], 1.0);
|
|
271
|
+
volumeActor.getProperty().setScalarOpacity(0, ofun);
|
|
272
|
+
|
|
273
|
+
if (!opacityMapping) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// add custom opacity points
|
|
278
|
+
opacityMapping.forEach(({ opacity, value }) => {
|
|
279
|
+
ofun.addPoint(value, opacity);
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Sets the inversion for the volume transfer function
|
|
285
|
+
*
|
|
286
|
+
* @param invert - Should the transfer function be inverted?
|
|
287
|
+
* @param volumeId - volumeId
|
|
288
|
+
* @param suppressEvents - If `true`, events will not be published
|
|
289
|
+
*
|
|
290
|
+
* @returns void
|
|
291
|
+
*/
|
|
292
|
+
private setInvert(
|
|
293
|
+
invert: boolean,
|
|
294
|
+
volumeId?: string,
|
|
295
|
+
suppressEvents?: boolean
|
|
296
|
+
) {
|
|
297
|
+
const applicableVolumeActorInfo = this._getApplicableVolumeActor(volumeId);
|
|
298
|
+
|
|
299
|
+
if (!applicableVolumeActorInfo) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
const volumeIdToUse = applicableVolumeActorInfo.volumeId;
|
|
304
|
+
|
|
305
|
+
const cfun = this._getOrCreateColorTransferFunction(volumeIdToUse);
|
|
306
|
+
invertRgbTransferFunction(cfun);
|
|
307
|
+
|
|
308
|
+
this.inverted = invert;
|
|
309
|
+
|
|
310
|
+
const { voiRange } = this.getProperties();
|
|
311
|
+
|
|
312
|
+
if (!suppressEvents) {
|
|
313
|
+
const eventDetail: VoiModifiedEventDetail = {
|
|
314
|
+
viewportId: this.id,
|
|
315
|
+
range: voiRange,
|
|
316
|
+
volumeId: volumeIdToUse,
|
|
317
|
+
VOILUTFunction: this.VOILUTFunction,
|
|
318
|
+
invert: this.inverted,
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
triggerEvent(this.element, Events.VOI_MODIFIED, eventDetail);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
private _getOrCreateColorTransferFunction(
|
|
326
|
+
volumeId: string
|
|
327
|
+
): vtkColorTransferFunction {
|
|
328
|
+
const applicableVolumeActorInfo = this._getApplicableVolumeActor(volumeId);
|
|
329
|
+
|
|
330
|
+
if (!applicableVolumeActorInfo) {
|
|
331
|
+
return null;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const { volumeActor } = applicableVolumeActorInfo;
|
|
335
|
+
|
|
336
|
+
const rgbTransferFunction = volumeActor
|
|
337
|
+
.getProperty()
|
|
338
|
+
.getRGBTransferFunction(0);
|
|
339
|
+
|
|
340
|
+
if (rgbTransferFunction) {
|
|
341
|
+
return rgbTransferFunction;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
const newRGBTransferFunction = vtkColorTransferFunction.newInstance();
|
|
345
|
+
volumeActor.getProperty().setRGBTransferFunction(0, newRGBTransferFunction);
|
|
346
|
+
|
|
347
|
+
return newRGBTransferFunction;
|
|
348
|
+
}
|
|
349
|
+
|
|
209
350
|
/**
|
|
210
351
|
* Sets the properties for the volume viewport on the volume
|
|
211
352
|
* (if fusion, it sets it for the first volume in the fusion)
|
|
@@ -219,27 +360,14 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
|
|
|
219
360
|
volumeId?: string,
|
|
220
361
|
suppressEvents = false
|
|
221
362
|
): void {
|
|
222
|
-
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const actorEntries = this.getActors();
|
|
363
|
+
const applicableVolumeActorInfo = this._getApplicableVolumeActor(volumeId);
|
|
227
364
|
|
|
228
|
-
if (!
|
|
365
|
+
if (!applicableVolumeActorInfo) {
|
|
229
366
|
return;
|
|
230
367
|
}
|
|
231
368
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
if (volumeId) {
|
|
235
|
-
volumeActor = this.getActor(volumeId)?.actor as vtkVolume;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// // set it for the first volume (if there are more than one - fusion)
|
|
239
|
-
if (!volumeActor) {
|
|
240
|
-
volumeActor = actorEntries[0].actor as vtkVolume;
|
|
241
|
-
volumeId = actorEntries[0].uid;
|
|
242
|
-
}
|
|
369
|
+
const { volumeActor } = applicableVolumeActorInfo;
|
|
370
|
+
const volumeIdToUse = applicableVolumeActorInfo.volumeId;
|
|
243
371
|
|
|
244
372
|
let voiRangeToUse = voiRange;
|
|
245
373
|
if (typeof voiRangeToUse === 'undefined') {
|
|
@@ -273,7 +401,7 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
|
|
|
273
401
|
const eventDetail: VoiModifiedEventDetail = {
|
|
274
402
|
viewportId: this.id,
|
|
275
403
|
range: voiRange,
|
|
276
|
-
volumeId:
|
|
404
|
+
volumeId: volumeIdToUse,
|
|
277
405
|
VOILUTFunction: this.VOILUTFunction,
|
|
278
406
|
};
|
|
279
407
|
|
|
@@ -285,23 +413,76 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
|
|
|
285
413
|
* Sets the properties for the volume viewport on the volume
|
|
286
414
|
* (if fusion, it sets it for the first volume in the fusion)
|
|
287
415
|
*
|
|
288
|
-
* @param
|
|
289
|
-
* @param
|
|
416
|
+
* @param VolumeViewportProperties - The properties to set
|
|
417
|
+
* @param [VolumeViewportProperties.voiRange] - Sets the lower and upper voi
|
|
418
|
+
* @param [VolumeViewportProperties.VOILUTFunction] - Sets the voi mode (LINEAR, or SAMPLED_SIGMOID)
|
|
419
|
+
* @param [VolumeViewportProperties.invert] - Inverts the color transfer function
|
|
420
|
+
* @param [VolumeViewportProperties.colormap] - Sets the colormap
|
|
421
|
+
* @param [VolumeViewportProperties.preset] - Sets the colormap
|
|
290
422
|
* @param volumeId - The volume id to set the properties for (if undefined, the first volume)
|
|
291
423
|
* @param suppressEvents - If true, the viewport will not emit events
|
|
292
424
|
*/
|
|
293
425
|
public setProperties(
|
|
294
|
-
{
|
|
426
|
+
{
|
|
427
|
+
voiRange,
|
|
428
|
+
VOILUTFunction,
|
|
429
|
+
invert,
|
|
430
|
+
colormap,
|
|
431
|
+
preset,
|
|
432
|
+
}: VolumeViewportProperties = {},
|
|
295
433
|
volumeId?: string,
|
|
296
434
|
suppressEvents = false
|
|
297
435
|
): void {
|
|
298
|
-
|
|
436
|
+
// Note: colormap should always be done first, since we can then
|
|
437
|
+
// modify the voiRange
|
|
438
|
+
if (colormap !== undefined) {
|
|
439
|
+
this.setColormap(colormap, volumeId, suppressEvents);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
if (voiRange !== undefined) {
|
|
299
443
|
this.setVOI(voiRange, volumeId, suppressEvents);
|
|
300
444
|
}
|
|
301
445
|
|
|
302
|
-
if (VOILUTFunction) {
|
|
446
|
+
if (VOILUTFunction !== undefined) {
|
|
303
447
|
this.setVOILUTFunction(VOILUTFunction, volumeId, suppressEvents);
|
|
304
448
|
}
|
|
449
|
+
|
|
450
|
+
if (invert !== undefined && this.inverted !== invert) {
|
|
451
|
+
this.setInvert(invert, volumeId, suppressEvents);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
if (preset !== undefined) {
|
|
455
|
+
this.setPreset(preset, volumeId, suppressEvents);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Sets the specified preset for the volume with the given ID
|
|
461
|
+
*
|
|
462
|
+
* @param presetName - The name of the preset to apply (e.g., "CT-Bone").
|
|
463
|
+
* @param volumeId - The ID of the volume to set the preset for.
|
|
464
|
+
* @param suppressEvents - If `true`, events will not be emitted during the preset application.
|
|
465
|
+
*
|
|
466
|
+
* @returns void
|
|
467
|
+
*/
|
|
468
|
+
private setPreset(presetName, volumeId, suppressEvents) {
|
|
469
|
+
const applicableVolumeActorInfo = this._getApplicableVolumeActor(volumeId);
|
|
470
|
+
|
|
471
|
+
if (!applicableVolumeActorInfo) {
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
const { volumeActor } = applicableVolumeActorInfo;
|
|
476
|
+
|
|
477
|
+
const preset = VIEWPORT_PRESETS.find((preset) => {
|
|
478
|
+
return preset.name === presetName;
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
if (!preset) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
applyPreset(volumeActor, preset);
|
|
305
486
|
}
|
|
306
487
|
|
|
307
488
|
/**
|
|
@@ -328,7 +509,7 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
|
|
|
328
509
|
const voiRange = voiRanges.length ? voiRanges[0].voiRange : null;
|
|
329
510
|
const VOILUTFunction = this.VOILUTFunction;
|
|
330
511
|
|
|
331
|
-
return { voiRange, VOILUTFunction };
|
|
512
|
+
return { voiRange, VOILUTFunction, invert: this.inverted };
|
|
332
513
|
};
|
|
333
514
|
|
|
334
515
|
/**
|
|
@@ -500,6 +681,32 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
|
|
|
500
681
|
console.warn('Method "setOrientation" needs implementation');
|
|
501
682
|
}
|
|
502
683
|
|
|
684
|
+
private _getApplicableVolumeActor(volumeId?: string) {
|
|
685
|
+
if (volumeId !== undefined && !this.getActor(volumeId)) {
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
const actorEntries = this.getActors();
|
|
690
|
+
|
|
691
|
+
if (!actorEntries.length) {
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
let volumeActor;
|
|
696
|
+
|
|
697
|
+
if (volumeId) {
|
|
698
|
+
volumeActor = this.getActor(volumeId)?.actor as vtkVolume;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
// // set it for the first volume (if there are more than one - fusion)
|
|
702
|
+
if (!volumeActor) {
|
|
703
|
+
volumeActor = actorEntries[0].actor as vtkVolume;
|
|
704
|
+
volumeId = actorEntries[0].uid;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
return { volumeActor, volumeId };
|
|
708
|
+
}
|
|
709
|
+
|
|
503
710
|
private async _isValidVolumeInputArray(
|
|
504
711
|
volumeInputArray: Array<IVolumeInput>,
|
|
505
712
|
FrameOfReferenceUID: string
|
|
@@ -61,7 +61,7 @@ function handlePreScaledVolume(imageVolume: IImageVolume, voi: VOIRange) {
|
|
|
61
61
|
* Therefore, we follow the majority of other viewers and we set the min/max
|
|
62
62
|
* for the scaled PT to be 0, 5
|
|
63
63
|
*/
|
|
64
|
-
if (generalSeriesModule.modality
|
|
64
|
+
if (_isCurrentImagePTPrescaled(generalSeriesModule.modality, imageVolume)) {
|
|
65
65
|
return {
|
|
66
66
|
lower: 0,
|
|
67
67
|
upper: 5,
|
|
@@ -224,4 +224,16 @@ function _getImageScalarDataFromImageVolume(
|
|
|
224
224
|
return imageScalarData;
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
+
function _isCurrentImagePTPrescaled(modality, imageVolume) {
|
|
228
|
+
if (modality !== 'PT' || !imageVolume.isPreScaled) {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (!imageVolume.scaling?.PT.suvbw) {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
|
|
227
239
|
export default setDefaultVolumeVOI;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import RGB from './RGB';
|
|
2
|
+
|
|
3
|
+
type ColormapRegistration = {
|
|
4
|
+
ColorSpace: string;
|
|
5
|
+
Name: string;
|
|
6
|
+
RGBPoints: RGB[];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type OpacityMapping = {
|
|
10
|
+
/** value to map to opacity */
|
|
11
|
+
value: number;
|
|
12
|
+
/** opacity value */
|
|
13
|
+
opacity: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type ColormapPublic = {
|
|
17
|
+
/** name of the colormap */
|
|
18
|
+
name: string;
|
|
19
|
+
/** midpoint mapping between values to opacity if the colormap
|
|
20
|
+
* is getting used for fusion, this is an array of arrays which
|
|
21
|
+
* each array containing 2 values, the first value is the value
|
|
22
|
+
* to map to opacity and the second value is the opacity value.
|
|
23
|
+
* By default, the minimum value is mapped to 0 opacity and the
|
|
24
|
+
* maximum value is mapped to 1 opacity, but you can configure
|
|
25
|
+
* the points in the middle to be mapped to different opacities
|
|
26
|
+
* instead of a linear mapping from 0 to 1.
|
|
27
|
+
*/
|
|
28
|
+
opacityMapping?: OpacityMapping[];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type { ColormapRegistration, ColormapPublic };
|
package/src/types/EventTypes.ts
CHANGED
|
@@ -18,6 +18,12 @@ type PTScaling = {
|
|
|
18
18
|
suvbwToSuvlbm?: number;
|
|
19
19
|
/** suv body weight to suv body surface area */
|
|
20
20
|
suvbwToSuvbsa?: number;
|
|
21
|
+
/** SUV body weight */
|
|
22
|
+
suvbw?: number;
|
|
23
|
+
/** SUV lean body mass */
|
|
24
|
+
suvlbm?: number;
|
|
25
|
+
/** SUV body surface area */
|
|
26
|
+
suvbsa?: number;
|
|
21
27
|
};
|
|
22
28
|
|
|
23
29
|
type Scaling = {
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import InterpolationType from '../enums/InterpolationType';
|
|
2
|
-
import
|
|
3
|
-
import { VOIRange } from './voi';
|
|
2
|
+
import { ViewportProperties } from './ViewportProperties';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Stack Viewport Properties
|
|
7
6
|
*/
|
|
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;
|
|
7
|
+
type StackViewportProperties = ViewportProperties & {
|
|
15
8
|
/** interpolation type - linear or nearest neighbor */
|
|
16
9
|
interpolationType?: InterpolationType;
|
|
17
10
|
/** image rotation */
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { VOILUTFunctionType } from '../enums';
|
|
2
|
+
import { VOIRange } from './voi';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Shared Viewport Properties between Stack and Volume Viewports
|
|
6
|
+
*/
|
|
7
|
+
type ViewportProperties = {
|
|
8
|
+
/** voi range (upper, lower) for the viewport */
|
|
9
|
+
voiRange?: VOIRange;
|
|
10
|
+
/** VOILUTFunction type which is LINEAR or SAMPLED_SIGMOID */
|
|
11
|
+
VOILUTFunction?: VOILUTFunctionType;
|
|
12
|
+
/** invert flag - whether the image is inverted */
|
|
13
|
+
invert?: boolean;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type { ViewportProperties };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { ColormapPublic } from './Colormap';
|
|
2
|
+
import { ViewportProperties } from './ViewportProperties';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Stack Viewport Properties
|
|
6
6
|
*/
|
|
7
|
-
type VolumeViewportProperties = {
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
|
|
7
|
+
type VolumeViewportProperties = ViewportProperties & {
|
|
8
|
+
/** color maps */
|
|
9
|
+
colormap?: ColormapPublic;
|
|
10
|
+
/** 3d preset */
|
|
11
|
+
preset?: string;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
export default VolumeViewportProperties;
|
package/src/types/index.ts
CHANGED
|
@@ -75,6 +75,8 @@ import type ICachedGeometry from './ICachedGeometry';
|
|
|
75
75
|
import type { IContourSet } from './IContourSet';
|
|
76
76
|
import type { IContour } from './IContour';
|
|
77
77
|
import type RGB from './RGB';
|
|
78
|
+
import { ColormapPublic, ColormapRegistration } from './Colormap';
|
|
79
|
+
import type { ViewportProperties } from './ViewportProperties';
|
|
78
80
|
|
|
79
81
|
export type {
|
|
80
82
|
// config
|
|
@@ -107,6 +109,7 @@ export type {
|
|
|
107
109
|
IViewport,
|
|
108
110
|
StackViewportProperties,
|
|
109
111
|
VolumeViewportProperties,
|
|
112
|
+
ViewportProperties,
|
|
110
113
|
PublicViewportInput,
|
|
111
114
|
VolumeActor,
|
|
112
115
|
Actor,
|
|
@@ -159,4 +162,6 @@ export type {
|
|
|
159
162
|
IContour,
|
|
160
163
|
// Color
|
|
161
164
|
RGB,
|
|
165
|
+
ColormapPublic,
|
|
166
|
+
ColormapRegistration,
|
|
162
167
|
};
|
|
@@ -9,7 +9,10 @@ import { VolumeActor } from '../types/IActor';
|
|
|
9
9
|
* @param actor - The volume actor to apply the preset to.
|
|
10
10
|
* @param preset - The preset to apply.
|
|
11
11
|
*/
|
|
12
|
-
export default function applyPreset(
|
|
12
|
+
export default function applyPreset(
|
|
13
|
+
actor: VolumeActor,
|
|
14
|
+
preset: ViewportPreset
|
|
15
|
+
) {
|
|
13
16
|
// Create color transfer function
|
|
14
17
|
const colorTransferArray = preset.colorTransfer
|
|
15
18
|
.split(' ')
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ColormapRegistration } from '../types';
|
|
2
|
+
|
|
3
|
+
const _colormaps = new Map();
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Register a colormap
|
|
7
|
+
* @param name - name of the colormap
|
|
8
|
+
* @param colormap - colormap object
|
|
9
|
+
*/
|
|
10
|
+
function registerColormap(colormap: ColormapRegistration) {
|
|
11
|
+
_colormaps.set(colormap.Name, colormap);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get a colormap by name
|
|
16
|
+
* @param name - name of the colormap
|
|
17
|
+
* @returns colormap object
|
|
18
|
+
*/
|
|
19
|
+
function getColormap(name) {
|
|
20
|
+
return _colormaps.get(name);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Get all registered colormap names
|
|
25
|
+
* @returns array of colormap names
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
function getColormapNames() {
|
|
29
|
+
return Array.from(_colormaps.keys());
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { getColormap, getColormapNames, registerColormap };
|
package/src/utilities/index.ts
CHANGED
|
@@ -48,6 +48,7 @@ import getScalarDataType from './getScalarDataType';
|
|
|
48
48
|
// name spaces
|
|
49
49
|
import * as planar from './planar';
|
|
50
50
|
import * as windowLevel from './windowLevel';
|
|
51
|
+
import * as colormap from './colormap';
|
|
51
52
|
|
|
52
53
|
export {
|
|
53
54
|
csUtils as invertRgbTransferFunction,
|
|
@@ -79,7 +80,7 @@ export {
|
|
|
79
80
|
transformWorldToIndex,
|
|
80
81
|
loadImageToCanvas,
|
|
81
82
|
renderToCanvasCPU,
|
|
82
|
-
renderToCanvasGPU,
|
|
83
|
+
renderToCanvasGPU,
|
|
83
84
|
worldToImageCoords,
|
|
84
85
|
imageToWorldCoords,
|
|
85
86
|
getVolumeSliceRangeInfo,
|
|
@@ -99,4 +100,5 @@ export {
|
|
|
99
100
|
deepMerge,
|
|
100
101
|
getScalingParameters,
|
|
101
102
|
getScalarDataType,
|
|
103
|
+
colormap,
|
|
102
104
|
};
|