This repository contains the tools and scripts necessary to convert DICOM Whole Slide Images (WSI), which may be composed of multiple files, into a single, standardized SVS file format.
To clearly associate the workflow steps with the corresponding code files, please refer to the table below:
| Step | Description | Script |
|---|---|---|
| Step 1 | DICOM File Compressor: Aggregation and Packaging | data_compress.ipynb |
| Step 2 | ZIP to SVS Converter: Format Transformation | DICOM_to_SVS.ipynb |
Script: data_compress.ipynb
This script aggregates all the individual DICOM files (*.dcm) that constitute a single Whole Slide Image (WSI) across different resolutions, compressing them into one ZIP archive.
Adjust the paths below in your Python script (data_compress.ipynb) to define the source files and the output location.
# Set the desired output directory for the single ZIP file
output_dir = '/path/to/your/output/folder'
# Set the desired unique identifier for the slide. This will be the name of the output ZIP file.
slide_id = 'YOUR_CUSTOM_ID'
# Replace these paths with the complete list of ALL DICOM file paths
# that belong to this specific Whole Slide Image (WSI).
file_list = [
"/path/to/your/wsi_1/file1.dcm",
"/path/to/your/wsi_1/file2.dcm",
# ... add all other .dcm paths for this WSI here
]A single compressed ZIP file, created in the specified output_dir.
/path/to/your/output/folder/[slide_id].zipScript: DICOM_to_SVS.ipynb
This step utilizes a conversion function to decompress the archive generated in Step 1 and transform the contained DICOM files into the SVS format.
# Convert the DICOM ZIP file to the SVS format
from_DICOM_to_SVS(
path_to_folder='/path/to/DICOMtoSVS/test', # Directory containing the input files
is_zipped=True, # Flag indicating if the input is a zipped file
label=True, # Include the Label image
macro=True, # Include the Macro image
anonymize=False, # Retain original patient information
add_DICOM_tags=True # Embed DICOM tags into the SVS file
)The converted SVS file will be placed in a corresponding output directory (e.g., test_output if the input directory was test).
/path/to/test_output/*.svsThis tool and workflow were developed based on the previous work provided by the following repository:
- DICOMtoSVS: [https://github.com/bertrandchauveau/DICOMtoSVS]