spacr 0.2.3__py3-none-any.whl → 0.2.5__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.
Files changed (61) hide show
  1. spacr/app_annotate.py +3 -4
  2. spacr/core.py +100 -282
  3. spacr/gui.py +20 -38
  4. spacr/gui_core.py +406 -499
  5. spacr/gui_elements.py +395 -60
  6. spacr/gui_utils.py +393 -73
  7. spacr/io.py +130 -50
  8. spacr/measure.py +199 -154
  9. spacr/plot.py +108 -42
  10. spacr/resources/font/open_sans/OFL.txt +93 -0
  11. spacr/resources/font/open_sans/OpenSans-Italic-VariableFont_wdth,wght.ttf +0 -0
  12. spacr/resources/font/open_sans/OpenSans-VariableFont_wdth,wght.ttf +0 -0
  13. spacr/resources/font/open_sans/README.txt +100 -0
  14. spacr/resources/font/open_sans/static/OpenSans-Bold.ttf +0 -0
  15. spacr/resources/font/open_sans/static/OpenSans-BoldItalic.ttf +0 -0
  16. spacr/resources/font/open_sans/static/OpenSans-ExtraBold.ttf +0 -0
  17. spacr/resources/font/open_sans/static/OpenSans-ExtraBoldItalic.ttf +0 -0
  18. spacr/resources/font/open_sans/static/OpenSans-Italic.ttf +0 -0
  19. spacr/resources/font/open_sans/static/OpenSans-Light.ttf +0 -0
  20. spacr/resources/font/open_sans/static/OpenSans-LightItalic.ttf +0 -0
  21. spacr/resources/font/open_sans/static/OpenSans-Medium.ttf +0 -0
  22. spacr/resources/font/open_sans/static/OpenSans-MediumItalic.ttf +0 -0
  23. spacr/resources/font/open_sans/static/OpenSans-Regular.ttf +0 -0
  24. spacr/resources/font/open_sans/static/OpenSans-SemiBold.ttf +0 -0
  25. spacr/resources/font/open_sans/static/OpenSans-SemiBoldItalic.ttf +0 -0
  26. spacr/resources/font/open_sans/static/OpenSans_Condensed-Bold.ttf +0 -0
  27. spacr/resources/font/open_sans/static/OpenSans_Condensed-BoldItalic.ttf +0 -0
  28. spacr/resources/font/open_sans/static/OpenSans_Condensed-ExtraBold.ttf +0 -0
  29. spacr/resources/font/open_sans/static/OpenSans_Condensed-ExtraBoldItalic.ttf +0 -0
  30. spacr/resources/font/open_sans/static/OpenSans_Condensed-Italic.ttf +0 -0
  31. spacr/resources/font/open_sans/static/OpenSans_Condensed-Light.ttf +0 -0
  32. spacr/resources/font/open_sans/static/OpenSans_Condensed-LightItalic.ttf +0 -0
  33. spacr/resources/font/open_sans/static/OpenSans_Condensed-Medium.ttf +0 -0
  34. spacr/resources/font/open_sans/static/OpenSans_Condensed-MediumItalic.ttf +0 -0
  35. spacr/resources/font/open_sans/static/OpenSans_Condensed-Regular.ttf +0 -0
  36. spacr/resources/font/open_sans/static/OpenSans_Condensed-SemiBold.ttf +0 -0
  37. spacr/resources/font/open_sans/static/OpenSans_Condensed-SemiBoldItalic.ttf +0 -0
  38. spacr/resources/font/open_sans/static/OpenSans_SemiCondensed-Bold.ttf +0 -0
  39. spacr/resources/font/open_sans/static/OpenSans_SemiCondensed-BoldItalic.ttf +0 -0
  40. spacr/resources/font/open_sans/static/OpenSans_SemiCondensed-ExtraBold.ttf +0 -0
  41. spacr/resources/font/open_sans/static/OpenSans_SemiCondensed-ExtraBoldItalic.ttf +0 -0
  42. spacr/resources/font/open_sans/static/OpenSans_SemiCondensed-Italic.ttf +0 -0
  43. spacr/resources/font/open_sans/static/OpenSans_SemiCondensed-Light.ttf +0 -0
  44. spacr/resources/font/open_sans/static/OpenSans_SemiCondensed-LightItalic.ttf +0 -0
  45. spacr/resources/font/open_sans/static/OpenSans_SemiCondensed-Medium.ttf +0 -0
  46. spacr/resources/font/open_sans/static/OpenSans_SemiCondensed-MediumItalic.ttf +0 -0
  47. spacr/resources/font/open_sans/static/OpenSans_SemiCondensed-Regular.ttf +0 -0
  48. spacr/resources/font/open_sans/static/OpenSans_SemiCondensed-SemiBold.ttf +0 -0
  49. spacr/resources/font/open_sans/static/OpenSans_SemiCondensed-SemiBoldItalic.ttf +0 -0
  50. spacr/resources/icons/logo.pdf +2786 -6
  51. spacr/resources/icons/logo_spacr.png +0 -0
  52. spacr/resources/icons/logo_spacr_1.png +0 -0
  53. spacr/settings.py +12 -87
  54. spacr/utils.py +45 -10
  55. {spacr-0.2.3.dist-info → spacr-0.2.5.dist-info}/METADATA +5 -1
  56. spacr-0.2.5.dist-info/RECORD +100 -0
  57. spacr-0.2.3.dist-info/RECORD +0 -58
  58. {spacr-0.2.3.dist-info → spacr-0.2.5.dist-info}/LICENSE +0 -0
  59. {spacr-0.2.3.dist-info → spacr-0.2.5.dist-info}/WHEEL +0 -0
  60. {spacr-0.2.3.dist-info → spacr-0.2.5.dist-info}/entry_points.txt +0 -0
  61. {spacr-0.2.3.dist-info → spacr-0.2.5.dist-info}/top_level.txt +0 -0
