De-Identification of Medical Imaging Data: A Comprehensive Tool for Ensuring Patient Privacy
This repository contains the De-Identification of Medical Imaging Data: A Comprehensive Tool for Ensuring Patient Privacy, which enables users to anonymize a wide variety of medical imaging types, including:
- Magnetic Resonance Imaging (MRI)
- Computer Tomography (CT)
- Ultrasound (US)
- Whole Slide Images (WSI)
- MRI raw data (twix)
This tool combines multiple anonymization steps, including metadata deidentification, defacing, and skull-stripping, while being faster than current state-of-the-art deidentification tools.
Getting Started
You can install the anonymization tool directly via pip or Docker.
Installation via pip
Our tool is available via pip. You can install it with the following command:
pip install mede
Additional Dependencies for Text Removal
We also implement a manual text removal feature that can be used to remove any remaining text from the images. This feature is optional and can be enabled with the additional --refine flag.
This will open an interactive window where you can manually select any remaining text/artifacts and remove them by drawing a bounding box around them.
To draw a bounding box, click and hold the left mouse button, drag to create a rectangle around the text/artifact you want to remove, and then release the mouse button. The selected area will be filled with black pixels to effectively remove the text/artifact from the image.
To reset the image to its original state, press the r key while the interactive window is open.
To save the changes, press space or enter.
The following installation is only necessary if you want to use the old text removal feature and have an older version of MEDE installed:
If you want to use the old text removal feature, you also need to install Google's Tesseract OCR engine. Follow the installation instructions for your operating system here.
-
On Ubuntu:
sudo apt install tesseract-ocr sudo apt install libtesseract-dev
-
On macOS (via Homebrew):
brew install tesseract
Installation via Docker
Alternatively, this tool is distributed via Docker. You can find the Docker images here. The Docker image is available for Linux-based (including macOS) amd64 and arm64 platforms.
Steps:
-
Pull the Docker image:
docker pull morrempe/mede:[tag] # Replace [tag] with either arm64 or amd64
-
Run the Docker container with an attached volume:
Your data will be mounted in thedatafolder:docker run --rm -it -v [Path/to/your/data]:/data morrempe/mede:[tag]
-
Run the script with the corresponding CLI parameters:
mede-deidentify [your flags]
Usage
De-Identification CLI
The mede-deidentify command-line interface (CLI) allows you to de-identify medical imaging data with various options. Below is the detailed usage guide:
mede-deidentify [-h] [-v | --verbose] [-t | --text-removal] [-i | --input]
[-o OUTPUT] [--gpu] [-s | --skull_strip] [-de | --deface]
[-tw | --twix] [-w | --wsi] [-r | --rename]
[-p PROCESSES]
[-d {basicProfile,cleanDescOpt,cleanGraphOpt,cleanStructContOpt,
rtnDevIdOpt,rtnInstIdOpt,rtnLongFullDatesOpt,
rtnLongModifDatesOpt,rtnPatCharsOpt,rtnSafePrivOpt,
rtnUIDsOpt} ...]
Options
| Option | Description |
|---|---|
-h, --help |
Show the help message and exit. |
-v, --verbose |
Enable verbose output. |
-i INPUT, --input INPUT |
Path to the input data. |
-o OUTPUT, --output OUTPUT |
Path to save the output data. |
--gpu GPU |
Specify the GPU device number (default: 0). |
-s, --skull_strip |
Perform skull stripping. |
-de, --deface |
Perform defacing. |
-tw, --twix |
Process MRI raw data (twix format) and anonymize metadata. |
-w, --wsi |
Process Whole Slide Images (WSI). |
-t, --text-removal |
Perform text removal. |
--refine |
Enable interactive refinement of text removal results. |
-r, --rename |
Rename files during processing. |
-p PROCESSES, --processes PROCESSES |
Number of processes to use for multiprocessing. |
-d, --deidentification-profile |
Specify one or more DICOM deidentification profiles to apply (see below). |
De-Identification Profiles
The -d or --deidentification-profile option allows you to specify one or more DICOM deidentification profiles. Available profiles include:
basicProfilecleanDescOptcleanGraphOptcleanStructContOptrtnDevIdOptrtnInstIdOptrtnLongFullDatesOptrtnLongModifDatesOptrtnPatCharsOptrtnSafePrivOptrtnUIDsOpt
You can specify multiple profiles by separating them with spaces. For example:
mede-deidentify -d basicProfile cleanDescOpt
Example Usage
Here’s an example of how to use the CLI:
mede-deidentify -i /path/to/input -o /path/to/output -s -d basicProfile
This command will:
- Take input data from
/path/to/input. - Save the output to
/path/to/output. - Apply skull stripping.
- Use the
basicProfiledeidentification profile.
Citation
If you use our tool in your work, please cite us with the following BibTeX entry.
@article{rempe2025identification,
title={De-identification of medical imaging data: a comprehensive tool for ensuring patient privacy},
author={Rempe, Moritz and Heine, Lukas and Seibold, Constantin and H{\"o}rst, Fabian and Kleesiek, Jens},
journal={European Radiology},
pages={1--10},
year={2025},
publisher={Springer}
}
Metadata
Release files for mede 0.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mede-0.0.12.tar.gz | 76.7 MB | Without provenance | Details for mede-0.0.12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mede-0.0.12-py3-none-any.whl | Python 3 | none | any | Details for mede-0.0.12-py3-none-any.whl |
Total release size: 118.1 MB
Release files / mede-0.0.12.tar.gz
| Download URL | mede-0.0.12.tar.gz |
|---|---|
| Size | 76.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
321de3a5ae80115e274adc6b0ac699c3b8cc9dff3ac2bf434d2cc56c77d84442
|
|
BLAKE2b-256 checksum How to use checksums |
90836ff7e8c0240b28359ac2c1869334659b07fc02bdb3cc51d033d702459c83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Release files / mede-0.0.12-py3-none-any.whl
| Download URL | mede-0.0.12-py3-none-any.whl |
|---|---|
| Size | 41.3 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0d5ff22237302bd4a73120db72bec4f5d1aa7c512c47247c6d64c45195db944a
|
|
BLAKE2b-256 checksum How to use checksums |
bd3b6aa86d84fd7f0092d3ca54e3f10308d085a1c9f0557b29a1cf5bc5faea5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Security for mede 0.0.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.