|
| 1 | +#!/usr/bin/env python |
| 2 | +import argparse |
| 3 | +import sys |
| 4 | +from itk import RTK as rtk |
| 5 | + |
| 6 | +if __name__ == '__main__': |
| 7 | + # Argument parsing |
| 8 | + parser = argparse.ArgumentParser(description= |
| 9 | + "Creates an RTK geometry file from simulated/regular trajectory. See http://www.openrtk.org/Doxygen/DocGeo3D.html for more information.") |
| 10 | + |
| 11 | + parser.add_argument('--nproj', '-n', type=int, help='Number of projections') |
| 12 | + parser.add_argument('--output', '-o', help='Output file name') |
| 13 | + parser.add_argument('--verbose', '-v', type=bool, default=False, help='Verbose execution') |
| 14 | + parser.add_argument('--config', '-c', help='Config file') |
| 15 | + parser.add_argument('--first_angle', '-f', type=float, default=0, help='First angle in degrees') |
| 16 | + parser.add_argument('--arc', '-a', type=float, default=360, help='Angular arc covevered by the acquisition in degrees') |
| 17 | + parser.add_argument('--sdd', type=float, default=1536, help='Source to detector distance (mm)') |
| 18 | + parser.add_argument('--sid', type=float, default=1000, help='Source to isocenter distance (mm)') |
| 19 | + parser.add_argument('--proj_iso_x', type=float, default=0, help='X coordinate of detector point (0,0) mm in rotated coordinate system') |
| 20 | + parser.add_argument('--proj_iso_y', type=float, default=0, help='Y coordinate of detector point (0,0) mm in rotated coordinate system') |
| 21 | + parser.add_argument('--source_x', type=float, default=0, help='X coordinate of source in rotated coordinate system') |
| 22 | + parser.add_argument('--source_y', type=float, default=0, help='Y coordinate of source in rotated coordinate system') |
| 23 | + parser.add_argument('--out_angle', type=float, default=0, help='Out of plane angle') |
| 24 | + parser.add_argument('--in_angle', type=float, default=0, help='In plane angle') |
| 25 | + parser.add_argument('--rad_cyl', type=float, default=0, help='Radius cylinder of cylindrical detector') |
| 26 | + |
| 27 | + args = parser.parse_args() |
| 28 | + |
| 29 | + if args.nproj is None or args.output is None: |
| 30 | + parser.print_help() |
| 31 | + sys.exit() |
| 32 | + |
| 33 | + # Simulated Geometry |
| 34 | + GeometryType = rtk.ThreeDCircularProjectionGeometry |
| 35 | + geometry = GeometryType.New() |
| 36 | + |
| 37 | + for noProj in range(0, args.nproj): |
| 38 | + angle = args.first_angle + noProj * args.arc / args.nproj |
| 39 | + geometry.AddProjection(args.sid, |
| 40 | + args.sdd, |
| 41 | + angle, |
| 42 | + args.proj_iso_x, |
| 43 | + args.proj_iso_y, |
| 44 | + args.out_angle, |
| 45 | + args.in_angle, |
| 46 | + args.source_x, |
| 47 | + args.source_y) |
| 48 | + |
| 49 | + geometry.SetRadiusCylindricalDetector(args.rad_cyl) |
| 50 | + |
| 51 | + writer = rtk.ThreeDCircularProjectionGeometryXMLFileWriter.New() |
| 52 | + writer.SetFilename(args.output) |
| 53 | + writer.SetObject(geometry) |
| 54 | + writer.WriteFile() |
0 commit comments