diff --git a/totalsegmentator/config.py b/totalsegmentator/config.py index eed6dae9e..d9d4739b3 100644 --- a/totalsegmentator/config.py +++ b/totalsegmentator/config.py @@ -59,6 +59,7 @@ def increase_prediction_counter(): config = json.load(open(totalseg_config_file, "r")) config["prediction_counter"] += 1 json.dump(config, open(totalseg_config_file, "w"), indent=4) + return config def get_version(): @@ -69,7 +70,7 @@ def get_version(): def send_usage_stats(config, params): - if config["send_usage_stats"]: + if config is not None and config["send_usage_stats"]: params["roi_subset"] = "" if params["roi_subset"] is None else "-".join(params["roi_subset"]) diff --git a/totalsegmentator/python_api.py b/totalsegmentator/python_api.py index 225542f7e..6d21d08a0 100644 --- a/totalsegmentator/python_api.py +++ b/totalsegmentator/python_api.py @@ -212,8 +212,8 @@ def totalsegmentator(input, output, ml=False, nr_thr_resamp=1, nr_thr_saving=6, quiet=quiet, verbose=verbose, test=test, skip_saving=skip_saving) seg = seg_img.get_fdata().astype(np.uint8) - config = setup_totalseg() - increase_prediction_counter() + setup_totalseg() + config = increase_prediction_counter() send_usage_stats(config, {"task": task, "fast": fast, "preview": preview, "multilabel": ml, "roi_subset": roi_subset, "statistics": statistics, "radiomics": radiomics})