This project evaluates how graph construction methods affect a GNN's capability to capture spatial heterogeneity in cancerous tissue in the Grand Challenge on Breast Cancer Histology Images.
The Grand Challenge included 400 microscopy images of 4 classes of breast cancer. For the purpose of this project, I used two classes (cancerous and non-cancerous). While the model achieved relatively high classification accuracy (around 90%), the primary focus of this work is on evaluating how different graph construction strategies preserve spatial heterogeneity patterns.
-
notebooks/analysis.ipynb— Explanation of full experimental pipeline and visualization of results
-
src/graph_construction_helpers.py— Spatial graph construction methodsvisualizers.py— All plotting and visualization utilitiesdata_helpers.py— Dataset loading and preprocessingextract_features.py- Extracts and saves DenseNet-121 features from WSIsmacenko_normalizer.py- Helper class for macenko normalizationtrain_gnn.py— GNN model definition and trainingtest_heterogeneity.py- Analyzes tissue heterogeneity in DenseNet features and trained GNNstest_gnn.py- Tests GNN ensemble accuracy
-
data/- CSV outputs from heterogeneity experiments
-
requirements.txt
- Install dependencies:
pip install -r requirements.txt
- Update the
bach_directorypath inconstants.pyto match the path to thePhotosfolder of the BACH dataset. - Open and run
notebooks/analysis.ipynb. All figures and results will be generated. - The training pipeline from start to end involves running
train_test_split.py→extract_features.py→train_gnn.py. - To rerun heterogeneity metrics, run
test_heterogeneity.py. - To retrain models, run
train_gnn.py.
The project also includes support for the BreakHis dataset, although no data from BreakHis was used in analysis due to variations in magnification between the two datasets. Update the breakhis_directory path in constants.py. Each file contains a flag that defines
dataset = "bach"
To run that file on BreakHis, change the flag to
dataset = "breakhis"
- Patch-level feature extraction using pretrained CNNs
- Graph construction based on spatial and feature relationships:
- Euclidean radius
- Spatial k-NN
- Delaunay triangulation
- Feature k-NN
- Local heterogeneity quantified via neighborhood cosine dissimilarity
- GraphSAGE used to study learned aggregation effects
[1] Brussee, S., Buzzanca, G., Schrader, A. M. R., & Kers, J. (2025). Graph neural networks in histopathology: Emerging trends and future directions. Medical Image Analysis, 101, 103444. https://doi.org/10.1016/j.media.2024.103444
[2] Dolezal, J.M., Kochanny, S., Dyer, E. et al. Slideflow: deep learning for digital histopathology with real-time whole-slide visualization. BMC Bioinformatics 25, 134 (2024). https://doi.org/10.1186/s12859-024-05758-x
[3] Hameed, Z., Garcia-Zapirain, B., Aguirre, J.J. et al. Multiclass classification of breast cancer histopathology images using multilevel features of deep convolutional neural network. Sci Rep 12, 15600 (2022). https://doi.org/10.1038/s41598-022-19278-2
[4] Hamilton, William & Ying, Rex & Leskovec, Jure. (2017). Inductive Representation Learning on Large Graphs. 10.48550/arXiv.1706.02216.
[5] Huang, G., Liu, Z., Van Der Maaten, L., & Weinberger, K. Q. (2017). Densely connected Convolutional Networks. 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2261–2269. https://doi.org/10.1109/cvpr.2017.243
[6] Macenko, M., Niethammer, M., Marron, J. S., Borland, D., Woosley, J. T., Xiaojun Guan, Schmitt, C., & Thomas, N. E. (2009). A method for normalizing histology slides for quantitative analysis. 2009 IEEE International Symposium on Biomedical Imaging: From Nano to Macro, 1107–1110. https://doi.org/10.1109/isbi.2009.5193250