spacr 0.0.18__py3-none-any.whl → 0.0.21__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: spacr
3
- Version: 0.0.18
3
+ Version: 0.0.21
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
@@ -9,29 +9,32 @@ Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Operating System :: OS Independent
11
11
  License-File: LICENSE
12
- Requires-Dist: torch
13
- Requires-Dist: torchvision
14
- Requires-Dist: torch-geometric
15
- Requires-Dist: numpy
16
- Requires-Dist: pandas
17
- Requires-Dist: statsmodels
18
- Requires-Dist: scikit-image
19
- Requires-Dist: scikit-learn
20
- Requires-Dist: seaborn
21
- Requires-Dist: matplotlib
22
- Requires-Dist: pillow
23
- Requires-Dist: imageio
24
- Requires-Dist: scipy
25
- Requires-Dist: ipywidgets
26
- Requires-Dist: mahotas
27
- Requires-Dist: btrack
28
- Requires-Dist: trackpy
29
- Requires-Dist: cellpose
30
- Requires-Dist: IPython
31
- Requires-Dist: opencv-python-headless
32
- Requires-Dist: umap
33
- Requires-Dist: ttkthemes
34
- Requires-Dist: lxml
12
+ Requires-Dist: torch >=2.2.1
13
+ Requires-Dist: torchvision >=0.17.1
14
+ Requires-Dist: torch-geometric >=2.5.1
15
+ Requires-Dist: numpy >=1.26.4
16
+ Requires-Dist: pandas >=2.2.1
17
+ Requires-Dist: statsmodels >=0.14.1
18
+ Requires-Dist: scikit-image >=0.22.0
19
+ Requires-Dist: scikit-learn >=1.4.1
20
+ Requires-Dist: seaborn >=0.13.2
21
+ Requires-Dist: matplotlib >=3.8.3
22
+ Requires-Dist: shap >=0.45.0
23
+ Requires-Dist: pillow >=10.2.0
24
+ Requires-Dist: imageio >=2.34.0
25
+ Requires-Dist: scipy >=1.12.0
26
+ Requires-Dist: ipywidgets >=8.1.2
27
+ Requires-Dist: mahotas >=1.4.13
28
+ Requires-Dist: btrack >=0.6.5
29
+ Requires-Dist: trackpy >=0.6.2
30
+ Requires-Dist: cellpose >=3.0.6
31
+ Requires-Dist: IPython >=8.18.1
32
+ Requires-Dist: opencv-python-headless >=4.9.0.80
33
+ Requires-Dist: umap >=0.1.1
34
+ Requires-Dist: ttkthemes >=3.2.2
35
+ Requires-Dist: xgboost >=2.0.3
36
+ Requires-Dist: PyWavelets >=1.6.0
37
+ Requires-Dist: lxml >=5.1.0
35
38
  Provides-Extra: dev
36
39
  Requires-Dist: pytest >=3.9 ; extra == 'dev'
37
40
  Provides-Extra: full
@@ -49,7 +52,7 @@ Requires-Dist: opencv-python-headless ; extra == 'headless'
49
52
  <tr>
50
53
  <td>
51
54
 
52
- Spatial phenotype analysis of crisp screens (SpaCr). A collection of functions for generating cellpose masks -> single object images and measurements -> annotation and classification of single object images. Spacr uses batch normalization to facilitate accurate segmentation of objects with low foreground representation.
55
+ Spatial phenotype analysis of CRISPR-Cas9 screens (SpaCr). The spatial organization of organelles and proteins within cells constitutes a key level of functional regulation. In the context of infectious disease, the spatial relationships between host cell structures and intracellular pathogens are critical to understand host clearance mechanisms and how pathogens evade them. Spacr is a Python-based software package for generating single cell image data for deep-learning sub-cellular/cellular phenotypic classification from pooled genetic CRISPR-Cas9 screens. 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.
53
56
 
54
57
  </td>
55
58
  <td>
