From 1edbc5600d4a2cc7a2f720ad1e1b84661138bae4 Mon Sep 17 00:00:00 2001 From: Lucas Gandel Date: Wed, 8 Apr 2020 08:30:08 +0200 Subject: [PATCH 1/2] ENH: Add rtkSimulatedGeometry python application --- .../rtksimulatedgeometry/CMakeLists.txt | 4 ++ .../rtksimulatedgeometry.py | 54 +++++++++++++++++++ setup.py | 3 ++ 3 files changed, 61 insertions(+) create mode 100644 applications/rtksimulatedgeometry/rtksimulatedgeometry.py diff --git a/applications/rtksimulatedgeometry/CMakeLists.txt b/applications/rtksimulatedgeometry/CMakeLists.txt index ddea10316..773eee78e 100644 --- a/applications/rtksimulatedgeometry/CMakeLists.txt +++ b/applications/rtksimulatedgeometry/CMakeLists.txt @@ -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() diff --git a/applications/rtksimulatedgeometry/rtksimulatedgeometry.py b/applications/rtksimulatedgeometry/rtksimulatedgeometry.py new file mode 100644 index 000000000..ff87ebdf6 --- /dev/null +++ b/applications/rtksimulatedgeometry/rtksimulatedgeometry.py @@ -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() diff --git a/setup.py b/setup.py index 8d761dbf1..a4f6f3200 100644 --- a/setup.py +++ b/setup.py @@ -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/', From a6437840acca825ce7daacc92aa2833ffd4f244d Mon Sep 17 00:00:00 2001 From: Lucas Gandel Date: Wed, 8 Apr 2020 18:09:49 +0200 Subject: [PATCH 2/2] COMP: Set latest available itk version in setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a4f6f3200..4a946a962 100644 --- a/setup.py +++ b/setup.py @@ -47,6 +47,6 @@ keywords='RTK Reconstruction Toolkit', url=r'https://www.openrtk.org/', install_requires=[ - r'itk>=5.1' + r'itk>=5.1rc03' ] )