generated from ArcanaFramework/fileformats-extension-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
extras/fileformats/extras/medimage/tests/test_deidentify.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import pytest | ||
from fileformats.core.exceptions import FileFormatsExtrasError | ||
from fileformats.medimage import DicomImage, DicomDir, DicomSeries, Nifti1 | ||
from medimages4tests.dummy.dicom.mri.t1w.siemens.skyra.syngo_d13c import ( | ||
get_image as get_dicom_image, | ||
) | ||
from fileformats.medimage import Vnd_Siemens_Biograph128Vision_Vr20b_PetSinogram | ||
|
||
|
||
@pytest.fixture(params=["image", "dir", "series"]) | ||
def dicom(request): | ||
dicom_dir = get_dicom_image(first_name="John", last_name="Doe") | ||
dicom_files = (p for p in dicom_dir.iterdir() if p.suffix == ".dcm") | ||
if request.param == "image": | ||
return DicomImage(next(dicom_files)) | ||
elif request.param == "dir": | ||
return DicomDir(dicom_dir) | ||
else: | ||
return DicomSeries(dicom_files) | ||
|
||
|
||
def test_deidentify_dicom(dicom): | ||
assert str(dicom.metadata["PatientName"]) == "Doe^John" | ||
deidentified = dicom.deidentify() | ||
assert str(deidentified.metadata["PatientName"]) == "Anonymous^Anonymous" | ||
|
||
|
||
def test_nifti_deidentify(): | ||
nifti = Nifti1.sample() | ||
deidentified = nifti.deidentify() | ||
assert nifti is not deidentified | ||
assert nifti.hash_files() == deidentified.hash_files() | ||
|
||
|
||
def test_raw_pet_data_deidentify(): | ||
raw_pet = Vnd_Siemens_Biograph128Vision_Vr20b_PetSinogram.sample() | ||
with pytest.raises(FileFormatsExtrasError): | ||
raw_pet.deidentify() |