Deidentify DICOM files#

Use this script to deidentify DICOM files in external storage.

from pathlib import Path
from typing import List

from encord import EncordUserClient

def deidentify(
    integration_title: str,
    dicom_urls: List[str],
) -> List[str]:
    # Authentication: adapt the following line to your private key path
    private_key_path = Path.home() / ".ssh" / "id_ed25519"

    with as f:
        private_key =

    user_client = EncordUserClient.create_with_ssh_private_key(private_key)

    integration_hash = None

    # Find integration_hash for requested integration_title
    for integration in user_client.get_cloud_integrations():
        if integration.title == integration_title:
            integration_hash =

    if not integration_hash:
        raise Exception(
            f"Intgration with integration_title={integration_title} not found"

    deidentified_dicom_urls = []

    for dicom_url in dicom_urls:
        # requesting deidentification with batch == 1
        deidentified_dicom_url = user_client.deidentify_dicom_files(
        print(f"Deidentified url: {deidentified_dicom_url}")

    return deidentified_dicom_urls

_integration_title = "deid-demo-0dae9c7b-integration"
_dicom_urls = [
_deidentified_dicom_urls = deidentify(_integration_title, _dicom_urls)

Gallery generated by Sphinx-Gallery