Skip to content

Commit ab87d2f

Browse files
committed
Update to v25.1.0
1 parent 9bc5937 commit ab87d2f

File tree

7 files changed

+174
-4
lines changed

7 files changed

+174
-4
lines changed

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ keywords:
1919
- GUI
2020
- Python
2121
license: MIT
22-
version: 25.0.0
22+
version: 25.1.0
2323
date-released: '2023-03-25'

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="topasgraphsim",
8-
version="25.0.0",
8+
version="25.1.0",
99
author="Sebastian Schäfer",
1010
author_email="[email protected]",
1111
description="GUI to analyze the results of a Monte-Carlo radiation simulation",

topasgraphsim/src/classes/options.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from .tgs_graph import TGS_Plot
2020
from .sim_import import Simulation
2121
from .ptw_import import PTWMultimporter
22+
from .raystation_import import RayStationMultiImporter
2223
from .meas_import import TXTImporter
2324
from .profile import ProfileHandler
2425
from .paramframe import Parameters
@@ -98,6 +99,9 @@ def resource_path(relative_path):
9899
self.load_mcc_button = ctk.CTkButton(self.dataframe2, text = Text().loadmeasurement[self.lang], command = self.load_measurement, width=20)
99100
self.load_mcc_button.grid(row=0, column=1, sticky="nsew", padx=5, pady=(5,2))
100101

102+
self.load_raystation_button = ctk.CTkButton(self.dataframe2, text = Text().loadraystation[self.lang], command = self.load_raystation, width=20)
103+
self.load_raystation_button.grid(row=1, column=0, sticky="nsew", padx=5, pady=(5,2))
104+
101105
self.showgrid = ctk.BooleanVar(value=self.p.get_attribute("grid"))
102106

103107
self.gridoptions = ctk.StringVar(value=Text().gridoptions1[self.lang])
@@ -821,6 +825,13 @@ def load_measurement(self, path = None):
821825
if path != "" and path not in self.filenames:
822826
PTWMultimporter(path, self.tab(Text().data[self.lang]), self.parent.plots, self)
823827

