Skip to content

Commit

Permalink
ENH: Add rtkSimulatedGeometry python application
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasGandel committed Apr 14, 2020
1 parent e7e4c8d commit 1edbc56
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
4 changes: 4 additions & 0 deletions applications/rtksimulatedgeometry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ if(NOT RTK_INSTALL_NO_EXECUTABLES)
LIBRARY DESTINATION ${RTK_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries
ARCHIVE DESTINATION ${RTK_INSTALL_ARCHIVE_DIR} COMPONENT Development)
endforeach()

# Install Python application
install(FILES rtksimulatedgeometry.py
DESTINATION ${RTK_INSTALL_LIB_DIR} COMPONENT PythonWheelRuntimeLibraries)
endif()

54 changes: 54 additions & 0 deletions applications/rtksimulatedgeometry/rtksimulatedgeometry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env python
import argparse
import sys
from itk import RTK as rtk

if __name__ == '__main__':
# Argument parsing
parser = argparse.ArgumentParser(description=
"Creates an RTK geometry file from simulated/regular trajectory. See http://www.openrtk.org/Doxygen/DocGeo3D.html for more information.")

parser.add_argument('--nproj', '-n', type=int, help='Number of projections')
parser.add_argument('--output', '-o', help='Output file name')
parser.add_argument('--verbose', '-v', type=bool, default=False, help='Verbose execution')
parser.add_argument('--config', '-c', help='Config file')
parser.add_argument('--first_angle', '-f', type=float, default=0, help='First angle in degrees')
parser.add_argument('--arc', '-a', type=float, default=360, help='Angular arc covevered by the acquisition in degrees')
parser.add_argument('--sdd', type=float, default=1536, help='Source to detector distance (mm)')
parser.add_argument('--sid', type=float, default=1000, help='Source to isocenter distance (mm)')
parser.add_argument('--proj_iso_x', type=float, default=0, help='X coordinate of detector point (0,0) mm in rotated coordinate system')
parser.add_argument('--proj_iso_y', type=float, default=0, help='Y coordinate of detector point (0,0) mm in rotated coordinate system')
parser.add_argument('--source_x', type=float, default=0, help='X coordinate of source in rotated coordinate system')
parser.add_argument('--source_y', type=float, default=0, help='Y coordinate of source in rotated coordinate system')
parser.add_argument('--out_angle', type=float, default=0, help='Out of plane angle')
parser.add_argument('--in_angle', type=float, default=0, help='In plane angle')
parser.add_argument('--rad_cyl', type=float, default=0, help='Radius cylinder of cylindrical detector')

args = parser.parse_args()

if args.nproj is None or args.output is None:
parser.print_help()
sys.exit()

# Simulated Geometry
GeometryType = rtk.ThreeDCircularProjectionGeometry
geometry = GeometryType.New()

for noProj in range(0, args.nproj):
angle = args.first_angle + noProj * args.arc / args.nproj
geometry.AddProjection(args.sid,
args.sdd,
angle,
args.proj_iso_x,
args.proj_iso_y,
args.out_angle,
args.in_angle,
args.source_x,
args.source_y)

geometry.SetRadiusCylindricalDetector(args.rad_cyl)

writer = rtk.ThreeDCircularProjectionGeometryXMLFileWriter.New()
writer.SetFilename(args.output)
writer.SetObject(geometry)
writer.WriteFile()
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
"Operating System :: Unix",
"Operating System :: MacOS"
],
scripts=[
"lib/rtksimulatedgeometry.py"
],
license='Apache',
keywords='RTK Reconstruction Toolkit',
url=r'https://www.openrtk.org/',
Expand Down

0 comments on commit 1edbc56

Please sign in to comment.