From edada14774a9f93b70d784f4558a828ab417148b Mon Sep 17 00:00:00 2001 From: gurayerus <54039606+gurayerus@users.noreply.github.com> Date: Thu, 10 Oct 2024 17:14:11 -0400 Subject: [PATCH 1/2] Bug fix in reading nifti list The code for checking type of nifti files was failing due to a bug. It was written for a single extension given as str, not a list --- NiChart_DLMUSE/utils.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/NiChart_DLMUSE/utils.py b/NiChart_DLMUSE/utils.py index be618f4..c353768 100644 --- a/NiChart_DLMUSE/utils.py +++ b/NiChart_DLMUSE/utils.py @@ -92,11 +92,14 @@ def make_img_list(in_data: str) -> pd.DataFrame: else: with open(in_data, "r") as file: lines = file.readlines() - nii_files = [ - os.path.abspath(line.strip()) - for line in lines - if line.strip().endswith(LIST_IMG_EXT) # type:ignore - ] + nii_files = [] + for line in lines: + is_nifti = False + for tmp_ext in LIST_IMG_EXT: + if line.strip().endswith(tmp_ext): + is_nifti = True + if is_nifti == True: + nii_files.append(os.path.abspath(line.strip())) nii_files = np.array(nii_files) print(f"Detected {nii_files.shape[0]} images ...") # type:ignore From d9d04099993740fb63657d107445aefbb91b3fff Mon Sep 17 00:00:00 2001 From: Spiros Maggioros Date: Fri, 11 Oct 2024 12:25:08 +0300 Subject: [PATCH 2/2] Fixed pre-commit --- NiChart_DLMUSE/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NiChart_DLMUSE/utils.py b/NiChart_DLMUSE/utils.py index c353768..1888c8d 100644 --- a/NiChart_DLMUSE/utils.py +++ b/NiChart_DLMUSE/utils.py @@ -98,7 +98,7 @@ def make_img_list(in_data: str) -> pd.DataFrame: for tmp_ext in LIST_IMG_EXT: if line.strip().endswith(tmp_ext): is_nifti = True - if is_nifti == True: + if is_nifti is True: nii_files.append(os.path.abspath(line.strip())) nii_files = np.array(nii_files)