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 | 180x 180x 32x 148x 148x 148x 148x 148x | /* eslint no-bitwise: 0 */ import type { DataSet } from 'dicom-parser'; function getMinStoredPixelValue(dataSet: DataSet) { const pixelRepresentation = dataSet.uint16('x00280103'); const bitsStored = dataSet.uint16('x00280101'); if (pixelRepresentation === 0) { return 0; } return -1 << (bitsStored - 1); } // 0 = unsigned / US, 1 = signed / SS function getModalityLUTOutputPixelRepresentation(dataSet: DataSet) { // CT SOP Classes are always signed const sopClassUID = dataSet.string('x00080016'); if ( sopClassUID === '1.2.840.10008.5.1.4.1.1.2' || sopClassUID === '1.2.840.10008.5.1.4.1.1.2.1' ) { return 1; } // if rescale intercept and rescale slope are present, pass the minimum stored // pixel value through them to see if we get a signed output range const rescaleIntercept = dataSet.floatString('x00281052'); const rescaleSlope = dataSet.floatString('x00281053'); Iif (rescaleIntercept !== undefined && rescaleSlope !== undefined) { const minStoredPixelValue = getMinStoredPixelValue(dataSet); // const minModalityLutValue = minStoredPixelValue * rescaleSlope + rescaleIntercept; if (minModalityLutValue < 0) { return 1; } return 0; } // Output of non linear modality lut is always unsigned Iif (dataSet.elements.x00283000 && dataSet.elements.x00283000.length > 0) { return 0; } // If no modality lut transform, output is same as pixel representation return dataSet.uint16('x00280103'); } export default getModalityLUTOutputPixelRepresentation; |