spacr 0.0.21__py3-none-any.whl → 0.0.36__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_utils.py CHANGED
@@ -1,19 +1,208 @@
1
- import spacr, inspect, traceback, io, sys, ast, ctypes, matplotlib, re, csv
1
+ import os, spacr, inspect, traceback, io, sys, ast, ctypes, matplotlib, re, csv, requests
2
2
  import matplotlib.pyplot as plt
3
3
  matplotlib.use('Agg')
4
4
  import numpy as np
5
5
  import tkinter as tk
6
6
  from tkinter import ttk, messagebox
7
- from tkinter.font import nametofont
7
+ import tkinter.font as tkFont
8
8
  from torchvision import models
9
9
 
10
+ from .logger import log_function_call
11
+
10
12
  try:
11
13
  ctypes.windll.shcore.SetProcessDpiAwareness(True)
12
14
  except AttributeError:
13
15
  pass
14
16
 
15
- from .logger import log_function_call
17
+ def load_app(root, app_name, app_func):
18
+ # Destroy the current window
19
+ root.destroy()
20
+ # Create a new window for the app
21
+ app_window = tk.Tk()
22
+ app_window.title(f"SpaCr - {app_name}")
23
+ app_window.geometry("1200x800")
24
+ #app_window.attributes('-fullscreen', True)
25
+ app_window.configure(bg="black")
26
+ create_menu_bar(app_window) # Add menu to the new window
27
+ app_func(app_window, app_window.winfo_width(), app_window.winfo_height())
28
+
29
+ def create_menu_bar(root):
30
+
31
+ from .gui_mask_app import initiate_mask_root
32
+ from .gui_measure_app import initiate_measure_root
33
+ from .annotate_app import initiate_annotation_app_root
34
+ from .mask_app import initiate_mask_app_root
35
+ from .gui_classify_app import initiate_classify_root
36
+
37
+ gui_apps = {
38
+ "Mask": initiate_mask_root,
39
+ "Measure": initiate_measure_root,
40
+ "Annotate": initiate_annotation_app_root,
41
+ "Make Masks": initiate_mask_app_root,
42
+ "Classify": initiate_classify_root
43
+ }
44
+ # Create the menu bar
45
+ menu_bar = tk.Menu(root, bg="#008080", fg="white")
46
+ # Create a "SpaCr Applications" menu
47
+ app_menu = tk.Menu(menu_bar, tearoff=0, bg="#008080", fg="white")
48
+ menu_bar.add_cascade(label="SpaCr Applications", menu=app_menu)
49
+ # Add options to the "SpaCr Applications" menu
50
+ for app_name, app_func in gui_apps.items():
51
+ app_menu.add_command(label=app_name, command=lambda app_name=app_name, app_func=app_func: load_app(root, app_name, app_func))
52
+ # Add a separator and an exit option
53
+ app_menu.add_separator()
54
+ app_menu.add_command(label="Exit", command=root.quit)
55
+ # Configure the menu for the root window
56
+ root.config(menu=menu_bar)
57
+
58
+ class CustomButton(tk.Frame):
59
+ def __init__(self, parent, text="", command=None, *args, **kwargs):
60
+ super().__init__(parent, *args, **kwargs)
61
+ self.text = text
62
+ self.command = command
63
+
64
+ self.canvas = tk.Canvas(self, width=200, height=50, highlightthickness=0, bg="black")
65
+ self.canvas.grid(row=0, column=0)
66
+
67
+ self.button_bg = self.create_rounded_rectangle(0, 0, 200, 50, radius=20, fill="#800080")
68
+
69
+ # Load the Open Sans font
70
+ self.font_path = 'fonts/OpenSans-Regular.ttf'
71
+ if not os.path.exists(self.font_path):
72
+ self.download_font()
73
+
74
+ self.open_sans = tkFont.Font(family="Open Sans", size=10)
75
+ self.button_text = self.canvas.create_text(100, 25, text=self.text, fill="white", font=self.open_sans)
76
+
77
+ self.bind("<Enter>", self.on_enter)
78
+ self.bind("<Leave>", self.on_leave)
79
+ self.bind("<Button-1>", self.on_click)
80
+ self.canvas.bind("<Enter>", self.on_enter)
81
+ self.canvas.bind("<Leave>", self.on_leave)
82
+ self.canvas.bind("<Button-1>", self.on_click)
83
+
84
+ def on_enter(self, event=None):
85
+ self.canvas.itemconfig(self.button_bg, fill="#993399")
86
+
87
+ def on_leave(self, event=None):
88
+ self.canvas.itemconfig(self.button_bg, fill="#800080")
89
+
90
+ def on_click(self, event=None):
91
+ if self.command:
92
+ self.command()
93
+
94
+ def create_rounded_rectangle(self, x1, y1, x2, y2, radius=20, **kwargs):
95
+ points = [x1 + radius, y1,
96
+ x1 + radius, y1,
97
+ x2 - radius, y1,
98
+ x2 - radius, y1,
99
+ x2, y1,
100
+ x2, y1 + radius,
101
+ x2, y1 + radius,
102
+ x2, y2 - radius,
103
+ x2, y2 - radius,
104
+ x2, y2,
105
+ x2 - radius, y2,
106
+ x2 - radius, y2,
107
+ x1 + radius, y2,
108
+ x1 + radius, y2,
109
+ x1, y2,
110
+ x1, y2 - radius,
111
+ x1, y2 - radius,
112
+ x1, y1 + radius,
113
+ x1, y1 + radius,
114
+ x1, y1]
115
+
116
+ return self.canvas.create_polygon(points, **kwargs, smooth=True)
117
+
118
+ class ToggleSwitch(ttk.Frame):
119
+ def __init__(self, parent, text="", variable=None, command=None, *args, **kwargs):
120
+ super().__init__(parent, *args, **kwargs)
121
+ self.text = text
122
+ self.variable = variable if variable else tk.BooleanVar()
123
+ self.command = command
124
+
125
+ self.canvas = tk.Canvas(self, width=40, height=20, highlightthickness=0, bd=0, bg="black")
126
+ self.canvas.grid(row=0, column=1, padx=(10, 0))
127
+
128
+ # Background rounded rectangle with smaller dimensions and no outline
129
+ self.switch_bg = self.create_rounded_rectangle(2, 2, 38, 18, radius=9, outline="", fill="#fff")
130
+
131
+ # Switch ball with no outline
132
+ self.switch = self.canvas.create_oval(4, 4, 16, 16, outline="", fill="#800080") # Purple initially
133
+
134
+ self.label = ttk.Label(self, text=self.text, background="black", foreground="white")
135
+ self.label.grid(row=0, column=0, padx=(0, 10))
136
+
137
+ self.bind("<Button-1>", self.toggle)
138
+ self.canvas.bind("<Button-1>", self.toggle)
139
+ self.label.bind("<Button-1>", self.toggle)
140
+
141
+ self.update_switch()
142
+
143
+ def toggle(self, event=None):
144
+ self.variable.set(not self.variable.get())
145
+ self.animate_switch()
146
+ if self.command:
147
+ self.command()
148
+
149
+ def update_switch(self):
150
+ if self.variable.get():
151
+ self.canvas.itemconfig(self.switch, fill="#008080") # Teal
152
+ self.canvas.coords(self.switch, 24, 4, 36, 16) # Move switch to the right
153
+ else:
154
+ self.canvas.itemconfig(self.switch, fill="#800080") # Purple
155
+ self.canvas.coords(self.switch, 4, 4, 16, 16) # Move switch to the left
16
156
 
