This script is designed to de-identify Whole Slide Images (WSI) with the .svs format. It performs the following steps:
- Reads the WSI .svs file from the
./svs_image_files_to_deid
folder. - Generates a new unique name for the image using a combination of a UUID, timestamp, and the original file extension.
- Creates a copy of the image with the new name in the
./svs_image_files_to_deid
folder. - Removes the label image from the WSI file, if specified.
- Updates the image name and metadata, if specified.
- Moves the image to the final location in the
./svs_image_files_deided
folder with the specified name.
To run the script, follow these steps:
-
Make sure you have Python 3 installed on your system.
-
Open a terminal or command prompt.
-
Navigate to the directory where the script is located. In this case, it would be
./scripts/deid-wsi-svs-images/
. -
Create a virtual environment by running the following command:
python3 -m venv .venv
-
Activate the virtual environment. The command to activate the virtual environment depends on your operating system:
-
For Windows:
.venv\Scripts\activate
-
For macOS/Linux:
source .venv/bin/activate
-
-
Install any required dependencies by running:
pip install -r requirements.txt
-
Place the WSI .svs file that you want to de-identify in the
svs_image_files_to_deid
folder. -
Finally, run the script and pass the filename as an argument. The command would be:
python script-deid-wsi-svs.py --filename <filename> [--remove_label_image 'True'/'False'] [--update_image_name_and_metadata 'True'/'False'] [--verbose]
To rename remove the label image and rename the image and update metadata to keep it in sync-
python script-deid-wsi-svs.py --filename sample.svs
[or]
python script-deid-wsi-svs.py --filename sample.svs --remove_label_image True --update_image_name_and_metadata True
To Remove Label Image only -
python script-deid-wsi-svs.py --filename sample.svs --remove_label_image True --update_image_name_and_metadata False
To keep the Label Image and Rename the Image and update metadata to keep it in sync-
python script-deid-wsi-svs.py --filename sample.svs --remove_label_image False --update_image_name_and_metadata True
Replace <filename>
with the name of the file you want to de-identify (e.g., sample.svs
).
Optional arguments:
--remove_label_image
: Remove the label image from the WSI file. Options 'True' or 'False' (Default: 'True').--update_image_name_and_metadata
: Do not update the image name and metadata. Options 'True' or 'False' (Default: 'True').--verbose
: Increase output verbosity.
The file should be in the folder svs_image_files_to_deid
and the result will appear in svs_image_files_deided
with the new name if specified:
W + UUID + T + Timestamp + Original file extension
(e.g., W35784d32-299c-477e-a042-bfeffe790797T2023-04-18121126547122.svs
)
This script requires the following Python packages to be installed: See requirements.txt file.
The script assumes that the svs_image_files_to_deid, and svs_image_files_deided folders already exist in the same directory as the script. If they don't exist, please create them before running the script.
Please note that this script is specifically designed for de-identifying WSI images with the .svs format.