spacr 0.1.16__py3-none-any.whl → 0.1.50__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/app_annotate.py +1 -1
- spacr/app_classify.py +5 -203
- spacr/app_make_masks.py +1 -1
- spacr/app_make_masks_v2.py +2 -2
- spacr/app_mask.py +5 -250
- spacr/app_measure.py +5 -250
- spacr/deep_spacr.py +3 -1
- spacr/gui.py +22 -13
- spacr/gui_utils.py +1001 -681
- spacr/measure.py +24 -3
- spacr/settings.py +13 -2
- spacr/utils.py +59 -5
- {spacr-0.1.16.dist-info → spacr-0.1.50.dist-info}/METADATA +2 -1
- {spacr-0.1.16.dist-info → spacr-0.1.50.dist-info}/RECORD +18 -18
- spacr-0.1.50.dist-info/entry_points.txt +8 -0
- spacr-0.1.16.dist-info/entry_points.txt +0 -8
- {spacr-0.1.16.dist-info → spacr-0.1.50.dist-info}/LICENSE +0 -0
- {spacr-0.1.16.dist-info → spacr-0.1.50.dist-info}/WHEEL +0 -0
- {spacr-0.1.16.dist-info → spacr-0.1.50.dist-info}/top_level.txt +0 -0
spacr/measure.py
CHANGED
@@ -617,6 +617,13 @@ def _measure_crop_core(index, time_ls, file, settings):
|
|
617
617
|
start = time.time()
|
618
618
|
try:
|
619
619
|
source_folder = os.path.dirname(settings['input_folder'])
|
620
|
+
#if not os.path.basename(source_folder).endswith('merged'):
|
621
|
+
# source_folder = os.path.join(source_folder, 'merged')
|
622
|
+
# print(f'changed source_folder to {source_folder}')
|
623
|
+
|
624
|
+
#if not os.path.exists(source_folder):
|
625
|
+
# return
|
626
|
+
|
620
627
|
file_name = os.path.splitext(file)[0]
|
621
628
|
data = np.load(os.path.join(settings['input_folder'], file))
|
622
629
|
|
@@ -750,6 +757,15 @@ def _measure_crop_core(index, time_ls, file, settings):
|
|
750
757
|
if isinstance(settings['crop_mode'], list):
|
751
758
|
crop_ls = settings['crop_mode']
|
752
759
|
size_ls = settings['png_size']
|
760
|
+
|
761
|
+
if isinstance(size_ls[0], int):
|
762
|
+
size_ls = [size_ls]
|
763
|
+
if len(crop_ls) > 1 and len(size_ls) == 1:
|
764
|
+
size_ls = size_ls * len(crop_ls)
|
765
|
+
|
766
|
+
if len(crop_ls) != len(size_ls):
|
767
|
+
print(f"Setting: size_ls: {settings['png_size']} should be a list of integers, or a list of lists of integers if crop_ls: {settings['crop_mode']} has multiple elements")
|
768
|
+
|
753
769
|
for crop_idx, crop_mode in enumerate(crop_ls):
|
754
770
|
width, height = size_ls[crop_idx]
|
755
771
|
if crop_mode == 'cell':
|
@@ -926,9 +942,14 @@ def measure_crop(settings):
|
|
926
942
|
settings = get_measure_crop_settings(settings)
|
927
943
|
settings = measure_test_mode(settings)
|
928
944
|
|
929
|
-
|
930
|
-
|
931
|
-
|
945
|
+
#src_fldr = settings['input_folder']
|
946
|
+
#if not os.path.basename(src_fldr).endswith('merged'):
|
947
|
+
# settings['input_folder'] = os.path.join(src_fldr, 'merged')
|
948
|
+
# print(f"changed input_folder to {src_fldr}")
|
949
|
+
|
950
|
+
#if not os.path.exists(settings['input_folder']):
|
951
|
+
# print(f'input_folder: {settings["input_folder"]} does not exist')
|
952
|
+
# return
|
932
953
|
|
933
954
|
if settings['cell_mask_dim'] is None:
|
934
955
|
settings['include_uninfected'] = True
|
spacr/settings.py
CHANGED
@@ -27,7 +27,13 @@ def set_default_plot_merge_settings():
|
|
27
27
|
|
28
28
|
def set_default_settings_preprocess_generate_masks(src, settings={}):
|
29
29
|
# Main settings
|
30
|
-
|
30
|
+
if src != None:
|
31
|
+
settings['src'] = src
|
32
|
+
else:
|
33
|
+
settings.setdefault('src', 'path')
|
34
|
+
if 'src' not in settings:
|
35
|
+
settings['src'] = 'path'
|
36
|
+
|
31
37
|
settings.setdefault('preprocess', True)
|
32
38
|
settings.setdefault('masks', True)
|
33
39
|
settings.setdefault('save', True)
|
@@ -212,9 +218,12 @@ def get_umap_image_settings(settings={}):
|
|
212
218
|
|
213
219
|
def get_measure_crop_settings(settings):
|
214
220
|
|
221
|
+
settings.setdefault('src', 'path')
|
222
|
+
|
215
223
|
# Test mode
|
216
224
|
settings.setdefault('test_mode', False)
|
217
225
|
settings.setdefault('test_nr', 10)
|
226
|
+
settings.setdefault('channels', [0,1,2,3])
|
218
227
|
|
219
228
|
#measurement settings
|
220
229
|
settings.setdefault('save_measurements',True)
|
@@ -260,7 +269,7 @@ def get_measure_crop_settings(settings):
|
|
260
269
|
|
261
270
|
# Miscellaneous settings
|
262
271
|
settings.setdefault('experiment', 'exp')
|
263
|
-
settings.setdefault('cells', 'HeLa')
|
272
|
+
settings.setdefault('cells', ['HeLa'])
|
264
273
|
settings.setdefault('cell_loc', None)
|
265
274
|
settings.setdefault('pathogens', ['ME49Dku80WT', 'ME49Dku80dgra8:GRA8', 'ME49Dku80dgra8', 'ME49Dku80TKO'])
|
266
275
|
settings.setdefault('pathogen_loc', [['c1', 'c2', 'c3', 'c4', 'c5', 'c6'], ['c7', 'c8', 'c9', 'c10', 'c11', 'c12'], ['c13', 'c14', 'c15', 'c16', 'c17', 'c18'], ['c19', 'c20', 'c21', 'c22', 'c23', 'c24']])
|
@@ -304,6 +313,8 @@ def set_default_analyze_screen(settings):
|
|
304
313
|
|
305
314
|
def set_default_train_test_model(settings):
|
306
315
|
cores = os.cpu_count()-2
|
316
|
+
|
317
|
+
settings.setdefault('src','path')
|
307
318
|
settings.setdefault('train',True)
|
308
319
|
settings.setdefault('test',False)
|
309
320
|
settings.setdefault('classes',['nc','pc'])
|
spacr/utils.py
CHANGED
@@ -73,6 +73,65 @@ from scipy import stats
|
|
73
73
|
|
74
74
|
from .logger import log_function_call
|
75
75
|
|
76
|
+
import os
|
77
|
+
import signal
|
78
|
+
import psutil
|
79
|
+
import platform
|
80
|
+
from multiprocessing import set_start_method, get_start_method
|
81
|
+
|
82
|
+
def reset_mp():
|
83
|
+
current_method = get_start_method()
|
84
|
+
system = platform.system()
|
85
|
+
|
86
|
+
if system == 'Windows':
|
87
|
+
if current_method != 'spawn':
|
88
|
+
set_start_method('spawn', force=True)
|
89
|
+
elif system in ('Linux', 'Darwin'): # Darwin is macOS
|
90
|
+
if current_method != 'fork':
|
91
|
+
set_start_method('fork', force=True)
|
92
|
+
|
93
|
+
def is_multiprocessing_process(process):
|
94
|
+
""" Check if the process is a multiprocessing process. """
|
95
|
+
try:
|
96
|
+
for cmd in process.cmdline():
|
97
|
+
if 'multiprocessing' in cmd:
|
98
|
+
return True
|
99
|
+
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
|
100
|
+
pass
|
101
|
+
return False
|
102
|
+
|
103
|
+
def close_file_descriptors():
|
104
|
+
""" Close file descriptors and shared memory objects. """
|
105
|
+
import resource
|
106
|
+
|
107
|
+
soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
|
108
|
+
for fd in range(3, soft):
|
109
|
+
try:
|
110
|
+
os.close(fd)
|
111
|
+
except OSError:
|
112
|
+
pass
|
113
|
+
|
114
|
+
def close_multiprocessing_processes():
|
115
|
+
""" Close all multiprocessing processes. """
|
116
|
+
current_pid = os.getpid()
|
117
|
+
for proc in psutil.process_iter(['pid', 'cmdline']):
|
118
|
+
try:
|
119
|
+
# Skip the current process
|
120
|
+
if proc.info['pid'] == current_pid:
|
121
|
+
continue
|
122
|
+
|
123
|
+
# Check if the process is a multiprocessing process
|
124
|
+
if is_multiprocessing_process(proc):
|
125
|
+
proc.terminate()
|
126
|
+
proc.wait(timeout=5) # Wait up to 5 seconds for the process to terminate
|
127
|
+
print(f"Terminated process {proc.info['pid']}")
|
128
|
+
|
129
|
+
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess) as e:
|
130
|
+
print(f"Failed to terminate process {proc.info['pid']}: {e}")
|
131
|
+
|
132
|
+
# Close file descriptors
|
133
|
+
close_file_descriptors()
|
134
|
+
|
76
135
|
def check_mask_folder(src,mask_fldr):
|
77
136
|
|
78
137
|
mask_folder = os.path.join(src,'norm_channel_stack',mask_fldr)
|
@@ -92,19 +151,14 @@ def check_mask_folder(src,mask_fldr):
|
|
92
151
|
|
93
152
|
def smooth_hull_lines(cluster_data):
|
94
153
|
hull = ConvexHull(cluster_data)
|
95
|
-
|
96
154
|
# Extract vertices of the hull
|
97
155
|
vertices = hull.points[hull.vertices]
|
98
|
-
|
99
156
|
# Close the loop
|
100
157
|
vertices = np.vstack([vertices, vertices[0, :]])
|
101
|
-
|
102
158
|
# Parameterize the vertices
|
103
159
|
tck, u = splprep(vertices.T, u=None, s=0.0)
|
104
|
-
|
105
160
|
# Evaluate spline at new parameter values
|
106
161
|
new_points = splev(np.linspace(0, 1, 100), tck)
|
107
|
-
|
108
162
|
return new_points[0], new_points[1]
|
109
163
|
|
110
164
|
def _gen_rgb_image(image, channels):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: spacr
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.50
|
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
|
@@ -39,6 +39,7 @@ Requires-Dist: ttf-opensans >=2020.10.30
|
|
39
39
|
Requires-Dist: customtkinter <6.0,>=5.2.2
|
40
40
|
Requires-Dist: biopython <2.0,>=1.80
|
41
41
|
Requires-Dist: lxml <6.0,>=5.1.0
|
42
|
+
Requires-Dist: huggingface-hub <0.25,>=0.24.0
|
42
43
|
Provides-Extra: dev
|
43
44
|
Requires-Dist: pytest <3.11,>=3.9 ; extra == 'dev'
|
44
45
|
Provides-Extra: full
|
@@ -3,21 +3,21 @@ spacr/__main__.py,sha256=bkAJJD2kjIqOP-u1kLvct9jQQCeUXzlEjdgitwi1Lm8,75
|
|
3
3
|
spacr/alpha.py,sha256=Y95sLEfpK2OSYKRn3M8eUOU33JJeXfV8zhrC4KnwSTY,35244
|
4
4
|
spacr/annotate_app.py,sha256=imQ7ZEXDyM6ce1dxZ1xUS1-KequuF_NCI4xCaPLjvco,29275
|
5
5
|
spacr/annotate_app_v2.py,sha256=imQ7ZEXDyM6ce1dxZ1xUS1-KequuF_NCI4xCaPLjvco,29275
|
6
|
-
spacr/app_annotate.py,sha256=
|
7
|
-
spacr/app_classify.py,sha256=
|
8
|
-
spacr/app_make_masks.py,sha256=
|
9
|
-
spacr/app_make_masks_v2.py,sha256=
|
10
|
-
spacr/app_mask.py,sha256=
|
11
|
-
spacr/app_measure.py,sha256=
|
6
|
+
spacr/app_annotate.py,sha256=vL4u_54bOZ2BO-azEgMG9HlNBXBLCzhIs10QggS6Adk,23572
|
7
|
+
spacr/app_classify.py,sha256=urTP_wlZ58hSyM5a19slYlBxN0PdC-9-ga0hvq8CGWc,165
|
8
|
+
spacr/app_make_masks.py,sha256=rV2zoxYsJ8-uR39mXjDMkbNcxv-6vq2POw4QUTDD8_U,45072
|
9
|
+
spacr/app_make_masks_v2.py,sha256=jmLYKJSPhI3Zf5MnbHqLNO2asI49a0BBOo2Y4p2uz4o,30528
|
10
|
+
spacr/app_mask.py,sha256=l-dBY8ftzCMdDe6-pXc2Nh_u-idNL9G7UOARiLJBtds,153
|
11
|
+
spacr/app_measure.py,sha256=_K7APYIeOKpV6e_LcqabBjvEi7mfq9Fch8175x1x0k8,162
|
12
12
|
spacr/chris.py,sha256=YlBjSgeZaY8HPy6jkrT_ISAnCMAKVfvCxF0I9eAZLFM,2418
|
13
13
|
spacr/classify_app.py,sha256=Zi15ryc1ocYitRF4kyxlC27XxGyzfSPdvj2d6ZrSh7E,8446
|
14
14
|
spacr/cli.py,sha256=507jfOOEV8BoL4eeUcblvH-iiDHdBrEVJLu1ghAAPSc,1800
|
15
15
|
spacr/core.py,sha256=m9fsk-qDPow4AzOYpTIsd4jT7PF_L_4y5xillR5eRdk,160253
|
16
|
-
spacr/deep_spacr.py,sha256=
|
16
|
+
spacr/deep_spacr.py,sha256=rvqOoY9dadcTcKiABf61Nb8HEMVp1NouFmtAE2ee1T4,37056
|
17
17
|
spacr/foldseek.py,sha256=YIP1d4Ci6CeA9jSyiv-HTDbNmAmcSM9Y_DaOs7wYzLY,33546
|
18
18
|
spacr/get_alfafold_structures.py,sha256=ehx_MQgb12k3hFecP6cYVlm5TLO8iWjgevy8ESyS3cw,3544
|
19
19
|
spacr/graph_learning.py,sha256=1tR-ZxvXE3dBz1Saw7BeVFcrsUFu9OlUZeZVifih9eo,13070
|
20
|
-
spacr/gui.py,sha256=
|
20
|
+
spacr/gui.py,sha256=1pumw2O0dfDZ4Hw4V8-pMlvODegDNulXsLNEFAnIB7c,7297
|
21
21
|
spacr/gui_2.py,sha256=ZAI5quQYbhQJ40vK0NCqU_UMSPLkpfeQpomBWUSM0fc,6946
|
22
22
|
spacr/gui_annotate.py,sha256=ugBksLGOHdtOLlEuRyyc59TrkYKu3rDf8JxEgiBSVao,6536
|
23
23
|
spacr/gui_classify_app.py,sha256=Zi15ryc1ocYitRF4kyxlC27XxGyzfSPdvj2d6ZrSh7E,8446
|
@@ -26,29 +26,29 @@ spacr/gui_make_masks_app_v2.py,sha256=X3izTBXdCZDlkVe-fbG-jmCQtcAbmK0OIivjyWaLhu
|
|
26
26
|
spacr/gui_mask_app.py,sha256=mhTl_XzXLFl8Tx3WYEMpdYB_qw9u5JJa0EdkvlcIzAE,10706
|
27
27
|
spacr/gui_measure_app.py,sha256=_C1-XFL5HSquUEEbM_NcxdvHx-socPFCx85MBG4d6xo,10598
|
28
28
|
spacr/gui_sim_app.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
29
|
-
spacr/gui_utils.py,sha256=
|
29
|
+
spacr/gui_utils.py,sha256=jnbvfovPGcwY_hmHudEryhSBG3hFOUsV_iNQSokGHpM,70160
|
30
30
|
spacr/io.py,sha256=IoERqSwoxJrInYl-E0WfwFOEDZXFdJofk5DmpbyLGWM,112077
|
31
31
|
spacr/logger.py,sha256=7Zqr3TuuOQLWT32gYr2q1qvv7x0a2JhLANmZcnBXAW8,670
|
32
32
|
spacr/make_masks_app.py,sha256=iGaTwhowoe2JMOSOf8bJwQZTooRhLQx7KO0ewnAmqDY,45138
|
33
33
|
spacr/make_masks_app_v2.py,sha256=X3izTBXdCZDlkVe-fbG-jmCQtcAbmK0OIivjyWaLhug,30576
|
34
34
|
spacr/mask_app.py,sha256=mhTl_XzXLFl8Tx3WYEMpdYB_qw9u5JJa0EdkvlcIzAE,10706
|
35
|
-
spacr/measure.py,sha256=
|
35
|
+
spacr/measure.py,sha256=r5nxxULUyka2L5IVdnmEmnMywChY3a4DWGse3ygIh4Q,56000
|
36
36
|
spacr/measure_app.py,sha256=_C1-XFL5HSquUEEbM_NcxdvHx-socPFCx85MBG4d6xo,10598
|
37
37
|
spacr/old_code.py,sha256=jw67DAGoLBd7mWofVzRJSEmCI1Qrff26zIo65SEkV00,13817
|
38
38
|
spacr/plot.py,sha256=lrwU51OTWfby1wx73XGyjYmTjLVia7WOmGH5LZZ-4jM,67145
|
39
39
|
spacr/sequencing.py,sha256=U_TBJGNfOBfokGegUe950W_KPfm51VOgpfibXoZ8RMQ,83974
|
40
|
-
spacr/settings.py,sha256=
|
40
|
+
spacr/settings.py,sha256=ElHlNBNqvjtHFD7WC-QqKqXjMeosKXqJKnjeRX0mHVo,21456
|
41
41
|
spacr/sim.py,sha256=FveaVgBi3eypO2oVB5Dx-v0CC1Ny7UPfXkJiiRRodAk,71212
|
42
42
|
spacr/sim_app.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
43
43
|
spacr/timelapse.py,sha256=KMYCgHzf9LTZe-lWl5mvH2EjbKRE6OhpwdY13wEumGc,39504
|
44
|
-
spacr/utils.py,sha256=
|
44
|
+
spacr/utils.py,sha256=MM31yWquNDFmhxAU3l3Qx64peQJ6VWOuNGS6gkia5AY,186541
|
45
45
|
spacr/version.py,sha256=axH5tnGwtgSnJHb5IDhiu4Zjk5GhLyAEDRe-rnaoFOA,409
|
46
46
|
spacr/models/cp/toxo_plaque_cyto_e25000_X1120_Y1120.CP_model,sha256=z8BbHWZPRnE9D_BHO0fBREE85c1vkltDs-incs2ytXQ,26566572
|
47
47
|
spacr/models/cp/toxo_plaque_cyto_e25000_X1120_Y1120.CP_model_settings.csv,sha256=fBAGuL_B8ERVdVizO3BHozTDSbZUh1yFzsYK3wkQN68,420
|
48
48
|
spacr/models/cp/toxo_pv_lumen.CP_model,sha256=2y_CindYhmTvVwBH39SNILF3rI3x9SsRn6qrMxHy3l0,26562451
|
49
|
-
spacr-0.1.
|
50
|
-
spacr-0.1.
|
51
|
-
spacr-0.1.
|
52
|
-
spacr-0.1.
|
53
|
-
spacr-0.1.
|
54
|
-
spacr-0.1.
|
49
|
+
spacr-0.1.50.dist-info/LICENSE,sha256=SR-2MeGc6SCM1UORJYyarSWY_A-JaOMFDj7ReSs9tRM,1083
|
50
|
+
spacr-0.1.50.dist-info/METADATA,sha256=5AUx1Qr2W-JmYcI3gGVkgO96mPAG01o8qj8_Mjlh6ho,5050
|
51
|
+
spacr-0.1.50.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
52
|
+
spacr-0.1.50.dist-info/entry_points.txt,sha256=BMC0ql9aNNpv8lUZ8sgDLQMsqaVnX5L535gEhKUP5ho,296
|
53
|
+
spacr-0.1.50.dist-info/top_level.txt,sha256=GJPU8FgwRXGzKeut6JopsSRY2R8T3i9lDgya42tLInY,6
|
54
|
+
spacr-0.1.50.dist-info/RECORD,,
|
@@ -0,0 +1,8 @@
|
|
1
|
+
[console_scripts]
|
2
|
+
annotate = spacr.app_annotate:gui_annotate
|
3
|
+
classify = spacr.app_classify:start_classify_app
|
4
|
+
make_masks = spacr.app_make_masks:gui_make_masks
|
5
|
+
mask = spacr.app_mask:start_mask_app
|
6
|
+
measure = spacr.app_measure:start_measure_app
|
7
|
+
sim = spacr.app_sim:gui_sim
|
8
|
+
spacr = spacr.gui:gui_app
|
@@ -1,8 +0,0 @@
|
|
1
|
-
[console_scripts]
|
2
|
-
annotate = spacr.app_annotate:gui_annotate
|
3
|
-
classify = spacr.app_classify:gui_classify
|
4
|
-
make_masks = spacr.app_make_mask:gui_make_masks
|
5
|
-
mask = spacr.app_mask:gui_mask
|
6
|
-
measure = spacr.app_measure:gui_measure
|
7
|
-
sim = spacr.app_sim:gui_sim
|
8
|
-
spacr = spacr.gui:gui_app
|
File without changes
|
File without changes
|
File without changes
|