157
+ def animate_switch(self):
158
+ if self.variable.get():
159
+ start_x, end_x = 4, 24
160
+ final_color = "#008080" # Teal
161
+ else:
162
+ start_x, end_x = 24, 4
163
+ final_color = "#800080" # Purple
164
+
165
+ self.animate_movement(start_x, end_x, final_color)
166
+
167
+ def animate_movement(self, start_x, end_x, final_color):
168
+ step = 1 if start_x < end_x else -1
169
+ for i in range(start_x, end_x, step):
170
+ self.canvas.coords(self.switch, i, 4, i + 12, 16)
171
+ self.canvas.update()
172
+ self.after(10) # Small delay for smooth animation
173
+ self.canvas.itemconfig(self.switch, fill=final_color)
174
+
175
+ def get(self):
176
+ return self.variable.get()
177
+
178
+ def set(self, value):
179
+ self.variable.set(value)
180
+ self.update_switch()
181
+
182
+ def create_rounded_rectangle(self, x1, y1, x2, y2, radius=9, **kwargs): # Smaller radius for smaller switch
183
+ points = [x1 + radius, y1,
184
+ x1 + radius, y1,
185
+ x2 - radius, y1,
186
+ x2 - radius, y1,
187
+ x2, y1,
188
+ x2, y1 + radius,
189
+ x2, y1 + radius,
190
+ x2, y2 - radius,
191
+ x2, y2 - radius,
192
+ x2, y2,
193
+ x2 - radius, y2,
194
+ x2 - radius, y2,
195
+ x1 + radius, y2,
196
+ x1 + radius, y2,
197
+ x1, y2,
198
+ x1, y2 - radius,
199
+ x1, y2 - radius,
200
+ x1, y1 + radius,
201
+ x1, y1 + radius,
202
+ x1, y1]
203
+
204
+ return self.canvas.create_polygon(points, **kwargs, smooth=True)
205
+
17
206
  def set_default_font(root, font_name="Helvetica", size=12):
18
207
  default_font = (font_name, size)
19
208
  root.option_add("*Font", default_font)
@@ -21,13 +210,63 @@ def set_default_font(root, font_name="Helvetica", size=12):
21
210
  root.option_add("*TLabel.Font", default_font)
22
211
  root.option_add("*TEntry.Font", default_font)
23
212
 
213
+ def check_and_download_font():
214
+ font_name = "Open Sans"
215
+ font_dir = "fonts"
216
+ font_path = os.path.join(font_dir, "OpenSans-Regular.ttf")
217
+
218
+ # Check if the font is already available
219
+ available_fonts = list(tkFont.families())
220
+ if font_name not in available_fonts:
221
+ print(f"Font '{font_name}' not found. Downloading...")
222
+ if not os.path.exists(font_dir):
223
+ os.makedirs(font_dir)
224
+
225
+ if not os.path.exists(font_path):
226
+ url = "https://github.com/google/fonts/blob/main/apache/opensans/OpenSans-Regular.ttf?raw=true"
227
+ response = requests.get(url)
228
+ with open(font_path, "wb") as f:
229
+ f.write(response.content)
230
+
231
+ # Load the font
232
+ try:
233
+ tkFont.nametofont("TkDefaultFont").configure(family=font_name, size=10)
234
+ tkFont.nametofont("TkTextFont").configure(family=font_name, size=10)
235
+ tkFont.nametofont("TkHeadingFont").configure(family=font_name, size=12)
236
+ except tk.TclError:
237
+ tkFont.nametofont("TkDefaultFont").configure(family="Open Sans", size=10)
238
+ tkFont.nametofont("TkTextFont").configure(family="Open Sans", size=10)
239
+ tkFont.nametofont("TkHeadingFont").configure(family="Open Sans", size=12)
240
+ else:
241
+ tkFont.nametofont("TkDefaultFont").configure(family=font_name, size=10)
242
+ tkFont.nametofont("TkTextFont").configure(family=font_name, size=10)
243
+ tkFont.nametofont("TkHeadingFont").configure(family=font_name, size=12)
244
+
245
+ def style_text_boxes_v1(style):
246
+ style.configure('TEntry', padding='5 5 5 5', borderwidth=1, relief='solid', fieldbackground='#000000', foreground='#ffffff')
247
+ style.configure('TCombobox', fieldbackground='#000000', background='#000000', foreground='#ffffff')
248
+ style.configure('Custom.TButton', padding='10 10 10 10', borderwidth=1, relief='solid', background='#008080', foreground='#ffffff', font=('Open Sans', 10, 'bold'))
249
+ style.map('Custom.TButton',
250
+ background=[('active', '#66b2b2'), ('disabled', '#004d4d'), ('!disabled', '#008080')],
251
+ foreground=[('active', '#ffffff'), ('disabled', '#888888')])
252
+ style.configure('Custom.TLabel', padding='5 5 5 5', borderwidth=1, relief='flat', background='#000000', foreground='#ffffff', font=('Open Sans', 10))
253
+ style.configure('TCheckbutton', background='#333333', foreground='#ffffff', indicatoron=False, relief='flat')
254
+ style.map('TCheckbutton', background=[('selected', '#555555'), ('active', '#555555')])
255
+
24
256
  def style_text_boxes(style):
