All files / dicomImageLoader/src/imageLoader/wadors/metaData getOverlayPlaneModule.ts

0% Statements 0/18
0% Branches 0/4
0% Functions 0/1
0% Lines 0/15

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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56                                                                                                               
import getValue from './getValue';
import getNumberValue from './getNumberValue';
import type { WADORSMetaData } from '../../../types';
 
export default function getOverlayPlaneModule(metaData: WADORSMetaData) {
  const overlays = [];
 
  for (let overlayGroup = 0x00; overlayGroup <= 0x1e; overlayGroup += 0x02) {
    let groupStr = `x60${overlayGroup.toString(16)}`;
 
    if (groupStr.length === 4) {
      groupStr = `x600${overlayGroup.toString(16)}`;
    }
 
    /**
     * @todo there is a type issue with WADORSMetaData. Currently WADORSMetaData
     * on includes  string[] | number[] | boolean. from the look of this, data
     * is a more complex type
     */
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    const data = getValue(metaData[`${groupStr}3000`]) as any;
 
    if (!data) {
      continue;
    }
 
    const pixelData = [];
 
    for (let i = 0; i < data.length; i++) {
      for (let k = 0; k < 8; k++) {
        const byte_as_int = metaData.Value[data.dataOffset + i];
 
        pixelData[i * 8 + k] = (byte_as_int >> k) & 0b1; // eslint-disable-line no-bitwise
      }
    }
 
    overlays.push({
      rows: getNumberValue(metaData[`${groupStr}0010`]),
      columns: getNumberValue(metaData[`${groupStr}0011`]),
      type: getValue(metaData[`${groupStr}0040`]),
      x: getNumberValue(metaData[`${groupStr}0050`], 1) - 1,
      y: getNumberValue(metaData[`${groupStr}0050`], 0) - 1,
      pixelData,
      description: getValue(metaData[`${groupStr}0022`]),
      label: getValue(metaData[`${groupStr}1500`]),
      roiArea: getValue(metaData[`${groupStr}1301`]),
      roiMean: getValue(metaData[`${groupStr}1302`]),
      roiStandardDeviation: getValue(metaData[`${groupStr}1303`]),
    });
  }
 
  return {
    overlays,
  };
}