diff --git a/presidio-image-redactor/presidio_image_redactor/dicom_image_redactor_engine.py b/presidio-image-redactor/presidio_image_redactor/dicom_image_redactor_engine.py index 89c6ea1a8..b3846762d 100644 --- a/presidio-image-redactor/presidio_image_redactor/dicom_image_redactor_engine.py +++ b/presidio-image-redactor/presidio_image_redactor/dicom_image_redactor_engine.py @@ -955,7 +955,7 @@ def _get_analyzer_results( supported_entity="PERSON", deny_list=phi_list ) - if type(ad_hoc_recognizers) is None: + if ad_hoc_recognizers is None: ad_hoc_recognizers = [deny_list_recognizer] elif type(ad_hoc_recognizers) is list: ad_hoc_recognizers.append(deny_list_recognizer) diff --git a/presidio-image-redactor/tests/integration/resources/0_ORIGINAL_redacted.dcm b/presidio-image-redactor/tests/integration/resources/0_ORIGINAL_redacted.dcm new file mode 100644 index 000000000..769549139 Binary files /dev/null and b/presidio-image-redactor/tests/integration/resources/0_ORIGINAL_redacted.dcm differ diff --git a/presidio-image-redactor/tests/integration/test_dicom_image_redactor_engine_integration.py b/presidio-image-redactor/tests/integration/test_dicom_image_redactor_engine_integration.py index 04ca53460..f76fe46a8 100644 --- a/presidio-image-redactor/tests/integration/test_dicom_image_redactor_engine_integration.py +++ b/presidio-image-redactor/tests/integration/test_dicom_image_redactor_engine_integration.py @@ -75,6 +75,20 @@ def test_redact_image_correctly(engine_builder: Callable, dcm_filepath: Path): ) +def test_compare_original_to_redacted(): + """Test the redact_and_return_bbox function.""" + input_path = Path(RESOURCES_PARENT_DIR, "0_ORIGINAL.dcm") + input_image = pydicom.dcmread(input_path) + redacted_path = Path(RESOURCES_PARENT_DIR, "0_ORIGINAL_redacted.dcm") + expected_redacted = pydicom.dcmread(redacted_path) + engine = DicomImageRedactorEngine() + actual_redacted, bboxes = engine.redact_and_return_bbox( + image=input_image, + use_metadata=True + ) + assert np.array_equal(expected_redacted.pixel_array, actual_redacted.pixel_array) + + @pytest.mark.parametrize("engine_builder", all_engines_required()) def test_redact_from_single_file_correctly(engine_builder: Callable): """Test the redact_from_file function with single file case.