This repository contains code for comparing various pre-trained foundational models on computational pathology tasks using Representational Similarity Analysis (RSA). The analysis focuses on Whole Slide Images (WSIs) from The Cancer Genome Atlas (TCGA) for four cancer subtypes: Breast Invasive Carcinoma (BRCA), Colon Adenocarcinoma (COAD), Lung Adenocarcinoma (LUAD), and Lung Squamous Cell Carcinoma (LUSC).
The primary goal of this project is to understand how different state-of-the-art vision models represent histopathology image patches from different cancer types. We achieve this by:
The following pre-trained models are included in the comparison:
hf_hub:MahmoodLab/conch (ViT-B-16 based)vinid/plip (CLIP based)hf_hub:prov-gigapath/prov-gigapathwisdomik/QuiltNet-B-32 (CLIP based)timm implementation, ImageNet pre-trained.hf-hub:MahmoodLab/UNI2-hhf-hub:paige-ai/Virchow2└── vmath20-isopath/
├── README.md # This file
├── FinalRDMGenerationAnalysisV2.ipynb # Jupyter Notebook for all RSA, clustering, specificity, and spectral analyses
├── LICENSE # MIT License file
├── preprocessing.py # Script for WSI loading, patch extraction, and saving
└── generate_embeddings/ # Directory containing scripts/notebooks for generating embeddings
├── ConchEmbeddings.ipynb # Generates embeddings using CONCH
├── plip.py # Generates embeddings using PLIP
├── prov.py # Generates embeddings using Prov-GigaPath
├── quiltnet.py # Generates embeddings using QuiltNet
├── resnet.py # Generates embeddings using ResNet50
├── uni.py # Generates embeddings using UNI
└── virchow.py # Generates embeddings using Virchow
.svs files) and corresponding metadata (e.g., gdc_sample_sheet.tsv). Paths in the scripts point to a specific cluster setup (/tcga/, /lotterlab/).preprocessing.py):
openslide..npy files (one file per slide) to a designated directory (e.g., /lotterlab/users/vmishra/preprocessed_patches_LUAD).generate_embeddings/):
.npy patch files for all 4 cancer types..npy files (one file per cancer type per model, e.g., brca_embeddings_conch.npy) to a designated directory (e.g., /lotterlab/users/vmishra/).FinalRDMGenerationAnalysisV2.ipynb):
/lotterlab/users/vmishra/batched_embeddings).rsatoolbox and saves them (e.g., /lotterlab/users/vmishra/rdms). Also calculates overall RDMs for visualization.Note: The paths in the scripts (/tcga/, /lotterlab/users/vmishra/) are hardcoded and specific to a particular compute environment. You will need to adapt these paths to your own data storage and output directories.
preprocessing.py for metadata, input WSI data, and the output directory for preprocessed patches.python preprocessing.pygenerate_embeddings/:
cuda:1).login() is called.python generate_embeddings/resnet.py) or execute the notebook cells.FinalRDMGenerationAnalysisV2.ipynb to point to the saved embeddings (full and batched), RDM storage, and desired output locations for figures and CSV files.The primary results are:
.npy files containing patch embeddings for each model and cancer type..npy files containing batched embeddings..npy files containing RDM matrices for each model and batch..png and .pdf files for RDM visualizations, similarity heatmaps, dendrograms, and spectral analysis plots..csv files containing the results of the Slide and Disease Specificity analyses.These are generated during the execution of the scripts and notebooks, typically saved either in the local directory or in the specified output paths (e.g., /lotterlab/users/vmishra/rdms).
This project is licensed under the MIT License - see the LICENSE file for details.
127 commits
Jupyter Notebook
99.5%
This repository contains code for comparing various pre-trained foundational models on computational pathology tasks using Representational Similarity Analysis (RSA). The analysis focuses on Whole Slide Images (WSIs) from The Cancer Genome Atlas (TCGA) for four cancer subtypes: Breast Invasive Carcinoma (BRCA), Colon Adenocarcinoma (COAD), Lung Adenocarcinoma (LUAD), and Lung Squamous Cell Carcinoma (LUSC).
The primary goal of this project is to understand how different state-of-the-art vision models represent histopathology image patches from different cancer types. We achieve this by:
The following pre-trained models are included in the comparison:
hf_hub:MahmoodLab/conch (ViT-B-16 based)vinid/plip (CLIP based)hf_hub:prov-gigapath/prov-gigapathwisdomik/QuiltNet-B-32 (CLIP based)timm implementation, ImageNet pre-trained.hf-hub:MahmoodLab/UNI2-hhf-hub:paige-ai/Virchow2└── vmath20-isopath/
├── README.md # This file
├── FinalRDMGenerationAnalysisV2.ipynb # Jupyter Notebook for all RSA, clustering, specificity, and spectral analyses
├── LICENSE # MIT License file
├── preprocessing.py # Script for WSI loading, patch extraction, and saving
└── generate_embeddings/ # Directory containing scripts/notebooks for generating embeddings
├── ConchEmbeddings.ipynb # Generates embeddings using CONCH
├── plip.py # Generates embeddings using PLIP
├── prov.py # Generates embeddings using Prov-GigaPath
├── quiltnet.py # Generates embeddings using QuiltNet
├── resnet.py # Generates embeddings using ResNet50
├── uni.py # Generates embeddings using UNI
└── virchow.py # Generates embeddings using Virchow
.svs files) and corresponding metadata (e.g., gdc_sample_sheet.tsv). Paths in the scripts point to a specific cluster setup (/tcga/, /lotterlab/).preprocessing.py):
openslide..npy files (one file per slide) to a designated directory (e.g., /lotterlab/users/vmishra/preprocessed_patches_LUAD).generate_embeddings/):
.npy patch files for all 4 cancer types..npy files (one file per cancer type per model, e.g., brca_embeddings_conch.npy) to a designated directory (e.g., /lotterlab/users/vmishra/).FinalRDMGenerationAnalysisV2.ipynb):
/lotterlab/users/vmishra/batched_embeddings).rsatoolbox and saves them (e.g., /lotterlab/users/vmishra/rdms). Also calculates overall RDMs for visualization.Note: The paths in the scripts (/tcga/, /lotterlab/users/vmishra/) are hardcoded and specific to a particular compute environment. You will need to adapt these paths to your own data storage and output directories.
preprocessing.py for metadata, input WSI data, and the output directory for preprocessed patches.python preprocessing.pygenerate_embeddings/:
cuda:1).login() is called.python generate_embeddings/resnet.py) or execute the notebook cells.FinalRDMGenerationAnalysisV2.ipynb to point to the saved embeddings (full and batched), RDM storage, and desired output locations for figures and CSV files.The primary results are:
.npy files containing patch embeddings for each model and cancer type..npy files containing batched embeddings..npy files containing RDM matrices for each model and batch..png and .pdf files for RDM visualizations, similarity heatmaps, dendrograms, and spectral analysis plots..csv files containing the results of the Slide and Disease Specificity analyses.These are generated during the execution of the scripts and notebooks, typically saved either in the local directory or in the specified output paths (e.g., /lotterlab/users/vmishra/rdms).
This project is licensed under the MIT License - see the LICENSE file for details.
127 commits
Jupyter Notebook
99.5%