From 10ed5668d2d4bdd017d5236d2f141eb4ae3f97fb Mon Sep 17 00:00:00 2001 From: Gensollen Date: Thu, 19 Oct 2023 09:25:16 +0200 Subject: [PATCH] [FIX] Fix bad session labels in `T1Linear` pipeline (#1000) * fix session labels in T1Linear * Update clinica/pipelines/t1_linear/anat_linear_utils.py Co-authored-by: Ghislain Vaillant --------- Co-authored-by: Ghislain Vaillant --- clinica/pipelines/t1_linear/anat_linear_utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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",