From ceb092ca30c0f4051ff30a96966e5173648d279e Mon Sep 17 00:00:00 2001 From: Spiros Maggioros Date: Fri, 1 Nov 2024 21:19:53 +0200 Subject: [PATCH] Forgot os.listdir to traverse --- NiChart_DLMUSE/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NiChart_DLMUSE/utils.py b/NiChart_DLMUSE/utils.py index 78f24f3..1fdb6b9 100644 --- a/NiChart_DLMUSE/utils.py +++ b/NiChart_DLMUSE/utils.py @@ -146,6 +146,8 @@ def get_bids_prefix(filename: str, folder: bool = False) -> str: while char != checker: prefix += char idx += 1 + if idx >= len(filename): + break char = filename[idx] return prefix @@ -208,7 +210,7 @@ def merge_bids_output_data(out_data: str) -> None: for split in os.listdir(out_data): if get_bids_prefix(split, True) == "split": s5_relabeled_dir = os.path.join(out_data, split, "temp_working_dir", "s5_relabeled") - for img in s5_relabeled_dir: + for img in os.listdir(s5_relabeled_dir): os.system(f"mv {s5_relabeled_dir}/{img} {out_data}/{get_bids_prefix(img)}/anat/") def split_data(in_dir: str, N: int) -> list: