Automated Morphological Analysis of Microglia After Stroke

Microglia are the resident immune cells of the brain and react quickly to changes in their environment with transcriptional regulation and morphological changes. Brain tissue injury such as ischemic stroke induces a local inflammatory response encompassing microglial activation. The change in activation status of a microglia is reflected in its gradual morphological transformation from a highly ramified into a less ramified or amoeboid cell shape. For this reason, the morphological changes of microglia are widely utilized to quantify microglial activation and studying their involvement in virtually all brain diseases. However, the currently available methods, which are mainly based on manual rating of immunofluorescent microscopic images, are often inaccurate, rater biased, and highly time consuming. To address these issues, we created a fully automated image analysis tool, which enables the analysis of microglia morphology from a confocal Z-stack and providing up to 59 morphological features. We developed the algorithm on an exploratory dataset of microglial cells from a stroke mouse model and validated the findings on an independent data set. In both datasets, we could demonstrate the ability of the algorithm to sensitively discriminate between the microglia morphology in the peri-infarct and the contralateral, unaffected cortex. Dimensionality reduction by principal component analysis allowed to generate a highly sensitive compound score for microglial shape analysis. Finally, we tested for concordance of results between the novel automated analysis tool and the conventional manual analysis and found a high degree of correlation. In conclusion, our novel method for the fully automatized analysis of microglia morphology shows excellent accuracy and time efficacy compared to traditional analysis methods. This tool, which we make openly available, could find application to study microglia morphology using fluorescence imaging in a wide range of brain disease models.

The Mask Cell was refined in several steps: 1. Removal of small clusters with a volume less than 10 m 3 from Mask Cell .
2. Filling of holes in Mask Cell . Holes were determined in 3D as connected out-mask voxel cluster without connection to the borders of the 3D volume.
3. Definition of the branches (Mask Branches ) and soma of the cells (Mask Soma ). Branches were defined as the parts of the whole cell mask (Mask Cell ) with a diameter being in any direction less than 3 m. This was done using the MATLAB function 'imopen' with a spherical structuring element of radius 1.5 m.
4. Filling of small gaps in Mask Cell in the immediate vicinity of the soma. Such gaps might potentially arise from the usage of different thresholds for the creation of the masks combined to build the Mask Cell . This was done by applying the MATLAB function 'imclose' with a spherical structuring element of radius 1.2 m to the Mask Cell , inclusively masking the gap filled Mask Cell by a dilated soma mask and adding the original, non-gap filled Mask Cell . The dilation of Mask Soma was done using the MATLAB function 'imdilate' with a spherical structuring element of radius 1.2 m.
The Mask Nuclei was refined in following way: 1. Masking the Mask Nuclei with the Mask Soma to remove artefacts which might result from overlaps of Mask4 and Mask5 in areas where microglia cell branches lie in very close proximity to non-microglia nuclei.
2. Removal of small clusters with volume less than 10 m 3 from Mask Nuclei .
After these refinement steps, the Mask Soma and Mask Branches were redefined within the Mask Cell , in the same way as explained above, but allowing a larger diameter for branches (diameter less than 3.6 m), thereby restricting the soma to areas within the mask with larger diameters. Voxel cluster in the Mask Soma were removed, if no nucleus was found within its area in the Mask Nuclei .
The Mask Soma was dilated (Mask SomaDilated ) using the MATLAB function 'imdilate' with a spherical structuring element of radius 1.2 m and by masking it inclusively by the Mask Cell .
The purpose of Mask SomaDilated was twofold: i) Include minor bumps on the surface of the soma into the soma mask, instead of considering them as cell branches. ii) Separate cell branches, which share the same basis or are connected by ridges on the surface of the soma.

Definition of the skeleton and segregation of cells
The skeleton resulting from the watershed segmentation was refined, in order to avoid artificial cycles in the skeleton, lying internally of enlarged volumes in the cell soma or branches. This was done in two ways. i) Watershed segments which had no or very little contact to the surface of the cell were merged to the neighboring watershed segment, to which it had the largest area of contact. ii) In regions of the cell where more than two watershed segments met, edges were removed by giving preference to edges between watershed segments with larger area of contact over those with smaller area of contact until all cycles were broken up.
Major branches of the skeleton were defined from the skeleton nodes and edges being located inside the Mask Branches . To define distinct branches, these nodes were split into subsets meeting the requirement that each pair of their nodes is connected by a pathway of nodes and edges being part of the same subset. In addition, these subsets were only considered to be major branches of the cell, if any pair of its nodes was connected by a pathway of edges being at least 2 µm long.
Branch segments were defined as all possible pathways of nodes and edges with exactly two nodes being connected by a number of edges unequal two (i.e. end-/branching-nodes).
Cycles in the branches were defined as pathways of edges and nodes wherein a node is reachable from itself.

