S3segmenter is a Matlab-based set of functions that generates single cell (nuclei and cytoplasm) label masks. Inputs are:
- an .ome.tif (preferably flat field corrected)
- a 3-class probability maps derived from a deep learning model such as UNet. Classes include background, nuclei contours, and nuclei foreground.
The centers of each nuclei are obtained by finding local maxima from the nuclei foreground. These are used for marker-controlled watershed constrained by the nuclei contours.
To segment cytoplasm, the nuclei are in turn used for a marker-controlled watershed segmentation constrained by a cytoplasmic marker such as B-catenin. The channel number of this marker must be specified. A 3-pixel annulus around each nucleus will also be used to segment cytoplasm.
How to run: In Matlab, set path to the folder of the cloned repo. Type: O2batchS3segmenterWrapperR('/path/to/files/')
Use the following name-value pairs arguments to customize the code to your experiment:
ip.addParamValue('HPC','false',@(x)(ismember(x,{'true','false'})));
% if using a cluster, this specifies which file index to work on
ip.addParamValue('fileNum',1,@(x)(numel(x) > 0 & all(x > 0 )));
% select any number of channels for cytoplasm
ip.addParamValue('CytoMaskChan',[2],@(x)(numel(x) > 0 & all(x > 0 )));
% select any number of channels for tissue mask
ip.addParamValue('TissueMaskChan',[3],@(x)(numel(x) > 0 & all(x > 0 )));
% constrict the tissue mask to eliminate high autofluorescent regions
ip.addParamValue('RefineTissueMask',[0],@(x)(numel(x) > 0 & all(x > 0 )));
% set to true if sample is TMA cores
ip.addParamValue('mask','tissue',@(x)(ismember(x,{'TMA','tissue','none'})));
% interactiveCrop - a GUI-based crop selector,
% 'autoCrop' - takes the middle third region,
% 'dearray', set to true if using TMA cores,
% 'noCrop', no cropping
ip.addParamValue('crop','noCrop',@(x)(ismember(x,{'interactiveCrop','autoCrop','dearray','noCrop'})));
ip.addParamValue('cytoMethod','distanceTransform',@(x)(ismember(x,{'RF','distanceTransform','bwdistanceTransform','ring'})));
% feature to threshold nuclei.
% 'IntPM' - intensity of probability map,
% 'Int' - intensity of DAPI channel,
% 'LoG', intensity of LoG filter response,
% 'none', accept all nuclei
ip.addParamValue('nucleiFilter','IntPM',@(x)(ismember(x,{'LoG','Int','IntPM','none'})));
% extracts intensity features from mask
ip.addParamValue('measureFeatures','false',@(x)(ismember(x,{'true','false'})));
ip.addParamValue('nucleiRegion','watershedContourInt',@(x)(ismember(x,{'watershedContourDist','watershedContourInt','watershedBWDist','dilation'})));
ip.addParamValue('resizeFactor',1,@(x)(numel(x) == 1 & all(x > 0 )));
% specify range of nuclei diameters in pixels ie [3 30].
ip.addParamValue('logSigma',[2.5],@(x)(numel(x) >0 & all(x > 0 )));
% channels for measuring features. If 0, assume all channels.
ip.addParamValue('chanRange',[0],@(x)(numel(x) >0 & all(x > 0 )));
ip.addParamValue('upSample',2,@(x)(numel(x) == 1 & all(x > 0 )));
ip.addParamValue('Docker','false',@(x)(ismember(x,{'true','false'})));
ip.addParamValue('dockerParams',0,@(x)(numel(x)==1));
Segmentation label masks for nuclei, cytoplasm, and cell will be saved to a subfolder under each parent image folder as a .tif file. Also saved are a 2-channel tif file with the DAPI and nuclei outlines for quality control.
References: S Saka, Y Wang, J Kishi, A Zhu, Y Zeng, W Xie, K Kirli, C Yapp, M Cicconet, BJ Beliveau, SW Lapan, S Yin, M Lin, E Boyde, PS Kaeser, G Pihan, GM Church, P Yin, Highly multiplexed in situ protein imaging with signal amplification by Immuno-SABER, Nat Biotechnology (accepted)