Eric Hidari ([email protected]) 2021-09-11
This section describes the Standard Operation Procedure (SOP) for the analysis of IHC (DAB-AT8 tau) post mortem brain images. The goal is to generate cellular level structured data of quantified pathology and morphology information. Groovy scripts (within Qupath_script
folder) and Python functions (within util.py
) mentioned in this document are loaded from bankofbrain
. Commands and plugins in QuPath are highlighted.
- Import the '.svs' images into QuPath 0.2.3 (StarDist plugin needs to be installed, see QuPath website) and create a project. Open Script Editor and load
Tissue_detection.groovy
, adjust the threshold to separate the tissue block from the background. Change the threshold until the entire tissue is selected. - Manually inspect the annotation to specify the boundary. Set the annotation to mutable and remove large blood vessels, black fractal artefacts, black fiducial markers, blurred tissue and overlapped tissue.
- Segment the cortical region blocks to white and grey matter. Use Brush tool to outline the grey matter at low magnification and adjust the boundary at high magnification. Look up the image at high contrast can guide one through the drawings. Outline the white matter by annotation subtraction. Assign the white matter annotation with the QuPath built-in class 'Tumor' and grey matter with 'Stroma'. Select a cortical ribbon within the cortical grey matter that has a relatively uniform thickness, and assign it with 'Region'.
- For cerebellum sections, first identify the granular cell layer using the Pixel classifier plugin with the pre-trained classifier
granular_cells.json
. Then use Brush tool to select the white matter. Assign the white matter annotation with 'Tumor' and granular cells with 'Immune cells'. - For basal ganglia sections, a neuropathologist will be required to conduct the segmentation of globus pallidus, striatum and subthalamic nucleus.
- Run
Stardist_segment.groovy
within QuPath on the entire project for cell detection and measurements. RunStardist_segment_BG.groovy
on basal ganglia slides annotated by the neuropathologist. Parameters related to Stardist and cell expansion can be adjusted in the script. - Run
Export_cortical_ribbons.groovy
andExport_white_matter.groovy
to output the cortical ribbon and the white matter annotations to json files.
- Modify
sql_config.json
file to configure the PostgreSQL database for storing the information. - Run
add_tables_to_sql
function to add cell characterisation tables to the database, including a BRIN index table for fast queries. - Run
add_cortical_ribbons
andadd_white_matter
functions to add the cortical ribbon and the white matter annotations to the database.
- Run
generate_all_positive_cell
function to retrieve the number of tau positive/negative cells for each slide subregions. Alternatively, rungenerate_all_positive_cell_threshold
function if a custom threshold for dividing positive/negative cells is desired. - Run
generate_all_ribbon_distance
function to measure distances to the grey/white matter boundary for each cortical ribbon cells for cortical layer distribution analysis. - Run the statistical analysis and figure plotting (detailed in the PSP cohort paper) using the workflow defined in the Jupyter Notebook
Histology-pathology-PSP-cohort-paper.ipynb
.
This sections document the scripts within the bankofbrain
package.
These scripts are located in the Qupath_script
folder and should be run within the QuPath Script Editor.
Export all annotations of the image to a json file. Useful for transferring annotations between projects.
Export the label images of the slide for easy access of the metadata.
Import the annotation of cortical ribbon into the opened whole-slide image. Can be modified to import other annotations.
Import an annotation and calculate the Jaccard index between the imported region and the current region. Useful for assessing interrater segmentation agreement.
Make a screenshot of the section and save it as a thumbnail image.
For each detected cell in the selected region, export a small square field of view image. Useful for generating images for machine learning training.
Assign the cell type from data table to the detected cells in the image and visualise them. Useful for visualising cell type distribution in the image after machine learning classification.
Export the cell annotations to json file for cross-validation with automatic cell detection.
Measure the pixel-based tau stain in all subregions and all detected cells, with the threshold configured in tau.json
. Useful for extracting the proportion of somatic tau within the total cell burden.
Export the measurement table of all annotations of the image.
Move the viewer to FOVs centring around cells from the data table. Useful for viewing selected cells of interest following classification, such as checking scenarios where cells are misclassified.
Automatically detect the tissue boundary with the defined threshold. Adjust the threshold so that the correct region is selected.
Detect and characterise the cells in the whole slide image using StarDist (The pre-trained deep learning model he_heavy_augment
is used, download here) and assign them to the region where they are located. If the region is annotated basal ganglia, please use Stardist_segment_BG.groovy
instead.
See above.
These functions are located at utils.py
and could be run inside the folder where the dependent class library pgclasses.py
is located.
Add cell data to the PostgreSQL database and table specified in the configuration file sql_config.json
.
Generate the number of neighbour features for each cell in the data table. The definition of neighbour radiuses range can be modified as a parameter.
Generate the mean value of features for the neighbourhood of each cell in the data table. The definition of number neighbour and radius neighbour can be modified as parameters.
Add cortical ribbon or white matter annotation to the PostgreSQL database.
Drop the cell record of the slide from the PostgreSQL cell table.
Retrieve the cell record of the slide from the PostgreSQL cell table.
Generate a table of all cells located at the cortical ribbon for the slide. Useful for extracting cells from the grey matter of the brain with a defined layered structure.
Generate a table counting the tau positive and negative cells for all subregions of all slides using the default colour threshold.
Generate a table counting the tau positive and negative cells for all subregions of all slides using a custom colour threshold defined as a parameter.
Generate a table of all cells located at the cortical ribbon for the slide with their distance to the white/grey matter boundary measured. Useful for analysing the cortical layer distribution of tau pathology.