-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathrun_quality_control.py
More file actions
93 lines (84 loc) · 2.89 KB
/
run_quality_control.py
File metadata and controls
93 lines (84 loc) · 2.89 KB
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
# Executes the QualityControl class which runs a suite of tests on the current patient,
# case and treatment plan (including ROIs, beam sets, beams, objectives, etc).
#
# Authors:
# Christoffer Lervåg & Marit Funderud
# Helse Møre og Romsdal HF
#
# System configuration:
from connect import *
import datetime
import sys
from tkinter import *
from tkinter import messagebox
# Log start time:
time_start = datetime.datetime.now()
# Add necessary folders to the system path:
sys.path.append("C:\\temp\\raystation-scripts\\def_regions")
sys.path.append("C:\\temp\\raystation-scripts\\functions")
sys.path.append("C:\\temp\\raystation-scripts\\gui_classes")
sys.path.append("C:\\temp\\raystation-scripts\\rt_classes")
sys.path.append("C:\\temp\\raystation-scripts\\settings")
sys.path.append("C:\\temp\\raystation-scripts\\ts_classes")
sys.path.append("C:\\temp\\raystation-scripts\\various_classes")
sys.path.append(r'C:\temp\raystation-scripts')
# Local script imports:
import quality_control as QC
# "Global" variables:
try:
patient = get_current("Patient")
except SystemError:
raise IOError("No patient loaded.")
try:
case = get_current("Case")
except SystemError:
raise IOError("No case loaded.")
try:
plan = get_current("Plan")
except SystemError:
raise IOError("No plan loaded.")
# Set up and execute the quality control class:
qc = QC.QualityControl(patient, case, plan)
# Create title and body strings:
title = "Plan Quality Control"
summary = qc.result.failure_summary()
if qc.result.nr_failures() == 0:
# Zero failures:
text = "Ingen problemer ble funnet! :)\n\n"
else:
# One or more failures:
text = str(qc.result.nr_failures()) + " mulige problemer ble funnet:\n\n" + summary
# Log finish time and format a time string:
time_end = datetime.datetime.now()
elapsed_time = time_end - time_start
if elapsed_time.seconds > 3600:
hours = elapsed_time.seconds // 3600 % 3600
minutes = (elapsed_time.seconds - hours * 3600) // 60 % 60
seconds = elapsed_time.seconds - hours * 3600 - minutes * 60
else:
hours = 0
minutes = elapsed_time.seconds // 60 % 60
seconds = elapsed_time.seconds - minutes * 60
# Append time string to result:
if hours > 0:
text += "\n\n" + "Tidsbruk: " +str(hours) + " time(r) " + str(minutes) + " min " + str(seconds) + " sek"
else:
if minutes > 0:
text += "\n\n" + "Tidsbruk: " + str(minutes) + " min " + str(seconds) + " sek"
else:
text += "\n\n" + "Tidsbruk: " + str(seconds) + " sek"
# Display the messagebox GUI with a visible taskbar icon:
# Create the root window:
root = Tk()
# Hide the root window
root.withdraw()
# Set the taskbar icon:
root.iconbitmap(r'C:\temp\raystation-scripts\media\icons\qc.ico')
# Show the root window (so it has a taskbar presence):
root.deiconify()
# Set title:
root.title("Plan Quality Control")
# Show the message box:
messagebox.showinfo(title, text)
# Close the root window after the messagebox is dismissed:
root.destroy()