forked from arcadelab/deepdrr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_projector.py
32 lines (24 loc) · 906 Bytes
/
example_projector.py
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
#! python3
"""Minimal projection example with DeepDRR."""
import deepdrr
from deepdrr import geo
from deepdrr.utils import test_utils, image_utils
from deepdrr.projector import Projector
def main():
output_dir = test_utils.get_output_dir()
data_dir = test_utils.download_sampledata("CTPelvic1K_sample")
patient = deepdrr.Volume.from_nifti(
data_dir / "dataset6_CLINIC_0001_data.nii.gz", use_thresholding=True
)
patient.faceup()
# define the simulated C-arm
carm = deepdrr.MobileCArm(patient.center_in_world + geo.v(0, 0, -300))
# project in the AP view
with Projector(patient, carm=carm) as projector:
carm.move_to(alpha=0, beta=0)
image = projector()
path = output_dir / "example_projector.png"
image_utils.save(path, image)
print(f"saved example projection image to {path.absolute()}")
if __name__ == "__main__":
main()