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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | 128x 45x 45x 45x 45x | import { isEqual } from './isEqual';
import { CalibrationTypes } from '../enums';
// TODO: Use ENUMS from dcmjs
const projectionRadiographSOPClassUIDs = new Set([
'1.2.840.10008.5.1.4.1.1.1', // CR Image Storage
'1.2.840.10008.5.1.4.1.1.1.1', // Digital X-Ray Image Storage – for Presentation
'1.2.840.10008.5.1.4.1.1.1.1.1', // Digital X-Ray Image Storage – for Processing
'1.2.840.10008.5.1.4.1.1.1.2', // Digital Mammography X-Ray Image Storage – for Presentation
'1.2.840.10008.5.1.4.1.1.1.2.1', // Digital Mammography X-Ray Image Storage – for Processing
'1.2.840.10008.5.1.4.1.1.1.3', // Digital Intra – oral X-Ray Image Storage – for Presentation
'1.2.840.10008.5.1.4.1.1.1.3.1', // Digital Intra – oral X-Ray Image Storage – for Processing
'1.2.840.10008.5.1.4.1.1.12.1', // X-Ray Angiographic Image Storage
'1.2.840.10008.5.1.4.1.1.12.1.1', // Enhanced XA Image Storage
'1.2.840.10008.5.1.4.1.1.12.2', // X-Ray Radiofluoroscopic Image Storage
'1.2.840.10008.5.1.4.1.1.12.2.1', // Enhanced XRF Image Storage
'1.2.840.10008.5.1.4.1.1.12.3', // X-Ray Angiographic Bi-plane Image Storage Retired
]);
/**
* Calculates the ERMF value using any of:
* * EstimatedRadiographicMagnificationFactor
* * PixelSpacing / Imager Pixel Spacing
* * Distance Source / imager / patient pair
*
* @returns ERMF if available. True means the PixelSpacing has been pre-calculated
*/
export function getERMF(instance) {
const {
PixelSpacing,
ImagerPixelSpacing,
EstimatedRadiographicMagnificationFactor: ermf,
// Naming is traditionally sid/sod here
DistanceSourceToDetector: sid,
DistanceSourceToEntrance: soe,
DistanceSourceToPatient: sod = soe,
} = instance;
if (ermf > 1) {
return ermf;
}
if (sod < sid) {
return sid / sod;
}
if (ImagerPixelSpacing?.[0] > PixelSpacing?.[0]) {
return true;
}
}
/**
* Given an instance, calculates the project (radiographic) pixel spacing
* plus the type of calibration that got used for it.
*/
export function calculateRadiographicPixelSpacing(instance) {
const { PixelSpacing, ImagerPixelSpacing, PixelSpacingCalibrationType } =
instance;
const isProjection = true;
if (PixelSpacing && PixelSpacingCalibrationType === 'GEOMETRY') {
if (isEqual(PixelSpacing, ImagerPixelSpacing)) {
console.warn(
'Calibration type is geometry, but pixel spacing and imager pixel spacing identical',
PixelSpacing,
ImagerPixelSpacing
);
}
return {
PixelSpacing,
type: CalibrationTypes.ERMF,
isProjection,
};
}
if (PixelSpacing && PixelSpacingCalibrationType === 'FIDUCIAL') {
return {
PixelSpacing,
type: CalibrationTypes.CALIBRATED,
isProjection,
};
}
if (ImagerPixelSpacing) {
const ermf = getERMF(instance);
if (ermf > 1) {
const correctedPixelSpacing = ImagerPixelSpacing.map(
(pixelSpacing) => pixelSpacing / ermf
);
return {
PixelSpacing: correctedPixelSpacing,
type: CalibrationTypes.ERMF,
isProjection,
};
}
if (ermf === true) {
return {
PixelSpacing,
type: CalibrationTypes.ERMF,
isProjection,
};
}
if (ermf) {
console.error('Illegal ERMF value:', ermf);
}
return {
PixelSpacing: PixelSpacing || ImagerPixelSpacing,
type: CalibrationTypes.PROJECTION,
isProjection,
};
}
return {
PixelSpacing,
type: CalibrationTypes.UNKNOWN,
isProjection,
};
}
export function getPixelSpacingInformation(instance) {
const { PixelSpacing, SOPClassUID } = instance;
const isProjection = projectionRadiographSOPClassUIDs.has(SOPClassUID);
Iif (isProjection) {
return calculateRadiographicPixelSpacing(instance);
}
return {
PixelSpacing,
type: CalibrationTypes.NOT_APPLICABLE,
isProjection: false,
};
}
export default getPixelSpacingInformation;
|