diff --git a/clinica/iotools/bids_utils.py b/clinica/iotools/bids_utils.py index 19ec84547..324ef4571 100644 --- a/clinica/iotools/bids_utils.py +++ b/clinica/iotools/bids_utils.py @@ -292,7 +292,7 @@ def from_original_study_id(cls, study_id: str) -> str: ) def to_original_study_id(self) -> str: - return str(self.replace("sub-HABS", "P_")) + return str(self).replace("sub-HABS", "P_") class IXIBIDSSubjectID(BIDSSubjectID): @@ -317,7 +317,7 @@ def from_original_study_id(cls, study_id: str) -> str: ) def to_original_study_id(self) -> str: - return str(self.replace("sub-", "")) + return str(self).replace("sub-", "") # -- Methods for the clinical data -- diff --git a/test/unittests/iotools/test_bids_utils.py b/test/unittests/iotools/test_bids_utils.py index f39bdef63..a26dbe03b 100644 --- a/test/unittests/iotools/test_bids_utils.py +++ b/test/unittests/iotools/test_bids_utils.py @@ -93,7 +93,7 @@ def test_study_to_bids_id_value_error(study, study_id): @pytest.mark.parametrize( - "study,expected,bids_id", + "study,source_id,bids_id", [ (StudyName.ADNI, "001_S_0001", "sub-ADNI001S0001"), (StudyName.NIFD, "1_S_0001", "sub-NIFD1S0001"), @@ -106,10 +106,10 @@ def test_study_to_bids_id_value_error(study, study_id): (StudyName.IXI, "IXI001", "sub-IXI001"), ], ) -def test_bids_to_study(study, bids_id, expected): +def test_bids_to_study(study, bids_id, source_id): from clinica.iotools.bids_utils import bids_id_factory - assert bids_id_factory(study).to_original_study_id(bids_id) == expected + assert bids_id_factory(study)(bids_id).to_original_study_id() == source_id def create_clinical_data(tmp_path: Path, study_name: StudyName) -> Path: