Skip to content

Commit 33838a3

Browse files
committed
fix rename in utils and keep only txt params file
1 parent b5bfe4a commit 33838a3

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

src/rbc/core/utils.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,10 @@ def get_base_entities(
4747

4848
def rename(in_file: str | Path, new_name: str | Path) -> Path:
4949
"""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)
50+
target = in_file.with_name(new_name)
51+
if in_file == target:
52+
return in_file
53+
return Path(shutil.move(str(in_file), str(target)))
5554

5655
def save_directory(in_dir: str | Path, out_dir: str | Path, name: str) -> Path:
5756
"""Save a directory by copying it to a new location.

src/rbc/workflows/functional.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def single_session(in_bold: Path, output_dir: Path, start_tr: int = 2) -> None:
5656
(motion_reference.output_file, None, "sbref", ".nii.gz"),
5757
(motion_corrected.bold.with_suffix(".nii.gz"), "motion", "bold", ".nii.gz"),
5858
(motion_corrected.par, "motionParams", "motion", ".txt"),
59-
(motion_corrected.par, "movementParameters", "motion", ".1D"),
6059
(motion_corrected.rms_rel, "relsDisplacement", "motion", ".rms"),
6160
(motion_corrected.rms_abs, "maxDisplacement", "motion", ".rms"),
6261
]
@@ -71,7 +70,7 @@ def single_session(in_bold: Path, output_dir: Path, start_tr: int = 2) -> None:
7170
rename(
7271
out_file,
7372
bids(desc=desc, suffix=suffix, ext=ext)
74-
if desc
73+
if desc is not None
7574
else bids(suffix=suffix, ext=ext),
7675
)
7776
for out_file, desc, suffix, ext in outputs

0 commit comments

Comments
 (0)