Skip to content

Commit

Permalink
Rename rescaleLut to modalityLut, fixes #1553
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Nov 15, 2023
1 parent 6e65dbb commit 8b084b5
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 29 deletions.
8 changes: 4 additions & 4 deletions resources/doc/img/sequence-view-creation.puml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ deactivate Image

View -> WindowLut: get window lut
activate WindowLut
WindowLut --> RescaleLut: get rescale lut
activate RescaleLut
RescaleLut --> WindowLut: rescale lut
deactivate RescaleLut
WindowLut --> ModalityLut: get rescale lut
activate ModalityLut
ModalityLut --> WindowLut: rescale lut
deactivate ModalityLut
WindowLut -> View: window lut
deactivate WindowLut

Expand Down
2 changes: 1 addition & 1 deletion resources/doc/tutorials/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ canvas array data:
(see [image/iterator.js](./global.html#range))
1. From stored type range to physical range using a [Modality LUT](http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.11.html): rescale slope and intercept are used
in the conversion equation: `y = slope * x + intercept`
(see [image/rescaleLut.js](./RescaleLut.html))
(see [image/modalityLut.js](./ModalityLut.html))
1. Select part of the range using a [VOI LUT](http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.11.2.html#table_C.11-2) (Value Of Interest): window width and level (or centre)
allow to focus on a specific range (especially useful for normed data such
as in CT)
Expand Down
11 changes: 7 additions & 4 deletions src/image/rescaleLut.js → src/image/modalityLut.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import {RescaleSlopeAndIntercept} from './rsi';
/* eslint-enable no-unused-vars */

/**
* Rescale LUT class.
* Typically converts from integer to float.
* Modality LUT class: compensates for any modality-specific presentation.
* Typically consists of a rescale slope and intercept to
* rescale the data range.
*
* @see https://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.11.html
*/
export class RescaleLut {
export class ModalityLut {

/**
* The rescale slope.
Expand Down Expand Up @@ -85,4 +88,4 @@ export class RescaleLut {
return this.#isIdRsi ? offset : this.#lut[offset];
}

} // class RescaleLut
} // class ModalityLut
6 changes: 3 additions & 3 deletions src/image/view.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Index} from '../math/index';
import {RescaleLut} from './rescaleLut';
import {ModalityLut} from './modalityLut';
import {WindowLut} from './windowLut';
import {luts} from './luts';
import {WindowCenterAndWidth} from './windowCenterAndWidth';
Expand Down Expand Up @@ -353,12 +353,12 @@ export class View {
isDiscrete = false;
}
// create the rescale lookup table
const rescaleLut = new RescaleLut(
const modalityLut = new ModalityLut(
rsi,
this.#image.getMeta().BitsStored);
// create the window lookup table
this.#windowLut = new WindowLut(
rescaleLut,
modalityLut,
this.#image.getMeta().IsSigned,
isDiscrete);
}
Expand Down
30 changes: 15 additions & 15 deletions src/image/windowLut.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// doc imports
/* eslint-disable no-unused-vars */
import {RescaleLut} from './rescaleLut';
import {ModalityLut} from './modalityLut';
import {WindowCenterAndWidth} from './windowCenterAndWidth';
/* eslint-enable no-unused-vars */

Expand All @@ -11,11 +11,11 @@ import {WindowCenterAndWidth} from './windowCenterAndWidth';
export class WindowLut {

/**
* The rescale LUT.
* The modality LUT.
*
* @type {RescaleLut}
* @type {ModalityLut}
*/
#rescaleLut;
#modalityLut;

/**
* The window level.
Expand Down Expand Up @@ -49,15 +49,15 @@ export class WindowLut {
* Construct a window LUT object, window level is set with
* the 'setWindowLevel' method.
*
* @param {RescaleLut} rescaleLut The associated rescale LUT.
* @param {ModalityLut} modalityLut The associated rescale LUT.
* @param {boolean} isSigned Flag to know if the data is signed or not.
* @param {boolean} isDiscrete Flag to know if the input data is discrete.
*/
constructor(rescaleLut, isSigned, isDiscrete) {
this.#rescaleLut = rescaleLut;
constructor(modalityLut, isSigned, isDiscrete) {
this.#modalityLut = modalityLut;

if (isSigned) {
const size = this.#rescaleLut.getLength();
const size = this.#modalityLut.getLength();
this.#signedShift = size / 2;
} else {
this.#signedShift = 0;
Expand All @@ -76,12 +76,12 @@ export class WindowLut {
}

/**
* Get the rescale lut.
* Get the modality lut.
*
* @returns {RescaleLut} The rescale lut.
* @returns {ModalityLut} The modality lut.
*/
getRescaleLut() {
return this.#rescaleLut;
getModalityLut() {
return this.#modalityLut;
}

/**
Expand All @@ -95,17 +95,17 @@ export class WindowLut {

// possible signed shift (LUT indices are positive)
this.#windowLevel.setSignedOffset(
this.#rescaleLut.getRSI().getSlope() * this.#signedShift);
this.#modalityLut.getRSI().getSlope() * this.#signedShift);

// create lut if not continous
if (this.#isDiscrete) {
const size = this.#rescaleLut.getLength();
const size = this.#modalityLut.getLength();
// use clamped array (polyfilled in env.js)
this.#lut = new Uint8ClampedArray(size);
// by default WindowLevel returns a value in the [0,255] range
// this is ok with regular Arrays and ClampedArray.
for (let i = 0; i < size; ++i) {
this.#lut[i] = this.#windowLevel.apply(this.#rescaleLut.getValue(i));
this.#lut[i] = this.#windowLevel.apply(this.#modalityLut.getValue(i));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import {
luts
} from './image/luts';
import {RescaleSlopeAndIntercept} from './image/rsi';
import {RescaleLut} from './image/rescaleLut';
import {ModalityLut} from './image/modalityLut';
import {WindowLut} from './image/windowLut';
import {
defaultPresets,
Expand Down Expand Up @@ -119,7 +119,7 @@ export {
Size,
Spacing,
RescaleSlopeAndIntercept,
RescaleLut,
ModalityLut,
WindowLut,
WindowCenterAndWidth,
Index,
Expand Down

0 comments on commit 8b084b5

Please sign in to comment.