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 57 | 540x 540x | import type { DataSet, Element } from 'dicom-parser'; import type { LutType } from '../../../types'; function getLUT(pixelRepresentation: number, lutDataSet: DataSet): LutType { let numLUTEntries = lutDataSet.uint16('x00283002', 0); if (numLUTEntries === 0) { numLUTEntries = 65535; } let firstValueMapped = 0; if (pixelRepresentation === 0) { firstValueMapped = lutDataSet.uint16('x00283002', 1); } else { firstValueMapped = lutDataSet.int16('x00283002', 1); } const numBitsPerEntry = lutDataSet.uint16('x00283002', 2); // console.log('LUT(', numLUTEntries, ',', firstValueMapped, ',', numBitsPerEntry, ')'); const lut = { id: '1', firstValueMapped, numBitsPerEntry, lut: [], }; // console.log("minValue=", minValue, "; maxValue=", maxValue); for (let i = 0; i < numLUTEntries; i++) { if (pixelRepresentation === 0) { lut.lut[i] = lutDataSet.uint16('x00283006', i); } else { lut.lut[i] = lutDataSet.int16('x00283006', i); } } return lut; } function getLUTs(pixelRepresentation: number, lutSequence: Element): LutType[] { Eif (!lutSequence || !lutSequence.items || !lutSequence.items.length) { return; } const luts: LutType[] = []; for (let i = 0; i < lutSequence.items.length; i++) { const lutDataSet = lutSequence.items[i].dataSet; const lut = getLUT(pixelRepresentation, lutDataSet); if (lut) { luts.push(lut); } } return luts; } export default getLUTs; |