spacr 1.0.7__py3-none-any.whl → 1.0.9__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
@@ -9,7 +9,7 @@ import psutil
9
9
  from PIL import Image, ImageTk
10
10
  from screeninfo import get_monitors
11
11
 
12
- from .gui_elements import AnnotateApp, spacrEntry, spacrCheck, spacrCombo
12
+ from .gui_elements import spacrEntry, spacrCheck, spacrCombo
13
13
 
14
14
  try:
15
15
  ctypes.windll.shcore.SetProcessDpiAwareness(True)
@@ -208,114 +208,6 @@ def cancel_after_tasks(frame):
208
208
  frame.after_cancel(task)
209
209
  frame.after_tasks.clear()
210
210
 
211
- def annotate(settings):
212
- from .settings import set_annotate_default_settings
213
- settings = set_annotate_default_settings(settings)
214
- src = settings['src']
215
-
216
- db = os.path.join(src, 'measurements/measurements.db')
217
- conn = sqlite3.connect(db)
218
- c = conn.cursor()
219
- c.execute('PRAGMA table_info(png_list)')
220
- cols = c.fetchall()
221
- if settings['annotation_column'] not in [col[1] for col in cols]:
222
- c.execute(f"ALTER TABLE png_list ADD COLUMN {settings['annotation_column']} integer")
223
- conn.commit()
224
- conn.close()
225
-
226
- root = tk.Tk()
227
-
228
- root.geometry(f"{root.winfo_screenwidth()}x{root.winfo_screenheight()}")
229
-
230
- db_path = os.path.join(settings['src'], 'measurements/measurements.db')
231
-
232
- app = AnnotateApp(root,
233
- db_path=db_path,
234
- src=settings['src'],
235
- image_type=settings['image_type'],
236
- channels=settings['channels'],
237
- image_size=settings['img_size'],
238
- annotation_column=settings['annotation_column'],
239
- normalize=settings['normalize'],
240
- percentiles=settings['percentiles'],
241
- measurement=settings['measurement'],
242
- threshold=settings['threshold'],
243
- normalize_channels=settings['normalize_channels'])
244
-
245
- app.load_images()
246
- root.mainloop()
247
-
248
- def generate_annotate_fields(frame):
249
- from .settings import set_annotate_default_settings
250
- from .gui_elements import set_dark_style
251
-
252
- style_out = set_dark_style(ttk.Style())
253
- font_loader = style_out['font_loader']
254
- font_size = style_out['font_size'] - 2
255
-
256
- vars_dict = {}
257
- settings = set_annotate_default_settings(settings={})
258
-
259
- for setting in settings:
260
- vars_dict[setting] = {
261
- 'entry': ttk.Entry(frame),
262
- 'value': settings[setting]
263
- }
264
-
265
- # Arrange input fields and labels
266
- for row, (name, data) in enumerate(vars_dict.items()):
267
- tk.Label(
268
- frame,
269
- text=f"{name.replace('_', ' ').capitalize()}:",
270
- bg=style_out['bg_color'],
271
- fg=style_out['fg_color'],
272
- font=font_loader.get_font(size=font_size)
273
- ).grid(row=row, column=0)
274
-
275
- value = data['value']
276
- if isinstance(value, list):
277
- string_value = ','.join(map(str, value))
278
- elif isinstance(value, (int, float, bool)):
279
- string_value = str(value)
280
- elif value is None:
281
- string_value = ''
282
- else:
283
- string_value = value
284
-
285
- data['entry'].insert(0, string_value)
286
- data['entry'].grid(row=row, column=1)
287
-
288
- return vars_dict
289
-
290
- def run_annotate_app(vars_dict, parent_frame):
291
- settings = {key: data['entry'].get() for key, data in vars_dict.items()}
292
- settings['channels'] = settings['channels'].split(',')
293
- settings['img_size'] = list(map(int, settings['img_size'].split(','))) # Convert string to list of integers
294
- settings['percentiles'] = list(map(int, settings['percentiles'].split(','))) # Convert string to list of integers
295
- settings['normalize'] = settings['normalize'].lower() == 'true'
296
- settings['normalize_channels'] = settings['channels'].split(',')
297
- settings['rows'] = int(settings['rows'])
298
- settings['columns'] = int(settings['columns'])
299
- settings['measurement'] = settings['measurement'].split(',')
300
- settings['threshold'] = None if settings['threshold'].lower() == 'none' else int(settings['threshold'])
301
-
302
- # Clear previous content instead of destroying the root
303
- if hasattr(parent_frame, 'winfo_children'):
304
- for widget in parent_frame.winfo_children():
305
- widget.destroy()
306
-
307
- # Start the annotate application in the same root window
308
- annotate_app(parent_frame, settings)
309
-
310
- # Global list to keep references to PhotoImage objects
311
- global_image_refs = []
312
-
313
- def annotate_app(parent_frame, settings):
314
- global global_image_refs
315
- global_image_refs.clear()
316
- root = parent_frame.winfo_toplevel()
317
- annotate_with_image_refs(settings, root, lambda: load_next_app(root))
318
-
319
211
  def load_next_app(root):