25
- style.configure('TEntry', padding='5 5 5 5', borderwidth=1, relief='solid', background='#333333', foreground='#ffffff')
26
- style.configure('TButton', padding='10 10 10 10', borderwidth=1, relief='solid', background='#444444', foreground='#ffffff', font=('Helvetica', 12, 'bold'))
27
- style.map('TButton',
28
- background=[('active', '#555555'), ('disabled', '#222222')],
257
+ check_and_download_font()
258
+ open_sans = tkFont.Font(family="Open Sans", size=10) # Define the Open Sans font
259
+ style.configure('TEntry', padding='5 5 5 5', borderwidth=1, relief='solid', fieldbackground='#000000', foreground='#ffffff', font=open_sans)
260
+ style.configure('TCombobox', fieldbackground='#000000', background='#000000', foreground='#ffffff', font=open_sans)
261
+ style.configure('Custom.TButton', padding='10 10 10 10', borderwidth=1, relief='solid', background='#008080', foreground='#ffffff', font=open_sans)
262
+ style.map('Custom.TButton',
263
+ background=[('active', '#66b2b2'), ('disabled', '#004d4d'), ('!disabled', '#008080')],
29
264
  foreground=[('active', '#ffffff'), ('disabled', '#888888')])
30
- style.configure('TLabel', padding='5 5 5 5', borderwidth=1, relief='flat', background='#2e2e2e', foreground='#ffffff')
265
+ style.configure('Custom.TLabel', padding='5 5 5 5', borderwidth=1, relief='flat', background='#000000', foreground='#ffffff', font=open_sans)
266
+ style.configure('TCheckbutton', background='#333333', foreground='#ffffff', indicatoron=False, relief='flat', font=open_sans)
267
+ style.map('TCheckbutton', background=[('selected', '#555555'), ('active', '#555555')])
268
+
269
+
31
270
 
32
271
  def read_settings_from_csv(csv_file_path):
33
272
  settings = {}
@@ -66,17 +305,8 @@ def disable_interactivity(fig):
66
305
  for handler_id in list(handlers.keys()):
67
306
  fig.canvas.mpl_disconnect(handler_id)
68
307
 
69
- def set_default_font_v1(app, font_name="Arial Bold", size=10):
70
- default_font = nametofont("TkDefaultFont")
71
- text_font = nametofont("TkTextFont")
72
- fixed_font = nametofont("TkFixedFont")
73
-
74
- # Set the family to Open Sans and size as desired
75
- for font in (default_font, text_font, fixed_font):
76
- font.config(family=font_name, size=size)
77
-
78
308
  class ScrollableFrame(ttk.Frame):
79
- def __init__(self, container, *args, bg='#333333', **kwargs):
309
+ def __init__(self, container, *args, bg='black', **kwargs):
80
310
  super().__init__(container, *args, **kwargs)
81
311
  self.configure(style='TFrame') # Ensure this uses the styled frame from dark mode
82
312
 
@@ -381,32 +611,31 @@ def classify_variables():
381
611
  }
382
612
  return variables
383
613
 
384
-
385
- #@log_function_call
386
614
  def create_input_field(frame, label_text, row, var_type='entry', options=None, default_value=None):
387
- label = ttk.Label(frame, text=label_text, style='TLabel') # Assuming you have a dark mode style for labels too
615
+ label = ttk.Label(frame, text=label_text, style='Custom.TLabel') # Apply Custom.TLabel style for labels
388
616
  label.grid(column=0, row=row, sticky=tk.W, padx=5, pady=5)
389
617
 
390
618
  if var_type == 'entry':
391
619
  var = tk.StringVar(value=default_value) # Set default value
392
- entry = ttk.Entry(frame, textvariable=var, style='TEntry') # Assuming you have a dark mode style for entries
620
+ entry = ttk.Entry(frame, textvariable=var, style='TEntry') # Apply TEntry style for entries
393
621
  entry.grid(column=1, row=row, sticky=tk.EW, padx=5)
622
+ return (label, entry, var) # Return both the label and the entry, and the variable
394
623
  elif var_type == 'check':
395
624
  var = tk.BooleanVar(value=default_value) # Set default value (True/False)
396
- # Use the custom style for Checkbutton
397
- check = ttk.Checkbutton(frame, variable=var, style='Dark.TCheckbutton')
625
+ check = ToggleSwitch(frame, text=label_text, variable=var) # Use ToggleSwitch class
398
626
  check.grid(column=1, row=row, sticky=tk.W, padx=5)
627
+ return (label, check, var) # Return both the label and the checkbutton, and the variable
399
628
  elif var_type == 'combo':
400
629
  var = tk.StringVar(value=default_value) # Set default value
401
- combo = ttk.Combobox(frame, textvariable=var, values=options, style='TCombobox') # Assuming you have a dark mode style for comboboxes
630
+ combo = ttk.Combobox(frame, textvariable=var, values=options, style='TCombobox') # Apply TCombobox style
402
631
  combo.grid(column=1, row=row, sticky=tk.EW, padx=5)
403
632
  if default_value:
404
633
  combo.set(default_value)
634
+ return (label, combo, var) # Return both the label and the combobox, and the variable
405
635
  else:
406
636
  var = None # Placeholder in case of an undefined var_type
407
-
408
- return var
409
-
637
+ return (label, None, var)
638
+
410
639
  def mask_variables():