@@ -68,16 +71,18 @@ Spatial phenotype analysis of crisp screens (SpaCr). A collection of functions f
68
71
 
69
72
  - **Crop Images:** Objects (e.g. cells) can be saved as PNGs from the object area or bounding box area of each object. Object paths are saved in an sql database that can be annotated and used to train CNNs/Transformer models for classefication tasks.
70
73
 
71
- - **Train CNNs or Transformers:** Train Torch Convolutional Neural Networks (CNNs) or Transformers to classify single object images. Train Torch models with IRM/ERM, checkpointing,
74
+ - **Train CNNs or Transformers:** Train Torch Convolutional Neural Networks (CNNs) or Transformers to classify single object images. Train Torch models with IRM/ERM, checkpointing.
72
75
 
73
76
  - **Manual Annotation:** Supports manual annotation of single cell images and segmentation to refine training datasets for training CNNs/Transformers or cellpose, respectively.
74
77
 
75
78
  - **Finetune Cellpose Models:** Adjust pre-existing Cellpose models to your specific dataset for improved performance.
76
79
 
77
- - **Timelapse Data Support:** Includes support for analyzing timelapse data.
80
+ - **Timelapse Data Support:** Track objects in timelapse image data.
78
81
 
79
82
  - **Simulations:** Simulate spatial phenotype screens.
80
83
 
84
+ - **Misc:** Analyze Ca oscillation, recruitment, infection rate, plaque size/count.
85
+
81
86
  ## Installation
82
87
 
83
88
  spacr requires Tkinter for its graphical user interface features.
