spacr 0.1.77__py3-none-any.whl → 0.1.85__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- spacr/gui.py +67 -20
- spacr/gui_core.py +206 -82
- spacr/gui_elements.py +144 -79
- spacr/io.py +1 -1
- spacr/measure.py +14 -14
- spacr/settings.py +258 -97
- spacr/test_gui.py +0 -0
- {spacr-0.1.77.dist-info → spacr-0.1.85.dist-info}/METADATA +1 -1
- {spacr-0.1.77.dist-info → spacr-0.1.85.dist-info}/RECORD +13 -12
- {spacr-0.1.77.dist-info → spacr-0.1.85.dist-info}/LICENSE +0 -0
- {spacr-0.1.77.dist-info → spacr-0.1.85.dist-info}/WHEEL +0 -0
- {spacr-0.1.77.dist-info → spacr-0.1.85.dist-info}/entry_points.txt +0 -0
- {spacr-0.1.77.dist-info → spacr-0.1.85.dist-info}/top_level.txt +0 -0
spacr/gui_elements.py
CHANGED
@@ -14,23 +14,97 @@ from collections import deque
|
|
14
14
|
from skimage.draw import polygon, line
|
15
15
|
from skimage.transform import resize
|
16
16
|
from scipy.ndimage import binary_fill_holes, label
|
17
|
+
from tkinter import ttk, scrolledtext
|
18
|
+
|
19
|
+
def set_dark_style(style, parent_frame=None, containers=None, widgets=None, font_family="Arial", font_size=12, bg_color='black', fg_color='white', active_color='teal', inactive_color='gray'):
|
20
|
+
|
21
|
+
if active_color == 'teal':
|
22
|
+
active_color = '#008080'
|
23
|
+
if inactive_color == 'gray':
|
24
|
+
inactive_color = '#555555'
|
25
|
+
if bg_color == 'black':
|
26
|
+
bg_color = '#000000'
|
27
|
+
if fg_color == 'white':
|
28
|
+
fg_color = '#ffffff'
|
29
|
+
|
30
|
+
font_style = tkFont.Font(family=font_family, size=font_size)
|
31
|
+
style.configure('TEntry', padding='5 5 5 5', borderwidth=1, relief='solid', fieldbackground=bg_color, foreground=fg_color, font=font_style)
|
32
|
+
style.configure('TCombobox', fieldbackground=bg_color, background=bg_color, foreground=fg_color, selectbackground=bg_color, selectforeground=fg_color, font=font_style)
|
33
|
+
style.map('TCombobox', fieldbackground=[('readonly', bg_color)], foreground=[('readonly', fg_color)], selectbackground=[('readonly', bg_color)], selectforeground=[('readonly', fg_color)])
|
34
|
+
style.configure('Custom.TButton', background=bg_color, foreground=fg_color, bordercolor=fg_color, focusthickness=3, focuscolor=fg_color, font=(font_family, font_size))
|
35
|
+
style.map('Custom.TButton', background=[('active', active_color), ('!active', bg_color)], foreground=[('active', fg_color), ('!active', fg_color)], bordercolor=[('active', fg_color), ('!active', fg_color)])
|
36
|
+
style.configure('Custom.TLabel', padding='5 5 5 5', borderwidth=1, relief='flat', background=bg_color, foreground=fg_color, font=font_style)
|
37
|
+
style.configure('Spacr.TCheckbutton', background=bg_color, foreground=fg_color, indicatoron=False, relief='flat', font="15")
|
38
|
+
style.map('Spacr.TCheckbutton', background=[('selected', bg_color), ('active', bg_color)], foreground=[('selected', fg_color), ('active', fg_color)])
|
39
|
+
style.configure('TLabel', background=bg_color, foreground=fg_color, font=font_style)
|
40
|
+
style.configure('TFrame', background=bg_color)
|
41
|
+
style.configure('TPanedwindow', background=bg_color)
|
42
|
+
style.configure('TNotebook', background=bg_color, tabmargins=[2, 5, 2, 0])
|
43
|
+
style.configure('TNotebook.Tab', background=bg_color, foreground=fg_color, padding=[5, 5], font=font_style)
|
44
|
+
style.map('TNotebook.Tab', background=[('selected', active_color), ('active', active_color)], foreground=[('selected', fg_color), ('active', fg_color)])
|
45
|
+
style.configure('TButton', background=bg_color, foreground=fg_color, padding='5 5 5 5', font=font_style)
|
46
|
+
style.map('TButton', background=[('active', active_color), ('disabled', inactive_color)])
|
47
|
+
style.configure('Vertical.TScrollbar', background=bg_color, troughcolor=bg_color, bordercolor=bg_color)
|
48
|
+
style.configure('Horizontal.TScrollbar', background=bg_color, troughcolor=bg_color, bordercolor=bg_color)
|
49
|
+
style.configure('Custom.TLabelFrame', font=(font_family, font_size, 'bold'), background=bg_color, foreground='white', relief='solid', borderwidth=1)
|
50
|
+
style.configure('Custom.TLabelFrame.Label', background=bg_color, foreground='white', font=(font_family, font_size, 'bold'))
|
51
|
+
|
52
|
+
if parent_frame:
|
53
|
+
parent_frame.configure(bg=bg_color)
|
54
|
+
parent_frame.grid_rowconfigure(0, weight=1)
|
55
|
+
parent_frame.grid_columnconfigure(0, weight=1)
|
56
|
+
|
57
|
+
if containers:
|
58
|
+
for container in containers:
|
59
|
+
if isinstance(container, ttk.Frame):
|
60
|
+
container_style = ttk.Style()
|
61
|
+
container_style.configure(f'{container.winfo_class()}.TFrame', background=bg_color)
|
62
|
+
container.configure(style=f'{container.winfo_class()}.TFrame')
|
63
|
+
else:
|
64
|
+
container.configure(bg=bg_color)
|
65
|
+
|
66
|
+
if widgets:
|
67
|
+
for widget in widgets:
|
68
|
+
if isinstance(widget, (tk.Label, tk.Button, tk.Frame, ttk.LabelFrame, tk.Canvas)):
|
69
|
+
widget.configure(bg=bg_color)
|
70
|
+
if isinstance(widget, (tk.Label, tk.Button)):
|
71
|
+
widget.configure(fg=fg_color, font=(font_family, font_size))
|
72
|
+
if isinstance(widget, scrolledtext.ScrolledText):
|
73
|
+
widget.configure(bg=bg_color, fg=fg_color, insertbackground=fg_color)
|
74
|
+
if isinstance(widget, tk.OptionMenu):
|
75
|
+
widget.configure(bg=bg_color, fg=fg_color, font=(font_family, font_size))
|
76
|
+
menu = widget['menu']
|
77
|
+
menu.configure(bg=bg_color, fg=fg_color, font=(font_family, font_size))
|
78
|
+
|
79
|
+
return {'font_family':font_family, 'font_size':font_size, 'bg_color':bg_color, 'fg_color':fg_color, 'active_color':active_color, 'inactive_color':inactive_color}
|
80
|
+
|
81
|
+
def set_default_font(root, font_name="Arial", size=12):
|
82
|
+
default_font = (font_name, size)
|
83
|
+
root.option_add("*Font", default_font)
|
84
|
+
root.option_add("*TButton.Font", default_font)
|
85
|
+
root.option_add("*TLabel.Font", default_font)
|
86
|
+
root.option_add("*TEntry.Font", default_font)
|
17
87
|
|
18
88
|
class spacrDropdownMenu(tk.OptionMenu):
|
19
89
|
def __init__(self, parent, variable, options, command=None, **kwargs):
|
20
90
|
self.variable = variable
|
21
91
|
self.variable.set("Select Category")
|
22
92
|
super().__init__(parent, self.variable, *options, command=command, **kwargs)
|
23
|
-
self.
|
93
|
+
self.update_styles()
|
94
|
+
|
95
|
+
def update_styles(self, active_categories=None):
|
96
|
+
style = ttk.Style()
|
97
|
+
style_out = set_dark_style(style, widgets=[self])
|
24
98
|
self.menu = self['menu']
|
25
|
-
|
99
|
+
style_out = set_dark_style(style, widgets=[self.menu])
|
26
100
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
101
|
+
if active_categories is not None:
|
102
|
+
for idx in range(self.menu.index("end") + 1):
|
103
|
+
option = self.menu.entrycget(idx, "label")
|
104
|
+
if option in active_categories:
|
105
|
+
self.menu.entryconfig(idx, background=style_out['active_color'], foreground=style_out['fg_color'])
|
106
|
+
else:
|
107
|
+
self.menu.entryconfig(idx, background=style_out['bg_color'], foreground=style_out['fg_color'])
|
34
108
|
|
35
109
|
class spacrCheckbutton(ttk.Checkbutton):
|
36
110
|
def __init__(self, parent, text="", variable=None, command=None, *args, **kwargs):
|
@@ -39,6 +113,9 @@ class spacrCheckbutton(ttk.Checkbutton):
|
|
39
113
|
self.variable = variable if variable else tk.BooleanVar()
|
40
114
|
self.command = command
|
41
115
|
self.configure(text=self.text, variable=self.variable, command=self.command, style='Spacr.TCheckbutton')
|
116
|
+
style = ttk.Style()
|
117
|
+
_ = set_dark_style(style, widgets=[self])
|
118
|
+
|
42
119
|
|
43
120
|
class spacrFrame(ttk.Frame):
|
44
121
|
def __init__(self, container, width=None, *args, bg='black', **kwargs):
|
@@ -65,25 +142,25 @@ class spacrFrame(ttk.Frame):
|
|
65
142
|
self.grid_columnconfigure(0, weight=1)
|
66
143
|
self.grid_columnconfigure(1, weight=0)
|
67
144
|
|
68
|
-
|
69
|
-
|
145
|
+
style = ttk.Style()
|
146
|
+
_ = set_dark_style(style, containers=[self], widgets=[canvas, scrollbar, self.scrollable_frame])
|
70
147
|
|
71
148
|
class spacrLabel(tk.Frame):
|
72
149
|
def __init__(self, parent, text="", font=None, style=None, align="right", **kwargs):
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
super().__init__(parent, **kwargs)
|
150
|
+
valid_kwargs = {k: v for k, v in kwargs.items() if k not in ['foreground', 'background', 'font', 'anchor', 'justify', 'wraplength']}
|
151
|
+
super().__init__(parent, **valid_kwargs)
|
152
|
+
|
77
153
|
self.text = text
|
78
|
-
self.kwargs = label_kwargs
|
79
154
|
self.align = align
|
80
155
|
screen_height = self.winfo_screenheight()
|
81
156
|
label_height = screen_height // 50
|
82
157
|
label_width = label_height * 10
|
83
|
-
|
158
|
+
style_out = set_dark_style(ttk.Style())
|
159
|
+
|
160
|
+
self.canvas = tk.Canvas(self, width=label_width, height=label_height, highlightthickness=0, bg=style_out['bg_color'])
|
84
161
|
self.canvas.grid(row=0, column=0, sticky="ew")
|
85
162
|
|
86
|
-
self.font_style = font if font else tkFont.Font(family=
|
163
|
+
self.font_style = font if font else tkFont.Font(family=style_out['font_family'], size=style_out['font_size'], weight=tkFont.NORMAL)
|
87
164
|
self.style = style
|
88
165
|
|
89
166
|
if self.align == "center":
|
@@ -95,13 +172,15 @@ class spacrLabel(tk.Frame):
|
|
95
172
|
|
96
173
|
if self.style:
|
97
174
|
ttk_style = ttk.Style()
|
98
|
-
ttk_style.configure(self.style,
|
99
|
-
self.label_text = ttk.Label(self.canvas, text=self.text, style=self.style, anchor=text_anchor
|
175
|
+
ttk_style.configure(self.style, font=self.font_style, background=style_out['bg_color'], foreground=style_out['fg_color'])
|
176
|
+
self.label_text = ttk.Label(self.canvas, text=self.text, style=self.style, anchor=text_anchor)
|
100
177
|
self.label_text.pack(fill=tk.BOTH, expand=True)
|
101
178
|
else:
|
102
179
|
self.label_text = self.canvas.create_text(label_width // 2 if self.align == "center" else label_width - 5,
|
103
|
-
label_height // 2, text=self.text, fill=
|
180
|
+
label_height // 2, text=self.text, fill=style_out['fg_color'],
|
104
181
|
font=self.font_style, anchor=anchor_value, justify=tk.RIGHT)
|
182
|
+
|
183
|
+
_ = set_dark_style(ttk.Style(), containers=[self], widgets=[self.canvas])
|
105
184
|
|
106
185
|
def set_text(self, text):
|
107
186
|
if self.style:
|
@@ -112,22 +191,23 @@ class spacrLabel(tk.Frame):
|
|
112
191
|
class spacrButton(tk.Frame):
|
113
192
|
def __init__(self, parent, text="", command=None, font=None, *args, **kwargs):
|
114
193
|
super().__init__(parent, *args, **kwargs)
|
194
|
+
|
115
195
|
self.text = text
|
116
196
|
self.command = command
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
#print(button_height, button_width)
|
197
|
+
button_height = 50
|
198
|
+
button_width = 140
|
199
|
+
style_out = set_dark_style(ttk.Style())
|
122
200
|
|
123
|
-
#
|
124
|
-
self.canvas = tk.Canvas(self, width=button_width + 4, height=button_height + 4, highlightthickness=0, bg=
|
201
|
+
# Create the canvas first
|
202
|
+
self.canvas = tk.Canvas(self, width=button_width + 4, height=button_height + 4, highlightthickness=0, bg=style_out['bg_color'])
|
125
203
|
self.canvas.grid(row=0, column=0)
|
126
204
|
|
127
|
-
|
205
|
+
# Apply dark style and get color settings
|
206
|
+
color_settings = set_dark_style(ttk.Style(), containers=[self], widgets=[self.canvas])
|
128
207
|
|
129
|
-
self.
|
130
|
-
self.
|
208
|
+
self.button_bg = self.create_rounded_rectangle(2, 2, button_width + 2, button_height + 2, radius=20, fill=color_settings['bg_color'], outline=color_settings['fg_color'])
|
209
|
+
self.font_style = font if font else tkFont.Font(family=color_settings['font_family'], size=color_settings['font_size'], weight=tkFont.NORMAL)
|
210
|
+
self.button_text = self.canvas.create_text((button_width + 4) // 2, (button_height + 4) // 2, text=self.text, fill=color_settings['fg_color'], font=self.font_style)
|
131
211
|
|
132
212
|
self.bind("<Enter>", self.on_enter)
|
133
213
|
self.bind("<Leave>", self.on_leave)
|
@@ -136,11 +216,15 @@ class spacrButton(tk.Frame):
|
|
136
216
|
self.canvas.bind("<Leave>", self.on_leave)
|
137
217
|
self.canvas.bind("<Button-1>", self.on_click)
|
138
218
|
|
219
|
+
self.bg_color = color_settings['bg_color']
|
220
|
+
self.active_color = color_settings['active_color']
|
221
|
+
self.fg_color = color_settings['fg_color']
|
222
|
+
|
139
223
|
def on_enter(self, event=None):
|
140
|
-
self.canvas.itemconfig(self.button_bg, fill=
|
224
|
+
self.canvas.itemconfig(self.button_bg, fill=self.active_color)
|
141
225
|
|
142
226
|
def on_leave(self, event=None):
|
143
|
-
self.canvas.itemconfig(self.button_bg, fill=
|
227
|
+
self.canvas.itemconfig(self.button_bg, fill=self.bg_color)
|
144
228
|
|
145
229
|
def on_click(self, event=None):
|
146
230
|
if self.command:
|
@@ -177,17 +261,20 @@ class spacrSwitch(ttk.Frame):
|
|
177
261
|
self.text = text
|
178
262
|
self.variable = variable if variable else tk.BooleanVar()
|
179
263
|
self.command = command
|
180
|
-
self.canvas = tk.Canvas(self, width=40, height=20, highlightthickness=0, bd=0
|
264
|
+
self.canvas = tk.Canvas(self, width=40, height=20, highlightthickness=0, bd=0)
|
181
265
|
self.canvas.grid(row=0, column=1, padx=(10, 0))
|
182
266
|
self.switch_bg = self.create_rounded_rectangle(2, 2, 38, 18, radius=9, outline="", fill="#fff")
|
183
|
-
self.switch = self.canvas.create_oval(4, 4, 16, 16, outline="", fill="#800080")
|
184
|
-
self.label = spacrLabel(self, text=self.text
|
267
|
+
self.switch = self.canvas.create_oval(4, 4, 16, 16, outline="", fill="#800080")
|
268
|
+
self.label = spacrLabel(self, text=self.text)
|
185
269
|
self.label.grid(row=0, column=0, padx=(0, 10))
|
186
270
|
self.bind("<Button-1>", self.toggle)
|
187
271
|
self.canvas.bind("<Button-1>", self.toggle)
|
188
272
|
self.label.bind("<Button-1>", self.toggle)
|
189
273
|
self.update_switch()
|
190
274
|
|
275
|
+
style = ttk.Style()
|
276
|
+
_ = set_dark_style(style, containers=[self], widgets=[self.canvas, self.label])
|
277
|
+
|
191
278
|
def toggle(self, event=None):
|
192
279
|
self.variable.set(not self.variable.get())
|
193
280
|
self.animate_switch()
|
@@ -196,19 +283,19 @@ class spacrSwitch(ttk.Frame):
|
|
196
283
|
|
197
284
|
def update_switch(self):
|
198
285
|
if self.variable.get():
|
199
|
-
self.canvas.itemconfig(self.switch, fill="#008080")
|
200
|
-
self.canvas.coords(self.switch, 24, 4, 36, 16)
|
286
|
+
self.canvas.itemconfig(self.switch, fill="#008080")
|
287
|
+
self.canvas.coords(self.switch, 24, 4, 36, 16)
|
201
288
|
else:
|
202
|
-
self.canvas.itemconfig(self.switch, fill="#800080")
|
203
|
-
self.canvas.coords(self.switch, 4, 4, 16, 16)
|
289
|
+
self.canvas.itemconfig(self.switch, fill="#800080")
|
290
|
+
self.canvas.coords(self.switch, 4, 4, 16, 16)
|
204
291
|
|
205
292
|
def animate_switch(self):
|
206
293
|
if self.variable.get():
|
207
294
|
start_x, end_x = 4, 24
|
208
|
-
final_color = "#008080"
|
295
|
+
final_color = "#008080"
|
209
296
|
else:
|
210
297
|
start_x, end_x = 24, 4
|
211
|
-
final_color = "#800080"
|
298
|
+
final_color = "#800080"
|
212
299
|
|
213
300
|
self.animate_movement(start_x, end_x, final_color)
|
214
301
|
|
@@ -217,7 +304,7 @@ class spacrSwitch(ttk.Frame):
|
|
217
304
|
for i in range(start_x, end_x, step):
|
218
305
|
self.canvas.coords(self.switch, i, 4, i + 12, 16)
|
219
306
|
self.canvas.update()
|
220
|
-
self.after(10)
|
307
|
+
self.after(10)
|
221
308
|
self.canvas.itemconfig(self.switch, fill=final_color)
|
222
309
|
|
223
310
|
def get(self):
|
@@ -227,7 +314,7 @@ class spacrSwitch(ttk.Frame):
|
|
227
314
|
self.variable.set(value)
|
228
315
|
self.update_switch()
|
229
316
|
|
230
|
-
def create_rounded_rectangle(self, x1, y1, x2, y2, radius=9, **kwargs):
|
317
|
+
def create_rounded_rectangle(self, x1, y1, x2, y2, radius=9, **kwargs):
|
231
318
|
points = [x1 + radius, y1,
|
232
319
|
x1 + radius, y1,
|
233
320
|
x2 - radius, y1,
|
@@ -265,17 +352,18 @@ class spacrToolTip:
|
|
265
352
|
self.tooltip_window = tk.Toplevel(self.widget)
|
266
353
|
self.tooltip_window.wm_overrideredirect(True)
|
267
354
|
self.tooltip_window.wm_geometry(f"+{x}+{y}")
|
268
|
-
self.tooltip_window.
|
269
|
-
label = tk.Label(self.tooltip_window, text=self.text, background="#333333", foreground="white", relief='flat', borderwidth=0)
|
355
|
+
label = tk.Label(self.tooltip_window, text=self.text, relief='flat', borderwidth=0)
|
270
356
|
label.grid(row=0, column=0, padx=5, pady=5)
|
271
357
|
|
358
|
+
style = ttk.Style()
|
359
|
+
_ = set_dark_style(style, containers=[self.tooltip_window], widgets=[label])
|
360
|
+
|
272
361
|
def hide_tooltip(self, event):
|
273
362
|
if self.tooltip_window:
|
274
363
|
self.tooltip_window.destroy()
|
275
364
|
self.tooltip_window = None
|
276
365
|
|
277
366
|
class modify_masks:
|
278
|
-
|
279
367
|
def __init__(self, root, folder_path, scale_factor):
|
280
368
|
self.root = root
|
281
369
|
self.folder_path = folder_path
|
@@ -1439,7 +1527,14 @@ def create_menu_bar(root):
|
|
1439
1527
|
"Make Masks": (lambda frame: initiate_root(frame, 'make_masks'), "Adjust pre-existing Cellpose models to your specific dataset for improved performance"),
|
1440
1528
|
"Classify": (lambda frame: initiate_root(frame, 'classify'), "Train Torch Convolutional Neural Networks (CNNs) or Transformers to classify single object images."),
|
1441
1529
|
"Sequencing": (lambda frame: initiate_root(frame, 'sequencing'), "Analyze sequencing data."),
|
1442
|
-
"Umap": (lambda frame: initiate_root(frame, 'umap'), "Generate UMAP embeddings with datapoints represented as images.")
|
1530
|
+
"Umap": (lambda frame: initiate_root(frame, 'umap'), "Generate UMAP embeddings with datapoints represented as images."),
|
1531
|
+
"Train Cellpose": (lambda frame: initiate_root(frame, 'train_cellpose'), "Train custom Cellpose models."),
|
1532
|
+
"ML Analyze": (lambda frame: initiate_root(frame, 'ml_analyze'), "Machine learning analysis of data."),
|
1533
|
+
"Cellpose Masks": (lambda frame: initiate_root(frame, 'cellpose_masks'), "Generate Cellpose masks."),
|
1534
|
+
"Cellpose All": (lambda frame: initiate_root(frame, 'cellpose_all'), "Run Cellpose on all images."),
|
1535
|
+
"Map Barcodes": (lambda frame: initiate_root(frame, 'map_barcodes'), "Map barcodes to data."),
|
1536
|
+
"Regression": (lambda frame: initiate_root(frame, 'regression'), "Perform regression analysis."),
|
1537
|
+
"Recruitment": (lambda frame: initiate_root(frame, 'recruitment'), "Analyze recruitment data.")
|
1443
1538
|
}
|
1444
1539
|
|
1445
1540
|
def load_app_wrapper(app_name, app_func):
|
@@ -1458,34 +1553,4 @@ def create_menu_bar(root):
|
|
1458
1553
|
app_menu.add_separator()
|
1459
1554
|
app_menu.add_command(label="Exit", command=root.quit)
|
1460
1555
|
# Configure the menu for the root window
|
1461
|
-
root.config(menu=menu_bar)
|
1462
|
-
|
1463
|
-
def set_dark_style(style):
|
1464
|
-
font_style = tkFont.Font(family="Helvetica", size=24)
|
1465
|
-
style.configure('TEntry', padding='5 5 5 5', borderwidth=1, relief='solid', fieldbackground='black', foreground='#ffffff', font=font_style)
|
1466
|
-
style.configure('TCombobox', fieldbackground='black', background='black', foreground='#ffffff', selectbackground='black', selectforeground='#ffffff', font=font_style)
|
1467
|
-
style.map('TCombobox', fieldbackground=[('readonly', 'black')], foreground=[('readonly', '#ffffff')], selectbackground=[('readonly', 'black')], selectforeground=[('readonly', '#ffffff')])
|
1468
|
-
style.configure('Custom.TButton', background='black', foreground='white', bordercolor='white', focusthickness=3, focuscolor='white', font=('Helvetica', 12))
|
1469
|
-
style.map('Custom.TButton', background=[('active', 'teal'), ('!active', 'black')], foreground=[('active', 'white'), ('!active', 'white')], bordercolor=[('active', 'white'), ('!active', 'white')])
|
1470
|
-
style.configure('Custom.TLabel', padding='5 5 5 5', borderwidth=1, relief='flat', background='black', foreground='#ffffff', font=font_style)
|
1471
|
-
style.configure('Spacr.TCheckbutton', background='black', foreground='#ffffff', indicatoron=False, relief='flat', font="15")
|
1472
|
-
style.map('Spacr.TCheckbutton', background=[('selected', 'black'), ('active', 'black')], foreground=[('selected', '#ffffff'), ('active', '#ffffff')])
|
1473
|
-
style.configure('TLabel', background='black', foreground='#ffffff', font=font_style)
|
1474
|
-
style.configure('TFrame', background='black')
|
1475
|
-
style.configure('TPanedwindow', background='black')
|
1476
|
-
style.configure('TNotebook', background='black', tabmargins=[2, 5, 2, 0])
|
1477
|
-
style.configure('TNotebook.Tab', background='black', foreground='#ffffff', padding=[5, 5], font=font_style)
|
1478
|
-
style.map('TNotebook.Tab', background=[('selected', '#555555'), ('active', '#555555')], foreground=[('selected', '#ffffff'), ('active', '#ffffff')])
|
1479
|
-
style.configure('TButton', background='black', foreground='#ffffff', padding='5 5 5 5', font=font_style)
|
1480
|
-
style.map('TButton', background=[('active', '#555555'), ('disabled', '#333333')])
|
1481
|
-
style.configure('Vertical.TScrollbar', background='black', troughcolor='black', bordercolor='black')
|
1482
|
-
style.configure('Horizontal.TScrollbar', background='black', troughcolor='black', bordercolor='black')
|
1483
|
-
style.configure('Custom.TLabelFrame', font=('Helvetica', 10, 'bold'), background='black', foreground='white', relief='solid', borderwidth=1)
|
1484
|
-
style.configure('Custom.TLabelFrame.Label', background='black', foreground='white', font=('Helvetica', 10, 'bold'))
|
1485
|
-
|
1486
|
-
def set_default_font(root, font_name="Helvetica", size=12):
|
1487
|
-
default_font = (font_name, size)
|
1488
|
-
root.option_add("*Font", default_font)
|
1489
|
-
root.option_add("*TButton.Font", default_font)
|
1490
|
-
root.option_add("*TLabel.Font", default_font)
|
1491
|
-
root.option_add("*TEntry.Font", default_font)
|
1556
|
+
root.config(menu=menu_bar)
|
spacr/io.py
CHANGED
@@ -1693,7 +1693,7 @@ def _save_settings_to_db(settings):
|
|
1693
1693
|
settings_df['setting_value'] = settings_df['setting_value'].apply(str)
|
1694
1694
|
display(settings_df)
|
1695
1695
|
# Determine the directory path
|
1696
|
-
src = os.path.dirname(settings['
|
1696
|
+
src = os.path.dirname(settings['src'])
|
1697
1697
|
directory = f'{src}/measurements'
|
1698
1698
|
# Create the directory if it doesn't exist
|
1699
1699
|
os.makedirs(directory, exist_ok=True)
|
spacr/measure.py
CHANGED
@@ -610,7 +610,7 @@ def _measure_crop_core(index, time_ls, file, settings):
|
|
610
610
|
|
611
611
|
start = time.time()
|
612
612
|
try:
|
613
|
-
source_folder = os.path.dirname(settings['
|
613
|
+
source_folder = os.path.dirname(settings['src'])
|
614
614
|
#if not os.path.basename(source_folder).endswith('merged'):
|
615
615
|
# source_folder = os.path.join(source_folder, 'merged')
|
616
616
|
# print(f'changed source_folder to {source_folder}')
|
@@ -619,7 +619,7 @@ def _measure_crop_core(index, time_ls, file, settings):
|
|
619
619
|
# return
|
620
620
|
|
621
621
|
file_name = os.path.splitext(file)[0]
|
622
|
-
data = np.load(os.path.join(settings['
|
622
|
+
data = np.load(os.path.join(settings['src'], file))
|
623
623
|
data_type = data.dtype
|
624
624
|
if data_type not in ['uint8','uint16']:
|
625
625
|
data_type_before = data_type
|
@@ -663,7 +663,7 @@ def _measure_crop_core(index, time_ls, file, settings):
|
|
663
663
|
cell_mask, nucleus_mask = _relabel_parent_with_child_labels(cell_mask, nucleus_mask)
|
664
664
|
data[:, :, settings['cell_mask_dim']] = cell_mask
|
665
665
|
data[:, :, settings['nucleus_mask_dim']] = nucleus_mask
|
666
|
-
save_folder = settings['
|
666
|
+
save_folder = settings['src']
|
667
667
|
np.save(os.path.join(save_folder, file), data)
|
668
668
|
else:
|
669
669
|
nucleus_mask = np.zeros_like(data[:, :, 0])
|
@@ -941,13 +941,13 @@ def measure_crop(settings):
|
|
941
941
|
settings = get_measure_crop_settings(settings)
|
942
942
|
settings = measure_test_mode(settings)
|
943
943
|
|
944
|
-
#src_fldr = settings['
|
944
|
+
#src_fldr = settings['src']
|
945
945
|
#if not os.path.basename(src_fldr).endswith('merged'):
|
946
|
-
# settings['
|
947
|
-
# print(f"changed
|
946
|
+
# settings['src'] = os.path.join(src_fldr, 'merged')
|
947
|
+
# print(f"changed src to {src_fldr}")
|
948
948
|
|
949
|
-
#if not os.path.exists(settings['
|
950
|
-
# print(f'
|
949
|
+
#if not os.path.exists(settings['src']):
|
950
|
+
# print(f'src: {settings["src"]} does not exist')
|
951
951
|
# return
|
952
952
|
|
953
953
|
if settings['cell_mask_dim'] is None:
|
@@ -961,7 +961,7 @@ def measure_crop(settings):
|
|
961
961
|
else:
|
962
962
|
settings['cytoplasm'] = False
|
963
963
|
|
964
|
-
dirname = os.path.dirname(settings['
|
964
|
+
dirname = os.path.dirname(settings['src'])
|
965
965
|
settings_df = pd.DataFrame(list(settings.items()), columns=['Key', 'Value'])
|
966
966
|
settings_csv = os.path.join(dirname,'settings','measure_crop_settings.csv')
|
967
967
|
os.makedirs(os.path.join(dirname,'settings'), exist_ok=True)
|
@@ -997,7 +997,7 @@ def measure_crop(settings):
|
|
997
997
|
|
998
998
|
_save_settings_to_db(settings)
|
999
999
|
|
1000
|
-
files = [f for f in os.listdir(settings['
|
1000
|
+
files = [f for f in os.listdir(settings['src']) if f.endswith('.npy')]
|
1001
1001
|
n_jobs = settings['n_jobs'] or mp.cpu_count()-4
|
1002
1002
|
print(f'using {n_jobs} cpu cores')
|
1003
1003
|
|
@@ -1018,7 +1018,7 @@ def measure_crop(settings):
|
|
1018
1018
|
|
1019
1019
|
if settings['representative_images']:
|
1020
1020
|
if settings['save_png']:
|
1021
|
-
img_fldr = os.path.join(os.path.dirname(settings['
|
1021
|
+
img_fldr = os.path.join(os.path.dirname(settings['src']), 'data')
|
1022
1022
|
sc_img_fldrs = _list_endpoint_subdirectories(img_fldr)
|
1023
1023
|
|
1024
1024
|
for i, well_src in enumerate(sc_img_fldrs):
|
@@ -1037,7 +1037,7 @@ def measure_crop(settings):
|
|
1037
1037
|
#traceback.print_exc()
|
1038
1038
|
|
1039
1039
|
if settings['save_measurements']:
|
1040
|
-
db_path = os.path.join(os.path.dirname(settings['
|
1040
|
+
db_path = os.path.join(os.path.dirname(settings['src']), 'measurements', 'measurements.db')
|
1041
1041
|
channel_indices = settings['png_dims']
|
1042
1042
|
channel_indices = [min(value, 2) for value in channel_indices]
|
1043
1043
|
_generate_representative_images(db_path,
|
@@ -1061,13 +1061,13 @@ def measure_crop(settings):
|
|
1061
1061
|
|
1062
1062
|
if settings['timelapse']:
|
1063
1063
|
if settings['timelapse_objects'] == 'nucleus':
|
1064
|
-
folder_path = settings['
|
1064
|
+
folder_path = settings['src']
|
1065
1065
|
mask_channels = [settings['nucleus_mask_dim'], settings['pathogen_mask_dim'],settings['cell_mask_dim']]
|
1066
1066
|
object_types = ['nucleus','pathogen','cell']
|
1067
1067
|
_timelapse_masks_to_gif(folder_path, mask_channels, object_types)
|
1068
1068
|
|
1069
1069
|
#if settings['save_png']:
|
1070
|
-
img_fldr = os.path.join(os.path.dirname(settings['
|
1070
|
+
img_fldr = os.path.join(os.path.dirname(settings['src']), 'data')
|
1071
1071
|
sc_img_fldrs = _list_endpoint_subdirectories(img_fldr)
|
1072
1072
|
_scmovie(sc_img_fldrs)
|
1073
1073
|
print("Successfully completed run")
|