spacr 0.1.50__py3-none-any.whl → 0.1.61__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 +8 -2
- spacr/app_annotate.py +3 -3
- spacr/app_make_masks.py +3 -6
- spacr/app_make_masks_v2.py +4 -4
- spacr/app_sequencing.py +8 -0
- spacr/app_umap.py +8 -0
- spacr/core.py +9 -7
- spacr/gui.py +12 -6
- spacr/gui_core.py +608 -0
- spacr/gui_elements.py +322 -0
- spacr/gui_run.py +58 -0
- spacr/gui_utils.py +21 -1407
- spacr/gui_wrappers.py +137 -0
- spacr/measure.py +6 -8
- spacr/plot.py +53 -1
- spacr/sequencing.py +1 -17
- spacr/settings.py +428 -4
- spacr/utils.py +19 -11
- {spacr-0.1.50.dist-info → spacr-0.1.61.dist-info}/METADATA +1 -1
- {spacr-0.1.50.dist-info → spacr-0.1.61.dist-info}/RECORD +24 -18
- {spacr-0.1.50.dist-info → spacr-0.1.61.dist-info}/LICENSE +0 -0
- {spacr-0.1.50.dist-info → spacr-0.1.61.dist-info}/WHEEL +0 -0
- {spacr-0.1.50.dist-info → spacr-0.1.61.dist-info}/entry_points.txt +0 -0
- {spacr-0.1.50.dist-info → spacr-0.1.61.dist-info}/top_level.txt +0 -0
spacr/__init__.py
CHANGED
@@ -14,11 +14,16 @@ from . import timelapse
|
|
14
14
|
from . import deep_spacr
|
15
15
|
from . import app_annotate
|
16
16
|
from . import gui_utils
|
17
|
+
from . import gui_elements
|
18
|
+
from . import gui_core
|
19
|
+
from . import gui_run
|
20
|
+
from . import gui_wrappers
|
17
21
|
from . import app_make_masks
|
18
|
-
from . import app_make_masks_v2
|
19
22
|
from . import app_mask
|
20
23
|
from . import app_measure
|
21
24
|
from . import app_classify
|
25
|
+
from . import app_sequencing
|
26
|
+
from . import app_umap
|
22
27
|
from . import logger
|
23
28
|
|
24
29
|
|
@@ -36,10 +41,11 @@ __all__ = [
|
|
36
41
|
"app_annotate",
|
37
42
|
"gui_utils",
|
38
43
|
"app_make_masks",
|
39
|
-
"app_make_masks_v2",
|
40
44
|
"app_mask",
|
41
45
|
"app_measure",
|
42
46
|
"app_classify",
|
47
|
+
"app_sequencing",
|
48
|
+
"app_umap",
|
43
49
|
"logger"
|
44
50
|
]
|
45
51
|
|
spacr/app_annotate.py
CHANGED
@@ -13,7 +13,7 @@ from IPython.display import display, HTML
|
|
13
13
|
from tkinter import font as tkFont
|
14
14
|
from tkinter import TclError
|
15
15
|
|
16
|
-
from .
|
16
|
+
from .gui_elements import spacrFrame, spacrButton, set_dark_style, create_menu_bar, set_default_font
|
17
17
|
|
18
18
|
class ImageApp:
|
19
19
|
def __init__(self, root, db_path, src, image_type=None, channels=None, grid_rows=None, grid_cols=None, image_size=(200, 200), annotation_column='annotate', normalize=False, percentiles=(1,99), measurement=None, threshold=None):
|
@@ -379,7 +379,7 @@ def initiate_annotation_app_root(parent_frame):
|
|
379
379
|
container = tk.PanedWindow(parent_frame, orient=tk.HORIZONTAL, bg='black')
|
380
380
|
container.pack(fill=tk.BOTH, expand=True)
|
381
381
|
|
382
|
-
scrollable_frame =
|
382
|
+
scrollable_frame = spacrFrame(container, bg='black')
|
383
383
|
container.add(scrollable_frame, stretch="always")
|
384
384
|
|
385
385
|
# Setup input fields
|
@@ -444,7 +444,7 @@ def initiate_annotation_app_root(parent_frame):
|
|
444
444
|
# Start the annotate application in the same root window
|
445
445
|
annotate_app(parent_frame, settings)
|
446
446
|
|
447
|
-
run_button =
|
447
|
+
run_button = spacrButton(scrollable_frame.scrollable_frame, text="Run", command=run_app,
|
448
448
|
font=tkFont.Font(family="Arial", size=12, weight=tkFont.NORMAL))
|
449
449
|
run_button.grid(row=row, column=0, columnspan=2, pady=10, padx=10)
|
450
450
|
|
spacr/app_make_masks.py
CHANGED
@@ -9,11 +9,8 @@ from skimage.transform import resize
|
|
9
9
|
from scipy.ndimage import binary_fill_holes, label
|
10
10
|
import tkinter as tk
|
11
11
|
from tkinter import ttk
|
12
|
-
from ttkthemes import ThemedTk
|
13
12
|
|
14
|
-
from .
|
15
|
-
|
16
|
-
from .gui_utils import ScrollableFrame, CustomButton, set_dark_style, create_menu_bar, set_default_font
|
13
|
+
from .gui_elements import spacrFrame, spacrButton, set_dark_style, create_menu_bar, set_default_font
|
17
14
|
|
18
15
|
class modify_masks:
|
19
16
|
|
@@ -869,7 +866,7 @@ def initiate_mask_app_root(parent_frame):
|
|
869
866
|
container = tk.PanedWindow(parent_frame, orient=tk.HORIZONTAL)
|
870
867
|
container.pack(fill=tk.BOTH, expand=True)
|
871
868
|
|
872
|
-
scrollable_frame =
|
869
|
+
scrollable_frame = spacrFrame(container, bg='black')
|
873
870
|
container.add(scrollable_frame, stretch="always")
|
874
871
|
|
875
872
|
# Setup input fields
|
@@ -897,7 +894,7 @@ def initiate_mask_app_root(parent_frame):
|
|
897
894
|
# Start the modify_masks application in the same root window
|
898
895
|
app_instance = modify_masks(parent_frame, folder_path, scale_factor)
|
899
896
|
|
900
|
-
run_button =
|
897
|
+
run_button = spacrButton(scrollable_frame.scrollable_frame, text="Run", command=run_app)
|
901
898
|
run_button.grid(row=row, column=0, columnspan=2, pady=10, padx=10)
|
902
899
|
|
903
900
|
return parent_frame
|
spacr/app_make_masks_v2.py
CHANGED
@@ -13,7 +13,7 @@ from ttkthemes import ThemedTk
|
|
13
13
|
from pyqtgraph import GraphicsLayoutWidget, ViewBox, ImageItem, mkQApp
|
14
14
|
|
15
15
|
from .logger import log_function_call
|
16
|
-
from .gui_utils import
|
16
|
+
from .gui_utils import spacrFrame, spacrButton, set_dark_style, create_menu_bar, set_default_font
|
17
17
|
|
18
18
|
class ModifyMasks:
|
19
19
|
def __init__(self, root, folder_path, scale_factor):
|
@@ -635,7 +635,7 @@ def initiate_mask_app_root(width, height):
|
|
635
635
|
root = ThemedTk(theme=theme)
|
636
636
|
style = ttk.Style(root)
|
637
637
|
set_dark_style(style)
|
638
|
-
|
638
|
+
set_default_font(root, font_name="Arial", size=8)
|
639
639
|
root.geometry(f"{width}x{height}")
|
640
640
|
root.title("Mask App")
|
641
641
|
create_menu_bar(root)
|
@@ -643,7 +643,7 @@ def initiate_mask_app_root(width, height):
|
|
643
643
|
container = tk.PanedWindow(root, orient=tk.HORIZONTAL)
|
644
644
|
container.pack(fill=tk.BOTH, expand=True)
|
645
645
|
|
646
|
-
scrollable_frame =
|
646
|
+
scrollable_frame = spacrFrame(container, bg='black')
|
647
647
|
container.add(scrollable_frame, stretch="always")
|
648
648
|
|
649
649
|
vars_dict = {
|
@@ -673,7 +673,7 @@ def initiate_mask_app_root(width, height):
|
|
673
673
|
|
674
674
|
create_dark_mode(root, style, console_output=None)
|
675
675
|
|
676
|
-
run_button =
|
676
|
+
run_button = spacrButton(scrollable_frame.scrollable_frame, text="Run", command=run_app)
|
677
677
|
run_button.grid(row=row, column=0, columnspan=2, pady=10, padx=10)
|
678
678
|
|
679
679
|
return root
|
spacr/app_sequencing.py
ADDED
spacr/app_umap.py
ADDED
spacr/core.py
CHANGED
@@ -1668,7 +1668,7 @@ def preprocess_generate_masks(src, settings={}):
|
|
1668
1668
|
|
1669
1669
|
from .io import preprocess_img_data, _load_and_concatenate_arrays
|
1670
1670
|
from .plot import plot_merged, plot_arrays
|
1671
|
-
from .utils import _pivot_counts_table, check_mask_folder, adjust_cell_masks
|
1671
|
+
from .utils import _pivot_counts_table, check_mask_folder, adjust_cell_masks
|
1672
1672
|
from .settings import set_default_settings_preprocess_generate_masks, set_default_plot_merge_settings
|
1673
1673
|
|
1674
1674
|
settings = set_default_settings_preprocess_generate_masks(src, settings)
|
@@ -3021,9 +3021,9 @@ def generate_image_umap(settings={}):
|
|
3021
3021
|
"""
|
3022
3022
|
|
3023
3023
|
from .io import _read_and_join_tables
|
3024
|
-
from .utils import get_db_paths, preprocess_data, reduction_and_clustering, remove_noise, generate_colors, correct_paths, plot_embedding, plot_clusters_grid, cluster_feature_analysis
|
3025
|
-
from .settings import
|
3026
|
-
settings =
|
3024
|
+
from .utils import get_db_paths, preprocess_data, reduction_and_clustering, remove_noise, generate_colors, correct_paths, plot_embedding, plot_clusters_grid, cluster_feature_analysis #, generate_umap_from_images
|
3025
|
+
from .settings import set_default_umap_image_settings
|
3026
|
+
settings = set_default_umap_image_settings(settings)
|
3027
3027
|
|
3028
3028
|
if isinstance(settings['src'], str):
|
3029
3029
|
settings['src'] = [settings['src']]
|
@@ -3109,7 +3109,9 @@ def generate_image_umap(settings={}):
|
|
3109
3109
|
|
3110
3110
|
else:
|
3111
3111
|
if settings['resnet_features']:
|
3112
|
-
|
3112
|
+
# placeholder for resnet features, not implemented yet
|
3113
|
+
pass
|
3114
|
+
#numeric_data, embedding, labels = generate_umap_from_images(image_paths, settings['n_neighbors'], settings['min_dist'], settings['metric'], settings['clustering'], settings['eps'], settings['min_samples'], settings['n_jobs'], settings['verbose'])
|
3113
3115
|
else:
|
3114
3116
|
# Apply the trained reducer to the entire dataset
|
3115
3117
|
numeric_data = preprocess_data(all_df, settings['filter_by'], settings['remove_highly_correlated'], settings['log_data'], settings['exclude'])
|
@@ -3205,9 +3207,9 @@ def reducer_hyperparameter_search(settings={}, reduction_params=None, dbscan_par
|
|
3205
3207
|
|
3206
3208
|
from .io import _read_and_join_tables
|
3207
3209
|
from .utils import get_db_paths, preprocess_data, search_reduction_and_clustering, generate_colors
|
3208
|
-
from .settings import
|
3210
|
+
from .settings import set_default_umap_image_settings
|
3209
3211
|
|
3210
|
-
settings =
|
3212
|
+
settings = set_default_umap_image_settings(settings)
|
3211
3213
|
pointsize = settings['dot_size']
|
3212
3214
|
if isinstance(dbscan_params, dict):
|
3213
3215
|
dbscan_params = [dbscan_params]
|
spacr/gui.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
import tkinter as tk
|
2
2
|
from tkinter import ttk
|
3
3
|
from PIL import Image, ImageTk
|
4
|
-
import os
|
5
|
-
import requests
|
4
|
+
import os, requests
|
6
5
|
from multiprocessing import set_start_method
|
7
|
-
from .
|
6
|
+
from .gui_elements import spacrButton, create_menu_bar, set_dark_style
|
7
|
+
from .gui_core import initiate_root
|
8
8
|
from .app_annotate import initiate_annotation_app_root
|
9
9
|
from .app_make_masks import initiate_mask_app_root
|
10
10
|
|
@@ -24,7 +24,9 @@ class MainApp(tk.Tk):
|
|
24
24
|
"Measure": (lambda frame: initiate_root(frame, 'measure'), "Measure single object intensity and morphological feature. Crop and save single object image"),
|
25
25
|
"Annotate": (initiate_annotation_app_root, "Annotation single object images on a grid. Annotations are saved to database."),
|
26
26
|
"Make Masks": (initiate_mask_app_root, "Adjust pre-existing Cellpose models to your specific dataset for improved performance"),
|
27
|
-
"Classify": (lambda frame: initiate_root(frame, 'classify'), "Train Torch Convolutional Neural Networks (CNNs) or Transformers to classify single object images.")
|
27
|
+
"Classify": (lambda frame: initiate_root(frame, 'classify'), "Train Torch Convolutional Neural Networks (CNNs) or Transformers to classify single object images."),
|
28
|
+
"Sequencing": (lambda frame: initiate_root(frame, 'sequencing'), "Analyze sequensing data."),
|
29
|
+
"Umap": (lambda frame: initiate_root(frame, 'umap'), "Generate UMAP embedings with datapoints represented as images.")
|
28
30
|
}
|
29
31
|
|
30
32
|
self.selected_app = tk.StringVar()
|
@@ -41,6 +43,10 @@ class MainApp(tk.Tk):
|
|
41
43
|
self.load_app(default_app, self.gui_apps[default_app][3])
|
42
44
|
elif default_app == "Classify":
|
43
45
|
self.load_app(default_app, self.gui_apps[default_app][4])
|
46
|
+
elif default_app == "Sequencing":
|
47
|
+
self.load_app(default_app, self.gui_apps[default_app][5])
|
48
|
+
elif default_app == "Umap":
|
49
|
+
self.load_app(default_app, self.gui_apps[default_app][6])
|
44
50
|
|
45
51
|
def create_widgets(self):
|
46
52
|
# Create the menu bar
|
@@ -81,8 +87,8 @@ class MainApp(tk.Tk):
|
|
81
87
|
app_func, app_desc = app_data
|
82
88
|
|
83
89
|
# Create custom button with text
|
84
|
-
|
85
|
-
button = ttk.Button(buttons_frame, text=app_name, command=lambda app_name=app_name, app_func=app_func: self.load_app(app_name, app_func), style='Custom.TButton')
|
90
|
+
button = spacrButton(buttons_frame, text=app_name, command=lambda app_name=app_name, app_func=app_func: self.load_app(app_name, app_func), font=('Helvetica', 12))
|
91
|
+
#button = ttk.Button(buttons_frame, text=app_name, command=lambda app_name=app_name, app_func=app_func: self.load_app(app_name, app_func), style='Custom.TButton')
|
86
92
|
button.grid(row=i, column=0, pady=10, padx=10, sticky="w")
|
87
93
|
|
88
94
|
description_label = tk.Label(buttons_frame, text=app_desc, bg="black", fg="white", wraplength=800, justify="left", font=('Helvetica', 12))
|