Skip to content

Commit

Permalink
Add test for handling pet images registered on T1w image
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasGensollen committed Dec 3, 2024
1 parent 830b4ac commit 10bce0a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
9 changes: 9 additions & 0 deletions clinica/utils/testing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,15 @@ def _build_pet_linear(directory: Path, sub: str, ses: str, config: dict) -> None

tracer = Tracer(config["acq_label"])
suvr = SUVRReferenceRegion(config["suvr_reference_region"])
if config.get("save_PETinT1w", False):
(
directory
/ "subjects"
/ sub
/ ses
/ "pet_linear"
/ f"{sub}_{ses}_trc-{tracer.value}_pet_space-T1w_pet.nii.gz"
).touch()
for filename in (
f"{sub}_{ses}_trc-{tracer.value}_pet_space-MNI152NLin2009cSym_desc-Crop_res-1x1x1_suvr-{suvr.value}_pet.nii.gz",
f"{sub}_{ses}_trc-{tracer.value}_pet_space-T1w_rigid.mat",
Expand Down
23 changes: 23 additions & 0 deletions test/unittests/pipelines/pet/test_pet_linear_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def test_pet_linear_get_processed_visits(tmp_path, mocker):
├── ses-M000
│ └── pet_linear
│ ├── sub-02_ses-M000_trc-18FFDG_pet_space-MNI152NLin2009cSym_desc-Crop_res-1x1x1_suvr-pons_pet.nii.gz
│ ├── sub-02_ses-M000_trc-18FFDG_pet_space-T1w_pet.nii.gz
│ └── sub-02_ses-M000_trc-18FFDG_pet_space-T1w_rigid.mat
└── ses-M006
└── pet_linear
Expand Down Expand Up @@ -116,6 +117,7 @@ def test_pet_linear_get_processed_visits(tmp_path, mocker):
"acq_label": Tracer.FDG,
"suvr_reference_region": SUVRReferenceRegion.PONS,
"uncropped_image": False,
"save_PETinT1w": True,
}
},
"subjects": {
Expand All @@ -140,6 +142,26 @@ def test_pet_linear_get_processed_visits(tmp_path, mocker):
},
},
)
# We remove the pet image registered on the T1w image for sub-01 and session M006
(
caps
/ "subjects"
/ "sub-01"
/ "ses-M006"
/ "pet_linear"
/ "sub-01_ses-M006_trc-18FFDG_pet_space-T1w_pet.nii.gz"
).unlink()
pipeline = PETLinear(
bids_directory=str(bids),
caps_directory=str(caps),
parameters={
"acq_label": Tracer.FDG,
"suvr_reference_region": SUVRReferenceRegion.PONS,
"uncropped_image": False,
"save_PETinT1w": True,
},
)
assert pipeline.get_processed_visits() == [Visit("sub-02", "ses-M000")]

pipeline = PETLinear(
bids_directory=str(bids),
Expand All @@ -148,6 +170,7 @@ def test_pet_linear_get_processed_visits(tmp_path, mocker):
"acq_label": Tracer.FDG,
"suvr_reference_region": SUVRReferenceRegion.PONS,
"uncropped_image": False,
"save_PETinT1w": False,
},
)

Expand Down

0 comments on commit 10bce0a

Please sign in to comment.