spacr/gui.py CHANGED
@@ -15,30 +15,29 @@ class MainApp(tk.Tk):
15
15
  self.title("SpaCr GUI Collection")
16
16
  self.configure(bg='#333333') # Set window background to dark gray
17
17
 
18
- # Initialize style and apply dark style to the main window
19
18
  style = ttk.Style()
20
19
  self.color_settings = set_dark_style(style, parent_frame=self)
21
- self.main_buttons = {} # Initialize main_buttons dictionary here
22
- self.additional_buttons = {} # Initialize additional_buttons dictionary here
20
+ self.main_buttons = {}
21
+ self.additional_buttons = {}
23
22
 
24
23
  self.main_gui_apps = {
25
- "Mask": (lambda frame: initiate_root(frame, 'mask'), "Generate cellpose masks for cells, nuclei and pathogen images."),
26
- "Measure": (lambda frame: initiate_root(frame, 'measure'), "Measure single object intensity and morphological feature. Crop and save single object image"),
27
- "Annotate": (lambda frame: initiate_root(frame, 'annotate'), "Annotation single object images on a grid. Annotations are saved to database."),
28
- "Make Masks": (lambda frame: initiate_root(frame, 'make_masks'), "Adjust pre-existing Cellpose models to your specific dataset for improved performance"),
29
- "Classify": (lambda frame: initiate_root(frame, 'classify'), "Train Torch Convolutional Neural Networks (CNNs) or Transformers to classify single object images."),
24
+ "Mask": (lambda frame: initiate_root(self, 'mask'), "Generate cellpose masks for cells, nuclei and pathogen images."),
25
+ "Measure": (lambda frame: initiate_root(self, 'measure'), "Measure single object intensity and morphological feature. Crop and save single object image"),
26
+ "Annotate": (lambda frame: initiate_root(self, 'annotate'), "Annotation single object images on a grid. Annotations are saved to database."),
27
+ "Make Masks": (lambda frame: initiate_root(self, 'make_masks'), "Adjust pre-existing Cellpose models to your specific dataset for improved performance"),
28
+ "Classify": (lambda frame: initiate_root(self, 'classify'), "Train Torch Convolutional Neural Networks (CNNs) or Transformers to classify single object images."),
30
29
  }
31
30
 
