Skip to content

Commit

Permalink
Fixed wrong condition for dicom metadata (#1347)
Browse files Browse the repository at this point in the history
* fixed wrong condition for dicom metadata

* added redacted file for tests
  • Loading branch information
omri374 committed Mar 29, 2024
1 parent 49a996d commit ffa29f8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ffa29f8

Please sign in to comment.