spacr 0.1.0__py3-none-any.whl → 0.1.6__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/__init__.py +19 -12
- spacr/annotate_app.py +258 -99
- spacr/annotate_app_v2.py +163 -4
- spacr/app_annotate.py +538 -0
- spacr/app_classify.py +8 -0
- spacr/app_make_masks.py +925 -0
- spacr/app_make_masks_v2.py +686 -0
- spacr/app_mask.py +8 -0
- spacr/app_measure.py +8 -0
- spacr/app_sequencing.py +8 -0
- spacr/app_umap.py +8 -0
- spacr/classify_app.py +201 -0
- spacr/core.py +8 -6
- spacr/deep_spacr.py +3 -1
- spacr/gui.py +50 -31
- spacr/gui_2.py +106 -36
- spacr/gui_annotate.py +145 -0
- spacr/gui_classify_app.py +22 -8
- spacr/gui_core.py +608 -0
- spacr/gui_elements.py +322 -0
- spacr/gui_make_masks_app.py +927 -0
- spacr/gui_make_masks_app_v2.py +688 -0
- spacr/gui_mask_app.py +42 -15
- spacr/gui_measure_app.py +46 -21
- spacr/gui_run.py +58 -0
- spacr/gui_utils.py +78 -967
- spacr/gui_wrappers.py +137 -0
- spacr/make_masks_app.py +929 -0
- spacr/make_masks_app_v2.py +688 -0
- spacr/mask_app.py +239 -915
- spacr/measure.py +24 -3
- spacr/measure_app.py +246 -0
- spacr/sequencing.py +1 -17
- spacr/settings.py +441 -6
- spacr/sim_app.py +0 -0
- spacr/utils.py +60 -7
- {spacr-0.1.0.dist-info → spacr-0.1.6.dist-info}/METADATA +13 -22
- spacr-0.1.6.dist-info/RECORD +60 -0
- spacr-0.1.6.dist-info/entry_points.txt +8 -0
- spacr-0.1.0.dist-info/RECORD +0 -40
- spacr-0.1.0.dist-info/entry_points.txt +0 -9
- {spacr-0.1.0.dist-info → spacr-0.1.6.dist-info}/LICENSE +0 -0
- {spacr-0.1.0.dist-info → spacr-0.1.6.dist-info}/WHEEL +0 -0
- {spacr-0.1.0.dist-info → spacr-0.1.6.dist-info}/top_level.txt +0 -0
spacr/gui_mask_app.py
CHANGED
@@ -97,19 +97,23 @@ def import_settings(scrollable_frame):
|
|
97
97
|
vars_dict = generate_fields(new_settings, scrollable_frame)
|
98
98
|
|
99
99
|
#@log_function_call
|
100
|
-
def initiate_mask_root(parent_frame
|
100
|
+
def initiate_mask_root(parent_frame):
|
101
101
|
global vars_dict, q, canvas, fig_queue, canvas_widget, thread_control, advanced_var, scrollable_frame
|
102
102
|
|
103
103
|
style = ttk.Style(parent_frame)
|
104
104
|
set_dark_style(style)
|
105
105
|
style_text_boxes(style)
|
106
|
-
set_default_font(parent_frame, font_name="
|
106
|
+
set_default_font(parent_frame, font_name="Helvetica", size=8)
|
107
107
|
parent_frame.configure(bg='black')
|
108
108
|
parent_frame.grid_rowconfigure(0, weight=1)
|
109
109
|
parent_frame.grid_columnconfigure(0, weight=1)
|
110
110
|
|
111
111
|
fig_queue = Queue()
|
112
112
|
|
113
|
+
# Initialize after_tasks if not already done
|
114
|
+
if not hasattr(parent_frame, 'after_tasks'):
|
115
|
+
parent_frame.after_tasks = []
|
116
|
+
|
113
117
|
def _process_fig_queue():
|
114
118
|
global canvas
|
115
119
|
try:
|
@@ -130,14 +134,20 @@ def initiate_mask_root(parent_frame, width, height):
|
|
130
134
|
except Exception as e:
|
131
135
|
traceback.print_exc()
|
132
136
|
finally:
|
133
|
-
canvas_widget.after(100, _process_fig_queue)
|
137
|
+
after_id = canvas_widget.after(100, _process_fig_queue)
|
138
|
+
parent_frame.after_tasks.append(after_id)
|
134
139
|
|
135
140
|
def _process_console_queue():
|
136
141
|
while not q.empty():
|
137
142
|
message = q.get_nowait()
|
138
143
|
console_output.insert(tk.END, message)
|
139
144
|
console_output.see(tk.END)
|
140
|
-
console_output.after(100, _process_console_queue)
|
145
|
+
after_id = console_output.after(100, _process_console_queue)
|
146
|
+
parent_frame.after_tasks.append(after_id)
|
147
|
+
|
148
|
+
# Clear previous content if any
|
149
|
+
for widget in parent_frame.winfo_children():
|
150
|
+
widget.destroy()
|
141
151
|
|
142
152
|
vertical_container = tk.PanedWindow(parent_frame, orient=tk.HORIZONTAL)
|
143
153
|
vertical_container.grid(row=0, column=0, sticky=tk.NSEW)
|
@@ -164,25 +174,27 @@ def initiate_mask_root(parent_frame, width, height):
|
|
164
174
|
vars_dict['Test mode'] = (None, None, tk.BooleanVar(value=False))
|
165
175
|
|
166
176
|
# Button section
|
167
|
-
test_mode_button = CustomButton(scrollable_frame.scrollable_frame, text="Test Mode", command=toggle_test_mode)
|
177
|
+
test_mode_button = CustomButton(scrollable_frame.scrollable_frame, text="Test Mode", command=toggle_test_mode, font=('Helvetica', 10))
|
178
|
+
#CustomButton(buttons_frame, text=app_name, command=lambda app_name=app_name: self.load_app(app_name, app_func), font=('Helvetica', 12))
|
179
|
+
|
168
180
|
test_mode_button.grid(row=47, column=1, pady=10, padx=10)
|
169
|
-
import_btn = CustomButton(scrollable_frame.scrollable_frame, text="Import", command=lambda: import_settings(scrollable_frame))
|
181
|
+
import_btn = CustomButton(scrollable_frame.scrollable_frame, text="Import", command=lambda: import_settings(scrollable_frame), font=('Helvetica', 10))
|
170
182
|
import_btn.grid(row=47, column=0, pady=10, padx=10)
|
171
183
|
run_button = CustomButton(scrollable_frame.scrollable_frame, text="Run", command=lambda: start_process(q, fig_queue))
|
172
184
|
run_button.grid(row=45, column=0, pady=10, padx=10)
|
173
|
-
abort_button = CustomButton(scrollable_frame.scrollable_frame, text="Abort", command=initiate_abort)
|
185
|
+
abort_button = CustomButton(scrollable_frame.scrollable_frame, text="Abort", command=initiate_abort, font=('Helvetica', 10))
|
174
186
|
abort_button.grid(row=45, column=1, pady=10, padx=10)
|
175
|
-
progress_label = ttk.Label(scrollable_frame.scrollable_frame, text="Processing: 0%", background="black", foreground="white")
|
187
|
+
progress_label = ttk.Label(scrollable_frame.scrollable_frame, text="Processing: 0%", background="black", foreground="white")
|
176
188
|
progress_label.grid(row=50, column=0, columnspan=2, sticky="ew", pady=(5, 0), padx=10)
|
177
189
|
|
178
190
|
# Plot Canvas Section
|
179
|
-
plot_frame = tk.PanedWindow(vertical_container, orient=tk.VERTICAL)
|
191
|
+
plot_frame = tk.PanedWindow(vertical_container, orient=tk.VERTICAL)
|
180
192
|
vertical_container.add(plot_frame, stretch="always")
|
181
|
-
figure = Figure(figsize=(30, 4), dpi=100, facecolor='black')
|
193
|
+
figure = Figure(figsize=(30, 4), dpi=100, facecolor='black')
|
182
194
|
plot = figure.add_subplot(111)
|
183
195
|
plot.plot([], []) # This creates an empty plot.
|
184
196
|
plot.axis('off')
|
185
|
-
canvas = FigureCanvasTkAgg(figure, master=plot_frame)
|
197
|
+
canvas = FigureCanvasTkAgg(figure, master=plot_frame)
|
186
198
|
canvas.get_tk_widget().configure(cursor='arrow', background='black', highlightthickness=0)
|
187
199
|
canvas_widget = canvas.get_tk_widget()
|
188
200
|
plot_frame.add(canvas_widget, stretch="always")
|
@@ -206,15 +218,30 @@ def initiate_mask_root(parent_frame, width, height):
|
|
206
218
|
_process_console_queue()
|
207
219
|
_process_fig_queue()
|
208
220
|
|
209
|
-
parent_frame.after(100, lambda: main_thread_update_function(parent_frame, q, fig_queue, canvas_widget, progress_label))
|
221
|
+
after_id = parent_frame.after(100, lambda: main_thread_update_function(parent_frame, q, fig_queue, canvas_widget, progress_label))
|
222
|
+
parent_frame.after_tasks.append(after_id)
|
210
223
|
|
211
224
|
return parent_frame, vars_dict
|
212
225
|
|
213
226
|
def gui_mask():
|
214
227
|
root = tk.Tk()
|
215
|
-
root.
|
216
|
-
root.
|
217
|
-
|
228
|
+
width = root.winfo_screenwidth()
|
229
|
+
height = root.winfo_screenheight()
|
230
|
+
root.geometry(f"{width}x{height}")
|
231
|
+
root.title("SpaCr: generate masks")
|
232
|
+
|
233
|
+
# Clear previous content if any
|
234
|
+
if hasattr(root, 'content_frame'):
|
235
|
+
for widget in root.content_frame.winfo_children():
|
236
|
+
widget.destroy()
|
237
|
+
root.content_frame.grid_forget()
|
238
|
+
else:
|
239
|
+
root.content_frame = tk.Frame(root)
|
240
|
+
root.content_frame.grid(row=1, column=0, sticky="nsew")
|
241
|
+
root.grid_rowconfigure(1, weight=1)
|
242
|
+
root.grid_columnconfigure(0, weight=1)
|
243
|
+
|
244
|
+
initiate_mask_root(root.content_frame)
|
218
245
|
create_menu_bar(root)
|
219
246
|
root.mainloop()
|
220
247
|
|
spacr/gui_measure_app.py
CHANGED
@@ -19,6 +19,15 @@ from .gui_utils import measure_variables, measure_crop_wrapper, clear_canvas, ch
|
|
19
19
|
|
20
20
|
thread_control = {"run_thread": None, "stop_requested": False}
|
21
21
|
|
22
|
+
def import_settings(scrollable_frame):
|
23
|
+
global vars_dict
|
24
|
+
|
25
|
+
csv_file_path = filedialog.askopenfilename(filetypes=[("CSV files", "*.csv")])
|
26
|
+
csv_settings = read_settings_from_csv(csv_file_path)
|
27
|
+
variables = measure_variables()
|
28
|
+
new_settings = update_settings_from_csv(variables, csv_settings)
|
29
|
+
vars_dict = generate_fields(new_settings, scrollable_frame)
|
30
|
+
|
22
31
|
def toggle_test_mode():
|
23
32
|
global vars_dict
|
24
33
|
current_state = vars_dict['test_mode'][2].get()
|
@@ -86,29 +95,24 @@ def initiate_abort():
|
|
86
95
|
thread_control["run_thread"] = None
|
87
96
|
|
88
97
|
#@log_function_call
|
89
|
-
def
|
90
|
-
global vars_dict
|
91
|
-
|
92
|
-
csv_file_path = filedialog.askopenfilename(filetypes=[("CSV files", "*.csv")])
|
93
|
-
csv_settings = read_settings_from_csv(csv_file_path)
|
94
|
-
variables = measure_variables()
|
95
|
-
new_settings = update_settings_from_csv(variables, csv_settings)
|
96
|
-
vars_dict = generate_fields(new_settings, scrollable_frame)
|
97
|
-
|
98
|
-
#@log_function_call
|
99
|
-
def initiate_measure_root(parent_frame):#, width, height):
|
98
|
+
def initiate_measure_root(parent_frame):
|
100
99
|
global vars_dict, q, canvas, fig_queue, canvas_widget, thread_control, variables, advanced_var, scrollable_frame
|
101
100
|
|
102
101
|
style = ttk.Style(parent_frame)
|
103
102
|
set_dark_style(style)
|
104
103
|
style_text_boxes(style)
|
105
|
-
set_default_font(parent_frame, font_name="
|
104
|
+
set_default_font(parent_frame, font_name="Helvetica", size=8)
|
106
105
|
|
107
106
|
parent_frame.configure(bg='black')
|
108
107
|
parent_frame.grid_rowconfigure(0, weight=1)
|
109
108
|
parent_frame.grid_columnconfigure(0, weight=1)
|
109
|
+
|
110
110
|
fig_queue = Queue()
|
111
111
|
|
112
|
+
# Initialize after_tasks if not already done
|
113
|
+
if not hasattr(parent_frame, 'after_tasks'):
|
114
|
+
parent_frame.after_tasks = []
|
115
|
+
|
112
116
|
def _process_fig_queue():
|
113
117
|
global canvas
|
114
118
|
try:
|
@@ -129,14 +133,20 @@ def initiate_measure_root(parent_frame):#, width, height):
|
|
129
133
|
except Exception as e:
|
130
134
|
traceback.print_exc()
|
131
135
|
finally:
|
132
|
-
canvas_widget.after(100, _process_fig_queue)
|
136
|
+
after_id = canvas_widget.after(100, _process_fig_queue)
|
137
|
+
parent_frame.after_tasks.append(after_id)
|
133
138
|
|
134
139
|
def _process_console_queue():
|
135
140
|
while not q.empty():
|
136
141
|
message = q.get_nowait()
|
137
142
|
console_output.insert(tk.END, message)
|
138
143
|
console_output.see(tk.END)
|
139
|
-
console_output.after(100, _process_console_queue)
|
144
|
+
after_id = console_output.after(100, _process_console_queue)
|
145
|
+
parent_frame.after_tasks.append(after_id)
|
146
|
+
|
147
|
+
# Clear previous content if any
|
148
|
+
for widget in parent_frame.winfo_children():
|
149
|
+
widget.destroy()
|
140
150
|
|
141
151
|
vertical_container = tk.PanedWindow(parent_frame, orient=tk.HORIZONTAL)
|
142
152
|
vertical_container.grid(row=0, column=0, sticky=tk.NSEW)
|
@@ -165,11 +175,11 @@ def initiate_measure_root(parent_frame):#, width, height):
|
|
165
175
|
# Button section
|
166
176
|
test_mode_button = CustomButton(scrollable_frame.scrollable_frame, text="Test Mode", command=toggle_test_mode)
|
167
177
|
test_mode_button.grid(row=47, column=1, pady=10, padx=10)
|
168
|
-
import_btn = CustomButton(scrollable_frame.scrollable_frame, text="Import
|
178
|
+
import_btn = CustomButton(scrollable_frame.scrollable_frame, text="Import", command=lambda: import_settings(scrollable_frame), font=('Helvetica', 10))
|
169
179
|
import_btn.grid(row=47, column=0, pady=20, padx=20)
|
170
|
-
run_button = CustomButton(scrollable_frame.scrollable_frame, text="Run", command=lambda: start_process(q, fig_queue))
|
180
|
+
run_button = CustomButton(scrollable_frame.scrollable_frame, text="Run", command=lambda: start_process(q, fig_queue), font=('Helvetica', 10))
|
171
181
|
run_button.grid(row=45, column=0, pady=20, padx=20)
|
172
|
-
abort_button = CustomButton(scrollable_frame.scrollable_frame, text="Abort", command=initiate_abort)
|
182
|
+
abort_button = CustomButton(scrollable_frame.scrollable_frame, text="Abort", command=initiate_abort, font=('Helvetica', 10))
|
173
183
|
abort_button.grid(row=45, column=1, pady=20, padx=20)
|
174
184
|
progress_label = ttk.Label(scrollable_frame.scrollable_frame, text="Processing: 0%", background="black", foreground="white") # Create progress field
|
175
185
|
progress_label.grid(row=50, column=0, columnspan=2, sticky="ew", pady=(5, 0), padx=10)
|
@@ -205,15 +215,30 @@ def initiate_measure_root(parent_frame):#, width, height):
|
|
205
215
|
_process_console_queue()
|
206
216
|
_process_fig_queue()
|
207
217
|
|
208
|
-
parent_frame.after(100, lambda: main_thread_update_function(parent_frame, q, fig_queue, canvas_widget, progress_label))
|
218
|
+
after_id = parent_frame.after(100, lambda: main_thread_update_function(parent_frame, q, fig_queue, canvas_widget, progress_label))
|
219
|
+
parent_frame.after_tasks.append(after_id)
|
209
220
|
|
210
221
|
return parent_frame, vars_dict
|
211
222
|
|
212
223
|
def gui_measure():
|
213
224
|
root = tk.Tk()
|
214
|
-
root.
|
215
|
-
root.
|
216
|
-
|
225
|
+
width = root.winfo_screenwidth()
|
226
|
+
height = root.winfo_screenheight()
|
227
|
+
root.geometry(f"{width}x{height}")
|
228
|
+
root.title("SpaCr: measure objects")
|
229
|
+
|
230
|
+
# Clear previous content if any
|
231
|
+
if hasattr(root, 'content_frame'):
|
232
|
+
for widget in root.content_frame.winfo_children():
|
233
|
+
widget.destroy()
|
234
|
+
root.content_frame.grid_forget()
|
235
|
+
else:
|
236
|
+
root.content_frame = tk.Frame(root)
|
237
|
+
root.content_frame.grid(row=1, column=0, sticky="nsew")
|
238
|
+
root.grid_rowconfigure(1, weight=1)
|
239
|
+
root.grid_columnconfigure(0, weight=1)
|
240
|
+
|
241
|
+
initiate_measure_root(root.content_frame)
|
217
242
|
create_menu_bar(root)
|
218
243
|
root.mainloop()
|
219
244
|
|
spacr/gui_run.py
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
import traceback
|
2
|
+
from .gui_wrappers import measure_crop_wrapper, preprocess_generate_masks_wrapper, train_test_model_wrapper, umap_wrapper, sequencing_wrapper
|
3
|
+
|
4
|
+
def run_mask_gui(settings, q, fig_queue, stop_requested):
|
5
|
+
from .gui_utils import process_stdout_stderr
|
6
|
+
process_stdout_stderr(q)
|
7
|
+
try:
|
8
|
+
preprocess_generate_masks_wrapper(settings, q, fig_queue)
|
9
|
+
except Exception as e:
|
10
|
+
q.put(f"Error during processing: {e}")
|
11
|
+
traceback.print_exc()
|
12
|
+
finally:
|
13
|
+
stop_requested.value = 1
|
14
|
+
|
15
|
+
def run_sequencing_gui(settings, q, fig_queue, stop_requested):
|
16
|
+
from .gui_utils import process_stdout_stderr
|
17
|
+
process_stdout_stderr(q)
|
18
|
+
try:
|
19
|
+
sequencing_wrapper(settings, q, fig_queue)
|
20
|
+
except Exception as e:
|
21
|
+
q.put(f"Error during processing: {e}")
|
22
|
+
traceback.print_exc()
|
23
|
+
finally:
|
24
|
+
stop_requested.value = 1
|
25
|
+
|
26
|
+
def run_umap_gui(settings, q, fig_queue, stop_requested):
|
27
|
+
from .gui_utils import process_stdout_stderr
|
28
|
+
process_stdout_stderr(q)
|
29
|
+
try:
|
30
|
+
umap_wrapper(settings, q, fig_queue)
|
31
|
+
except Exception as e:
|
32
|
+
q.put(f"Error during processing: {e}")
|
33
|
+
traceback.print_exc()
|
34
|
+
finally:
|
35
|
+
stop_requested.value = 1
|
36
|
+
|
37
|
+
def run_measure_gui(settings, q, fig_queue, stop_requested):
|
38
|
+
from .gui_utils import process_stdout_stderr
|
39
|
+
process_stdout_stderr(q)
|
40
|
+
try:
|
41
|
+
settings['input_folder'] = settings['src']
|
42
|
+
measure_crop_wrapper(settings=settings, q=q, fig_queue=fig_queue)
|
43
|
+
except Exception as e:
|
44
|
+
q.put(f"Error during processing: {e}")
|
45
|
+
traceback.print_exc()
|
46
|
+
finally:
|
47
|
+
stop_requested.value = 1
|
48
|
+
|
49
|
+
def run_classify_gui(settings, q, fig_queue, stop_requested):
|
50
|
+
from .gui_utils import process_stdout_stderr
|
51
|
+
process_stdout_stderr(q)
|
52
|
+
try:
|
53
|
+
train_test_model_wrapper(settings['src'], settings)
|
54
|
+
except Exception as e:
|
55
|
+
q.put(f"Error during processing: {e}")
|
56
|
+
traceback.print_exc()
|
57
|
+
finally:
|
58
|
+
stop_requested.value = 1
|