Definition of morphological features
Sphericity is a measure of the compactness of a 3-dimensional object, and a function of its volume V and surface area A. A sphere would be the most compact 3D object having a score of one. Sphericity was calculated as: Circularity is a measure of the compactness of a 2-dimensional object, and a function of its area A and perimeter P. A circle would be the most compact 2D object having a score of 1. It was calculated for the 2D projection of the cell mask along the Z-axis: Solidity was calculated for the 2D projection of the cell mask along the Z-axis as the proportion of the pixels in the convex hull that were also in the cell.
The length of branches was defined in two ways: 1. "branch length skeleton" was defined as the longest of the pathways of edges and nodes between the first node outside the soma and any end-node in the same branch.
2. "branch length air-line" was defined as the Euclidian distance between the same pair of nodes, for which the "branch length skeleton" was defined.
Graph theory based centrality measures were calculated using the MATLAB function 'centrality'. Node centrality can be considered as the importance of a node for the graph (i.e. the mathematical representation of the skeleton), according to certain criterions. The here used centrality measures were the degree of the nodes, their closeness and their betweenness.

Supplementary Figures
Supplementary figure 1: Assessment of image quality using spatial correlations between successive slices. Spatial correlation between neighboring images (slices) increase with signal strength and decrease with noise, and hence is related to the signal-to-noise ratio. Images were removed from the top and bottom of the image stack, if spatial correlations with their neighboring images were falling below a threshold of 0.78 in either of the two channels (DAPI and anti-Iba1 staining). Dashed lies indicate the range of over-threshold, good quality images in the DAPI (blue) and anti-Iba1 (green) channel, respectively. The overlap of these two ranges (here coinciding with the range of over-threshold images in the anti-Iba1 channel) was used for analysis.

Supplementary figure 2: Validation of the automated analysis.
In the validation dataset, each shape feature showed a comparable or even higher performance to discriminate between cells in the peri-infarct area and in the contralateral hemisphere, as estimated by the area under the curve (AUC) from receiver operating characteristic (ROC) analysis. Each data-point represents the AUC scores for one feature, as calculated in the exploratory dataset and in the independent validation dataset. Intersections of the orthogonal slices are indicated by cross-hairs. Scale is indicated in µm.

Supplementary video 1: Skeleton of cells throughout a whole Z-stack.
The video starts with a static picture of the maximum-intensity projection along the Z-direction of the image stack, including anti-Iba1 (green) and DAPI (blue) staining. Subsequently a projection of the segmented microglia cells (green) and nuclei (blue) is shown. The skeleton is overlayed, with skeleton nodes colored according to cell identity (colors chosen at random). The view zooms in, to show a magnified view of a part of the skeleton in rotation.

Supplementary video 2: Surface model and skeleton of a segregated cell in rotation.
The initially opaque surface of the cell becomes gradually transparent, in order to show the underlying skeleton model of the cell structure. Skeleton nodes are represented by spheres, with colors indicating their properties. Red: node at the center of the soma; Orange: all other nodes inside the soma; Green: branching points; Pink: end-points of the skeleton; Blue: nodes which were connected to neighboring cells before segregation into individual cells; Brown: all other nodes inside the branches.

Supplementary Tables
Supplementary Table 1: Shape features Label, AUC score, type and definition of each of the 59 shape features. For features marked by an asterisk (*) additional explanation is available in the Supplemental Material section "Definition of morphological features". The type of a feature indicates whether it is based on simple shape properties, like volume or surface area (simple); based on skeleton properties (skeleton); or based on graph theoretical measures of centrality (graph). For features which could be defined for each node or branch of the cells skeleton, the scores for 5 percentiles were extracted: the minimum, 25 th percentile, median, 75 th percentile and maximum. These percentiles are indicated by the suffices P0, P25, P50, P75 and P100 (added to the label of the feature). Features, which were selected for the PCA analysis, are highlighted in light blue.