diff --git a/clinica/pipelines/t1_linear/anat_linear_utils.py b/clinica/pipelines/t1_linear/anat_linear_utils.py index 61a9879a2..1aafbd605 100644 --- a/clinica/pipelines/t1_linear/anat_linear_utils.py +++ b/clinica/pipelines/t1_linear/anat_linear_utils.py @@ -32,7 +32,13 @@ def _get_substitutions_datasink(bids_image_id: str, suffix: str) -> list: substitutions : List of tuples of str List of length 3 containing the substitutions to perform. """ - bids_image_id_without_suffix = bids_image_id.rstrip(f"_{suffix}") + # TODO: Use str.removesuffix once Python 3.8 compatibility is dropped. + if bids_image_id.endswith(f"_{suffix}"): + bids_image_id_without_suffix = bids_image_id[: -(len(suffix) + 1)] + else: + raise ValueError( + f"bids image ID {bids_image_id} should end with provided {suffix}." + ) return [ ( f"{bids_image_id}Warped_cropped.nii.gz",