spacr 0.0.1__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 +37 -0
- spacr/__main__.py +15 -0
- spacr/annotate_app.py +495 -0
- spacr/cli.py +203 -0
- spacr/core.py +2250 -0
- spacr/gui_mask_app.py +247 -0
- spacr/gui_measure_app.py +214 -0
- spacr/gui_utils.py +488 -0
- spacr/io.py +2271 -0
- spacr/logger.py +20 -0
- spacr/mask_app.py +818 -0
- spacr/measure.py +1014 -0
- spacr/old_code.py +104 -0
- spacr/plot.py +1273 -0
- spacr/sim.py +1187 -0
- spacr/timelapse.py +576 -0
- spacr/train.py +494 -0
- spacr/umap.py +689 -0
- spacr/utils.py +2726 -0
- spacr/version.py +19 -0
- spacr-0.0.1.dist-info/LICENSE +21 -0
- spacr-0.0.1.dist-info/METADATA +64 -0
- spacr-0.0.1.dist-info/RECORD +26 -0
- spacr-0.0.1.dist-info/WHEEL +5 -0
- spacr-0.0.1.dist-info/entry_points.txt +5 -0
- spacr-0.0.1.dist-info/top_level.txt +1 -0
spacr/old_code.py
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
def process_fig_queue_v1():
|
2
|
+
while not fig_queue.empty():
|
3
|
+
update_task = fig_queue.get()
|
4
|
+
try:
|
5
|
+
update_task()
|
6
|
+
except Exception as e:
|
7
|
+
print(f"Error processing fig_queue: {e}")
|
8
|
+
root.after(100, process_fig_queue)
|
9
|
+
|
10
|
+
def update_figure_in_gui_v1(fig):
|
11
|
+
|
12
|
+
|
13
|
+
def task():
|
14
|
+
global canvas, canvas_widget, fig_queue
|
15
|
+
disconnect_all_event_handlers(fig)
|
16
|
+
canvas.figure = fig
|
17
|
+
fig.set_size_inches(10, 10, forward=True)
|
18
|
+
for axis in fig.axes:
|
19
|
+
axis.set_visible(False)
|
20
|
+
canvas.draw()
|
21
|
+
canvas_widget.draw()
|
22
|
+
|
23
|
+
fig_queue.put(task)
|
24
|
+
|
25
|
+
def my_show_v1():
|
26
|
+
fig = plt.gcf()
|
27
|
+
update_figure_in_gui(fig)
|
28
|
+
|
29
|
+
def disconnect_all_event_handlers(fig):
|
30
|
+
canvas = fig.canvas
|
31
|
+
if canvas.callbacks.callbacks:
|
32
|
+
for event, callback_list in list(canvas.callbacks.callbacks.items()):
|
33
|
+
for cid in list(callback_list.keys()):
|
34
|
+
canvas.mpl_disconnect(cid)
|
35
|
+
return canvas
|
36
|
+
|
37
|
+
def resize_figure_to_canvas(fig, canvas):
|
38
|
+
canvas_width = canvas.winfo_width()
|
39
|
+
canvas_height = canvas.winfo_height()
|
40
|
+
|
41
|
+
# Convert pixels to inches for matplotlib
|
42
|
+
fig_width = canvas_width / fig.dpi
|
43
|
+
fig_height = canvas_height / fig.dpi
|
44
|
+
|
45
|
+
# Resizing the figure
|
46
|
+
fig.set_size_inches(fig_width, fig_height, forward=True)
|
47
|
+
|
48
|
+
# Optionally, hide axes
|
49
|
+
for ax in fig.axes:
|
50
|
+
ax.set_visible(False)
|
51
|
+
|
52
|
+
return fig
|
53
|
+
|
54
|
+
def process_fig_queue_v1():
|
55
|
+
global canvas
|
56
|
+
while not fig_queue.empty():
|
57
|
+
try:
|
58
|
+
fig = fig_queue.get_nowait()
|
59
|
+
canvas.figure = fig
|
60
|
+
canvas.draw()
|
61
|
+
except queue.Empty:
|
62
|
+
pass
|
63
|
+
except Exception as e:
|
64
|
+
print(f"Error processing fig_queue: {e}")
|
65
|
+
traceback.print_exc()
|
66
|
+
root.after(100, process_fig_queue)
|
67
|
+
|
68
|
+
def process_fig_queue():
|
69
|
+
while not fig_queue.empty():
|
70
|
+
try:
|
71
|
+
fig = fig_queue.get_nowait()
|
72
|
+
# Signal the main thread to update the GUI with the new figure
|
73
|
+
root.after_idle(update_canvas_with_figure, fig)
|
74
|
+
except queue.Empty:
|
75
|
+
pass
|
76
|
+
except Exception as e:
|
77
|
+
print(f"Error processing fig_queue: {e}")
|
78
|
+
traceback.print_exc()
|
79
|
+
# Reschedule itself to run again
|
80
|
+
root.after(100, process_fig_queue)
|
81
|
+
|
82
|
+
def update_canvas_with_figure(fig):
|
83
|
+
global canvas
|
84
|
+
# Resize the figure to fit the canvas
|
85
|
+
canvas_width = canvas.get_tk_widget().winfo_width()
|
86
|
+
canvas_height = canvas.get_tk_widget().winfo_height()
|
87
|
+
fig_width = canvas_width / fig.dpi
|
88
|
+
fig_height = canvas_height / fig.dpi
|
89
|
+
fig.set_size_inches(fig_width, fig_height, forward=True)
|
90
|
+
# Hide the axes if needed
|
91
|
+
for ax in fig.axes:
|
92
|
+
ax.set_visible(False)
|
93
|
+
# Update the canvas with the new figure
|
94
|
+
canvas.figure = fig
|
95
|
+
canvas.draw_idle() # Use draw_idle for efficiency and thread safety
|
96
|
+
|
97
|
+
def run_mask_gui(q):
|
98
|
+
global vars_dict
|
99
|
+
try:
|
100
|
+
settings = check_mask_gui_settings(vars_dict)
|
101
|
+
settings = add_mask_gui_defaults(settings)
|
102
|
+
preprocess_generate_masks_wrapper(settings['src'], settings=settings, advanced_settings={})
|
103
|
+
except Exception as e:
|
104
|
+
q.put(f"Error during processing: {e}\n")
|