Apr 18, 2024

Public workspaceCODA (part 5): nuclear coordinate generation | HuBMAP | JHU-TMC V.2

  • 1Johns Hopkins University;
  • 2Johns Hopkins Medicine
Open access
Protocol CitationKyu Sang Han, Pei-Hsun Wu, Joel Sunshine, Ashley Kiemen, Sashank Reddy, Denis Wirtz 2024. CODA (part 5): nuclear coordinate generation | HuBMAP | JHU-TMC. protocols.io https://dx.doi.org/10.17504/protocols.io.dm6gpz8z8lzp/v2Version created by Kyu Sang Han
Manuscript citation:
A.M. Braxton, A.L. Kiemen, M.P. Grahn, A. Forjaz, J. Parksong, J.M. Babu, J. Lai, L. Zheng, N. Niknafs, L. Jiang, H. Cheng, Q. Song, R. Reichel, S. Graham, A.I. Damanakis, C.G. Fischer, S. Mou, C. Metz, J. Granger, X.-D. Liu, N. Bachmann, Y. Zhu, Y.Z. Liu, C. Almagro-Pérez, A.C. Jiang, J. Yoo, B. Kim, S. Du, E. Foster, J.Y. Hsu, P.A. Rivera, L.C. Chu, D. Liu, E.K. Fishman, A. Yuille, N.J. Roberts, E.D. Thompson, R.B. Scharpf, T.C. Cornish, Y. Jiao, R. Karchin, R.H. Hruban, P.-H. Wu, D. Wirtz, and L.D. Wood, “3D genomic mapping reveals multifocality of human pancreatic precancers”, Nature (2024)

A.L. Kiemen, A. Forjaz, R. Sousa, K. Sang Han, R.H. Hruban, L.D. Wood, P.H. Wu, and D. Wirtz, “High-resolution 3D printing of pancreatic ductal microanatomy enabled by serial histology”, Advanced Materials Technologies 9, 2301837 (2024)

T. Yoshizawa, J. W. Lee, S.-M. Hong, D.J. Jung, M. Noe, W. Sbijewski, A. Kiemen, P.H, Wu, D. Wirtz, R.H. Hruban, L.D. Wood, and K. Oshima. “Three-dimensional analysis of ductular reactions and their correlation with liver regeneration and fibrosis”, Virchows Archiv (2023).

A.L. Kiemen, A.I. Damanakis, A.M. Braxton, J. He, D. Laheru, E.K. Fishman, P. Chames, C. Almagro Perez, P.-H. Wu, D. Wirtz, L.D. Wood, and R. Hruban, “Tissue clearing and 3D reconstruction of digitized, serially sectioned slides provide novel insights into pancreatic cancer”, Med 4, 75-91 (2023)

A. Kiemen, Y. Choi, A. Braxton, C. Almagro Perez, S. Graham, M. Grahm, N., N. Roberts, L. Wood, P. Wu, R. Hruban, and D. Wirtz, “Intraparenchymal metastases as a cause for local recurrence of pancreatic cancer”, Histopathology 82: 504-506 (2022)

A.L. Kiemen, A.M. Braxton, M.P. Grahn, K.S. Han, J.M. Babu, R. Reichel, A.C. Jiang, B. Kim, J. Hsu, F. Amoa, S. Reddy, S.-M. Hong, T.C. Cornish, E.D. Thompson, P. Huang, L.D. Wood, R.H. Hruban, D. Wirtz and P.H. Wu, “CODA: quantitative 3D reconstruction of large tissues at cellular resolution”, Nature Methods 19: 1490-1499 (2022)

K.S.Han, I. Sander, J. Kumer, E. Resnick, C. Booth, B. Starich, J. Walston, A.L. Kiemen, S. Reddy, C. Joshu, J. Sunshine, D. Wirtz, P.-H. Wu "The microanatomy of human skin in aging." bioRxiv (2024): 2024-04.
License: This is an open access protocol distributed under the terms of the Creative Commons Attribution License,  which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited
Protocol status: Working
We use this protocol and it's working
Created: April 18, 2024
Last Modified: April 18, 2024
Protocol Integer ID: 98445
Keywords: CODA, deeplearning, semanticsegmentation, machinelearning
Funders Acknowledgement:
Institute of Arthritis and Musculoskeletal and Skin Diseases
Grant ID: U54AR081774
National Cancer Institute
Grant ID: U54CA143868
Abstract
In this section, generate nuclear coordinates on the high-resolution H&E images through color deconvolution and identification of two-dimensional intensity minimums in the hematoxylin channels of the images (corresponding to the dark blue nuclei). This calculation is done on the high-resolution tiff images saved inside pth10x.

