-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfigure_generator
113 lines (106 loc) · 3.6 KB
/
figure_generator
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function, division
import argparse, datetime, ast
import FigureGenerator as sm
from FigureGenerator.screenshot_maker import FigureGenerator
if __name__ == "__main__":
copyrightMessage = (
"Contact: [email protected]\n\n"
+ "This program is NOT FDA/CE approved and NOT intended for clinical use.\nCopyright (c) "
+ str(datetime.date.today().year)
+ " University of Pennsylvania. All rights reserved."
)
parser = argparse.ArgumentParser(
prog="FigureGenerator",
formatter_class=argparse.RawTextHelpFormatter,
description="Constructing screenshots from medical images.\n\n"
+ copyrightMessage,
)
parser.add_argument(
"-images",
type=str,
help="Input image files (comma-separated without any spaces in path and co-registered)",
required=True,
)
parser.add_argument(
"-masks",
type=str,
default=None,
help="Mask files (comma-separated without any spaces in path and co-registered with images); if multiple files are passed, first is ground truth",
required=False,
)
parser.add_argument(
"-opacity",
type=float,
default=0.5,
help="Mask opacity between 0-1",
required=False,
)
parser.add_argument(
"-ylabels",
type=str,
default=None,
help="The comma-separated ylabels that will be displayed on the subplots' y-axis",
required=False,
)
# parser.add_argument(
# "-colormap",
# type=str,
# default="jet",
# help="The color map to use for alpha blending. All options in https://simpleitk.org/doxygen/latest/html/classitk_1_1simple_1_1ScalarToRGBColormapImageFilter.html#ad6f89e6e076652b4debdfbfd82234c6f",
# required=False,
# )
parser.add_argument(
"-output",
type=str,
help="Output screenshot file",
required=True,
)
## this is problematic because these numbers will need to be translated after resampling the image
# parser.add_argument(
# "-slice",
# type=str,
# default=None,
# help="Slice number to pick screenshots from; if not defined and mask present, slices with largest areas are used; if masks are absent, middle of each axis from image(s) is used",
# required=False,
# )
parser.add_argument(
"-axisrow",
type=ast.literal_eval,
default=False,
help="Put all axes views across each column and stack images and blends in rows, defaults to False",
required=False,
)
parser.add_argument(
"-boundtype",
type=str,
default="None",
help="Construct bounding box around specified region; can be 'none, image or mask'",
required=False,
)
parser.add_argument(
"-fontsize",
type=int,
default=15,
help="Font size for all text on the figure",
required=False,
)
parser.add_argument(
"-borderpc",
type=float,
default=0.05,
help="Percentage of size to use as border around bounding box (used only when mask and bounded are defined)",
required=False,
)
parser.add_argument(
"-v",
"--version",
action="version",
version="%(prog)s v{}".format(sm.version) + "\n\n" + copyrightMessage,
help="Show program's version number and exit.",
)
args = parser.parse_args()
fig_generator = FigureGenerator(args)
fig_generator.save_image(fig_generator.output)
print("Finished.")