We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b5bfe4a commit 33838a3Copy full SHA for 33838a3
2 files changed
src/rbc/core/utils.py
@@ -47,11 +47,10 @@ def get_base_entities(
47
48
def rename(in_file: str | Path, new_name: str | Path) -> Path:
49
"""Rename a file, keeping it in the same directory."""
50
- in_file = Path(in_file)
51
- new_path = in_file.with_name(Path(new_name).name)
52
- if new_path.exists():
53
- raise FileExistsError(f"Target file already exists: {new_path}")
54
- return in_file.rename(new_path)
+ target = in_file.with_name(new_name)
+ if in_file == target:
+ return in_file
+ return Path(shutil.move(str(in_file), str(target)))
55
56
def save_directory(in_dir: str | Path, out_dir: str | Path, name: str) -> Path:
57
"""Save a directory by copying it to a new location.
src/rbc/workflows/functional.py
@@ -56,7 +56,6 @@ def single_session(in_bold: Path, output_dir: Path, start_tr: int = 2) -> None:
(motion_reference.output_file, None, "sbref", ".nii.gz"),
(motion_corrected.bold.with_suffix(".nii.gz"), "motion", "bold", ".nii.gz"),
58
(motion_corrected.par, "motionParams", "motion", ".txt"),
59
- (motion_corrected.par, "movementParameters", "motion", ".1D"),
60
(motion_corrected.rms_rel, "relsDisplacement", "motion", ".rms"),
61
(motion_corrected.rms_abs, "maxDisplacement", "motion", ".rms"),
62
]
@@ -71,7 +70,7 @@ def single_session(in_bold: Path, output_dir: Path, start_tr: int = 2) -> None:
71
70
rename(
72
out_file,
73
bids(desc=desc, suffix=suffix, ext=ext)
74
- if desc
+ if desc is not None
75
else bids(suffix=suffix, ext=ext),
76
)
77
for out_file, desc, suffix, ext in outputs
0 commit comments