Skip to content

Commit

Permalink
[FIX] Fix method BIDSubjectID.to_study_id() (aramis-lab#1335)
Browse files Browse the repository at this point in the history
  • Loading branch information
AliceJoubert authored and NicolasGensollen committed Oct 24, 2024
1 parent 7cbc43d commit d6123b3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions clinica/iotools/bids_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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 --
Expand Down
6 changes: 3 additions & 3 deletions test/unittests/iotools/test_bids_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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:
Expand Down

0 comments on commit d6123b3

Please sign in to comment.