Skip to content

Commit

Permalink
Adding examples of toggling metadata usage and saving bboxes (#1158)
Browse files Browse the repository at this point in the history
  • Loading branch information
niwilso authored Aug 28, 2023
1 parent 1a12771 commit 93934a9
Show file tree
Hide file tree
Showing 3 changed files with 498 additions and 432 deletions.
11 changes: 7 additions & 4 deletions docs/image-redactor/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,15 @@ Python script example can be found under:
dicom_image = pydicom.dcmread(input_path)
redacted_dicom_image = engine.redact(dicom_image, fill="contrast")

# Option 2: Redact from DICOM file
engine.redact_from_file(input_path, output_dir, padding_width=25, fill="contrast")
# Option 2: Redact from a loaded DICOM image and return redacted regions
redacted_dicom_image, bboxes = engine.redact_and_return_bbox(dicom_image, fill="contrast")

# Option 3: Redact from directory
# Option 3: Redact from DICOM file and save redacted regions as json file
engine.redact_from_file(input_path, output_dir, padding_width=25, fill="contrast", save_bboxes=True)

# Option 4: Redact from directory and save redacted regions as json files
ocr_kwargs = {"ocr_threshold": 50}
engine.redact_from_directory("path/to/your/dicom", output_dir, fill="background", ocr_kwargs=ocr_kwargs)
engine.redact_from_directory("path/to/your/dicom", output_dir, fill="background", save_bboxes=True, ocr_kwargs=ocr_kwargs)
```

### Evaluating de-identification performance
Expand Down
908 changes: 484 additions & 424 deletions docs/samples/python/example_dicom_image_redactor.ipynb

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions presidio-image-redactor/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,15 @@ engine = DicomImageRedactorEngine()
dicom_image = pydicom.dcmread(input_path)
redacted_dicom_image = engine.redact(dicom_image, fill="contrast")

# Option 2: Redact from DICOM file
engine.redact_from_file(input_path, output_dir, padding_width=25, fill="contrast")
# Option 2: Redact from a loaded DICOM image and return redacted regions
redacted_dicom_image, bboxes = engine.redact_and_return_bbox(dicom_image, fill="contrast")

# Option 3: Redact from directory
# Option 3: Redact from DICOM file and save redacted regions as json file
engine.redact_from_file(input_path, output_dir, padding_width=25, fill="contrast", save_bboxes=True)

# Option 4: Redact from directory and save redacted regions as json files
ocr_kwargs = {"ocr_threshold": 50}
engine.redact_from_directory("path/to/your/dicom", output_dir, fill="background", ocr_kwargs=ocr_kwargs)
engine.redact_from_directory("path/to/your/dicom", output_dir, fill="background", save_bboxes=True, ocr_kwargs=ocr_kwargs)
```

See the example notebook for more details and visual confirmation of the output: [docs/samples/python/example_dicom_image_redactor.ipynb](../docs/samples/python/example_dicom_image_redactor.ipynb).
Expand Down

0 comments on commit 93934a9

Please sign in to comment.