320
212
  # Get the next app function and arguments
321
213
  next_app_func = root.next_app_func
@@ -335,37 +227,6 @@ def load_next_app(root):
335
227
  new_root.title("SpaCr Application")
336
228
  next_app_func(new_root, *next_app_args)
337
229
 
338
- def annotate_with_image_refs(settings, root, shutdown_callback):
339
- from .settings import set_annotate_default_settings
340
-
341
- settings = set_annotate_default_settings(settings)
342
- src = settings['src']
343
-
344
- db = os.path.join(src, 'measurements/measurements.db')
345
- conn = sqlite3.connect(db)
346
- c = conn.cursor()
347
- c.execute('PRAGMA table_info(png_list)')
348
- cols = c.fetchall()
349
- if settings['annotation_column'] not in [col[1] for col in cols]:
350
- c.execute(f"ALTER TABLE png_list ADD COLUMN {settings['annotation_column']} integer")
351
- conn.commit()
352
- conn.close()
353
-
354
- screen_width = root.winfo_screenwidth()
355
- screen_height = root.winfo_screenheight()
356
- root.geometry(f"{screen_width}x{screen_height}")
357
-
358
- app = AnnotateApp(root, db, src, image_type=settings['image_type'], channels=settings['channels'], image_size=settings['img_size'], annotation_column=settings['annotation_column'], normalize=settings['normalize'], percentiles=settings['percentiles'], measurement=settings['measurement'], threshold=settings['threshold'], normalize_channels=settings['normalize_channels'], outline=settings['outline'], outline_threshold_factor=settings['outline_threshold_factor'], outline_sigma=settings['outline_sigma'])
359
-
360
- # Set the canvas background to black
361
- root.configure(bg='black')
362
-
363
- # Store the shutdown function and next app details in the root
364
- root.current_app_exit_func = lambda: [app.shutdown(), shutdown_callback()]
365
-
366
- # Call load_images after setting up the root window
367
- app.load_images()
368
-
369
230
  def convert_settings_dict_for_gui(settings):
370
231
  from torchvision import models as torch_models
371
232
  torchvision_models = [name for name, obj in torch_models.__dict__.items() if callable(obj)]