32
31
  self.additional_gui_apps = {
33
- "Sequencing": (lambda frame: initiate_root(frame, 'sequencing'), "Analyze sequencing data."),
34
- "Umap": (lambda frame: initiate_root(frame, 'umap'), "Generate UMAP embeddings with datapoints represented as images."),
35
- "Train Cellpose": (lambda frame: initiate_root(frame, 'train_cellpose'), "Train custom Cellpose models."),
36
- "ML Analyze": (lambda frame: initiate_root(frame, 'ml_analyze'), "Machine learning analysis of data."),
37
- "Cellpose Masks": (lambda frame: initiate_root(frame, 'cellpose_masks'), "Generate Cellpose masks."),
38
- "Cellpose All": (lambda frame: initiate_root(frame, 'cellpose_all'), "Run Cellpose on all images."),
39
- "Map Barcodes": (lambda frame: initiate_root(frame, 'map_barcodes'), "Map barcodes to data."),
40
- "Regression": (lambda frame: initiate_root(frame, 'regression'), "Perform regression analysis."),
41
- "Recruitment": (lambda frame: initiate_root(frame, 'recruitment'), "Analyze recruitment data.")
32
+ "Sequencing": (lambda frame: initiate_root(self, 'sequencing'), "Analyze sequencing data."),
33
+ "Umap": (lambda frame: initiate_root(self, 'umap'), "Generate UMAP embeddings with datapoints represented as images."),
34
+ "Train Cellpose": (lambda frame: initiate_root(self, 'train_cellpose'), "Train custom Cellpose models."),
35
+ "ML Analyze": (lambda frame: initiate_root(self, 'ml_analyze'), "Machine learning analysis of data."),
36
+ "Cellpose Masks": (lambda frame: initiate_root(self, 'cellpose_masks'), "Generate Cellpose masks."),
37
+ "Cellpose All": (lambda frame: initiate_root(self, 'cellpose_all'), "Run Cellpose on all images."),
38
+ "Map Barcodes": (lambda frame: initiate_root(self, 'map_barcodes'), "Map barcodes to data."),
39
+ "Regression": (lambda frame: initiate_root(self, 'regression'), "Perform regression analysis."),
40
+ "Recruitment": (lambda frame: initiate_root(self, 'recruitment'), "Analyze recruitment data.")
42
41
  }
43
42
 
44
43
  self.selected_app = tk.StringVar()
@@ -50,32 +49,25 @@ class MainApp(tk.Tk):
50
49
  self.load_app(default_app, self.additional_gui_apps[default_app][0])
51
50
 
52
51
  def create_widgets(self):
53
- # Create the menu bar
54
52
  create_menu_bar(self)
55
53
 
56
- # Create a canvas to hold the selected app and other elements
57
54
  self.canvas = tk.Canvas(self, highlightthickness=0)
58
55
  self.canvas.grid(row=0, column=0, sticky="nsew")
59
56
  self.grid_rowconfigure(0, weight=1)
60
57
  self.grid_columnconfigure(0, weight=1)
61
58
 
62
- # Create a frame inside the canvas to hold the main content
63
59
  self.content_frame = tk.Frame(self.canvas)
64
60
  self.content_frame.grid(row=0, column=0, sticky="nsew")
65
61
 
