Skip to content

Commit 1edbc56

Browse files
committed
ENH: Add rtkSimulatedGeometry python application
1 parent e7e4c8d commit 1edbc56

3 files changed

Lines changed: 61 additions & 0 deletions

File tree

applications/rtksimulatedgeometry/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,9 @@ if(NOT RTK_INSTALL_NO_EXECUTABLES)
1010
LIBRARY DESTINATION ${RTK_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries
1111
ARCHIVE DESTINATION ${RTK_INSTALL_ARCHIVE_DIR} COMPONENT Development)
1212
endforeach()
13+
14+
# Install Python application
15+
install(FILES rtksimulatedgeometry.py
16+
DESTINATION ${RTK_INSTALL_LIB_DIR} COMPONENT PythonWheelRuntimeLibraries)
1317
endif()
1418

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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()

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
"Operating System :: Unix",
4141
"Operating System :: MacOS"
4242
],
43+
scripts=[
44+
"lib/rtksimulatedgeometry.py"
45+
],
4346
license='Apache',
4447
keywords='RTK Reconstruction Toolkit',
4548
url=r'https://www.openrtk.org/',

0 commit comments

Comments
 (0)