io¶
xvr.io.intrinsics
¶
Intrinsics
dataclass
¶
Intrinsic parameters of an imaging system.
Supports mapping-style access (keys and __getitem__) so an instance
can be splatted into a renderer with **intrinsics.
| ATTRIBUTE | DESCRIPTION |
|---|---|
sdd |
Source-to-detector distance in millimeters.
TYPE:
|
delx |
Pixel spacing along the x-axis in millimeters.
TYPE:
|
dely |
Pixel spacing along the y-axis in millimeters.
TYPE:
|
x0 |
Detector origin offset along the x-axis in millimeters.
TYPE:
|
y0 |
Detector origin offset along the y-axis in millimeters.
TYPE:
|
xvr.io.xray
¶
read_xray
¶
read_xray(
filename: Path,
crop: int = 0,
subtract_background: bool = False,
linearize: bool = True,
reducefn: str | int | Callable = "max",
radius: float | None = None,
) -> tuple[Float[Tensor, "1 1 H W"], Intrinsics, bool]
Read and preprocess an X-ray image from a DICOM file.
Loads the pixel array, parses imaging system intrinsics, optionally reorients the image, reduces any temporal dimension, and applies configurable preprocessing.
| PARAMETER | DESCRIPTION |
|---|---|
filename
|
Path to the DICOM file.
TYPE:
|
crop
|
Total number of pixels to remove from each spatial dimension.
For example,
TYPE:
|
subtract_background
|
If True, subtract the mode image intensity and clamp the result to [0, 1].
TYPE:
|
linearize
|
If True, convert the image from exponential to linear form by applying a log transform.
TYPE:
|
reducefn
|
Controls how a multiframe (5D) DICOM is collapsed to a single 2D image. Accepted values:
|
radius
|
If given, treat the detector as circular with this radius (in pixels), centered on the image. Pixels outside the circle are set to the minimum intensity of the processed image.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
img
|
Preprocessed image tensor of shape
TYPE:
|
intrinsics
|
Imaging system intrinsic parameters.
TYPE:
|
pf_to_af
|
True if the image was reoriented from posterior-foot to anterior-foot orientation.
TYPE:
|
Source code in src/xvr/io/xray.py
parse_dicom_pose
¶
Convert DICOM pose params to a C-arm SE(3) pose.