Skip to content

Commit

Permalink
save segmentations arg
Browse files Browse the repository at this point in the history
  • Loading branch information
louisblankemeier committed Sep 25, 2023
1 parent 5784cb7 commit 987791a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions bin/C2C
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def argument_parser():
base_parser = argparse.ArgumentParser(add_help=False)
base_parser.add_argument("--input_path", "-i", type=str, required=True)
base_parser.add_argument("--output_path", "-o", type=str)
base_parser.add_argument("--save_segmentations", action="store_true")
base_parser.add_argument("--overwrite_outputs", action="store_true")

parser = argparse.ArgumentParser()
Expand Down
10 changes: 8 additions & 2 deletions comp2comp/utils/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from datetime import datetime
from pathlib import Path
from time import time
import shutil

from comp2comp.io.io_utils import get_dicom_or_nifti_paths_and_num

Expand Down Expand Up @@ -97,11 +98,16 @@ def process_3d(args, pipeline_builder):

pipeline(output_dir=output_dir, model_dir=model_dir)


if not args.save_segmentations:
# remove the segmentations folder
segmentations_dir = os.path.join(output_dir, "segmentations")
if os.path.exists(segmentations_dir):
shutil.rmtree(segmentations_dir)

print(f"Finished processing {path} in {time() - st:.1f} seconds\n")

except Exception:
print(f"ERROR PROCESSING {path}\n")
traceback.print_exc()
# if os.path.exists(output_dir):
# shutil.rmtree(output_dir)
continue

0 comments on commit 987791a

Please sign in to comment.