import matplotlib.pyplot as plt
import torch
from diffdrr.drr import DRR
from diffdrr.visualization import plot_drr
from diffdrrdata.deepfluoro import DeepFluoroDataset, Transforms
# Load a subject from the DeepFluoroDataset
= DeepFluoroDataset(id_number=1, bone_attenuation_multiplier=2.5)
deepfluoro
# Initialize the DRR module
= 4
subsample = DRR(
drr
deepfluoro.subject,
deepfluoro.focal_len,// subsample,
deepfluoro.height * subsample,
deepfluoro.delx =deepfluoro.x0,
x0=deepfluoro.y0,
y0
)= Transforms(deepfluoro.height // subsample)
transform
# Render a DRR from the ground truth camera pose
= deepfluoro[0]
gt, pose = drr(pose)
img = transform(gt), transform(img)
gt, img - img]), title=["Downsampled X-ray", "DRR", "Difference"])
plot_drr(torch.concat([gt, img, gt plt.show()
DiffDRR Datasets
Open-source 2D/3D registration datasets and dataloaders for
DiffDRR
Install
pip install diffdrrdata
DiffDRR
DiffDRR
is an differentiable X-ray renderer used for solving inverse problems in tomographic imaging. If you find DiffDRR
useful in your work, please cite our paper:
@inproceedings{gopalakrishnan2022fast,
title={Fast auto-differentiable digitally reconstructed radiographs for solving inverse problems in intraoperative imaging},
author={Gopalakrishnan, Vivek and Golland, Polina},
booktitle={Workshop on Clinical Image-Based Procedures},
pages={1--11},
year={2022},
organization={Springer}
}
Datasets
We provide APIs to load the following open-source datasets into DiffDRR
:
Dataset | Anatomy | # of Subjects | # of 2D Images | CTs | X-rays | GT Fiducials |
---|---|---|---|---|---|---|
DeepFluoro |
pelvis | 6 | 366 | ✅ | ✅ | ❌ |
Ljubljana |
neurovasculature | 10 | 20 | ✅ | ✅ | ✅ |
If you use any of these datasets, please cite the original papers.
DeepFluoro
DeepFluoro
(Grupp et al., 2020) provides paired X-ray fluoroscopy images and CT volume of the pelvis. The data were collected from six cadaveric subjects at John Hopkins University. Ground truth camera poses were estimated with an offline registration process. A visualization of the X-ray / CT pairs in the DeepFluoro
dataset is available here.
@article{grupp2020automatic,
title={Automatic annotation of hip anatomy in fluoroscopy for robust and efficient 2D/3D registration},
author={Grupp, Robert B and Unberath, Mathias and Gao, Cong and Hegeman, Rachel A and Murphy, Ryan J and Alexander, Clayton P and Otake, Yoshito and McArthur, Benjamin A and Armand, Mehran and Taylor, Russell H},
journal={International journal of computer assisted radiology and surgery},
volume={15},
pages={759--769},
year={2020},
publisher={Springer}
}
Ljubljana
Ljubljana
(Mitrovic et al., 2013) provides paired 2D/3D digital subtraction angiography (DSA) images. The data were collected from 10 patients undergoing endovascular image-guided interventions at the University of Ljubljana. Ground truth camera poses were estimated by registering surface fiducial markers.
@article{pernus20133d,
title={3D-2D registration of cerebral angiograms: A method and evaluation on clinical images},
author={Mitrović, Uros˘ and S˘piclin, Z˘iga and Likar, Bos˘tjan and Pernus˘, Franjo},
journal={IEEE transactions on medical imaging},
volume={32},
number={8},
pages={1550--1563},
year={2013},
publisher={IEEE}
}
from diffdrrdata.ljubljana import LjubljanaDataset, Transforms
# Load a subject from the LjubljanaDataset
= LjubljanaDataset(id_number=1)
ljubljana = ljubljana[0]
gt, pose, focal_len, height, width, delx, dely, x0, y0
# Initialize the DRR module
= 8
subsample = DRR(
drr
ljubljana.subject,
focal_len,// subsample,
height * subsample,
delx // subsample,
width * subsample,
dely =x0,
x0=y0,
y0=False,
reverse_x_axis
)= Transforms(height // subsample, width // subsample)
transform
# Render a DRR from the ground truth camera pose
= drr(pose)
img = transform(gt), transform(img)
gt, img - img]), title=["Downsampled X-ray", "DRR", "Difference"])
plot_drr(torch.concat([gt, img, gt plt.show()