Skip to content

Commit

Permalink
Fix issue where moosez breaks if a 'moosez' prefixed folder exists as…
Browse files Browse the repository at this point in the history
… the subject was already processed and segmentations exist.

Before this change, running `moosez` would fail if there was already a folder with a name starting with 'moosez'. This commit makes `moosez` ignore such folders, allowing multiple models to run sequentially without manual folder cleanup.

This patch allows commands like the following to be run one after another without any issues:
- `moosez -d path_to_dir -m your_model_1`
- `moosez -d path_to_dir -m your_model_2`
  • Loading branch information
LalithShiyam committed Oct 17, 2023
1 parent d5f4bec commit 13981b2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions moosez/image_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,10 @@ def standardize_to_nifti(parent_dir: str) -> None:
if os.path.isdir(subject_path):
images = os.listdir(subject_path)
for image in images:
if os.path.isdir(os.path.join(subject_path, image)):
image_path = os.path.join(subject_path, image)
non_nifti_to_nifti(image_path)
elif os.path.isfile(os.path.join(subject_path, image)):
image_path = os.path.join(subject_path, image)
image_path = os.path.join(subject_path, image)
path_is_valid = os.path.isdir(image_path) | os.path.isfile(image_path)
path_is_valid = path_is_valid & ("moosez" not in os.path.basename(image_path))
if path_is_valid:
non_nifti_to_nifti(image_path)
else:
continue
Expand Down

0 comments on commit 13981b2

Please sign in to comment.