411
640
  variables = {
412
641
  'src': ('entry', None, '/mnt/data/CellVoyager/40x/einar/mitotrackerHeLaToxoDsRed_20240224_123156/test_gui'),
@@ -473,7 +702,8 @@ def generate_fields(variables, scrollable_frame):
473
702
  vars_dict = {}
474
703
  row = 0
475
704
  for key, (var_type, options, default_value) in variables.items():
476
- vars_dict[key] = create_input_field(scrollable_frame.scrollable_frame, key, row, var_type, options, default_value)
705
+ label, widget, var = create_input_field(scrollable_frame.scrollable_frame, key, row, var_type, options, default_value)
706
+ vars_dict[key] = (label, widget, var) # Store the label, widget, and variable
477
707
  row += 1
478
708
  return vars_dict
479
709
 
@@ -489,7 +719,7 @@ class TextRedirector(object):
489
719
  pass
490
720
 
491
721
  def create_dark_mode(root, style, console_output):
492
- dark_bg = '#333333'
722
+ dark_bg = 'black'
493
723
  light_text = 'white'
494
724
  dark_text = 'black'
495
725
  input_bg = '#555555' # Slightly lighter background for input fields
@@ -505,16 +735,16 @@ def create_dark_mode(root, style, console_output):
505
735
  style.map('TCombobox', fieldbackground=[('readonly', input_bg)], selectbackground=[('readonly', input_bg)], foreground=[('readonly', dark_text)])
506
736
 
507
737
  if console_output != None:
508
- console_output.config(bg=dark_bg, fg=light_text, insertbackground=light_text) #, font=("Arial", 12)
738
+ console_output.config(bg=dark_bg, fg=light_text, insertbackground=light_text) #, font=("Open Sans", 12)
509
739
  root.configure(bg=dark_bg)
510
740
 
511
741
  def set_dark_style(style):
512
- style.configure('TFrame', background='#333333')
513
- style.configure('TLabel', background='#333333', foreground='white')
514
- style.configure('TEntry', background='#333333', foreground='white')
515
- style.configure('TCheckbutton', background='#333333', foreground='white')
742
+ style.configure('TFrame', background='black')
743
+ style.configure('TLabel', background='black', foreground='white')
744
+ style.configure('TEntry', background='black', foreground='white')
745
+ style.configure('TCheckbutton', background='black', foreground='white')
516
746
 
517
- #@log_function_call
747
+ ##@log_function_call
518
748
  def main_thread_update_function(root, q, fig_queue, canvas_widget, progress_label):
519
749
  try:
520
750
  ansi_escape_pattern = re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]')
@@ -603,7 +833,7 @@ def measure_crop_wrapper(settings, q, fig_queue):
603
833
  finally:
604
834
  plt.show = original_show # Restore the original plt.show function
605
835
 
606
- @log_function_call
836
+ #@log_function_call
607
837
  def preprocess_generate_masks_wrapper(settings, q, fig_queue):
608
838
  """
609
839
  Wraps the measure_crop function to integrate with GUI processes.
spacr/io.py CHANGED
@@ -529,7 +529,7 @@ class TarImageDataset(Dataset):
529
529
 
530
530
  return img, m.name
531
531
 
532
- @log_function_call
532
+ #@log_function_call
533
533
  def _rename_and_organize_image_files(src, regex, batch_size=100, pick_slice=False, skip_mode='01', metadata_type='', img_format='.tif'):
534
534
  """
535
535
  Convert z-stack images to maximum intensity projection (MIP) images.
@@ -930,7 +930,7 @@ def _mip_all(src, include_first_chan=True):
930
930
  np.save(os.path.join(src, filename), concatenated)
931
931
  return
932
932
 
933
- @log_function_call
933
+ #@log_function_call
934
934
  def _concatenate_channel(src, channels, randomize=True, timelapse=False, batch_size=100):
