Arpit Aggarwal, Haojia Li, and Anant Madabhushi
Python was used for this study.
The packages required for running this code are PyTorch, Numpy, Openslide, PIL, OpenCV, Pandas, Sklearn, and Matplotlib.
The main steps involved in the Collagen biomarker are as follows:
- Preprocessing steps (Extracting tiles from H&E-stained Whole Slide Images and Epithelium/Stroma segmentation)
- Extracting collagen features
For visualizing collagen fibers for some patches before feature extraction, please transfer some patches and epi/stroma masks to 'data/patches_for_visualization' and 'data/masks_for_visualization' directories respectively. Then run the python file 'python3 code/main_visualize_collagen_fibers.py' for saving example collagen fiber masks in the results directory 'results/collagen_fiber_masks'
For plotting heatmaps, please transfer some patches and epi/stroma masks to 'data/patches_for_visualization' and 'data/masks_for_visualization' directories respectively. Then run the python file 'python3 code/main_visualize_heatmaps.py' for saving example heatmaps in the results directory 'results/heatmaps_stroma' and 'results/heatmaps_peritumoral'
-
Preprocessing steps
a. Extracting tiles from H&E-stained Whole Slide Images - This extracts patches from the whole slide image of size 3000x3000-pixel. Run the python file 'python3 code/extract_patches.py' (specify the 'input_path' to the location where whole slide images exist and 'output_path' where you want to store the patches (keep it 'data/patches')).b. Epithelium/Stroma segmentation - To segment the epithelium/stromal regions on the patches extracted above, run the pretrained epithelium/stroma model 'python3 code/epithelium_stroma_segmentation.py'. The model weights file are located at 'code/epi_seg_unet.pth' (specify the 'input_path' to the location where patches are extracted and 'output_path' where you want to store the epithelium/stroma segmentation masks (keep it 'data/masks')).
In the epithelium/stroma mask, the white regions correspond to the tumor/epithelium areas and the black regions correspond to the stromal areas. We will use the black regions for segmenting collagen fibers and the following code automatically handles it (255-epi_stroma_mask). -
Extracting collagen features
As described in the manuscript, for extracting the collagen features run the file (code/main_patchLevelFeatures.py) that generates the Collagen Fiber Orientation Disorder map for each patch extracted. The feature maps will be stored over here 'results/patches'.
After obtaining the feature maps for each tile, run the file (code/main_patientLevelFeatures.py) that gives patient-level features (mean and maximum) for each patient, giving a total of 36 features. The features for each patient will be stored over here 'results/features' which can be used for downstream tasks like survival analysis etc.
Using the extracted features, use the notebook 'survival_analysis.ipynb' for an example demo for running the survival analysis pipeline.
Madabhushi Lab - This code is made available under Apache 2.0 with Commons Clause License and is available for non-commercial academic purposes.
