spacr 0.0.1__py3-none-any.whl → 0.0.2__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 CHANGED
@@ -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
 
spacr/alpha.py ADDED
@@ -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()
spacr/cli.py CHANGED
@@ -4,200 +4,38 @@ Copyright © 2023 Howard Hughes Medical Institute, Authored by Carsen Stringer a
4
4
 
5
5
  import argparse
6
6
 
7
+ import argparse
8
+
7
9
 
8
10
  def get_arg_parser():
9
- """ Parses command line arguments for cellpose main function
11
+ """ Parses command line arguments for spacr main functions
10
12
 
11
13
  Note: this function has to be in a separate file to allow autodoc to work for CLI.
12
14
  The autodoc_mock_imports in conf.py does not work for sphinx-argparse sometimes,
13
15
  see https://github.com/ashb/sphinx-argparse/issues/9#issue-1097057823
14
16
  """
15
-
16
- parser = argparse.ArgumentParser(description="Cellpose Command Line Parameters")
17
-
18
- # misc settings
19
- parser.add_argument("--version", action="store_true",
20
- help="show cellpose version info")
21
- parser.add_argument(
22
- "--verbose", action="store_true",
23
- help="show information about running and settings and save to log")
24
- parser.add_argument("--Zstack", action="store_true", help="run GUI in 3D mode")
25
-
26
- # settings for CPU vs GPU
17
+
18
+ parser = argparse.ArgumentParser(description="SPACR Mask App Command Line Parameters")
27
19
  hardware_args = parser.add_argument_group("Hardware Arguments")
28
- hardware_args.add_argument("--use_gpu", action="store_true",
29
- help="use gpu if torch with cuda installed")
30
- hardware_args.add_argument(
31
- "--gpu_device", required=False, default="0", type=str,
32
- help="which gpu device to use, use an integer for torch, or mps for M1")
33
- hardware_args.add_argument("--check_mkl", action="store_true",
34
- help="check if mkl working")
35
-
36
- # settings for locating and formatting images
37
20
  input_img_args = parser.add_argument_group("Input Image Arguments")
38
- input_img_args.add_argument("--dir", default=[], type=str,
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,
39
40
  help="folder containing data to run or train on.")
40
- input_img_args.add_argument(
41
- "--image_path", default=[], type=str, help=
42
- "if given and --dir not given, run on single image instead of folder (cannot train with this option)"
43
- )
44
- input_img_args.add_argument(
45
- "--look_one_level_down", action="store_true",
46
- help="run processing on all subdirectories of current folder")
47
- input_img_args.add_argument("--img_filter", default=[], type=str,
48
- help="end string for images to run on")
49
- input_img_args.add_argument(
50
- "--channel_axis", default=None, type=int,
51
- help="axis of image which corresponds to image channels")
52
- input_img_args.add_argument("--z_axis", default=None, type=int,
53
- help="axis of image which corresponds to Z dimension")
54
- input_img_args.add_argument(
55
- "--chan", default=0, type=int, help=
56
- "channel to segment; 0: GRAY, 1: RED, 2: GREEN, 3: BLUE. Default: %(default)s")
57
- input_img_args.add_argument(
58
- "--chan2", default=0, type=int, help=
59
- "nuclear channel (if cyto, optional); 0: NONE, 1: RED, 2: GREEN, 3: BLUE. Default: %(default)s"
60
- )
61
- input_img_args.add_argument("--invert", action="store_true",
62
- help="invert grayscale channel")
63
- input_img_args.add_argument(
64
- "--all_channels", action="store_true", help=
65
- "use all channels in image if using own model and images with special channels")
66
-
67
- # model settings
68
- model_args = parser.add_argument_group("Model Arguments")
69
- model_args.add_argument("--pretrained_model", required=False, default="cyto",
70
- type=str,
71
- help="model to use for running or starting training")
72
- model_args.add_argument("--restore_type", required=False, default=None,
73
- type=str,
74
- help="model to use for image restoration")
75
- model_args.add_argument("--chan2_restore", action="store_true",
76
- help="use nuclei restore model for second channel")
77
- model_args.add_argument(
78
- "--add_model", required=False, default=None, type=str,
79
- help="model path to copy model to hidden .cellpose folder for using in GUI/CLI")
80
-
81
- # algorithm settings
82
- algorithm_args = parser.add_argument_group("Algorithm Arguments")
83
- algorithm_args.add_argument(
84
- "--no_resample", action="store_true", help=
85
- "disable dynamics on full image (makes algorithm faster for images with large diameters)"
86
- )
87
- algorithm_args.add_argument(
88
- "--no_interp", action="store_true",
89
- help="do not interpolate when running dynamics (was default)")
90
- algorithm_args.add_argument("--no_norm", action="store_true",
91
- help="do not normalize images (normalize=False)")
92
- algorithm_args.add_argument(
93
- "--do_3D", action="store_true",
94
- help="process images as 3D stacks of images (nplanes x nchan x Ly x Lx")
95
- algorithm_args.add_argument(
96
- "--diameter", required=False, default=30., type=float, help=
97
- "cell diameter, if 0 will use the diameter of the training labels used in the model, or with built-in model will estimate diameter for each image"
98
- )
99
- algorithm_args.add_argument(
100
- "--stitch_threshold", required=False, default=0.0, type=float,
101
- help="compute masks in 2D then stitch together masks with IoU>0.9 across planes"
102
- )
103
- algorithm_args.add_argument(
104
- "--min_size", required=False, default=15, type=int,
105
- help="minimum number of pixels per mask, can turn off with -1")
106
-
107
- algorithm_args.add_argument(
108
- "--flow_threshold", default=0.4, type=float, help=
109
- "flow error threshold, 0 turns off this optional QC step. Default: %(default)s")
110
- algorithm_args.add_argument(
111
- "--cellprob_threshold", default=0, type=float,
112
- help="cellprob threshold, default is 0, decrease to find more and larger masks")
113
- algorithm_args.add_argument(
114
- "--niter", default=0, type=int,
115
- help="niter, number of iterations for dynamics for mask creation, default of 0 means it is proportional to diameter, set to a larger number like 2000 for very long ROIs")
116
-
117
- algorithm_args.add_argument("--anisotropy", required=False, default=1.0, type=float,
118
- help="anisotropy of volume in 3D")
119
- algorithm_args.add_argument("--exclude_on_edges", action="store_true",
120
- help="discard masks which touch edges of image")
121
- algorithm_args.add_argument(
122
- "--augment", action="store_true",
123
- help="tiles image with overlapping tiles and flips overlapped regions to augment"
124
- )
125
-
126
- # output settings
127
- output_args = parser.add_argument_group("Output Arguments")
128
- output_args.add_argument(
129
- "--save_png", action="store_true",
130
- help="save masks as png and outlines as text file for ImageJ")
131
- output_args.add_argument(
132
- "--save_tif", action="store_true",
133
- help="save masks as tif and outlines as text file for ImageJ")
134
- output_args.add_argument("--no_npy", action="store_true",
135
- help="suppress saving of npy")
136
- output_args.add_argument(
137
- "--savedir", default=None, type=str, help=
138
- "folder to which segmentation results will be saved (defaults to input image directory)"
139
- )
140
- output_args.add_argument(
141
- "--dir_above", action="store_true", help=
142
- "save output folders adjacent to image folder instead of inside it (off by default)"
143
- )
144
- output_args.add_argument("--in_folders", action="store_true",
145
- help="flag to save output in folders (off by default)")
146
- output_args.add_argument(
147
- "--save_flows", action="store_true", help=
148
- "whether or not to save RGB images of flows when masks are saved (disabled by default)"
149
- )
150
- output_args.add_argument(
151
- "--save_outlines", action="store_true", help=
152
- "whether or not to save RGB outline images when masks are saved (disabled by default)"
153
- )
154
- output_args.add_argument(
155
- "--save_rois", action="store_true",
156
- help="whether or not to save ImageJ compatible ROI archive (disabled by default)"
157
- )
158
- output_args.add_argument(
159
- "--save_txt", action="store_true",
160
- help="flag to enable txt outlines for ImageJ (disabled by default)")
161
- output_args.add_argument(
162
- "--save_mpl", action="store_true",
163
- help="save a figure of image/mask/flows using matplotlib (disabled by default). "
164
- "This is slow, especially with large images.")
165
-
166
- # training settings
167
- training_args = parser.add_argument_group("Training Arguments")
168
- training_args.add_argument("--train", action="store_true",
169
- help="train network using images in dir")
170
- training_args.add_argument("--train_size", action="store_true",
171
- help="train size network at end of training")
172
- training_args.add_argument("--test_dir", default=[], type=str,
173
- help="folder containing test data (optional)")
174
- training_args.add_argument(
175
- "--mask_filter", default="_masks", type=str, help=
176
- "end string for masks to run on. use '_seg.npy' for manual annotations from the GUI. Default: %(default)s"
177
- )
178
- training_args.add_argument(
179
- "--diam_mean", default=30., type=float, help=
180
- "mean diameter to resize cells to during training -- if starting from pretrained models it cannot be changed from 30.0"
181
- )
182
- training_args.add_argument("--learning_rate", default=0.2, type=float,
183
- help="learning rate. Default: %(default)s")
184
- training_args.add_argument("--weight_decay", default=0.00001, type=float,
185
- help="weight decay. Default: %(default)s")
186
- training_args.add_argument("--n_epochs", default=500, type=int,
187
- help="number of epochs. Default: %(default)s")
188
- training_args.add_argument("--batch_size", default=8, type=int,
189
- help="batch size. Default: %(default)s")
190
- training_args.add_argument(
191
- "--min_train_masks", default=5, type=int, help=
192
- "minimum number of masks a training image must have to be used. Default: %(default)s"
193
- )
194
- training_args.add_argument("--SGD", default=1, type=int, help="use SGD")
195
- training_args.add_argument(
196
- "--save_every", default=100, type=int,
197
- help="number of epochs to skip between saves. Default: %(default)s")
198
- training_args.add_argument(
199
- "--model_name_out", default=None, type=str,
200
- help="Name of model to save as, defaults to name describing model architecture. "
201
- "Model is saved in the folder specified by --dir in models subfolder.")
202
-
203
- return parser
41
+ return parser