935
935
  """
936
936
  Concatenates channel data from multiple files and saves the concatenated data as numpy arrays.
@@ -1257,7 +1257,7 @@ def delete_empty_subdirectories(folder_path):
1257
1257
  # An error occurred, likely because the directory is not empty
1258
1258
  #print(f"Skipping non-empty directory: {full_dir_path}")
1259
1259
 
1260
- @log_function_call
1260
+ #@log_function_call
1261
1261
  def preprocess_img_data(settings):
1262
1262
 
1263
1263
  from .plot import plot_arrays, _plot_4D_arrays
@@ -1300,6 +1300,7 @@ def preprocess_img_data(settings):
1300
1300
  extension_counts = Counter(extensions)
1301
1301
  most_common_extension = extension_counts.most_common(1)[0][0]
1302
1302
  img_format = None
1303
+
1303
1304
 
1304
1305
  delete_empty_subdirectories(src)
1305
1306
 
spacr/mask_app.py CHANGED
@@ -13,7 +13,7 @@ from ttkthemes import ThemedTk
13
13
 
14
14
  from .logger import log_function_call
15
15
 
16
- from .gui_utils import ScrollableFrame, set_dark_style, set_default_font, create_dark_mode
16
+ from .gui_utils import ScrollableFrame, set_dark_style, set_default_font, create_dark_mode, style_text_boxes, create_menu_bar
17
17
 
18
18
  class modify_masks:
19
19
 
@@ -753,15 +753,18 @@ class modify_masks:
753
753
  self.mask[labeled_mask == i] = 0 # Remove small objects
754
754
  self.update_display()
755
755
 
756
- @log_function_call
756
+ ##@log_function_call
757
757
  def initiate_mask_app_root(width, height):
758
758
  theme = 'breeze'
759
759
  root = ThemedTk(theme=theme)
760
760
  style = ttk.Style(root)
761
761
  set_dark_style(style)
762
- set_default_font(root, font_name="Arial", size=10)
762
+
763
+ style_text_boxes(style)
764
+ set_default_font(root, font_name="Arial", size=8)
763
765
  root.geometry(f"{width}x{height}")
764
766
  root.title("Mask App")
767
+ create_menu_bar(root)
765
768
 
766
769
  container = tk.PanedWindow(root, orient=tk.HORIZONTAL)
767
770
  container.pack(fill=tk.BOTH, expand=True)
@@ -806,7 +809,7 @@ def initiate_mask_app_root(width, height):
806
809
  create_dark_mode(root, style, console_output=None)
807
810
 
808
811
  run_button = ttk.Button(scrollable_frame.scrollable_frame, text="Run", command=run_app)
809
- run_button.grid(row=row, column=0, columnspan=2, pady=10)
812
+ run_button.grid(row=row, column=0, columnspan=2, pady=10, padx=10)
810
813
 
811
814
  return root
812
815
 
spacr/measure.py CHANGED
@@ -157,7 +157,7 @@ def _analyze_cytoskeleton(array, mask, channel):
157
157
 
158
158
  return pd.DataFrame(properties_list)
159
159
 
160
- @log_function_call
160
+ #@log_function_call
161
161
  def _morphological_measurements(cell_mask, nucleus_mask, pathogen_mask, cytoplasm_mask, settings, zernike=True, degree=8):
162
162
  """
163
163
  Calculate morphological measurements for cells, nucleus, pathogens, and cytoplasms based on the given masks.
@@ -501,7 +501,7 @@ def _estimate_blur(image):
501
501
  # Compute and return the variance of the Laplacian
502
502
  return lap.var()
503
503
 
504
- @log_function_call
504
+ #@log_function_call
505
505
  def _intensity_measurements(cell_mask, nucleus_mask, pathogen_mask, cytoplasm_mask, channel_arrays, settings, sizes=[3, 6, 12, 24], periphery=True, outside=True):
506
506
  """
507
507
  Calculate various intensity measurements for different regions in the image.
@@ -589,7 +589,7 @@ def _intensity_measurements(cell_mask, nucleus_mask, pathogen_mask, cytoplasm_ma
589
589
 
590
590
  return pd.concat(cell_dfs, axis=1), pd.concat(nucleus_dfs, axis=1), pd.concat(pathogen_dfs, axis=1), pd.concat(cytoplasm_dfs, axis=1)
591
591
 
592
- @log_function_call
592
+ #@log_function_call
593
593
  def _measure_crop_core(index, time_ls, file, settings):
594
594
 
595
595
  """
@@ -887,7 +887,7 @@ def _measure_crop_core(index, time_ls, file, settings):
887
887
  average_time = np.mean(time_ls) if len(time_ls) > 0 else 0
888
888
  return average_time, cells
889
889
 
890
- @log_function_call
890
+ #@log_function_call
891
891
  def measure_crop(settings):
892
892
 
