Skip to content

Commit

Permalink
Trying to fix dir problems again
Browse files Browse the repository at this point in the history
  • Loading branch information
spirosmaggioros committed Oct 11, 2024
1 parent 80d9624 commit b6cdb90
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 483 deletions.
30 changes: 12 additions & 18 deletions NiChart_DLMUSE/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,26 +124,20 @@ def main() -> None:
no_threads = args.cores # for now
subfolders = split_data(in_data, no_threads)

threads = []
for i in range(len(subfolders)):
##threads = []
##for i in range(len(subfolders)):
## curr_out_dir = out_dir + f"split_{i}"
## curr_thread = threading.Thread(
## target=run_pipeline, args=(subfolders[i], curr_out_dir, device)
## )
## curr_thread.start()
## threads.append(curr_thread)

##for t in threads:
## t.join()

if out_dir[len(out_dir) - 1] != '/':
# This is because sometimes users don't enter the dir
# like this: "output/" but like this "output"
out_dir += '/'

curr_out_dir = out_dir + f"split_{i}"
curr_thread = threading.Thread(
target=run_pipeline, args=(subfolders[i], curr_out_dir, device)
)
curr_thread.start()
threads.append(curr_thread)

for t in threads:
t.join()

remove_subfolders(in_data)
merge_output_data(out_dir)
remove_subfolders(in_data)

if __name__ == "__main__":
main()
17 changes: 8 additions & 9 deletions NiChart_DLMUSE/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def split_data(in_dir: str, N: int) -> list:


def remove_subfolders(in_dir: str) -> None:
os.system(f"rm -r {in_dir}/split_*")
os.system(f"rm -r {in_dir}split_*")

def merge_output_data(in_dir: str) -> None:
os.system(f"mkdir {in_dir}results")
Expand All @@ -181,14 +181,13 @@ def merge_output_data(in_dir: str) -> None:
os.system(f"mkdir {in_dir}results/s6_combined")

for dir in os.listdir(in_dir):
os.system(f"mv {in_dir}{dir}/s1_reorient_lps/* {in_dir}results/s1_reorient_lps/")
os.system(f"mv {in_dir}{dir}/s2_dlicv/* {in_dir}results/s2_dlicv/")
os.system(f"mv {in_dir}{dir}/s3_masked/* {in_dir}results/s3_masked/")
os.system(f"mv {in_dir}{dir}/s4_dlmuse/* {in_dir}results/s4_dlmuse/")
os.system(f"mv {in_dir}{dir}/s5_relabeled/* {in_dir}results/s5_relabeled/")
os.system(f"mv {in_dir}{dir}/s6_combined/* {in_dir}results/s6_combined/")

os.system(f"mv {in_dir}*.nii.gz {in_dir}results/")
os.system(f"mv {in_dir}{dir}/temp_working_dir/s1_reorient_lps/* {in_dir}results/s1_reorient_lps/")
os.system(f"mv {in_dir}{dir}/temp_working_dir/s2_dlicv/* {in_dir}results/s2_dlicv/")
os.system(f"mv {in_dir}{dir}/temp_working_dir/s3_masked/* {in_dir}results/s3_masked/")
os.system(f"mv {in_dir}{dir}/temp_working_dir/s4_dlmuse/* {in_dir}results/s4_dlmuse/")
os.system(f"mv {in_dir}{dir}/temp_working_dir/s5_relabeled/* {in_dir}results/s5_relabeled/")
os.system(f"mv {in_dir}{dir}/temp_working_dir/s6_combined/* {in_dir}results/s6_combined/")
os.system(f"mv {in_dir}*.nii.gz {in_dir}results/")

for dir in os.listdir(in_dir):
os.system(f"rm -r {dir}")
File renamed without changes.
File renamed without changes.
11 changes: 0 additions & 11 deletions output/split_2/temp_working_dir/s2_dlicv/dataset.json

This file was deleted.

Loading

0 comments on commit b6cdb90

Please sign in to comment.