spacr 0.2.2__py3-none-any.whl → 0.2.21__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 +2 -1
- spacr/gui_elements.py +1 -5
- spacr/resources/icons/abort.png +0 -0
- spacr/resources/icons/classify.png +0 -0
- spacr/resources/icons/make_masks.png +0 -0
- spacr/resources/icons/mask.png +0 -0
- spacr/resources/icons/measure.png +0 -0
- spacr/resources/icons/recruitment.png +0 -0
- spacr/resources/icons/regression.png +0 -0
- spacr/resources/icons/run.png +0 -0
- spacr/resources/icons/umap.png +0 -0
- {spacr-0.2.2.dist-info → spacr-0.2.21.dist-info}/METADATA +1 -1
- spacr-0.2.21.dist-info/RECORD +56 -0
- spacr/alpha.py +0 -807
- spacr/annotate_app.py +0 -670
- spacr/annotate_app_v2.py +0 -670
- spacr/app_make_masks_v2.py +0 -686
- spacr/classify_app.py +0 -201
- spacr/cli.py +0 -41
- spacr/foldseek.py +0 -779
- spacr/get_alfafold_structures.py +0 -72
- spacr/gui_2.py +0 -157
- spacr/gui_annotate.py +0 -145
- spacr/gui_classify_app.py +0 -201
- spacr/gui_make_masks_app.py +0 -927
- spacr/gui_make_masks_app_v2.py +0 -688
- spacr/gui_mask_app.py +0 -249
- spacr/gui_measure_app.py +0 -246
- spacr/gui_run.py +0 -58
- spacr/gui_sim_app.py +0 -0
- spacr/gui_wrappers.py +0 -149
- spacr/icons/abort.png +0 -0
- spacr/icons/abort.svg +0 -1
- spacr/icons/download.png +0 -0
- spacr/icons/download.svg +0 -1
- spacr/icons/download_for_offline_100dp_E8EAED_FILL0_wght100_GRAD-25_opsz48.png +0 -0
- spacr/icons/download_for_offline_100dp_E8EAED_FILL0_wght100_GRAD-25_opsz48.svg +0 -1
- spacr/icons/logo_spacr.png +0 -0
- spacr/icons/make_masks.png +0 -0
- spacr/icons/make_masks.svg +0 -1
- spacr/icons/map_barcodes.png +0 -0
- spacr/icons/map_barcodes.svg +0 -1
- spacr/icons/mask.png +0 -0
- spacr/icons/mask.svg +0 -1
- spacr/icons/measure.png +0 -0
- spacr/icons/measure.svg +0 -1
- spacr/icons/play_circle_100dp_E8EAED_FILL0_wght100_GRAD-25_opsz48.png +0 -0
- spacr/icons/play_circle_100dp_E8EAED_FILL0_wght100_GRAD-25_opsz48.svg +0 -1
- spacr/icons/run.png +0 -0
- spacr/icons/run.svg +0 -1
- spacr/icons/sequencing.png +0 -0
- spacr/icons/sequencing.svg +0 -1
- spacr/icons/settings.png +0 -0
- spacr/icons/settings.svg +0 -1
- spacr/icons/settings_100dp_E8EAED_FILL0_wght100_GRAD-25_opsz48.png +0 -0
- spacr/icons/settings_100dp_E8EAED_FILL0_wght100_GRAD-25_opsz48.svg +0 -1
- spacr/icons/stop_circle_100dp_E8EAED_FILL0_wght100_GRAD-25_opsz48.png +0 -0
- spacr/icons/stop_circle_100dp_E8EAED_FILL0_wght100_GRAD-25_opsz48.svg +0 -1
- spacr/icons/theater_comedy_100dp_E8EAED_FILL0_wght100_GRAD200_opsz48.png +0 -0
- spacr/icons/theater_comedy_100dp_E8EAED_FILL0_wght100_GRAD200_opsz48.svg +0 -1
- spacr/make_masks_app.py +0 -929
- spacr/make_masks_app_v2.py +0 -688
- spacr/mask_app.py +0 -249
- spacr/measure_app.py +0 -246
- spacr/models/cp/toxo_plaque_cyto_e25000_X1120_Y1120.CP_model +0 -0
- spacr/models/cp/toxo_plaque_cyto_e25000_X1120_Y1120.CP_model_settings.csv +0 -23
- spacr/models/cp/toxo_pv_lumen.CP_model +0 -0
- spacr/old_code.py +0 -358
- spacr/resources/icons/abort.svg +0 -1
- spacr/resources/icons/annotate.svg +0 -1
- spacr/resources/icons/classify.svg +0 -1
- spacr/resources/icons/download.svg +0 -1
- spacr/resources/icons/icon.psd +0 -0
- spacr/resources/icons/make_masks.svg +0 -1
- spacr/resources/icons/map_barcodes.svg +0 -1
- spacr/resources/icons/mask.svg +0 -1
- spacr/resources/icons/measure.svg +0 -1
- spacr/resources/icons/run.svg +0 -1
- spacr/resources/icons/run_2.png +0 -0
- spacr/resources/icons/run_2.svg +0 -1
- spacr/resources/icons/sequencing.svg +0 -1
- spacr/resources/icons/settings.svg +0 -1
- spacr/resources/icons/train_cellpose.svg +0 -1
- spacr/test_gui.py +0 -0
- spacr-0.2.2.dist-info/RECORD +0 -126
- /spacr/resources/icons/{cellpose.png → cellpose_all.png} +0 -0
- {spacr-0.2.2.dist-info → spacr-0.2.21.dist-info}/LICENSE +0 -0
- {spacr-0.2.2.dist-info → spacr-0.2.21.dist-info}/WHEEL +0 -0
- {spacr-0.2.2.dist-info → spacr-0.2.21.dist-info}/entry_points.txt +0 -0
- {spacr-0.2.2.dist-info → spacr-0.2.21.dist-info}/top_level.txt +0 -0
spacr/classify_app.py
DELETED
@@ -1,201 +0,0 @@
|
|
1
|
-
import sys, ctypes, matplotlib
|
2
|
-
import tkinter as tk
|
3
|
-
from tkinter import ttk, scrolledtext
|
4
|
-
from matplotlib.figure import Figure
|
5
|
-
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
|
6
|
-
from matplotlib.figure import Figure
|
7
|
-
matplotlib.use('Agg')
|
8
|
-
from tkinter import filedialog
|
9
|
-
from multiprocessing import Process, Queue, Value
|
10
|
-
import traceback
|
11
|
-
|
12
|
-
try:
|
13
|
-
ctypes.windll.shcore.SetProcessDpiAwareness(True)
|
14
|
-
except AttributeError:
|
15
|
-
pass
|
16
|
-
|
17
|
-
from .logger import log_function_call
|
18
|
-
from .gui_utils import ScrollableFrame, StdoutRedirector, CustomButton, set_dark_style, set_default_font, generate_fields, process_stdout_stderr, clear_canvas, main_thread_update_function
|
19
|
-
from .gui_utils import classify_variables, check_classify_gui_settings, train_test_model_wrapper, read_settings_from_csv, update_settings_from_csv, style_text_boxes, create_menu_bar
|
20
|
-
|
21
|
-
thread_control = {"run_thread": None, "stop_requested": False}
|
22
|
-
|
23
|
-
#@log_function_call
|
24
|
-
def initiate_abort():
|
25
|
-
global thread_control
|
26
|
-
if thread_control.get("stop_requested") is not None:
|
27
|
-
thread_control["stop_requested"].value = 1
|
28
|
-
|
29
|
-
if thread_control.get("run_thread") is not None:
|
30
|
-
thread_control["run_thread"].join(timeout=5)
|
31
|
-
if thread_control["run_thread"].is_alive():
|
32
|
-
thread_control["run_thread"].terminate()
|
33
|
-
thread_control["run_thread"] = None
|
34
|
-
|
35
|
-
#@log_function_call
|
36
|
-
def run_classify_gui(q, fig_queue, stop_requested):
|
37
|
-
global vars_dict
|
38
|
-
process_stdout_stderr(q)
|
39
|
-
try:
|
40
|
-
settings = check_classify_gui_settings(vars_dict)
|
41
|
-
for key in settings:
|
42
|
-
value = settings[key]
|
43
|
-
print(key, value, type(value))
|
44
|
-
train_test_model_wrapper(settings['src'], settings)
|
45
|
-
except Exception as e:
|
46
|
-
q.put(f"Error during processing: {e}")
|
47
|
-
traceback.print_exc()
|
48
|
-
finally:
|
49
|
-
stop_requested.value = 1
|
50
|
-
|
51
|
-
#@log_function_call
|
52
|
-
def start_process(q, fig_queue):
|
53
|
-
global thread_control
|
54
|
-
if thread_control.get("run_thread") is not None:
|
55
|
-
initiate_abort()
|
56
|
-
|
57
|
-
stop_requested = Value('i', 0) # multiprocessing shared value for inter-process communication
|
58
|
-
thread_control["stop_requested"] = stop_requested
|
59
|
-
thread_control["run_thread"] = Process(target=run_classify_gui, args=(q, fig_queue, stop_requested))
|
60
|
-
thread_control["run_thread"].start()
|
61
|
-
|
62
|
-
def import_settings(scrollable_frame):
|
63
|
-
global vars_dict
|
64
|
-
|
65
|
-
csv_file_path = filedialog.askopenfilename(filetypes=[("CSV files", "*.csv")])
|
66
|
-
csv_settings = read_settings_from_csv(csv_file_path)
|
67
|
-
variables = classify_variables()
|
68
|
-
new_settings = update_settings_from_csv(variables, csv_settings)
|
69
|
-
vars_dict = generate_fields(new_settings, scrollable_frame)
|
70
|
-
|
71
|
-
#@log_function_call
|
72
|
-
def initiate_classify_root(parent_frame):
|
73
|
-
global vars_dict, q, canvas, fig_queue, canvas_widget, thread_control
|
74
|
-
|
75
|
-
style = ttk.Style(parent_frame)
|
76
|
-
set_dark_style(style)
|
77
|
-
style_text_boxes(style)
|
78
|
-
set_default_font(parent_frame, font_name="Helvetica", size=8)
|
79
|
-
|
80
|
-
parent_frame.configure(bg='#333333')
|
81
|
-
parent_frame.grid_rowconfigure(0, weight=1)
|
82
|
-
parent_frame.grid_columnconfigure(0, weight=1)
|
83
|
-
fig_queue = Queue()
|
84
|
-
|
85
|
-
def _process_fig_queue():
|
86
|
-
global canvas
|
87
|
-
try:
|
88
|
-
while not fig_queue.empty():
|
89
|
-
clear_canvas(canvas)
|
90
|
-
fig = fig_queue.get_nowait()
|
91
|
-
for ax in fig.get_axes():
|
92
|
-
ax.set_xticks([]) # Remove x-axis ticks
|
93
|
-
ax.set_yticks([]) # Remove y-axis ticks
|
94
|
-
ax.xaxis.set_visible(False) # Hide the x-axis
|
95
|
-
ax.yaxis.set_visible(False) # Hide the y-axis
|
96
|
-
fig.tight_layout()
|
97
|
-
fig.set_facecolor('#333333')
|
98
|
-
canvas.figure = fig
|
99
|
-
fig_width, fig_height = canvas_widget.winfo_width(), canvas_widget.winfo_height()
|
100
|
-
fig.set_size_inches(fig_width / fig.dpi, fig_height / fig.dpi, forward=True)
|
101
|
-
canvas.draw_idle()
|
102
|
-
except Exception as e:
|
103
|
-
traceback.print_exc()
|
104
|
-
finally:
|
105
|
-
canvas_widget.after(100, _process_fig_queue)
|
106
|
-
|
107
|
-
def _process_console_queue():
|
108
|
-
while not q.empty():
|
109
|
-
message = q.get_nowait()
|
110
|
-
console_output.insert(tk.END, message)
|
111
|
-
console_output.see(tk.END)
|
112
|
-
console_output.after(100, _process_console_queue)
|
113
|
-
|
114
|
-
vertical_container = tk.PanedWindow(parent_frame, orient=tk.HORIZONTAL)
|
115
|
-
vertical_container.grid(row=0, column=0, sticky=tk.NSEW)
|
116
|
-
parent_frame.grid_rowconfigure(0, weight=1)
|
117
|
-
parent_frame.grid_columnconfigure(0, weight=1)
|
118
|
-
|
119
|
-
# Settings Section
|
120
|
-
settings_frame = tk.Frame(vertical_container, bg='#333333')
|
121
|
-
vertical_container.add(settings_frame, stretch="always")
|
122
|
-
settings_label = ttk.Label(settings_frame, text="Settings", background="#333333", foreground="white")
|
123
|
-
settings_label.grid(row=0, column=0, pady=10, padx=10)
|
124
|
-
scrollable_frame = ScrollableFrame(settings_frame, width=500)
|
125
|
-
scrollable_frame.grid(row=1, column=0, sticky="nsew")
|
126
|
-
settings_frame.grid_rowconfigure(1, weight=1)
|
127
|
-
settings_frame.grid_columnconfigure(0, weight=1)
|
128
|
-
|
129
|
-
# Setup for user input fields (variables)
|
130
|
-
variables = classify_variables()
|
131
|
-
vars_dict = generate_fields(variables, scrollable_frame)
|
132
|
-
|
133
|
-
# Button section
|
134
|
-
import_btn = CustomButton(scrollable_frame.scrollable_frame, text="Import", command=lambda: import_settings(scrollable_frame), font=('Helvetica', 10))
|
135
|
-
import_btn.grid(row=47, column=0, pady=20, padx=20)
|
136
|
-
run_button = CustomButton(scrollable_frame.scrollable_frame, text="Run", command=lambda: start_process(q, fig_queue), font=('Helvetica', 10))
|
137
|
-
run_button.grid(row=45, column=0, pady=20, padx=20)
|
138
|
-
abort_button = CustomButton(scrollable_frame.scrollable_frame, text="Abort", command=initiate_abort, font=('Helvetica', 10))
|
139
|
-
abort_button.grid(row=45, column=1, pady=20, padx=20)
|
140
|
-
progress_label = ttk.Label(scrollable_frame.scrollable_frame, text="Processing: 0%", background="black", foreground="white") # Create progress field
|
141
|
-
progress_label.grid(row=50, column=0, columnspan=2, sticky="ew", pady=(5, 0), padx=10)
|
142
|
-
|
143
|
-
# Plot Canvas Section
|
144
|
-
plot_frame = tk.PanedWindow(vertical_container, orient=tk.VERTICAL)
|
145
|
-
vertical_container.add(plot_frame, stretch="always")
|
146
|
-
figure = Figure(figsize=(30, 4), dpi=100, facecolor='#333333')
|
147
|
-
plot = figure.add_subplot(111)
|
148
|
-
plot.plot([], [])
|
149
|
-
plot.axis('off')
|
150
|
-
canvas = FigureCanvasTkAgg(figure, master=plot_frame)
|
151
|
-
canvas.get_tk_widget().configure(cursor='arrow', background='#333333', highlightthickness=0)
|
152
|
-
canvas_widget = canvas.get_tk_widget()
|
153
|
-
plot_frame.add(canvas_widget, stretch="always")
|
154
|
-
canvas.draw()
|
155
|
-
canvas.figure = figure
|
156
|
-
|
157
|
-
# Console Section
|
158
|
-
console_frame = tk.Frame(vertical_container, bg='#333333')
|
159
|
-
vertical_container.add(console_frame, stretch="always")
|
160
|
-
console_label = ttk.Label(console_frame, text="Console", background="#333333", foreground="white")
|
161
|
-
console_label.grid(row=0, column=0, pady=10, padx=10)
|
162
|
-
console_output = scrolledtext.ScrolledText(console_frame, height=10, bg='#333333', fg='white', insertbackground='white')
|
163
|
-
console_output.grid(row=1, column=0, sticky="nsew")
|
164
|
-
console_frame.grid_rowconfigure(1, weight=1)
|
165
|
-
console_frame.grid_columnconfigure(0, weight=1)
|
166
|
-
|
167
|
-
q = Queue()
|
168
|
-
sys.stdout = StdoutRedirector(console_output)
|
169
|
-
sys.stderr = StdoutRedirector(console_output)
|
170
|
-
|
171
|
-
_process_console_queue()
|
172
|
-
_process_fig_queue()
|
173
|
-
|
174
|
-
parent_frame.after(100, lambda: main_thread_update_function(parent_frame, q, fig_queue, canvas_widget, progress_label))
|
175
|
-
|
176
|
-
return parent_frame, vars_dict
|
177
|
-
|
178
|
-
def gui_classify():
|
179
|
-
root = tk.Tk()
|
180
|
-
width = root.winfo_screenwidth()
|
181
|
-
height = root.winfo_screenheight()
|
182
|
-
root.geometry(f"{width}x{height}")
|
183
|
-
root.title("SpaCr: classify objects")
|
184
|
-
|
185
|
-
# Clear previous content if any
|
186
|
-
if hasattr(root, 'content_frame'):
|
187
|
-
for widget in root.content_frame.winfo_children():
|
188
|
-
widget.destroy()
|
189
|
-
root.content_frame.grid_forget()
|
190
|
-
else:
|
191
|
-
root.content_frame = tk.Frame(root)
|
192
|
-
root.content_frame.grid(row=1, column=0, sticky="nsew")
|
193
|
-
root.grid_rowconfigure(1, weight=1)
|
194
|
-
root.grid_columnconfigure(0, weight=1)
|
195
|
-
|
196
|
-
initiate_classify_root(root.content_frame)
|
197
|
-
create_menu_bar(root)
|
198
|
-
root.mainloop()
|
199
|
-
|
200
|
-
if __name__ == "__main__":
|
201
|
-
gui_classify()
|
spacr/cli.py
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Copyright © 2023 Howard Hughes Medical Institute, Authored by Carsen Stringer and Marius Pachitariu and Michael Rariden.
|
3
|
-
"""
|
4
|
-
|
5
|
-
import argparse
|
6
|
-
|
7
|
-
import argparse
|
8
|
-
|
9
|
-
|
10
|
-
def get_arg_parser():
|
11
|
-
""" Parses command line arguments for spacr main functions
|
12
|
-
|
13
|
-
Note: this function has to be in a separate file to allow autodoc to work for CLI.
|
14
|
-
The autodoc_mock_imports in conf.py does not work for sphinx-argparse sometimes,
|
15
|
-
see https://github.com/ashb/sphinx-argparse/issues/9#issue-1097057823
|
16
|
-
"""
|
17
|
-
|
18
|
-
parser = argparse.ArgumentParser(description="SPACR Mask App Command Line Parameters")
|
19
|
-
hardware_args = parser.add_argument_group("Hardware Arguments")
|
20
|
-
input_img_args = parser.add_argument_group("Input Image Arguments")
|
21
|
-
#model_args = parser.add_argument_group("Model Arguments")
|
22
|
-
#algorithm_args = parser.add_argument_group("Algorithm Arguments")
|
23
|
-
#training_args = parser.add_argument_group("Training Arguments")
|
24
|
-
#output_args = parser.add_argument_group("Output Arguments")
|
25
|
-
|
26
|
-
# misc settings
|
27
|
-
parser.add_argument("--version", action="store_true",
|
28
|
-
help="show version info")
|
29
|
-
# misc settings
|
30
|
-
parser.add_argument("--headless", action="store_true",
|
31
|
-
help="run the app without the gui")
|
32
|
-
|
33
|
-
parser.add_argument("--verbose", action="store_true",
|
34
|
-
help="show information about running and settings and save to log")
|
35
|
-
|
36
|
-
hardware_args.add_argument("--gpu_device", required=False, default="0", type=str,
|
37
|
-
help="which gpu device to use, use an integer for torch, or mps for M1")
|
38
|
-
|
39
|
-
input_img_args.add_argument("--src", default=[], type=str,
|
40
|
-
help="folder containing data to run or train on.")
|
41
|
-
return parser
|