ljubljana

DiffDRR wrapper for the Ljubljana dataset

Dataset

The Ljubljana dataset is a collection of 2D and 3D digital subtraction angiography (DSA) images from 20 patients undergoing neurovascular procedures at the University of Ljubljana. For each patient there is

  • One 3D DSA volume (i.e., rotational angiography)
  • Two 2D DSA acquisitions (one AP and one LAT)

In total, the dataset comprises 20 3D DSA volumes and 20 2D DSA images.


source

LjubljanaDataset

 LjubljanaDataset (id_number:int, preprocess:bool=True)

A torch.utils.data.Dataset that stores the imaging data for subjects in the Ljubljana dataset.

Type Default Details
id_number int Subject ID in {1, …, 10}
preprocess bool True Convert X-rays from exponentiated to linear form

source

Transforms

 Transforms (height:int, width:int, eps:float=1e-06)

Standardize, resize, and normalize X-rays and DRRs before inputting to a deep learning model.

Code
from tqdm import tqdm

mean, vars = [], []
for idx in tqdm(range(1, 11), ncols=50):
    specimen = LjubljanaDataset(idx)
    for img, _, _, _, _, _, _, _, _ in specimen:
        img = (img - img.min()) / (img.max() - img.min())
        mean.append(img.mean())
        vars.append(img.var())

print("Pixel mean :", sum(mean) / len(mean))
print("Pixel std dev :", (sum(vars) / len(vars)).sqrt())
100%|█████████████| 10/10 [00:32<00:00,  3.26s/it]
Pixel mean : tensor(0.0306)
Pixel std dev : tensor(0.0594)

Basic functionalities

In the Ljubljana dataset, 3D fidicial markers were manually annotated along the centerline of many vessels in the neurovasculature. These can be projected into 2D using projective geometry.

Caution

Commercially available biplane scanners used in neurosurgery offer users many degrees of freedom, including control over the intrinsic parameters of the system. In particular, the focal length and principal points are different for every image in the Ljubljana dataset. Therefore, we return these intrinsic parameters along with the extrinsic camera pose for every image.

For every DSA acquisition in the Ljubljana dataset, we visualize

  • The ground truth image
  • A DRR rendered from the ground truth pose
  • An overlay of projected fiducial markers onto the DRR
  • The difference between the ground truth image and the DRR
  • The difference between the DRR and the ground truth image
Code
import matplotlib.pyplot as plt
from diffdrr.drr import DRR
from diffdrr.pose import RigidTransform
from diffdrr.visualization import plot_drr
from tqdm import tqdm


subsample = 8

for id_number in range(1, 11):
    ljubljana = LjubljanaDataset(id_number)

    for gt, pose, focal_len, height, width, delx, dely, x0, y0 in ljubljana:
        height = height // subsample
        width = width // subsample
        delx = delx * subsample
        dely = dely * subsample
        transforms = Transforms(height, width)

        drr = DRR(
            ljubljana.subject,
            focal_len,
            height,
            delx,
            width,
            dely,
            x0,
            y0,
            reverse_x_axis=False,
        )

        img = drr(pose)
        gt, img = transforms(gt), transforms(img)
        x = drr.perspective_projection(pose, ljubljana.subject.fiducials)

        fig, axs = plt.subplots(ncols=5, constrained_layout=True)
        axs = plot_drr(torch.concat([gt, img, img, gt - img, img - gt]), ticks=False, axs=axs)
        axs[2].scatter(x[0, ..., 0], x[0, ..., 1], s=0.05)
        plt.show()

Citations

If you use the Ljubljana dataset in your work, please cite the author’s original publication:

@article{pernus20133d,
  title={3D-2D registration of cerebral angiograms: A method and evaluation on clinical images},
  author={Mitrović, Uros and Spiclin, Ziga and Likar, Bostjan and Pernus, Franjo},
  journal={IEEE transactions on medical imaging},
  volume={32},
  number={8},
  pages={1550--1563},
  year={2013},
  publisher={IEEE}
}

If you find DiffDRR or DiffDRR-Datasets useful for 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}
}