Skip to content

Commit

Permalink
Fix wrong implementation of overwriting existing predictions (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
HangJung97 authored Feb 21, 2024
1 parent cf3df50 commit 21fa46b
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions ascent/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,21 @@ def check_input_folder_and_return_datalist(

# check if potential output files already existed in the output folder and remove the existing
# case ids from datalist
if overwrite_existing:
if not overwrite_existing:
if os.listdir(output_folder):
output_files = subfiles(output_folder, suffix=".nii.gz", join=False, sort=True)
if output_files:
existing_case_ids = [case[:-7] for case in output_files]
for case in existing_case_ids:
if case in maybe_case_ids:
index = np.argwhere(maybe_case_ids == case)
maybe_case_ids = np.delete(maybe_case_ids, index)
if "inference_raw" in os.listdir(output_folder):
output_files = subfiles(
os.path.join(output_folder, "inference_raw"),
suffix=".nii.gz",
join=False,
sort=True,
)
if output_files:
existing_case_ids = [case[:-7] for case in output_files]
for case in existing_case_ids:
if case in maybe_case_ids:
index = np.argwhere(maybe_case_ids == case)
maybe_case_ids = np.delete(maybe_case_ids, index)

all_files = subfiles(input_folder, suffix=".nii.gz", join=False, sort=True)
list_of_lists = [
Expand Down

0 comments on commit 21fa46b

Please sign in to comment.