CoolFace
Apppublic

Treav/DICOMDeidentify

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
deidentify.py27 linesDownload Raw Back to root
1import glob2from pathlib import Path3import matplotlib.pyplot as plt4import pydicom5from presidio_image_redactor import DicomImageRedactorEngine6import pytesseract7from pydicom import dcmread, dcmwrite8 9import os10def dicomprocess(pathDicom):11    engine = DicomImageRedactorEngine()12    # Load in and process your DICOM file as needed13    dicom_instance = pydicom.dcmread(pathDicom)14    # Redact15    redacted_dicom_instance = engine.redact(dicom_instance, fill="contrast")16    dcmwrite("redacted.dcm", redacted_dicom_instance)17    print("-----------------------------{}-------------------".format( os.path.realpath("redacted.dcm")))18    return os.path.realpath("redacted.dcm")19 20    21 22 23  24 25 26 27