spacr 0.0.1__tar.gz → 0.0.2__tar.gz

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 (64) hide show
  1. spacr-0.0.2/PKG-INFO +130 -0
  2. spacr-0.0.2/README.md +89 -0
  3. spacr-0.0.2/setup.py +63 -0
  4. {spacr-0.0.1 → spacr-0.0.2}/spacr/__init__.py +4 -0
  5. spacr-0.0.2/spacr/alpha.py +18 -0
  6. spacr-0.0.2/spacr/cli.py +41 -0
  7. {spacr-0.0.1 → spacr-0.0.2}/spacr/core.py +267 -56
  8. spacr-0.0.2/spacr/graph_learning.py +276 -0
  9. spacr-0.0.2/spacr/graph_learning_lap.py +84 -0
  10. spacr-0.0.1/spacr/gui_mask_app.py → spacr-0.0.2/spacr/gui_classify_app.py +59 -109
  11. spacr-0.0.2/spacr/gui_mask_app.py +199 -0
  12. {spacr-0.0.1 → spacr-0.0.2}/spacr/gui_measure_app.py +14 -28
  13. {spacr-0.0.1 → spacr-0.0.2}/spacr/gui_utils.py +311 -115
  14. {spacr-0.0.1 → spacr-0.0.2}/spacr/io.py +260 -112
  15. {spacr-0.0.1 → spacr-0.0.2}/spacr/measure.py +11 -17
  16. spacr-0.0.2/spacr/old_code.py +290 -0
  17. {spacr-0.0.1 → spacr-0.0.2}/spacr/plot.py +92 -85
  18. {spacr-0.0.1 → spacr-0.0.2}/spacr/sim.py +8 -1
  19. {spacr-0.0.1 → spacr-0.0.2}/spacr/timelapse.py +213 -52
  20. {spacr-0.0.1 → spacr-0.0.2}/spacr/train.py +7 -1
  21. {spacr-0.0.1 → spacr-0.0.2}/spacr/utils.py +220 -119
  22. spacr-0.0.2/spacr.egg-info/PKG-INFO +130 -0
  23. {spacr-0.0.1 → spacr-0.0.2}/spacr.egg-info/SOURCES.txt +16 -1
  24. {spacr-0.0.1 → spacr-0.0.2}/spacr.egg-info/entry_points.txt +2 -0
  25. spacr-0.0.2/spacr.egg-info/requires.txt +32 -0
  26. spacr-0.0.2/tests/test_annotate_app.py +58 -0
  27. spacr-0.0.2/tests/test_core.py +65 -0
  28. spacr-0.0.2/tests/test_gui_classify_app.py +28 -0
  29. spacr-0.0.2/tests/test_gui_mask_app.py +28 -0
  30. spacr-0.0.2/tests/test_gui_measure_app.py +28 -0
  31. spacr-0.0.2/tests/test_gui_sim_app.py +28 -0
  32. spacr-0.0.2/tests/test_gui_utils.py +90 -0
  33. spacr-0.0.2/tests/test_io.py +52 -0
  34. spacr-0.0.2/tests/test_mask_app.py +75 -0
  35. spacr-0.0.2/tests/test_measure.py +58 -0
  36. spacr-0.0.2/tests/test_plot.py +43 -0
  37. spacr-0.0.2/tests/test_sim.py +35 -0
  38. spacr-0.0.2/tests/test_timelapse.py +41 -0
  39. spacr-0.0.2/tests/test_train.py +39 -0
  40. spacr-0.0.2/tests/test_umap.py +43 -0
  41. spacr-0.0.2/tests/test_utils.py +33 -0
  42. spacr-0.0.1/PKG-INFO +0 -64
  43. spacr-0.0.1/README.md +0 -25
  44. spacr-0.0.1/setup.py +0 -56
  45. spacr-0.0.1/spacr/cli.py +0 -203
  46. spacr-0.0.1/spacr/old_code.py +0 -104
  47. spacr-0.0.1/spacr.egg-info/PKG-INFO +0 -64
  48. spacr-0.0.1/spacr.egg-info/requires.txt +0 -30
  49. spacr-0.0.1/tests/test_io.py +0 -0
  50. spacr-0.0.1/tests/test_measure.py +0 -0
  51. spacr-0.0.1/tests/test_plot.py +0 -0
  52. spacr-0.0.1/tests/test_timelapse.py +0 -0
  53. spacr-0.0.1/tests/test_util.py +0 -0
  54. {spacr-0.0.1 → spacr-0.0.2}/LICENSE +0 -0
  55. {spacr-0.0.1 → spacr-0.0.2}/setup.cfg +0 -0
  56. {spacr-0.0.1 → spacr-0.0.2}/spacr/__main__.py +0 -0
  57. {spacr-0.0.1 → spacr-0.0.2}/spacr/annotate_app.py +0 -0
  58. /spacr-0.0.1/tests/test_core.py → /spacr-0.0.2/spacr/gui_sim_app.py +0 -0
  59. {spacr-0.0.1 → spacr-0.0.2}/spacr/logger.py +0 -0
  60. {spacr-0.0.1 → spacr-0.0.2}/spacr/mask_app.py +0 -0
  61. {spacr-0.0.1 → spacr-0.0.2}/spacr/umap.py +0 -0
  62. {spacr-0.0.1 → spacr-0.0.2}/spacr/version.py +0 -0
  63. {spacr-0.0.1 → spacr-0.0.2}/spacr.egg-info/dependency_links.txt +0 -0
  64. {spacr-0.0.1 → spacr-0.0.2}/spacr.egg-info/top_level.txt +0 -0
