This repository contains a set of scripts to export QuPath annotations as GeoJSON and split the exported ROI coordinates by cell type (classification) for further analysis.
v0.3.3
ExAnnoClassifications.groovy: A Groovy script for QuPath to extract cell detection-based annotations (classifications) from QuPath TMA projects and save them as GeoJSON files.qupath_roi_splitter.py: A Python script to split the ROI coordinates of QuPath TMA annotations by cell type (classification) and save them as tab-separated text files.qupath_roi_splitter_folder.py: A folder version of thequpath_roi_splitter.pyscript that processes all GeoJSON files in a specified folder.
- QuPath (for
ExAnnoClassifications.groovy) - Python 3.6 or later
- OpenCV (cv2)
- GeoJSON
- Pandas
- NumPy
- Open QuPath and load your TMA project.
- In QuPath, go to
Automate > Show script editor. - Copy the content of the
ExAnnoClassifications.groovyscript into the script editor. - Run the script. It will save the exported annotations as GeoJSON files in a folder named
annotations_export_[TMA_name]within your QuPath project directory.
Run qupath_roi_splitter.py with the --qupath_roi argument pointing to the GeoJSON file you want to process. --fill is an optional argument to fill the ROI polygons. --all is an optional argument to export all features of GeoJSON (ignores if classification is present). Add --img to create a PNG for each cell type with thicker ROI outlines, a grid, and labeled X/Y axes. The PNGs are cropped to the area containing the ROIs. Axis values remain the original QuPath pixel coordinates, with Y increasing downward. PNGs from the same input share the same crop and scale.
python qupath_roi_splitter.py --qupath_roi path/to/your/geojson_file.geojson --fillRun qupath_roi_splitter_folder.py with the qupath_roi_folder argument pointing to the folder containing the GeoJSON files you want to process. It supports the same --fill, --all, and --img options.
python qupath_roi_splitter_folder.py path/to/your/geojson_folder --fillThe scripts create a tab-separated text file for each cell type (classification) in the current working directory, named [TMA_name]_[cell_type].txt. With --img, they also create [TMA_name]_[cell_type].png plots.
This project is licensed under the MIT License. See the LICENSE file for details.