Title: Invalid escape sequence \* in glob pattern on line 44 causes SyntaxError in Python 3.12+
Description:
On line 44, the code uses the following glob pattern:
elif any(Path(args.data_dir).glob("*\*.nii.gz")):
The string "*\*.nii.gz" contains an invalid escape sequence \*. In Python versions prior to 3.12, this would raise a DeprecationWarning, but starting in Python 3.12, it raises a SyntaxError because \* is not a valid escape sequence.
This breaks compatibility with modern Python versions.
Suggested Fix:
Use rglob for recursive matching (which is likely the intended behavior), or use forward slashes with proper glob syntax:
✅ Recommended:
elif any(Path(args.data_dir).rglob("*.nii.gz")):
Alternatively (for one-level subdirectories only):
elif any(Path(args.data_dir).glob("*/*.nii.gz")):
Using raw strings (e.g., r"*\*.nii.gz") is not advised here because backslashes are not standard in glob patterns—forward slashes work cross-platform with pathlib.
Please update the pattern to ensure compatibility and correctness.
Title: Invalid escape sequence
\*in glob pattern on line 44 causes SyntaxError in Python 3.12+Description:
On line 44, the code uses the following glob pattern:
The string
"*\*.nii.gz"contains an invalid escape sequence\*. In Python versions prior to 3.12, this would raise aDeprecationWarning, but starting in Python 3.12, it raises aSyntaxErrorbecause\*is not a valid escape sequence.This breaks compatibility with modern Python versions.
Suggested Fix:
Use
rglobfor recursive matching (which is likely the intended behavior), or use forward slashes with proper glob syntax:✅ Recommended:
Alternatively (for one-level subdirectories only):
Using raw strings (e.g.,
r"*\*.nii.gz") is not advised here because backslashes are not standard in glob patterns—forward slashes work cross-platform withpathlib.Please update the pattern to ensure compatibility and correctness.