Skip to content

Commit a7442c8

Browse files
Merge branch 'main' of https://github.com/TheBestDestroyer/cellpose into TheBestDestroyer-main
2 parents 3d95187 + 26710f6 commit a7442c8

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

cellpose/__main__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ def main():
108108
default_model = "cyto3"
109109
backbone = "default"
110110

111+
if args.norm_percentile is not None:
112+
value1, value2 = args.norm_percentile
113+
normalize = {'percentile': (float(value1), float(value2))}
114+
else:
115+
normalize = (not args.no_norm)
116+
117+
111118
model_type = None
112119
if pretrained_model and not os.path.exists(pretrained_model):
113120
model_type = pretrained_model if pretrained_model is not None else "cyto3"
@@ -209,7 +216,7 @@ def main():
209216
cellprob_threshold=args.cellprob_threshold,
210217
stitch_threshold=args.stitch_threshold, min_size=args.min_size,
211218
invert=args.invert, batch_size=args.batch_size,
212-
interp=(not args.no_interp), normalize=(not args.no_norm),
219+
interp=(not args.no_interp), normalize=normalize,
213220
channel_axis=args.channel_axis, z_axis=args.z_axis,
214221
anisotropy=args.anisotropy, niter=args.niter,
215222
dP_smooth=args.dP_smooth)
@@ -303,7 +310,7 @@ def main():
303310
test_data=test_images, test_labels=test_labels,
304311
test_files=image_names_test, train_probs=train_probs,
305312
test_probs=test_probs, compute_flows=compute_flows,
306-
load_files=load_files, normalize=(not args.no_norm),
313+
load_files=load_files, normalize=normalize,
307314
channels=channels, channel_axis=args.channel_axis, rgb=(nchan == 3),
308315
learning_rate=args.learning_rate, weight_decay=args.weight_decay,
309316
SGD=args.SGD, n_epochs=args.n_epochs, batch_size=args.batch_size,
@@ -327,7 +334,7 @@ def main():
327334
load_files=load_files, channels=channels,
328335
min_train_masks=args.min_train_masks,
329336
channel_axis=args.channel_axis, rgb=(nchan == 3),
330-
nimg_per_epoch=args.nimg_per_epoch, normalize=(not args.no_norm),
337+
nimg_per_epoch=args.nimg_per_epoch, normalize=normalize,
331338
nimg_test_per_epoch=args.nimg_test_per_epoch,
332339
batch_size=args.batch_size)
333340
if test_images is not None:

cellpose/cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ def get_arg_parser():
9494
help="do not interpolate when running dynamics (was default)")
9595
algorithm_args.add_argument("--no_norm", action="store_true",
9696
help="do not normalize images (normalize=False)")
97+
parser.add_argument(
98+
'--norm_percentile',
99+
nargs=2, # Require exactly two values
100+
metavar=('VALUE1', 'VALUE2'),
101+
help="Provide two float values to set norm_percentile (e.g., --norm_percentile 1 99)"
102+
)
97103
algorithm_args.add_argument(
98104
"--do_3D", action="store_true",
99105
help="process images as 3D stacks of images (nplanes x nchan x Ly x Lx")

0 commit comments

Comments
 (0)