-
Notifications
You must be signed in to change notification settings - Fork 704
Open
Labels
Description
Hello !
First, thanks for this tool, it looks very promising, so congrats on the idea!
I have a question though.
I followed walkthrough from here:
I used the "0_ORIGINAL.dcm" file from the test files.
Here is my code to show it seems identical to the tutorial:
import pydicom
from presidio_image_redactor import DicomImageRedactorEngine
import matplotlib.pyplot as plt
def compare_dicom_images(
instance_original: pydicom.dataset.FileDataset,
instance_redacted: pydicom.dataset.FileDataset,
figsize: tuple = (11, 11)
) -> None:
"""Display the DICOM pixel arrays of both original and redacted as images.
Args:
instance_original (pydicom.dataset.FileDataset): A single DICOM instance (with text PHI).
instance_redacted (pydicom.dataset.FileDataset): A single DICOM instance (redacted PHI).
figsize (tuple): Figure size in inches (width, height).
"""
_, ax = plt.subplots(1, 2, figsize=figsize)
ax[0].imshow(instance_original.pixel_array, cmap="gray")
ax[0].set_title('Original')
ax[1].imshow(instance_redacted.pixel_array, cmap="gray")
ax[1].set_title('Redacted')
plt.show()
# Set input and output paths
input_path = "0_ORIGINAL.dcm"
output_dir = "./output"
# Initialize the engine
engine = DicomImageRedactorEngine()
# Option 1: Redact from a loaded DICOM image
dicom_image = pydicom.dcmread(input_path)
redacted_dicom_image = engine.redact(dicom_image, use_metadata=True, fill="contrast")
compare_dicom_images(dicom_image, redacted_dicom_image)
I don't understand why the Patient Name is not redacted like it is on your example :
For additional info, I am using Python 3.11.2 (but I tried with 3.9 too).
PS: I did not put it in bug since I am not 100% sure it is. It's probably on my side but I have no idea where it comes from...
Thanks in advance :)