@@ -462,7 +323,7 @@ def function_gui_wrapper(function=None, settings={}, q=None, fig_queue=None, imp
462
323
 
463
324
  def run_function_gui(settings_type, settings, q, fig_queue, stop_requested):
464
325
 
465
- from .core import generate_image_umap, preprocess_generate_masks
326
+ from .core import preprocess_generate_masks
466
327
  from .spacr_cellpose import identify_masks_finetune, check_cellpose_models
467
328
  from .submodules import analyze_recruitment
468
329
  from .ml import generate_ml_scores, perform_regression
@@ -506,9 +367,6 @@ def run_function_gui(settings_type, settings, q, fig_queue, stop_requested):
506
367
  elif settings_type == 'recruitment':
507
368
  function = analyze_recruitment
508
369
  imports = 1
509
- elif settings_type == 'umap':
510
- function = generate_image_umap
511
- imports = 1
512
370
  elif settings_type == 'analyze_plaques':
513
371
  function = analyze_plaques
514
372
  imports = 1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: spacr
3
- Version: 1.0.7
3
+ Version: 1.0.9
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
@@ -13,7 +13,7 @@ spacr/deep_spacr.py,sha256=uKACN4Gali9oH9YKxbNbd-MRztJvPSOOgx8LNI1mVRw,54459
13
13
  spacr/gui.py,sha256=zBjz05JMFbrw_I76n8B6gk4EVpX72UTeJouOgvAidjY,8404
14
14
  spacr/gui_core.py,sha256=854KnVy23nK7hdcyb9RKRIdrH0rPdLUbVxj2GCOLjsI,54031
15
15
  spacr/gui_elements.py,sha256=xefuE0_PgScPmX5Ibi2qIQl7U0K8D7HGmNKlU4RnsKU,75276
16
- spacr/gui_utils.py,sha256=VtIeYSPhNAZFMZsYMKzCB-V5T9SKEKVuXYOTpWjGFcU,40753
16
+ spacr/gui_utils.py,sha256=suWbrGhrAgvAqsU8FrDCNZSMz-yKLgBnbOG2BEza92g,34964
17
17
  spacr/io.py,sha256=hFT_yNQWuZf66s34MdnG8wVshXJvt7wgHKA2FVMMHCY,158978
18
18
  spacr/logger.py,sha256=lJhTqt-_wfAunCPl93xE65Wr9Y1oIHJWaZMjunHUeIw,1538
19
19
  spacr/measure.py,sha256=nYvrfVfCIqD1AUk4QBE2jtpeSFtLdfUcnkhkqf9G4xQ,60877
@@ -112,9 +112,9 @@ spacr/resources/icons/umap.png,sha256=dOLF3DeLYy9k0nkUybiZMe1wzHQwLJFRmgccppw-8b
112
112
  spacr/resources/images/plate1_E01_T0001F001L01A01Z01C02.tif,sha256=Tl0ZUfZ_AYAbu0up_nO0tPRtF1BxXhWQ3T3pURBCCRo,7958528
113
113
  spacr/resources/images/plate1_E01_T0001F001L01A02Z01C01.tif,sha256=m8N-V71rA1TT4dFlENNg8s0Q0YEXXs8slIn7yObmZJQ,7958528
114
114
  spacr/resources/images/plate1_E01_T0001F001L01A03Z01C03.tif,sha256=Pbhk7xn-KUP6RSIhJsxQcrHFImBm3GEpLkzx7WOc-5M,7958528
115
- spacr-1.0.7.dist-info/LICENSE,sha256=t0Pov6pnK8thLteoF4xZGmdCwe5mhNwl3OXxLYTGD9U,1081
116
- spacr-1.0.7.dist-info/METADATA,sha256=XephNrSZIP9Q8hNEMoX0KHI6qCuTvX7rEMd0lbotW40,10792
117
- spacr-1.0.7.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
118
- spacr-1.0.7.dist-info/entry_points.txt,sha256=6pHChJ00ozJ-Awokdfd28wUjiPXFJ8ONVx50rEKjBi8,176
119
- spacr-1.0.7.dist-info/top_level.txt,sha256=GJPU8FgwRXGzKeut6JopsSRY2R8T3i9lDgya42tLInY,6
120
- spacr-1.0.7.dist-info/RECORD,,
115
+ spacr-1.0.9.dist-info/LICENSE,sha256=t0Pov6pnK8thLteoF4xZGmdCwe5mhNwl3OXxLYTGD9U,1081
116
+ spacr-1.0.9.dist-info/METADATA,sha256=Ln0IiYj9ZZbfW6WURmUuLcwTKMd-7aPqiC-unhJoMuk,10792
117
+ spacr-1.0.9.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
118
+ spacr-1.0.9.dist-info/entry_points.txt,sha256=6pHChJ00ozJ-Awokdfd28wUjiPXFJ8ONVx50rEKjBi8,176
119
+ spacr-1.0.9.dist-info/top_level.txt,sha256=GJPU8FgwRXGzKeut6JopsSRY2R8T3i9lDgya42tLInY,6
120
+ spacr-1.0.9.dist-info/RECORD,,
File without changes
File without changes