Note on cell detection: It is important that the cell coordinates are generated on unregistered images, as warping caused by the registeration process can cause inaccuracies in nuclear detection performed on the registered images. Instead, detect coordinates on the unregistered images, then apply the registration transformations to the cell coordinates to determine their positions in registered space.
Nuclear coordinate generation
Nuclear coordinate generation
generate a mosaic image containing tiles from nine randomly chosen high-resolution images. This will be the image used to optimize the parameters for the cell detection algorithm. Given the path to the high-resolution images, the function will randomly choose nine files (filenames can overlap if the folder contains fewer than nine files). The low-resolution version of each image will be loaded and displayed to the user, prompting the user to click on a region containing tissue. This will be repeated nine times, after which the high-resolution mosaic image will be generated.

Note: When manually selecting regions for the mosaic image, select regions with various morphologies to ensure that your cell detection algorithm is robust.
make_cell_detection_mosaic(pth10x);
This function will create a subfolder containing the mosaic image:
pthmosaic=[pth10x,'cell_detection_validation'];
Manually count the nuclei on the mosaic image to generate ground-truth coordinates. Given the path to the mosaic image, this function will display the image to the user and prompt the user to zoom in. Zoom to a region where nuclei are clear, then press ‘spacebar.’ Click on each nucleus in the zoomed region, then press ‘z’ to zoom or scroll to another region in the image. Continue until all nuclei in the mosaic have been annotated. At any time, exit the code by pressing ‘z’ and selecting continue later. When you recall the code it will automatically continue from where you left off. When you are finished, press ‘z’ then select ‘Quit’.

For a mosaic image comprised of 9 200x 200 micron2
10x magnification tiles, manual annotation of nuclei for a medium dense tissue should take 30 – 45 minutes for a trained user.

manual_cell_count(pthmosaic);             

This will create a subfolder named ‘manual detection’ containing the manually identified coordinates inside a mat file in a variable named ‘xym.’

pth_mosaic_manul_coords=[pthmosaic,manual detection’];
Next, determine the optimal intensity cutoff and minimum spacing between nuclei to most maximize the true positives and minimize the false positives and false negatives in automatic determination of nuclear coordinates. This is done through comparison of the manually generated cell coordinates to several variations of automatically generated coordinates.
First, deconvolve the mosaic image to get its hematoxylin channel.
If the images are H&E, use the ImageJ default optical densities for H&E images.

This function generates output images containing the hematoxylin and eosin (or DAB) channel images:
pthmosaicH=[pth10x,'Hchannel'];
pthmosaicE=[pth10x,'Echannel'];
Next, optimize the parameters by iteratively generating nuclear coordinates on the mosaic image and comparing them to the manual cell detection.

get_nuclear_detection_parameters(pthmosaic)

This will generate a subfolder named ‘automatic detection’ containing the optimal automatically generated cell coordinates, and a subfolder named ‘optimization params’ containing the determined parameters.

paramsfile=[pthmosaic,'automatic_detection\optimized_params.mat'];
Now, apply the color deconvolution to the entire high-resolution dataset using the calculated parameters. We first deconvolve the images to get their hematoxylin channel. If the images are H&E, use the ImageJ default optical densities for H&E images:

stain_type=1;
If the images are IHC, use the ImageJ default optical densities for H DAB images.

stain_type=2;
deconvolve_histological_images(pth10x,stain_type);

This function generates output images containing the hematoxylin and eosin (or DAB, for IHC) channel images:

pthH=[pth10x,'Hchannel'];
pthE=[pth10x,'Echannel'];
Finally, apply the cell detection to the hematoxylin channel of the high-resolution images using the optimized parameters:

pthparams=[pth10x,'cell_detection_validation\automatic_detection'];
cell_detection(pthH,pthparams);
The workflow in this section will create a subfolder inside the high-resolution hematoxylin-channel tif image folder named ‘cell_counts’. Within ‘cell_counts’ will be a mat file corresponding to each tif image. Inside each mat file will be a variable named ‘xy’ with coordinates for each cell found in the corresponding image.

pthcoords=[pth10x,'cell_counts\'];