828+
def load_raystation(self, path = None):
829+
if path == None:
830+
path = fd.askopenfilename(filetypes=[("XLS files", "*.xls")])
831+
832+
if path != "" and path not in self.filenames:
833+
RayStationMultiImporter(path, self.tab(Text().data[self.lang]), self.parent.plots, self)
834+
824835
def load_txt(self, path = None):
825836
if path == None:
826837
path = fd.askopenfilename(filetypes=[("TXT files", "*.txt")])
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
import re
2+
import customtkinter as ctk
3+
4+
import numpy as np
5+
6+
from ..functions import dp, pdd
7+
from ..resources.language import Text
8+
from .profile import ProfileHandler
9+
from .tgs_graph import TGS_Plot
10+
from .paramframe import Parameters
11+
from .scrollframe import ScrollFrame
12+
13+
class RayStationData:
14+
def __init__(self, list, index):
15+
16+
self.axis = np.array(list[0])
17+
self.dose = np.array(list[1])
18+
self.direction = list[4]
19+
self.normpoint = max(self.dose)
20+
21+
self.std_dev = np.array([0.0 for i in range(len(self.dose))])
22+
23+
self.filepath = list[2]
24+
25+
if "/" in self.filepath:
26+
self.filename = self.filepath.split("/")[-1][:-4] + f" - Scan {index}"
27+
else:
28+
self.filename = self.filepath.split("\\")[-1][:-4] + f" - Scan {index}"
29+
30+
self.unit = list[3]
31+
32+
33+
def params(self):
34+
if self.direction == "Z":
35+
return pdd.calculate_parameters(
36+
np.array(self.axis),
37+
self.dose / max(self.dose),
38+
[],
39+
)
40+
else:
41+
params = dp.calculate_parameters(
42+
self.axis, self.dose / max(self.dose)
43+
)
44+
self.cax = params[1]
45+
return params
46+
47+
48+
class RayStationMultiImporter(ScrollFrame):
49+
def __init__(self, filepath, parent, plotlist, options):
50+
super().__init__(parent=parent)
51+
self.parent = parent
52+
self.text = Text()
53+
self.lang = ProfileHandler().get_attribute("language")
54+
self.plotlist = plotlist
55+
self.path = filepath
56+
self.options = options
57+
self.root = self.options.parent.master.master.parent
58+
self.pack_propagate(False)
59+
self.grid_propagate(False)
60+
self.canvas.pack_propagate(False)
61+
62+
with open(filepath, "r") as file:
63+
lines = file.readlines()
64+
unit = "Gy"
65+
self.alldata = []
66+
direction = ""
67+
field_size=""
68+
ssd=""
69+
for index, line in enumerate(lines):
70+
71+
if "SSD" in line:
72+
ssd = line.split(":;")[-1].strip()
73+
74+
elif "Fieldsize" in line:
75+
_, x1,y1,x2,y2 = line.split(";")
76+
x = abs(float(x1)) + abs(float(x2))
77+
y = abs(float(y1)) + abs(float(y2))
78+
field_size = f"{x}x{y} mm"
79+
80+
elif "CurveType" in line:
81+
direction = line.split(":;")[-1].strip()
82+
direcs = {"Inline":"X", "Crossline":"Y", "Depth":"Z", "Diagonal":"XY"}
83+
direction = direcs[direction]
84+
85+
if "StartPoint" in line:
86+
xdata, ydata = [], []
87+
i = 1
88+
while "End" not in lines[index + i]:
89+
xdata += [float(lines[index + i].split(";")[0])]
90+
ydata += [float(lines[index + i].split(";")[1])]
91+
i += 1
92+
self.alldata += [
93+
[np.array(xdata), np.array(ydata), filepath, unit, direction, ssd, field_size]
94+
]
95+
direction = ""
96+
ssd = ""
97+
field_size = ""
98+
99+
self.plots = []
100+
theme = ProfileHandler().get_attribute("color_scheme")
101+
colors2 = {"light": "#E5E5E5", "dark":"#212121"}
102+
colors3 = {"light": "#DBDBDB", "dark":"#2B2B2B"}
103+
self.configure(fg_color=colors2[theme])
104+
self.canvas.configure(bg=colors3[theme], highlightbackground=colors3[theme])
105+
self.scrollbar.configure(fg_color=colors3[theme])
106+
self.options.dataframe2.grid_remove()
107+
self.options.dataframe1.grid_remove()
108+
self.grid(row=0, rowspan=2, column=0, sticky="nsew")
109+
self.label = ctk.CTkLabel(self.viewPort, text=Text().select[self.lang], font=("Bahnschrift", 14, "bold"))
110+
self.label.pack(anchor="n", pady=5)
111+
self.variables = [ctk.BooleanVar() for i in range(len(self.alldata))]
112+
[var.set(False) for var in self.variables]
113+
self.buttons = [
114+
ctk.CTkCheckBox(
115+
self.viewPort,
116+
variable=self.variables[i],
117+
text=f"Scan {i+1}: {self.alldata[i][6]} {self.alldata[i][5]}mm {self.alldata[i][4]}",
118+
)
119+
for i in range(len(self.alldata))
120+
]
121+
[button.pack(anchor="w") for button in self.buttons]
122+
self.submitbutton = ctk.CTkButton(
123+
self.viewPort,
124+
text=Text().submit[ProfileHandler().get_attribute("language")],
125+
command=self.submit,
126+
)
127+
self.submitbutton.pack(anchor="s", pady=5)
128+
self.parent.master.master.parent.bind("<Return>", self.submit)
129+
130+
def submit(self, event=None):
131+
132+
self.plots = []
133+
134+
135+
for index, dataset in enumerate(self.alldata):
136+
if self.variables[index].get() != True:
137+
continue
138+
else:
139+
self.plotlist += [TGS_Plot(self.options, RayStationData(dataset, index + 1))]
140+
self.options.parameters.append(Parameters(self.options.paramslist.viewPort, self.plotlist[-1], self.lang))
141+
self.options.parameters[-1].grid(row=len(self.options.parameters)-1, sticky="ew", padx=5, pady=5)
142+
self.options.plotbuttons.append(ctk.CTkRadioButton(self.options.graphlist.viewPort, text=self.plotlist[-1].label, variable=self.options.current_plot, text_color = self.plotlist[-1].linecolor, value=self.plotlist[-1].label, command=self.options.change_current_plot, font=("Bahnschrift", 14, "bold")))
143+
self.options.plotbuttons[-1].grid(sticky="w", padx=5, pady=5)
144+
if len(self.options.parent.plots) == 1:
145+
self.options.enable_all_buttons()
146+
try:
147+
self.options.current_plot.set(self.plotlist[-1].label)
148+
self.options.filenames.append(self.path)
149+
self.options.parent.saved = False
150+
self.options.update_plotlist()
151+
self.options.parent.update()
152+
except IndexError:
153+
pass
154+
155+
self.canvas.unbind_all("<MouseWheel>")
156+
self.destroy()
157+
self.options.dataframe1.grid(row=1, column=0, sticky="nsew", padx=5, pady=5)
158+
self.options.dataframe2.grid(row=0, column=0, sticky="nsew", padx=5, pady=5)

topasgraphsim/src/classes/update.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
class CheckForUpdates:
1010
def __init__(self):
1111

12-
currentVersion = "25.0.0"
12+
currentVersion = "25.1.0"
1313
try:
1414
newestVersion = requests.get(
1515
"https://api.github.com/repos/sebasj13/topasgraphsim/releases/latest"

topasgraphsim/src/resources/language.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def __init__(self):
152152
self.linethickness = {"de": "Linienstärke", "en": "Line thickness"}
153153
self.linecolor = {"de": "Linienfarbe", "en": "Line color"}
154154
self.loadmeasurement = {"de": "Messung laden", "en": "Load measurement"}
155+
self.loadraystation = {"de": "RayStation-Daten laden", "en": "Load RayStation data"}
155156
self.local = {"de": "Lokal", "en": "Local"}
156157
self.globalg = {"de": "Global", "en": "Global"}
157158
self.gammatype = {"de": "Gamma-Typ", "en": "Gamma type"}

topasgraphsim/topasgraphsim.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(self):
2525
super().__init__()
2626

2727
self.appname = "TopasGraphSim"
28-
self.version = "25.0.0"
28+
self.version = "25.1.0"
2929
self.author = "Sebastian Schäfer"
3030
self.affiliation = "UK Halle\nMLU Halle-Wittenberg\nUK Hamburg-Eppendorf"
3131
self.title(f"{self.appname} - v.{self.version}")

0 commit comments

Comments
 (0)