All files / core/src/utilities getVOIRangeFromWindowLevel.ts

55.55% Statements 5/9
53.84% Branches 7/13
100% Functions 1/1
55.55% Lines 5/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27                        113x 113x 113x           113x       113x    
import { VOILUTFunctionType } from '../enums';
import type { VOIRange } from '../types';
import { toLowHighRange } from './windowLevel';
 
export default function getVOIRangeFromWindowLevel(
  windowWidth: number | number[] | undefined,
  windowCenter: number | number[] | undefined,
  voiLUTFunction: VOILUTFunctionType = VOILUTFunctionType.LINEAR
): VOIRange | undefined {
  let center: number | undefined;
  let width: number | undefined;
 
  if (typeof windowCenter === 'number' && typeof windowWidth === 'number') {
    center = windowCenter;
    width = windowWidth;
  } else Eif (Array.isArray(windowCenter) && Array.isArray(windowWidth)) {
    center = windowCenter[0];
    width = windowWidth[0];
  }
 
  Iif (center === undefined || width === undefined) {
    return;
  }
 
  return toLowHighRange(width, center, voiLUTFunction);
}