diff --git a/cellpose/__main__.py b/cellpose/__main__.py index 03a27d25..38a5ff42 100644 --- a/cellpose/__main__.py +++ b/cellpose/__main__.py @@ -31,7 +31,7 @@ def main(): """ args = get_arg_parser().parse_args( - ) # this has to be in a seperate file for autodoc to work + ) # this has to be in a separate file for autodoc to work if args.version: print(version_str) @@ -240,8 +240,16 @@ def main(): diams=diams, restore_type=restore_type, ratio=1.) if saving_something: - suffix = args.output_name if len(args.output_name) > 0 else "_cp_masks" - io.save_masks(image, masks, flows, image_name, + if args.savedir == None: # (1) If `savedir` is not defined, + if len(args.output_name) > 0: # then must have a non-zero `suffix` + suffix = args.output_name # which takes the value passes as a param., + else: suffix = "_cp_masks" # otherwise is the default value. + else: # (2) If `savedir` is defined, + if args.savedir != args.dir: # and different from `dir` then + suffix = args.output_name # takes the value passed as a param. (which can be empty string), + else: suffix = "_cp_masks" # otherwise is the default value. + + io.save_masks(image, masks, flows, image_name, suffix=suffix, png=args.save_png, tif=args.save_tif, save_flows=args.save_flows, save_outlines=args.save_outlines, diff --git a/cellpose/cli.py b/cellpose/cli.py index 64dec0bb..35987607 100644 --- a/cellpose/cli.py +++ b/cellpose/cli.py @@ -148,7 +148,7 @@ def get_arg_parser(): help="save masks as tif and outlines as text file for ImageJ") output_args.add_argument( "--output_name", default=[], type=str, - help="suffix for saved masks, default is _cp_masks") + help="suffix for saved masks, default is _cp_masks, can be empty if `savedir` used and different of `dir`") output_args.add_argument("--no_npy", action="store_true", help="suppress saving of npy") output_args.add_argument(