From 54c113215116a41dd689195192336ea6e9a191eb Mon Sep 17 00:00:00 2001 From: Jennings Zhang Date: Fri, 23 Feb 2024 13:43:20 -0500 Subject: [PATCH] Can remove colormapLabel --- src/NiivueMutator.ts | 13 ++++++------- src/model.ts | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/NiivueMutator.ts b/src/NiivueMutator.ts index 53e7f95..b654def 100644 --- a/src/NiivueMutator.ts +++ b/src/NiivueMutator.ts @@ -155,15 +155,14 @@ class NiivueMutator { */ private setColormapLabel( volume: NVRVolume, - colormapLabel: undefined | ColorMap, + colormapLabel: undefined | null | ColorMap, ) { - if (colormapLabel === undefined) { - throw new Error( - `colormapLabel is undefined, and unsetting of a colormapLabel is not supported.`, - ); - } const targetImage = this.nv.getMediaByUrl(volume.url) as NVImage; - targetImage.setColormapLabel(colormapLabel); + if (colormapLabel === undefined || colormapLabel === null) { + targetImage.colormapLabel = null; + } else { + targetImage.setColormapLabel(colormapLabel); + } this.nv.updateGLVolume(); } diff --git a/src/model.ts b/src/model.ts index f7a03bb..02e29ff 100644 --- a/src/model.ts +++ b/src/model.ts @@ -72,7 +72,7 @@ type SpecialVolumeOptions = { * * Example value: {@link FreeSurferColorLUT} */ - colormapLabel?: ColorMap; + colormapLabel?: ColorMap | null; }; /**