893
893
  """
spacr/old_code.py CHANGED
@@ -103,7 +103,7 @@ def run_mask_gui(q):
103
103
  except Exception as e:
104
104
  q.put(f"Error during processing: {e}\n")
105
105
 
106
- @log_function_call
106
+ #@log_function_call
107
107
  def main_thread_update_function(root, q, fig_queue, canvas_widget, progress_label):
108
108
  try:
109
109
  while not q.empty():
spacr/utils.py CHANGED
@@ -46,12 +46,6 @@ from torchvision.models.resnet import ResNet18_Weights, ResNet34_Weights, ResNet
46
46
 
47
47
  from .logger import log_function_call
48
48
 
49
- #from .io import _read_and_join_tables, _save_figure
50
- #from .timelapse import _btrack_track_cells, _trackpy_track_cells
51
- #from .plot import _plot_images_on_grid, plot_masks, _plot_histograms_and_stats, plot_resize, _plot_plates, _reg_v_plot, plot_masks
52
- #from .core import identify_masks
53
-
54
-
55
49
  def _gen_rgb_image(image, cahnnels):
56
50
  rgb_image = np.take(image, cahnnels, axis=-1)
57
51
  rgb_image = rgb_image.astype(float)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: spacr
3
- Version: 0.0.21
3
+ Version: 0.0.36
4
4
  Summary: Spatial phenotype analysis of crisp screens (SpaCr)
5
5
  Home-page: https://github.com/EinarOlafsson/spacr
6
6
  Author: Einar Birnir Olafsson
@@ -1,33 +1,35 @@
1
1
  spacr/__init__.py,sha256=mDi-Qu5r1vZnqIbUBV1JAoSq-mxmMEOmni1JSG2e4Wo,879
2
2
  spacr/__main__.py,sha256=_qRkhbFrH_cXr7AZs6KHL8Hh4VApqNdpNCtiKn2ePTo,285
3
3
  spacr/alpha.py,sha256=1LUtTaeVHqcTMxoCMA7mlsNYyaR0KEaXglwXsUQLwKo,13776
4
- spacr/annotate_app.py,sha256=jtm1HgWngv9BTsyVzdmBqg1flbmbXs9JkP6CB4wmOH8,19951
4
+ spacr/annotate_app.py,sha256=oP3aHbtWyvlg7Hnee5GIHzqeM8Jwf5Y9N2n6bO7ZtfY,20032
5
+ spacr/chris.py,sha256=YlBjSgeZaY8HPy6jkrT_ISAnCMAKVfvCxF0I9eAZLFM,2418
5
6
  spacr/cli.py,sha256=507jfOOEV8BoL4eeUcblvH-iiDHdBrEVJLu1ghAAPSc,1800
6
7
  spacr/core.py,sha256=_R8gXNnjf680yrnbCi2piWQUz7PDbqWYn7SL5MACLfo,156457
7
8
  spacr/foldseek.py,sha256=cWtLzvFF2O_mq5I71UMiuU9DTvDCp7wl6aaWAZRrBZc,33970
8
9
  spacr/get_alfafold_structures.py,sha256=n0g8gne-oyAV3Uo6qxZoJq5X1cUUyD8u0pOC_W2PX40,3541
9
10
  spacr/graph_learning.py,sha256=sD4eOC7Q16rr7WO20mCi_E16_LqioGUUgPamAHIIeNI,12568
10
11
  spacr/graph_learning_lap.py,sha256=MyNRLb63gsjBlui-ByZ0anHugYulL6M-OsGm8rnGBmE,3385
11
- spacr/gui_classify_app.py,sha256=-I06tVoA3U0jaAoTs32H1Y5ACMz6QBaEM1NEfg5w-9c,7965
12
- spacr/gui_mask_app.py,sha256=wb1w_-U1RTJFfRCGfdrkku4FVULSA_2gFZyVM9oQlB0,8752
13
- spacr/gui_measure_app.py,sha256=9mAw3Tiuq61uKTzMVslr0MgD8m1Lv5PNI0K4-gQiuXE,8061
12
+ spacr/gui.py,sha256=2d2JHYVWhEFUkB3u_2OarCV_V07eLtJKUMKVKuJ7nAo,6430
13
+ spacr/gui_classify_app.py,sha256=fWJOQO0NjhymdRxccQYlMVbDKBKEPHbAbU9NEdp0peI,7921
14
+ spacr/gui_mask_app.py,sha256=FXSMasIFBUZWXpVXELR21UevK8g65xqLxio9B2xEyYM,9754
15
+ spacr/gui_measure_app.py,sha256=tkshD4KOydHTWeViwkjQILowJUVs4PNhBZzy76jxssI,9680
14
16
  spacr/gui_sim_app.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- spacr/gui_utils.py,sha256=NlgGFt62yqYnusv4yT1yjPcjd-v29N4IYukkJkEdL28,30493
16
- spacr/io.py,sha256=gcQJ-WOzwDzRZsIzzIoMKIbhFN5AP9lYy2HCv9fG8CU,108683
17
+ spacr/gui_utils.py,sha256=f1kyecWyHygw9Eb67PbZ-wWXtn2b85E0LcOLl2Fi3g8,40717
18
+ spacr/io.py,sha256=sqWiLtUFiholVSAfMbeK8ssuAl9BiRzgfv9ixMsWDRE,108691
17
19
  spacr/logger.py,sha256=7Zqr3TuuOQLWT32gYr2q1qvv7x0a2JhLANmZcnBXAW8,670
18
- spacr/mask_app.py,sha256=B6-zYXVFg-cc58gLcz-Ry6LClO2jxLitL6B2ACb0HTw,39278
19
- spacr/measure.py,sha256=_f6UDugw75rILEg0uo2-QsUGUvc4AQdrdHl-BPZk74I,54686
20
- spacr/old_code.py,sha256=KxljHpKNsV5EfX9ifN2xJTnUeqAhyabZyfDWd5THOOc,11226
20
+ spacr/mask_app.py,sha256=dAMYQLn8jVbtsuoJ98p_Oih_XSMZpdOVPlefgjdVAZM,39378
21
+ spacr/measure.py,sha256=bS79LNOfb7j7_qf_lS9NVdO2vcgFsHC8DvPsSgMnvTA,54690
22
+ spacr/old_code.py,sha256=ujL-shd353C_Ac74MtzUTEHdpqsDguNwe_5FziUGA-M,11227
21
23
  spacr/plot.py,sha256=VtDKTJ_zo8CAVC3ILuIN_wUP6197vq089wNZuom7T8g,61655
22
24
  spacr/sim.py,sha256=2NR5hm--HVcYQnj1SCHoUCVbh_b2XUjjjfoAUIXFwnQ,72997
23
25
  spacr/timelapse.py,sha256=plPjR8nZ7_Q50VAvMvHK2TUE4F-vh7R23JnI6tSW02g,39661
24
26
  spacr/train.py,sha256=lp66dWYkiMMlgdYlMjAsJnkIZFWLizKB-xwyVnKgFBs,25904
25
27
  spacr/umap.py,sha256=4QSrQ16Og-Ijq-SwguMQT2f20UWz1LE5HQeSLmzSl8c,29370
26
- spacr/utils.py,sha256=r0BjycEXqr48m0xEW9o14bLPj62JNpmEUBaBwR817Bw,121205
28
+ spacr/utils.py,sha256=D3WRf_0w0T6dZHh3BfwScGBQjorljgWW6CQUdM0ToN8,120918
27
29
  spacr/version.py,sha256=axH5tnGwtgSnJHb5IDhiu4Zjk5GhLyAEDRe-rnaoFOA,409
28
- spacr-0.0.21.dist-info/LICENSE,sha256=SR-2MeGc6SCM1UORJYyarSWY_A-JaOMFDj7ReSs9tRM,1083
29
- spacr-0.0.21.dist-info/METADATA,sha256=u93xu8dbff0h_8p25GP5yi49sUOh7GS-axPRbik4qRk,4973
30
- spacr-0.0.21.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
31
- spacr-0.0.21.dist-info/entry_points.txt,sha256=5uyJaAxWCbjWYwP15InAKU1yFxTwyuvCGtIGceso1es,290
32
- spacr-0.0.21.dist-info/top_level.txt,sha256=GJPU8FgwRXGzKeut6JopsSRY2R8T3i9lDgya42tLInY,6
33
- spacr-0.0.21.dist-info/RECORD,,
30
+ spacr-0.0.36.dist-info/LICENSE,sha256=SR-2MeGc6SCM1UORJYyarSWY_A-JaOMFDj7ReSs9tRM,1083
31
+ spacr-0.0.36.dist-info/METADATA,sha256=NzLoqcIVHlvAZyDGvBM7lXQXeDGsop8N15bKVFTi3RI,4973
32
+ spacr-0.0.36.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
33
+ spacr-0.0.36.dist-info/entry_points.txt,sha256=_khj_UcegrI5N29QcgxECsxVsfpVQzG3U5OUoKdtTcw,288
34
+ spacr-0.0.36.dist-info/top_level.txt,sha256=GJPU8FgwRXGzKeut6JopsSRY2R8T3i9lDgya42tLInY,6
35
+ spacr-0.0.36.dist-info/RECORD,,
@@ -0,0 +1,8 @@
1
+ [console_scripts]
2
+ annotate = spacr.annotate_app:gui_annotation
3
+ classify = spacr.gui_classify_app:gui_classify
4
+ gui = spacr.gui:gui_app
5
+ make_masks = spacr.mask_app:gui_make_masks
6
+ mask = spacr.gui_mask_app:gui_mask
7
+ measure = spacr.gui_measure_app:gui_measure
8
+ sim = spacr.gui_sim_app:gui_sim
@@ -1,7 +0,0 @@
1
- [console_scripts]
2
- gui_annotation = spacr.annotate_app:gui_annotation
3
- gui_classify = spacr.gui_classify_app:gui_classify
4
- gui_make_masks = spacr.mask_app:gui_make_masks
5
- gui_mask = spacr.gui_mask_app:gui_mask
6
- gui_measure = spacr.gui_measure_app:gui_measure
7
- gui_sim = spacr.gui_sim_app:gui_sim
File without changes