@@ -0,0 +1,33 @@
1
+ spacr/__init__.py,sha256=mDi-Qu5r1vZnqIbUBV1JAoSq-mxmMEOmni1JSG2e4Wo,879
2
+ spacr/__main__.py,sha256=_qRkhbFrH_cXr7AZs6KHL8Hh4VApqNdpNCtiKn2ePTo,285
3
+ spacr/alpha.py,sha256=1LUtTaeVHqcTMxoCMA7mlsNYyaR0KEaXglwXsUQLwKo,13776
4
+ spacr/annotate_app.py,sha256=jtm1HgWngv9BTsyVzdmBqg1flbmbXs9JkP6CB4wmOH8,19951
5
+ spacr/cli.py,sha256=507jfOOEV8BoL4eeUcblvH-iiDHdBrEVJLu1ghAAPSc,1800
6
+ spacr/core.py,sha256=_R8gXNnjf680yrnbCi2piWQUz7PDbqWYn7SL5MACLfo,156457
7
+ spacr/foldseek.py,sha256=cWtLzvFF2O_mq5I71UMiuU9DTvDCp7wl6aaWAZRrBZc,33970
8
+ spacr/get_alfafold_structures.py,sha256=n0g8gne-oyAV3Uo6qxZoJq5X1cUUyD8u0pOC_W2PX40,3541
9
+ spacr/graph_learning.py,sha256=sD4eOC7Q16rr7WO20mCi_E16_LqioGUUgPamAHIIeNI,12568
10
+ 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
14
+ 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/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
21
+ spacr/plot.py,sha256=VtDKTJ_zo8CAVC3ILuIN_wUP6197vq089wNZuom7T8g,61655
22
+ spacr/sim.py,sha256=2NR5hm--HVcYQnj1SCHoUCVbh_b2XUjjjfoAUIXFwnQ,72997
23
+ spacr/timelapse.py,sha256=plPjR8nZ7_Q50VAvMvHK2TUE4F-vh7R23JnI6tSW02g,39661
24
+ spacr/train.py,sha256=lp66dWYkiMMlgdYlMjAsJnkIZFWLizKB-xwyVnKgFBs,25904
25
+ spacr/umap.py,sha256=4QSrQ16Og-Ijq-SwguMQT2f20UWz1LE5HQeSLmzSl8c,29370
26
+ spacr/utils.py,sha256=r0BjycEXqr48m0xEW9o14bLPj62JNpmEUBaBwR817Bw,121205
27
+ 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,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
spacr/gui_temp.py DELETED
@@ -1,212 +0,0 @@
1
- import sys, ctypes, csv, matplotlib
2
- import tkinter as tk
3
- from tkinter import ttk, scrolledtext
4
- from ttkthemes import ThemedTk
5
- from matplotlib.figure import Figure
6
- from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
7
- from matplotlib.figure import Figure
8
- matplotlib.use('Agg')
9
- from tkinter import filedialog
10
- from multiprocessing import Process, Queue, Value
11
- import traceback
12
-
13
- try:
14
- ctypes.windll.shcore.SetProcessDpiAwareness(True)
15
- except AttributeError:
16
- pass
17
-
18
- from .logger import log_function_call
19
- from .gui_utils import ScrollableFrame, StdoutRedirector, create_dark_mode, set_dark_style, set_default_font, mask_variables, generate_fields, check_mask_gui_settings, add_mask_gui_defaults, preprocess_generate_masks_wrapper, process_stdout_stderr
20
- from .gui_utils import safe_literal_eval, clear_canvas, main_thread_update_function
21
-
22
- thread_control = {"run_thread": None, "stop_requested": False}
23
-
24
- @log_function_call
25
- def initiate_abort():
26
- global thread_control
27
- if thread_control.get("stop_requested") is not None:
28
- thread_control["stop_requested"].value = 1
29
-
30
- if thread_control.get("run_thread") is not None:
31
- thread_control["run_thread"].join(timeout=5)
32
- if thread_control["run_thread"].is_alive():
33
- thread_control["run_thread"].terminate()
34
- thread_control["run_thread"] = None
35
-
36
- @log_function_call
37
- def run_mask_gui(q, fig_queue, stop_requested):
38
- global vars_dict
39
- process_stdout_stderr(q)
40
- try:
41
- settings = check_mask_gui_settings(vars_dict)
42
- settings = add_mask_gui_defaults(settings)
43
- #for key in settings:
44
- # value = settings[key]
45
- # print(key, value, type(value))
46
- preprocess_generate_masks_wrapper(settings, q, fig_queue)
47
- except Exception as e:
48
- q.put(f"Error during processing: {e}")
49
- traceback.print_exc()
50
- finally:
51
- stop_requested.value = 1
52
-
53
- @log_function_call
54
- def start_process(q, fig_queue):
55
- global thread_control
56
- if thread_control.get("run_thread") is not None:
57
- initiate_abort()
58
-
59
- stop_requested = Value('i', 0) # multiprocessing shared value for inter-process communication
60
- thread_control["stop_requested"] = stop_requested
61
- thread_control["run_thread"] = Process(target=run_mask_gui, args=(q, fig_queue, stop_requested))
62
- thread_control["run_thread"].start()
63
-
64
- def import_settings(scrollable_frame):
65
- global vars_dict, original_variables_structure
66
-
67
- csv_file_path = filedialog.askopenfilename(filetypes=[("CSV files", "*.csv")])
68
-
69
- if not csv_file_path:
70
- return
71
-
72
- imported_variables = {}
73
-
74
- with open(csv_file_path, newline='') as csvfile:
75
- reader = csv.DictReader(csvfile)
76
- for row in reader:
77
- key = row['Key']
78
- value = row['Value']
79
- # Evaluate the value safely using safe_literal_eval
80
- imported_variables[key] = safe_literal_eval(value)
81
-
82
- # Track changed variables and apply the imported ones, printing changes as we go
83
- for key, var in vars_dict.items():
84
- if key in imported_variables and var.get() != imported_variables[key]:
85
- print(f"Updating '{key}' from '{var.get()}' to '{imported_variables[key]}'")
86
- var.set(imported_variables[key])
87
-
88
- @log_function_call
89
- def initiate_mask_root(width, height):
90
- global root, vars_dict, q, canvas, fig_queue, canvas_widget, thread_control
91
-
92
- theme = 'breeze'
93
-
94
- if theme in ['clam']:
95
- root = tk.Tk()
96
- style = ttk.Style(root)
97
- style.theme_use(theme) #plastik, clearlooks, elegance, default was clam #alt, breeze, arc
98
- set_dark_style(style)
99
- elif theme in ['breeze']:
100
- root = ThemedTk(theme="breeze")
101
- style = ttk.Style(root)
102
- set_dark_style(style)
103
-
104
- set_default_font(root, font_name="Arial", size=10)
105
- #root.state('zoomed') # For Windows to maximize the window
106
- root.attributes('-fullscreen', True)
107
- root.geometry(f"{width}x{height}")
108
- root.title("SpaCer: generate masks")
109
- fig_queue = Queue()
110
-
111
- def _process_fig_queue():
112
- global canvas
113
- try:
114
- while not fig_queue.empty():
115
- clear_canvas(canvas)
116
- fig = fig_queue.get_nowait()
117
- #set_fig_text_properties(fig, font_size=8)
118
- for ax in fig.get_axes():
119
- ax.set_xticks([]) # Remove x-axis ticks
120
- ax.set_yticks([]) # Remove y-axis ticks
121
- ax.xaxis.set_visible(False) # Hide the x-axis
122
- ax.yaxis.set_visible(False) # Hide the y-axis
123
- #ax.title.set_fontsize(14)
124
- #disable_interactivity(fig)
125
- fig.tight_layout()
126
- fig.set_facecolor('#333333')
127
- canvas.figure = fig
128
- fig_width, fig_height = canvas_widget.winfo_width(), canvas_widget.winfo_height()
129
- fig.set_size_inches(fig_width / fig.dpi, fig_height / fig.dpi, forward=True)
130
- canvas.draw_idle()
131
- except Exception as e:
132
- traceback.print_exc()
133
- #pass
134
- finally:
135
- canvas_widget.after(100, _process_fig_queue)
136
-
137
- # Process queue for console output
138
- def _process_console_queue():
139
- while not q.empty():
140
- message = q.get_nowait()
141
- console_output.insert(tk.END, message)
142
- console_output.see(tk.END)
143
- console_output.after(100, _process_console_queue)
144
-
145
- # Vertical container for settings and console
146
- vertical_container = tk.PanedWindow(root, orient=tk.HORIZONTAL) #VERTICAL
147
- vertical_container.pack(fill=tk.BOTH, expand=True)
148
-
149
- # Scrollable Frame for user settings
150
- scrollable_frame = ScrollableFrame(vertical_container, bg='#333333')
151
- vertical_container.add(scrollable_frame, stretch="always")
152
-
153
- # Setup for user input fields (variables)
154
- variables = mask_variables()
155
- vars_dict = generate_fields(variables, scrollable_frame)
156
-
157
- # Horizontal container for Matplotlib figure and the vertical pane (for settings and console)
158
- horizontal_container = tk.PanedWindow(vertical_container, orient=tk.VERTICAL) #HORIZONTAL
159
- vertical_container.add(horizontal_container, stretch="always")
160
-
161
- # Matplotlib figure setup
162
- figure = Figure(figsize=(30, 4), dpi=100, facecolor='#333333')
163
- plot = figure.add_subplot(111)
164
- plot.plot([], []) # This creates an empty plot.
165
- plot.axis('off')
166
-
167
- # Embedding the Matplotlib figure in the Tkinter window
168
- canvas = FigureCanvasTkAgg(figure, master=horizontal_container)
169
- canvas.get_tk_widget().configure(cursor='arrow', background='#333333', highlightthickness=0)
170
- #canvas.get_tk_widget().configure(cursor='arrow')
171
- canvas_widget = canvas.get_tk_widget()
172
- horizontal_container.add(canvas_widget, stretch="always")
173
- canvas.draw()
174
-
175
- # Console output setup below the settings
176
- console_output = scrolledtext.ScrolledText(vertical_container, height=10)
177
- vertical_container.add(console_output, stretch="always")
178
-
179
- # Queue and redirection setup for updating console output safely
180
- q = Queue()
181
- sys.stdout = StdoutRedirector(console_output)
182
- sys.stderr = StdoutRedirector(console_output)
183
-
184
- # This is your GUI setup where you create the Run button
185
- run_button = ttk.Button(scrollable_frame.scrollable_frame, text="Run",command=lambda: start_process(q, fig_queue))
186
- run_button.grid(row=40, column=0, pady=10)
187
-
188
- abort_button = ttk.Button(scrollable_frame.scrollable_frame, text="Abort", command=initiate_abort)
189
- abort_button.grid(row=40, column=1, pady=10)
190
-
191
- progress_label = ttk.Label(scrollable_frame.scrollable_frame, text="Processing: 0%", background="#333333", foreground="white")
192
- progress_label.grid(row=41, column=0, columnspan=2, sticky="ew", pady=(5, 0))
193
-
194
- # Create the Import Settings button
195
- import_btn = tk.Button(root, text="Import Settings", command=lambda: import_settings(scrollable_frame))
196
- import_btn.pack(pady=20)
197
-
198
- _process_console_queue()
199
- _process_fig_queue()
200
- create_dark_mode(root, style, console_output)
201
-
202
- root.after(100, lambda: main_thread_update_function(root, q, fig_queue, canvas_widget, progress_label))
203
-
204
- return root, vars_dict
205
-
206
- def gui_mask():
207
- global vars_dict, root
208
- root, vars_dict = initiate_mask_root(1000, 1500)
209
- root.mainloop()
210
-
211
- if __name__ == "__main__":
212
- gui_mask()
@@ -1,58 +0,0 @@
1
- import unittest
2
- from unittest.mock import MagicMock
3
- from annotate_app import ImageApp
4
- from PIL import Image
5
-
6
- class TestImageApp(unittest.TestCase):
7
- def setUp(self):
8
- self.root = MagicMock()
9
- self.db_path = '/path/to/database.db'
10
- self.image_type = 'png'
11
- self.channels = ['r', 'g']
12
- self.grid_rows = 2
13
- self.grid_cols = 2
14
- self.image_size = (200, 200)
15
- self.annotation_column = 'annotate'
16
- self.image_app = ImageApp(self.root, self.db_path, self.image_type, self.channels, self.grid_rows, self.grid_cols, self.image_size, self.annotation_column)
17
-
18
- def test_normalize_image(self):
19
- img = Image.open('/path/to/image.png')
20
- normalized_img = self.image_app.normalize_image(img)
21
- self.assertIsInstance(normalized_img, Image.Image)
22
- self.assertEqual(normalized_img.mode, 'RGB')
23
-
24
- def test_add_colored_border(self):
25
- img = Image.open('/path/to/image.png')
26
- border_width = 5
27
- border_color = 'teal'
28
- bordered_img = self.image_app.add_colored_border(img, border_width, border_color)
29
- self.assertIsInstance(bordered_img, Image.Image)
30
- self.assertEqual(bordered_img.mode, 'RGB')
31
-
32
- def test_filter_channels(self):
33
- img = Image.open('/path/to/image.png')
34
- filtered_img = self.image_app.filter_channels(img)
35
- self.assertIsInstance(filtered_img, Image.Image)
36
- self.assertEqual(filtered_img.mode, 'L')
37
-
38
- def test_load_single_image(self):
39
- path_annotation_tuple = ('/path/to/image.png', 1)
40
- img, annotation = self.image_app.load_single_image(path_annotation_tuple)
41
- self.assertIsInstance(img, Image.Image)
42
- self.assertEqual(img.mode, 'RGB')
43
- self.assertEqual(annotation, 1)
44
-
45
- def test_get_on_image_click(self):
46
- path = '/path/to/image.png'
47
- label = MagicMock()
48
- img = Image.open('/path/to/image.png')
49
- callback = self.image_app.get_on_image_click(path, label, img)
50
- event = MagicMock(num=1)
51
- callback(event)
52
- self.assertEqual(self.image_app.pending_updates[path], 1)
53
- event = MagicMock(num=3)
54
- callback(event)
55
- self.assertEqual(self.image_app.pending_updates[path], 2)
56
-
57
- if __name__ == '__main__':
58
- unittest.main()
spacr/test_plot.py DELETED
@@ -1,43 +0,0 @@
1
- import unittest
2
- from unittest.mock import MagicMock
3
- from spacr.plot import _save_scimg_plot
4
- from unittest.mock import patch
5
-
6
- class TestSaveScimgPlot(unittest.TestCase):
7
- def setUp(self):
8
- self.src = "/path/to/images"
9
- self.nr_imgs = 16
10
- self.channel_indices = [0, 1, 2]
11
- self.um_per_pixel = 0.1
12
- self.scale_bar_length_um = 10
13
- self.standardize = True
14
- self.fontsize = 8
15
- self.show_filename = True
16
- self.channel_names = None
17
- self.dpi = 300
18
- self.plot = False
19
- self.i = 1
20
- self.all_folders = 1
21
-
22
- def test_save_scimg_plot(self):
23
- # Mock necessary dependencies
24
- _save_figure_mock = MagicMock()
25
- _visualize_scimgs_mock = MagicMock(return_value="mocked_figure")
26
- _plot_images_on_grid_mock = MagicMock(return_value="mocked_figure")
27
-
28
- # Patch the dependencies
29
- with patch('spacr.plot._save_figure', _save_figure_mock), \
30
- patch('spacr.plot._visualize_scimgs', _visualize_scimgs_mock), \
31
- patch('spacr.plot._plot_images_on_grid', _plot_images_on_grid_mock):
32
-
33
- # Call the function
34
- _save_scimg_plot(self.src, self.nr_imgs, self.channel_indices, self.um_per_pixel, self.scale_bar_length_um, self.standardize, self.fontsize, self.show_filename, self.channel_names, self.dpi, self.plot, self.i, self.all_folders)
35
-
36
- # Add your assertions here
37
- _visualize_scimgs_mock.assert_called_with(self.src, self.channel_indices, self.um_per_pixel, self.scale_bar_length_um, self.show_filename, self.standardize, self.nr_imgs, self.fontsize, self.channel_names, self.plot)
38
- _save_figure_mock.assert_called_with("mocked_figure", self.src, text='all_channels')
39
- _plot_images_on_grid_mock.assert_called_with("mocked_figure", self.channel_indices, self.um_per_pixel, self.scale_bar_length_um, self.fontsize, self.show_filename, self.channel_names, self.plot)
40
- # Add more assertions for other function calls if needed
41
-
42
- if __name__ == '__main__':
43
- unittest.main()
spacr/test_train.py DELETED
@@ -1,39 +0,0 @@
1
- import unittest
2
- from unittest.mock import MagicMock
3
- from spacr.train import train_model
4
-
5
- class TestTrainModel(unittest.TestCase):
6
- def test_train_model_erm(self):
7
- # Mock necessary dependencies
8
- train_loaders = [
9
- MagicMock(), # training data loader 1
10
- MagicMock() # training data loader 2
11
- ]
12
- val_loaders = [
13
- MagicMock() # validation data loader
14
- ]
15
- test_loaders = [
16
- MagicMock() # test data loader
17
- ]
18
-
19
- # Call the function
20
- train_model('/path/to/save', 'model_type', train_loaders, ['loader1', 'loader2'], train_mode='erm', epochs=100, val_loaders=val_loaders, test_loaders=test_loaders)
21
-
22
- # Add your assertions here
23
- # ...
24
-
25
- def test_train_model_irm(self):
26
- # Mock necessary dependencies
27
- train_loaders = [
28
- MagicMock(), # training data loader 1
29
- MagicMock() # training data loader 2
30
- ]
31
-
32
- # Call the function
33
- train_model('/path/to/save', 'model_type', train_loaders, ['loader1', 'loader2'], train_mode='irm', epochs=100)
34
-
35
- # Add your assertions here
36
- # ...
37
-
38
- if __name__ == '__main__':
39
- unittest.main()
spacr/test_utils.py DELETED
@@ -1,33 +0,0 @@
1
- import unittest
2
- import numpy as np
3
- from spacr.utils import _filter_cp_masks
4
-
5
- class TestFilterCPMasks(unittest.TestCase):
6
- def test_filter_cp_masks(self):
7
- # Create dummy inputs
8
- masks = [np.array([[1, 1, 0], [1, 0, 0], [0, 0, 0]]), np.array([[1, 1, 1], [1, 1, 1], [1, 1, 1]])]
9
- flows = [np.array([[0, 0, 0], [0, 0, 0], [0, 0, 0]])]
10
- filter_size = True
11
- minimum_size = 2
12
- maximum_size = 5
13
- remove_border_objects = True
14
- merge = True
15
- filter_dimm = True
16
- batch = np.zeros((2, 3, 3, 3))
17
- moving_avg_q1 = 0.0
18
- moving_avg_q3 = 0.0
19
- moving_count = 0
20
- plot = False
21
- figuresize = (10, 10)
22
-
23
- # Call the function
24
- filtered_masks = _filter_cp_masks(masks, flows, filter_size, minimum_size, maximum_size, remove_border_objects, merge, filter_dimm, batch, moving_avg_q1, moving_avg_q3, moving_count, plot, figuresize)
25
-
26
- # Add your assertions here
27
- self.assertEqual(len(filtered_masks), 2)
28
- self.assertTrue(np.array_equal(filtered_masks[0], np.array([[1, 1, 0], [1, 0, 0], [0, 0, 0]])))
29
- self.assertTrue(np.array_equal(filtered_masks[1], np.array([[1, 1, 1], [1, 1, 1], [1, 1, 1]])))
30
- # Add more assertions as needed
31
-
32
- if __name__ == '__main__':
33
- unittest.main()
@@ -1,36 +0,0 @@
1
- spacr/__init__.py,sha256=mDi-Qu5r1vZnqIbUBV1JAoSq-mxmMEOmni1JSG2e4Wo,879
2
- spacr/__main__.py,sha256=_qRkhbFrH_cXr7AZs6KHL8Hh4VApqNdpNCtiKn2ePTo,285
3
- spacr/alpha.py,sha256=Q1vnqO0hvU1G7QP26amFwJY2RjZ68zIc3jYoqQSBMrw,462
4
- spacr/annotate_app.py,sha256=IPgZfS4TrSqbJr81P1FWUNOgCPPcS6EdQjUsXRwY-4E,19932
5
- spacr/cli.py,sha256=507jfOOEV8BoL4eeUcblvH-iiDHdBrEVJLu1ghAAPSc,1800
6
- spacr/core.py,sha256=Evw5RNHK4V8fW2fovy-srVFpwsgI9xoaM30zrjKCCrs,110048
7
- spacr/graph_learning.py,sha256=vxPYlDucfHaLyB_nylFud1ZPnBZtD-fQu2csCxSaLyU,3911
8
- spacr/graph_learning_lap.py,sha256=vxPYlDucfHaLyB_nylFud1ZPnBZtD-fQu2csCxSaLyU,3911
9
- spacr/gui_classify_app.py,sha256=P_pZANoYSQBku-VGNwAaMcQ23oPVqLYnKmrWTuWsG4k,8466
10
- spacr/gui_mask_app.py,sha256=3dnaqkIPKTBQyrnHyFtARibiYl_0sdvTrqNDDOGys3E,8481
11
- spacr/gui_measure_app.py,sha256=157tCdhe__RViwj5pPUXP1g22HIgArAskaq5TmwIiM0,8534
12
- spacr/gui_sim_app.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- spacr/gui_temp.py,sha256=pq286z2oULO6ed97YoHxv7RfdbY2enGoFQWpHC2JyH8,8473
14
- spacr/gui_utils.py,sha256=2YjCAFRLCmHqPlHBMv6cOkVtg5SFN_6ziyCkLqLhvVc,29013
15
- spacr/io.py,sha256=ebYogNqac4C05_Xa7C5caMUsOPvq_3yyCzTuXXkb7OY,96271
16
- spacr/logger.py,sha256=7Zqr3TuuOQLWT32gYr2q1qvv7x0a2JhLANmZcnBXAW8,670
17
- spacr/mask_app.py,sha256=B6-zYXVFg-cc58gLcz-Ry6LClO2jxLitL6B2ACb0HTw,39278
18
- spacr/measure.py,sha256=NUs942gS3YpFEbHLolmMI3vxkFOJ8M45BwMMKqU4C34,51393
19
- spacr/old_code.py,sha256=5Nzb2hONomdFkBMrDmZmyq7ogE6RmXAunqVaoDhsP6c,4475
20
- spacr/plot.py,sha256=9PNQNuI83SNzw3guEHGfrWJ2rCxdSP_jtO09dQaronI,54566
21
- spacr/sim.py,sha256=tl40lgTMeeJSyBq_c-Rn54C9Ri0FJ2zLkLLLPLSjz3o,51534
22
- spacr/test_annotate_app.py,sha256=yBWl_80PgP9jo1ClN0E1zSJVvzDeLCZHrlAvciS5KaY,2283
23
- spacr/test_plot.py,sha256=K2LhpbWtrpQ0BWhEKZOJi4E-NsmS0U8yjBdKxCwwAAc,2075
24
- spacr/test_train.py,sha256=qN3N6UvgeK2P-nQlG1HGgsTVZu4XYxXYI-oY7B5AioM,1217
25
- spacr/test_utils.py,sha256=0MUYmaqEJqUpTXKgj4mhdhUwWtzYkJLFV11T3wR826Q,1307
26
- spacr/timelapse.py,sha256=_j6cSVaxOhM7mTfJuNNRKogJaIGz_fM92MIegE6Ykh0,25355
27
- spacr/train.py,sha256=r77zLvLFMzx6MJxXG3JjynD8qTWYM9pNgrChEXYQhtY,25631
28
- spacr/umap.py,sha256=4QSrQ16Og-Ijq-SwguMQT2f20UWz1LE5HQeSLmzSl8c,29370
29
- spacr/utils.py,sha256=cyk0MMxCKCOUU3-vuGVxV9VUp0OOF7LaLs-UBCXAI3w,116764
30
- spacr/version.py,sha256=axH5tnGwtgSnJHb5IDhiu4Zjk5GhLyAEDRe-rnaoFOA,409
31
- spacr-0.0.18.dist-info/LICENSE,sha256=SR-2MeGc6SCM1UORJYyarSWY_A-JaOMFDj7ReSs9tRM,1083
32
- spacr-0.0.18.dist-info/METADATA,sha256=NdAabLRZt8SDX5xUwY0kknYaxMgKirdi4gKiLh_ezCA,4108
33
- spacr-0.0.18.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
34
- spacr-0.0.18.dist-info/entry_points.txt,sha256=5uyJaAxWCbjWYwP15InAKU1yFxTwyuvCGtIGceso1es,290
35
- spacr-0.0.18.dist-info/top_level.txt,sha256=GJPU8FgwRXGzKeut6JopsSRY2R8T3i9lDgya42tLInY,6
36
- spacr-0.0.18.dist-info/RECORD,,