deid.tests package¶
Submodules¶
deid.tests.Xtest_dicom_header module¶
deid.tests.common module¶
deid.tests.test_clean module¶
-
class
deid.tests.test_clean.
TestClean
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
test_pixel_cleaner_keepcoordinates
()[source]¶ Test the pixel cleaner to ensure that a keepcoordinates retains appropriate pixels.
-
test_pixel_cleaner_keepcoordinates_from
()[source]¶ Test the pixel cleaner to ensure that multiple keep coordinates retrieved from a dicom field are appropriately retained.
-
test_pixel_cleaner_keepcoordinates_noaction
()[source]¶ Test the pixel cleaner to ensure that a keepcoordinates with no removecoordinates has no impact on the pixels.
-
test_pixel_cleaner_remove_all
()[source]¶ Test the pixel cleaner to ensure it appropriately clears all pixels.
-
test_pixel_cleaner_remove_coordinates
()[source]¶ Test the pixel cleaner to ensure it appropriately clears specified pixels.
-
test_pixel_cleaner_remove_coordinates_dicom_file
()[source]¶ Test the pixel cleaner to ensure it appropriately clears specified pixels.
-
deid.tests.test_clean_pixel_dimensions module¶
-
class
deid.tests.test_clean_pixel_dimensions.
TestCleanPizelDimensions
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
test_2d_Greyscale_image
()[source]¶ Test the pixel cleaner to ensure pixels are appropriately deidentified on “2D” images - Greyscale images. Pixel data will have the shape (X, Y)
-
test_2d_Greyscale_image_all
()[source]¶ Test the pixel cleaner to ensure pixels are appropriately deidentified - all keyword - on “2D” images - Greyscale images. Pixel data will have the shape (X, Y)
-
test_3d_Greyscale_cine_clip
()[source]¶ Test the pixel cleaner to ensure pixels are appropriately deidentified on “3D” images - greyscale cine clips. Pixel data will have the shape (frames, X, Y)
-
test_3d_Greyscale_cine_clip_all
()[source]¶ Test the pixel cleaner to ensure pixels are appropriately deidentified - all keyword - on “3D” images - greyscale cine clips. Pixel data will have the shape (frames, X, Y)
-
test_3d_RGB_image
()[source]¶ Test the pixel cleaner to ensure pixels are appropriately deidentified on “3D” images - RGB images. Pixel data will have the shape (X, Y, channel)
-
test_3d_RGB_image_all
()[source]¶ Test the pixel cleaner to ensure pixels are appropriately deidentified - all keyword - on “3D” images - RGB images. Pixel data will have the shape (X, Y, channel)
-
deid.tests.test_config module¶
deid.tests.test_data module¶
deid.tests.test_deid_recipe module¶
deid.tests.test_dicom_fields module¶
deid.tests.test_dicom_funcs module¶
deid.tests.test_dicom_groups module¶
deid.tests.test_dicom_tags module¶
Bases:
unittest.case.TestCase
Hook method for setting up the test fixture before exercising it.
Hook method for deconstructing the test fixture after testing it.
deid.tests.test_dicom_utils module¶
deid.tests.test_file_meta module¶
deid.tests.test_filter_detect module¶
-
class
deid.tests.test_filter_detect.
TestFilterDetect
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
test_filter_multiple_first_filter_match
()[source]¶ Test the DicomCleaner.detect to ensure multiple detected filters are appropriately detected.
-
test_filter_multiple_rule_innerop_false
()[source]¶ Test the DicomCleaner.detect to ensure multiple rules within a filter evaluated to false detects appropriately.
-
test_filter_multiple_second_filter_match
()[source]¶ Test the DicomCleaner.detect to ensure multiple detected filters are appropriately detected.
-
test_filter_multiple_two_filter_match
()[source]¶ Test the DicomCleaner.detect to ensure multiple detected filters are appropriately detected.
-
test_filter_multiple_zero_filter_match
()[source]¶ Test the DicomCleaner.detect to ensure multiple detected filters are appropriately not detected when they shouldn’t match.
-
test_filter_multple_rule_innerop_true
()[source]¶ Test the DicomCleaner.detect to ensure multiple rules within a filter evaluated to true detects appropriately.
-
test_filter_single_rule_false
()[source]¶ Test the DicomCleaner.detect to ensure a single rule evaluated to false detects appropriately.
-
test_filter_single_rule_innerop_false
()[source]¶ Test the DicomCleaner.detect to ensure a single rule with an inner operator evaluated to false detects appropriately.
-
deid.tests.test_replace_identifiers module¶
-
class
deid.tests.test_replace_identifiers.
TestDicom
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
test_add_tag_variable
()[source]¶ RECIPE RULE ADD 11112221 var:myVar ADD PatientIdentityRemoved var:myVar
-
test_add_tag_variable_save_true
()[source]¶ RECIPE RULE ADD 11112221 var:myVar ADD PatientIdentityRemoved var:myVar
-
test_addremove_compounding
()[source]¶ Testing add/remove compounding: Checks to ensure that multiple rules applied to the same field result in both rules being applied. While in practice this may be somewhat of a nonsensical use case when large recipes exist multiple rules may inadvertently be defined. In prior versions of pydicom/deid rules were additive and recipes are built in that manner. This test ensures consistency with prior versions.
%header ADD PatientIdentityRemoved YES REMOVE PatientIdentityRemoved
-
test_blank_field_keep_field_compounding_should_keep
()[source]¶ %header ADD PatientIdentityRemoved Yes BLANK StudyDate KEEP StudyDate
-
test_expanders
()[source]¶ RECIPE RULES REMOVE contains:Collimation REMOVE endswith:Diameter REMOVE startswith:Exposure
-
test_fieldset_remove
()[source]¶ RECIPE %fields field_set1 FIELD Manufacturer FIELD contains:Time %header REMOVE fields:field_set1
-
test_fieldset_remove_private
()[source]¶ %fields field_set2_private FIELD 00090010 FIELD PatientID %header REMOVE fields:field_set2_private
-
test_jitter_blank_date
()[source]¶ Testing to ensure jittering a date field which contains a blank value does not cause an unhandled exception
%header JITTER ContentDate 1
-
test_jitter_compounding
()[source]¶ Testing jitter compounding: Checks to ensure that multiple jitter rules applied to the same field result in both rules being applied. While in practice this may be somewhat of a nonsensical use case when large recipes exist multiple rules may inadvertently be defined. In prior versions of pydicom/deid rules were additive and recipes are built in that manner. This test ensures consistency with prior versions.
%header JITTER StudyDate 1 JITTER StudyDate 2
-
test_jitter_private_tag
()[source]¶ Testing to private tags can be jittered
%header JITTER 00291019 1
-
test_jitter_replace_compounding
()[source]¶ RECIPE RULE JITTER AcquisitionDate 1 REPLACE AcquisitionDate 20210330
-
test_jitter_values
()[source]¶ Testing to ensure fields (including non-DA/DT VR fields) identified by a values list are appropriately jittered
%values value_set1 FIELD StudyDate %header JITTER values:value_set1 1
-
test_nested_replace
()[source]¶ Fields are read into a dictionary lookup that should index back to the correct data element. We add this test to ensure this is happening, meaning that a replace action to a particular contains: string changes both top level and nested fields.
%header
REPLACE contains:StudyInstanceUID var:new_val
-
test_remove_all_add_field_compounding_should_add
()[source]¶ %header REMOVE ALL ADD PatientIdentityRemoved Yes ADD StudyDate 19700101
-
test_remove_all_blank_field_compounding_should_remove
()[source]¶ %header REMOVE ALL ADD PatientIdentityRemoved Yes BLANK StudyDate
-
test_remove_all_jitter_one_should_jitter
()[source]¶ %header REMOVE ALL JITTER StudyDate 1 ADD PatientIdentityRemoved Yes
-
test_remove_all_keep_field_compounding_should_keep
()[source]¶ %header REMOVE ALL KEEP StudyDate ADD PatientIdentityRemoved Yes
-
test_remove_all_keep_one_jitter_it_should_keep
()[source]¶ %header REMOVE ALL KEEP StudyDate JITTER StudyDate 1 ADD PatientIdentityRemoved Yes
-
test_remove_all_keep_one_replace_it_should_keep
()[source]¶ %header REMOVE ALL KEEP StudyDate REPLACE StudyDate 19700101 ADD PatientIdentityRemoved Yes
-
test_remove_all_replace_one_should_replace
()[source]¶ %header REMOVE ALL REPLACE StudyDate 19700101 ADD PatientIdentityRemoved Yes
-
test_remove_except_field_keep_other_field_compounding_should_keep
()[source]¶ %header REMOVE ALL ADD PatientIdentityRemoved Yes
-
test_remove_field_jitter_it_should_jitter
()[source]¶ %header REMOVE StudyDate JITTER StudyDate 1 ADD PatientIdentityRemoved Yes
-
test_remove_field_keep_same_field_compounding_should_keep
()[source]¶ %header REMOVE StudyDate KEEP StudyDate ADD PatientIdentityRemoved Yes
-
test_remove_field_replace_it_should_replace
()[source]¶ %header REMOVE StudyDate REPLACE StudyDate 19700101 ADD PatientIdentityRemoved Yes
-
test_remove_keep_add_field_compounding_should_add
()[source]¶ %header REMOVE ALL KEEP StudyDate ADD StudyDate 19700101 ADD PatientIdentityRemoved Yes
-
test_removeadd_compounding
()[source]¶ Testing remove/add compounding: Checks to ensure that multiple rules applied to the same field result in both rules being applied. While in practice this may be somewhat of a nonsensical use case when large recipes exist multiple rules may inadvertently be defined. In prior versions of pydicom/deid rules were additive and recipes are built in that manner. This test ensures consistency with prior versions.
%header REMOVE StudyDate ADD StudyDate 20200805
-
test_replace_with_constant
()[source]¶ RECIPE RULE REPLACE AccessionNumber 987654321 REPLACE 00190010 NEWVALUE!
-
test_strip_sequences
()[source]¶ Testing strip sequences: Checks to ensure that the strip_sequences removes all tags of type sequence. Since sequence removal relies on dicom.iterall(), nested sequences previously caused exceptions to be thrown when child (or duplicate) sequences existed within the header.
%header ADD PatientIdentityRemoved YES
-
test_tag_expanders_midtag
()[source]¶ REMOVE contains:8103 Should remove: (0008, 103e) Series Description
-
test_valueset_empty_remove
()[source]¶ Testing to ensure correct actions are taken when a defined valueset contains no data (the field identified has an empty value). Since the ConversionType flag contains “No Value”, in the test below, value_set1 will be empty and as a result this combination of rules should have no impact on the header. The input header should be identical to the output header.
%values value_set1 FIELD ConversionType %header REMOVE values:value_set1
-
test_valueset_private
()[source]¶ %values value_set2_private FIELD 00311020 SPLIT 00090010 by=” “;minlength=4 %header REMOVE values:value_set2_private
-
test_valueset_remove
()[source]¶ %values value_set1 FIELD contains:Manufacturer SPLIT contains:Physician by=”^”;minlength=3 %header REMOVE values:value_set1
-
test_valueset_remove_one_empty
()[source]¶ Testing to ensure correct actions are taken when a defined valueset contains a field that has an empty value. Since the ConversionType flag contains “No Value”, in the test below, value_set1 will only have the value from Manufacturer and should only identify the fields which contain “SIEMENS”.
%values value_set1 FIELD ConversionType FIELD Manufacturer %header REMOVE values:value_set1
-
deid.tests.test_utils module¶
-
class
deid.tests.test_utils.
TestUtils
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
test_get_installdir
()[source]¶ get install directory should return the base of where singularity is installed
-