spacr-0.0.2/PKG-INFO ADDED
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.1
2
+ Name: spacr
3
+ Version: 0.0.2
4
+ Summary: Spatial phenotype analysis of crisp screens (SpaCr)
5
+ Home-page: https://github.com/EinarOlafsson/spacr
6
+ Author: Einar Birnir Olafsson
7
+ Author-email: olafsson@med.umich.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ License-File: LICENSE
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: pillow>=10.2.0
23
+ Requires-Dist: imageio>=2.34.0
24
+ Requires-Dist: scipy>=1.12.0
25
+ Requires-Dist: ipywidgets>=8.1.2
26
+ Requires-Dist: mahotas>=1.4.13
27
+ Requires-Dist: btrack>=0.6.5
28
+ Requires-Dist: trackpy>=0.6.2
29
+ Requires-Dist: cellpose>=3.0.6
30
+ Requires-Dist: IPython>=8.18.1
31
+ Requires-Dist: opencv-python-headless>=4.9.0.80
32
+ Requires-Dist: umap>=0.1.1
33
+ Requires-Dist: ttkthemes>=3.2.2
34
+ Requires-Dist: lxml>=5.1.0
35
+ Provides-Extra: dev
36
+ Requires-Dist: pytest>=3.9; extra == "dev"
37
+ Provides-Extra: headless
38
+ Requires-Dist: opencv-python-headless; extra == "headless"
39
+ Provides-Extra: full
40
+ Requires-Dist: opencv-python; extra == "full"
41
+
42
+ [![PyPI version](https://badge.fury.io/py/spacr.svg)](https://badge.fury.io/py/spacr)
43
+ [![Python version](https://img.shields.io/pypi/pyversions/spacr)](https://pypistats.org/packages/spacr)
44
+ [![Licence: GPL v3](https://img.shields.io/github/license/EinarOlafsson/spacr)](https://github.com/EinarOlafsson/spacr/blob/master/LICENSE)
45
+ [![repo size](https://img.shields.io/github/repo-size/EinarOlafsson/spacr)](https://github.com/EinarOlafsson/spacr/)
46
+
47
+ # SpaCr
48
+ <table>
49
+ <tr>
50
+ <td>
51
+
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.
53
+
54
+ </td>
55
+ <td>
56
+
57
+ <img src="spacr/logo_spacr.png" alt="SPACR Logo" title="SPACR Logo" width="600"/>
58
+
59
+ </td>
60
+ </tr>
61
+ </table>
62
+
63
+ ## Features
64
+
65
+ - **Generate Masks:** Generate cellpose masks for cells, nuclei and pathogen images.
66
+
67
+ - **Object Measurements:** Measurements for each object including scikit-image-regionprops, intensity quantiles, shannon-entropy, pearsons and manders correlation, homogenicity and radial distribution. Measurements are saved to a sql database in object level tables.
68
+
69
+ - **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
+
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.
72
+
73
+ - **Manual Annotation:** Supports manual annotation of single cell images and segmentation to refine training datasets for training CNNs/Transformers or cellpose, respectively.
74
+
75
+ - **Finetune Cellpose Models:** Adjust pre-existing Cellpose models to your specific dataset for improved performance.
76
+
77
+ - **Timelapse Data Support:** Track objects in timelapse image data.
78
+
79
+ - **Simulations:** Simulate spatial phenotype screens.
80
+
81
+ - **Misc:** Analyze Ca oscillation, recruitment, infection rate, plaque size/count.
82
+
83
+ ## Installation
84
+
85
+ spacr requires Tkinter for its graphical user interface features.
86
+
87
+ ### Ubuntu
88
+
89
+ Before installing spacr, ensure Tkinter is installed:
90
+
91
+ (Tkinter is included with the standard Python installation on macOS, and Windows)
92
+
93
+ On Linux:
94
+
95
+ ```
96
+ sudo apt-get install python3-tk
97
+ ```
98
+
99
+ install spacr with pip
100
+
101
+ ```
102
+ pip install spacr
103
+ ```
104
+
105
+ To run spacr GUIs after installing spacr:
106
+
107
+ To generate masks:
108
+ ```
109
+ gui_mask
110
+ ```
111
+ To generate measurements and cropped images:
112
+ ```
113
+ gui_measure
114
+ ```
115
+ To curate masks for finetuning cellpose models:
116
+ ```
117
+ gui_make_masks
118
+ ```
119
+ To annotate paths to images in sql database created in gui_measure:
120
+ ```
121
+ gui_annotate
122
+ ```
123
+ Train torch CNNs/Transformers to classify single object images.
124
+ ```
125
+ gui_classify
126
+ ```
127
+ Simulate spatial phenotype screens.
128
+ ```
129
+ gui_sim
130
+ ```
spacr-0.0.2/README.md ADDED
@@ -0,0 +1,89 @@
1
+ [![PyPI version](https://badge.fury.io/py/spacr.svg)](https://badge.fury.io/py/spacr)
2
+ [![Python version](https://img.shields.io/pypi/pyversions/spacr)](https://pypistats.org/packages/spacr)
3
+ [![Licence: GPL v3](https://img.shields.io/github/license/EinarOlafsson/spacr)](https://github.com/EinarOlafsson/spacr/blob/master/LICENSE)
4
+ [![repo size](https://img.shields.io/github/repo-size/EinarOlafsson/spacr)](https://github.com/EinarOlafsson/spacr/)
5
+
6
+ # SpaCr
7
+ <table>
8
+ <tr>
9
+ <td>
10
+
11
+ 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.
12
+
13
+ </td>
14
+ <td>
15
+
16
+ <img src="spacr/logo_spacr.png" alt="SPACR Logo" title="SPACR Logo" width="600"/>
17
+
18
+ </td>
19
+ </tr>
20
+ </table>
21
+
22
+ ## Features
23
+
24
+ - **Generate Masks:** Generate cellpose masks for cells, nuclei and pathogen images.
25
+
26
+ - **Object Measurements:** Measurements for each object including scikit-image-regionprops, intensity quantiles, shannon-entropy, pearsons and manders correlation, homogenicity and radial distribution. Measurements are saved to a sql database in object level tables.
27
+
28
+ - **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.
29
+
30
+ - **Train CNNs or Transformers:** Train Torch Convolutional Neural Networks (CNNs) or Transformers to classify single object images. Train Torch models with IRM/ERM, checkpointing.
31
+
32
+ - **Manual Annotation:** Supports manual annotation of single cell images and segmentation to refine training datasets for training CNNs/Transformers or cellpose, respectively.
33
+
34
+ - **Finetune Cellpose Models:** Adjust pre-existing Cellpose models to your specific dataset for improved performance.
35
+
36
+ - **Timelapse Data Support:** Track objects in timelapse image data.
37
+
38
+ - **Simulations:** Simulate spatial phenotype screens.
39
+
40
+ - **Misc:** Analyze Ca oscillation, recruitment, infection rate, plaque size/count.
41
+
42
+ ## Installation
43
+
44
+ spacr requires Tkinter for its graphical user interface features.
45
+
46
+ ### Ubuntu
47
+
48
+ Before installing spacr, ensure Tkinter is installed:
49
+
50
+ (Tkinter is included with the standard Python installation on macOS, and Windows)
51
+
52
+ On Linux:
53
+
54
+ ```
55
+ sudo apt-get install python3-tk
56
+ ```
57
+
58
+ install spacr with pip
59
+
60
+ ```
61
+ pip install spacr
62
+ ```
63
+
64
+ To run spacr GUIs after installing spacr:
65
+
66
+ To generate masks:
67
+ ```
68
+ gui_mask
69
+ ```
70
+ To generate measurements and cropped images:
71
+ ```
72
+ gui_measure
73
+ ```
74
+ To curate masks for finetuning cellpose models:
75
+ ```
76
+ gui_make_masks
77
+ ```
78
+ To annotate paths to images in sql database created in gui_measure:
79
+ ```
80
+ gui_annotate
81
+ ```
82
+ Train torch CNNs/Transformers to classify single object images.
83
+ ```
84
+ gui_classify
85
+ ```
86
+ Simulate spatial phenotype screens.
87
+ ```
88
+ gui_sim
89
+ ```
spacr-0.0.2/setup.py ADDED
@@ -0,0 +1,63 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ # Ensure you have read the README.md content into a variable, e.g., `long_description`
4
+ with open("README.md", "r", encoding="utf-8") as fh:
5
+ long_description = fh.read()
6
+
7
+ dependencies = [
8
+ 'torch>=2.2.1',
9
+ 'torchvision>=0.17.1',
10
+ 'torch-geometric>=2.5.1',
11
+ 'numpy>=1.26.4',
12
+ 'pandas>=2.2.1',
13
+ 'statsmodels>=0.14.1',
14
+ 'scikit-image>=0.22.0',
15
+ 'scikit-learn>=1.4.1',
16
+ 'seaborn>=0.13.2',
17
+ 'matplotlib>=3.8.3',
18
+ 'pillow>=10.2.0',
19
+ 'imageio>=2.34.0',
20
+ 'scipy>=1.12.0',
21
+ 'ipywidgets>=8.1.2',
22
+ 'mahotas>=1.4.13',
23
+ 'btrack>=0.6.5',
24
+ 'trackpy>=0.6.2',
25
+ 'cellpose>=3.0.6',
26
+ 'IPython>=8.18.1',
27
+ 'opencv-python-headless>=4.9.0.80',
28
+ 'umap>=0.1.1',
29
+ 'ttkthemes>=3.2.2',
30
+ 'lxml>=5.1.0'
31
+ ]
32
+
33
+ setup(
34
+ name="spacr",
35
+ version="0.0.2",
36
+ author="Einar Birnir Olafsson",
37
+ author_email="olafsson@med.umich.com",
38
+ description="Spatial phenotype analysis of crisp screens (SpaCr)",
39
+ long_description=long_description,
40
+ url="https://github.com/EinarOlafsson/spacr",
41
+ packages=find_packages(exclude=["tests.*", "tests"]),
42
+ install_requires=dependencies,
43
+ entry_points={
44
+ 'console_scripts': [
45
+ 'gui_mask=spacr.gui_mask_app:gui_mask',
46
+ 'gui_measure=spacr.gui_measure_app:gui_measure',
47
+ 'gui_make_masks=spacr.mask_app:gui_make_masks',
48
+ 'gui_annotation=spacr.annotate_app:gui_annotation',
49
+ 'gui_classify=spacr.gui_classify_app:gui_classify',
50
+ 'gui_sim=spacr.gui_sim_app:gui_sim',
51
+ ],
52
+ },
53
+ extras_require={
54
+ 'dev': ['pytest>=3.9'],
55
+ 'headless': ['opencv-python-headless'],
56
+ 'full': ['opencv-python'],
57
+ },
58
+ classifiers=[
59
+ "Programming Language :: Python :: 3",
60
+ "License :: OSI Approved :: MIT License",
61
+ "Operating System :: OS Independent",
62
+ ]
63
+ )
@@ -11,9 +11,11 @@ from . import timelapse
11
11
  from . import train
12
12
  from . import mask_app
13
13
  from . import annotate_app
14
+ from . import graph_learning
14
15
  from . import gui_utils
15
16
  from . import gui_mask_app
16
17
  from . import gui_measure_app
18
+ from . import gui_classify_app
17
19
  from . import logger
18
20
 
19
21
  __all__ = [
@@ -26,10 +28,12 @@ __all__ = [
26
28
  "timelapse",
27
29
  "train",
28
30
  "annotate_app",
31
+ "graph_learning",
29
32
  "gui_utils",
30
33
  "mask_app",
31
34
  "gui_mask_app",
32
35
  "gui_measure_app",
36
+ "gui_classify_app",
33
37
  "logger"
34
38
  ]
35
39
 
@@ -0,0 +1,18 @@
1
+ def gui_mask():
2
+ from .cli import get_arg_parser
3
+ from .version import version_str
4
+
5
+ args = get_arg_parser().parse_args()
6
+
7
+ if args.version:
8
+ print(version_str)
9
+ return
10
+
11
+ if args.headless:
12
+ settings = {}
13
+ spacr.core.preprocess_generate_masks(settings['src'], settings=settings, advanced_settings={})
14
+ return
15
+
16
+ global vars_dict, root
17
+ root, vars_dict = initiate_mask_root(1000, 1500)
18
+ root.mainloop()
@@ -0,0 +1,41 @@
1
+ """
2
+ Copyright © 2023 Howard Hughes Medical Institute, Authored by Carsen Stringer and Marius Pachitariu and Michael Rariden.
3
+ """
4
+
5
+ import argparse
6
+
7
+ import argparse
8
+
9
+
10
+ def get_arg_parser():
11
+ """ Parses command line arguments for spacr main functions
12
+
13
+ Note: this function has to be in a separate file to allow autodoc to work for CLI.
14
+ The autodoc_mock_imports in conf.py does not work for sphinx-argparse sometimes,
15
+ see https://github.com/ashb/sphinx-argparse/issues/9#issue-1097057823
16
+ """
17
+
18
+ parser = argparse.ArgumentParser(description="SPACR Mask App Command Line Parameters")
19
+ hardware_args = parser.add_argument_group("Hardware Arguments")
20
+ input_img_args = parser.add_argument_group("Input Image Arguments")
21
+ #model_args = parser.add_argument_group("Model Arguments")
22
+ #algorithm_args = parser.add_argument_group("Algorithm Arguments")
23
+ #training_args = parser.add_argument_group("Training Arguments")
24
+ #output_args = parser.add_argument_group("Output Arguments")
25
+
26
+ # misc settings
27
+ parser.add_argument("--version", action="store_true",
28
+ help="show version info")
29
+ # misc settings
30
+ parser.add_argument("--headless", action="store_true",
31
+ help="run the app without the gui")
32
+
33
+ parser.add_argument("--verbose", action="store_true",
34
+ help="show information about running and settings and save to log")
35
+
36
+ hardware_args.add_argument("--gpu_device", required=False, default="0", type=str,
37
+ help="which gpu device to use, use an integer for torch, or mps for M1")
38
+
39
+ input_img_args.add_argument("--src", default=[], type=str,
40
+ help="folder containing data to run or train on.")
41
+ return parser