66
- # Center the content frame within the canvas
67
62
  self.canvas.create_window((self.winfo_screenwidth() // 2, self.winfo_screenheight() // 2), window=self.content_frame, anchor="center")
68
63
 
69
- # Apply dark style to canvas and content_frame
70
64
  set_dark_style(ttk.Style(), containers=[self.canvas, self.content_frame])
71
65
 
72
- # Create startup screen with buttons for each main GUI app and drop-down for additional apps
73
66
  self.create_startup_screen()
74
67
 
75
68
  def create_startup_screen(self):
76
69
  self.clear_frame(self.content_frame)
77
70
 
78
- # Create frames for the grids
79
71
  main_buttons_frame = tk.Frame(self.content_frame)
80
72
  main_buttons_frame.pack(pady=10)
81
73
  set_dark_style(ttk.Style(), containers=[main_buttons_frame])
@@ -84,41 +76,33 @@ class MainApp(tk.Tk):
84
76
  additional_buttons_frame.pack(pady=10)
85
77
  set_dark_style(ttk.Style(), containers=[additional_buttons_frame])
86
78
 
87
- # Create a frame for the description below the icon grids
88
79
  description_frame = tk.Frame(self.content_frame, height=70)
89
80
  description_frame.pack(fill=tk.X, pady=10)
90
- description_frame.pack_propagate(False) # Prevent the frame from resizing based on its content
81
+ description_frame.pack_propagate(False)
91
82
  set_dark_style(ttk.Style(), containers=[description_frame])
92
83
 
93
- # Use a Label widget to display descriptions
94
84
  self.description_label = tk.Label(description_frame, text="", wraplength=800, justify="center", font=('Helvetica', 12), fg=self.color_settings['fg_color'], bg=self.color_settings['bg_color'])
95
85
  self.description_label.pack(fill=tk.BOTH, pady=10)
96
86
 
97
- # Load the logo image and place it in the main apps row
98
87
  logo_button = spacrButton(main_buttons_frame, text="SpaCr", command=lambda: self.load_app("logo_spacr", initiate_root), icon_name="logo_spacr", size=100, show_text=False)
99
88
  logo_button.grid(row=0, column=0, padx=5, pady=5)
100
89
  self.main_buttons[logo_button] = "SpaCr provides a flexible toolset to extract single-cell images and measurements from high-content cell painting experiments, train deep-learning models to classify cellular/subcellular phenotypes, simulate, and analyze pooled CRISPR-Cas9 imaging screens.."
101
90
 
102
- # Create icon buttons for the main apps
103
91
  for i, (app_name, app_data) in enumerate(self.main_gui_apps.items()):
104
92
  app_func, app_desc = app_data
105
93
  button = spacrButton(main_buttons_frame, text=app_name, command=lambda app_name=app_name, app_func=app_func: self.load_app(app_name, app_func), icon_name=app_name.lower(), size=100, show_text=False)
106
94
  button.grid(row=0, column=i + 1, padx=5, pady=5)
107
95
  self.main_buttons[button] = app_desc
108
96
 
109
- # Create icon buttons for the additional apps
110
97
  for i, (app_name, app_data) in enumerate(self.additional_gui_apps.items()):
111
98
  app_func, app_desc = app_data
112
99
  button = spacrButton(additional_buttons_frame, text=app_name, command=lambda app_name=app_name, app_func=app_func: self.load_app(app_name, app_func), icon_name=app_name.lower(), size=75, show_text=False)
113
100
  button.grid(row=0, column=i, padx=5, pady=5)
114
101
  self.additional_buttons[button] = app_desc
115
102
 
116
- # Update description initially
117
103
  self.update_description()
118
- #
119
104
 
120
105
  def update_description(self):
121
- # Check all buttons and update description if any has the active color
122
106
  for button, desc in {**self.main_buttons, **self.additional_buttons}.items():
123
107
  if button.canvas.itemcget(button.button_bg, "fill") == self.color_settings['active_color']:
124
108
  self.show_description(desc)
@@ -128,18 +112,16 @@ class MainApp(tk.Tk):
128
112
  def show_description(self, description):
129
113
  if self.description_label.winfo_exists():
130
114
  self.description_label.config(text=description)
131
- self.description_label.update_idletasks() # Ensure the label updates immediately
115
+ self.description_label.update_idletasks()
132
116
 
133
117
  def clear_description(self):
134
118
  if self.description_label.winfo_exists():
135
119
  self.description_label.config(text="")
136
- self.description_label.update_idletasks() # Ensure the label updates immediately
120
+ self.description_label.update_idletasks()
137
121
 
138
122
  def load_app(self, app_name, app_func):
139
- # Clear the current content frame
140
123
  self.clear_frame(self.canvas)
141
124
 
142
- # Initialize the selected app
143
125
  app_frame = tk.Frame(self.canvas)
144
126
  app_frame.pack(fill=tk.BOTH, expand=True)
145
127
  set_dark_style(ttk.Style(), containers=[app_frame])
@@ -155,4 +137,4 @@ def gui_app():
155
137
 
156
138
  if __name__ == "__main__":
157
139
  set_start_method('spawn', force=True)
158
- gui_app()
140
+ gui_app()