JavaCyte, a novel open-source tool for automated quantification of key hallmarks of cardiac structural remodeling

Many cardiac pathologies involve changes in tissue structure. Conventional analysis of structural features is extremely time-consuming and subject to observer bias. The possibility to determine spatial interrelations between these features is often not fully exploited. We developed a staining protocol and an ImageJ-based tool (JavaCyte) for automated histological analysis of cardiac structure, including quantification of cardiomyocyte size, overall and endomysial fibrosis, spatial patterns of endomysial fibrosis, fibroblast density, capillary density and capillary size. This automated analysis was compared to manual quantification in several well-characterized goat models of atrial fibrillation (AF). In addition, we tested inter-observer variability in atrial biopsies from the CATCH-ME consortium atrial tissue bank, with patients stratified by their cardiovascular risk profile for structural remodeling. We were able to reproduce previous manually derived histological findings in goat models for AF and AV block (AVB) using JavaCyte. Furthermore, strong correlation was found between manual and automated observations for myocyte count (r = 0.94, p < 0.001), myocyte diameter (r = 0.97, p < 0.001), endomysial fibrosis (r = 0.98, p < 0.001) and capillary count (r = 0.95, p < 0.001) in human biopsies. No significant variation between observers was observed (ICC = 0.89, p < 0.001). We developed and validated an open-source tool for high-throughput, automated histological analysis of cardiac tissue properties. JavaCyte was as accurate as manual measurements, with less inter-observer variability and faster throughput.

www.nature.com/scientificreports/ surface area. Although this is a relevant correlate of oxygen diffusion distances, it does not accurately reflect the loss or gain in number of capillaries in settings with concomitant myocyte hypertrophy. In those circumstances, the number of capillaries per myocyte is needed to assess the degree of capillary rarefaction or angiogenesis. We developed a fluorescent triple staining method and an integrated suite of algorithms for the automated quantification of all of the aforementioned structural features. Wheat Germ Agglutinin (WGA) was used to visualize the extracellular matrix (ECM) 17 , yielding the number and size of myocytes, overall fibrosis and myocyte-to-myocyte distances as a measure for endomysial fibrosis. Capillaries were stained with the biotinylated isolectin Griffonia Simplifolia (GS-IB4) in animal tissues and CD31 in human biopsies, providing the size and number of capillaries. Fibroblasts were stained with anti-vimentin antibody, yielding the size and distribution of fibroblasts. From these data, the number of capillaries or fibroblasts can be calculated in a simple manner. Because the positions of all recognized structures are stored, this method also allows analysis of the spatial correlation between various parameters. This method was successfully tested in atrial tissue samples from goats, pigs, horses and humans. Here, we present the validation of the method in several goat models of AF that were previously characterized extensively by manual analysis. In addition, we analyzed biopsies from selected patient populations. In general, the extent of atrial pathology is far larger in patient samples than in animal models of heart disease. For this reason, we analyzed the degree of inter-observer variability in these human biopsies as a test case. For these data, we also extended our analysis to spatial heterogeneity in the distribution of endomysial fibrosis, thereby providing an example of the potential for further development.

Materials and methods
Tissue sampling. Collections of atrial tissue biopsies from several previously described and characterized goat models were used: sham-operated goats (n = 6), goats with AF maintained by burst pacing for 3 weeks (short term, ST, n = 7) and 6 months (long term, LT, n = 6) 18 and goats with atrial dilatation as a result of His bundle ablation (AV block, AVB, n = 6) 19 . All animal experiments were approved by the ethical board for animal experimentation 'Centrale Commissie Dierproeven (CCD)' and were in compliance with the European directive 2010/63/EU on the protection of animals used for scientific purposes. All research on human atrial tissue samples was performed in accordance with relevant guidelines, as approved by the ethical committee "METC academic hospital Maastricht/university Maastricht". Informed consent was obtained from all participants.
Human atrial samples (n = 14 left atrial appendages, LAA, and n = 8 right atrial appendages, RAA) were collected from the CATCH-ME atrial tissue biobank from patients undergoing coronary artery bypass grafting (CABG), valvular surgery or heart transplant surgery (Table 1). Patients were stratified based on the expected risk for the presence of atrial structural remodeling associated with their clinical profile. Cardiovascular risk profile positive patients (CVRP+, n = 11) were all diagnosed with both heart failure and persistent AF. Tissue from all but one of the patients in this group was obtained during a heart transplant xenograft surgery. The remaining patient was diagnosed with grade III mitral valve regurgitation. Most (n = 6) of the CVRP+ patients had an underlying valvular cardiomyopathy, predominantly resulting from the mitral valve. In two other CVRP+ patients, the cardiomyopathy was ischemic. None of the patients had a known genetic basis for cardiomyopathy, long QT syndrome or Brugada syndrome. Two CVRP+ patients, however, were diagnosed with an idiopathic non-obstructive cardiomyopathy. As a whole, ejection fractions were significantly lower in the CVRP+ group, resulting in a higher NYHA classification. Cardiovascular risk profile negative patients (CVRP-, n = 11) had no history of either AF or heart failure. In seven CVRP-patients, the primary indication for surgery was coronary artery bypass grafting (CABG). Three others had grade I or II mitral valve regurgitation, requiring mitral valve Triple staining. A complete and detailed protocol for the staining method is provided in supplement 1. All atrial tissues were excised rapidly, snap frozen and stored at − 80 °C. Cryosections of 6 µm were made at − 22 °C and stored at − 80 °C. Antigen fixation was performed by submerging slides in ice-cold acetone for 10 min. Nonspecific binding sites were blocked for 60 min with a blocking solution consisting of 2 m/v % fraction V BSA and 0.3 M glycine dissolved in PBS. Fibroblasts were visualized with an overnight stain using a mouse monoclonal anti-vimentin antibody at a concentration of 1/150. In human samples endothelial cells were stained overnight at room temperature with a monoclonal anti-human CD31 antibody at a concentration of 1/50. The next morning, sections were incubated for 120 min at room temperature with appropriate fluorescent secondary antibodies at a concentration of 1/200 (Fig. 2). Cell membranes were stained at room temperature using WGA lectin conjugated to an Alexa 594 fluorophore at a 1/200 dilution. In animal tissue, capillaries were labeled with the biotinylated GS-IB4 conjugated to Alexa Fluor 488 at a dilution of 1/200, for a duration of 120 min. Coverslips were mounted with 'Prolong Gold Antifade' mounting medium (ThermoFisher Scientific). Stained sections were stored at 4 °C prior to microscopy.  Fibrosis, myocyte size and myocyte dissociation index, clustering coefficient. A Phansalkar's algorithm for automatic local thresholding was used to delineate WGA-positive pixels (Fig. 3a,b). The total area of fibrosis was calculated as the fraction of WGA-positive pixels to the total pixel count. Next, the original WGA-images were filtered using a Gaussian blur function to reduce noise. For each image, the average contrast between WGA-positive and -negative pixels was used to obtain the ' optimal prominence' setting for cardiomyocyte detection using Fiji's built-in 'segment particles' function to determine local minima in fluorescence. Most of the recognized local minima are myocytes, but some local minima represent small dark patches within larger www.nature.com/scientificreports/ regions of fibrosis. To reduce the number of false positive structures, the pixel intensity directly surrounding local minima was determined. Local minima for which the surrounding pixel values where in the red spectrum were rejected as a cardiomyocyte and were masked. For the remaining local minima, Voronoi watershedding and particle analysis was applied. Myocyte size for each object was calculated as the minimal Feret diameter. For each detected myocyte, all directly neighboring myocytes were defined. A profile plot of the line selection between the local minima of each pair of neighboring myocytes was generated. The thickness of the ECM in between myocytes (i.e. endomysial collagen septa) was calculated as a measure of endomysial fibrosis ( Fig. 3c-e). Manual inspection of output images generated by JavaCyte (Fig. 3e) is required to guarantee optimal accuracy. In these output images, a thresholded version of the measurements taken is shown as an overlay with the original image, so the user can ascertain the accuracy of the analysis.

Microscopy.
As an extension of the method in human samples, a cardiomyocyte dissociation index (CDI) was obtained for each cell by determining the fraction of inter-cardiomyocyte distances that exceeded the mean value measured in CVRP-patients with an indication for CABG surgery, i.e. the 'healthiest' patients in our study population, by more than two standard deviations. Distribution of CDI was visualized for each image as a heat map (white cells are closely apposed to neighbors while dark red cells are isolated from neighbors, Fig. 3f). Furthermore, clustering of enhanced inter-myocyte distances was tested in analogy with the local clustering coefficient, as described in graph theory. Myocytes separated by a larger than normal area of endomysial fibrosis are connected in a clique. The clustering coefficient of myocytes in a clique is enhanced. The impact of augmented clustering coefficients in a clique directly corresponds to the size of the clique. The average clustering coefficient of all myocytes in an image was measured using Matlab. Permutation testing was applied to calculate the expected clustering coefficient in the case of a completely random distribution of inter-myocyte distances measured in the image. The mean of 1000 permutations defined the expected clustering coefficient. Furthermore, the proportion of permuted clustering coefficients smaller than the observed clustering coefficient was defined.
Capillary density and size. The number of capillaries was obtained by counting CD31 or GSIB4-positive structures using a particle analysis function after applying a Gaussian blur and Landini's 20 Hue-Saturation-Brightness (HSB)-based color threshold. A minimal size threshold of 1.5µm 2 was used to reduce noise. For each image, capillary density was calculated as the number of capillaries per myocyte. For the determination of capillary size, a circularity filter of 0.35 was used to select transversely cut capillaries prior to calculations of the minimal Feret diameter (Fig. 4).
Fibroblast density. Vimentin positive objects were selected applying Landini's color threshold 20 . Vimentin shows some cross-reactivity to endothelial cells 21 , which was confirmed by overlaying thresholded GS-I4B/ CD31 and vimentin images. For analysis of fibroblast density, we therefore subtracted the thresholded GS-I4B/ CD31 images from the thresholded vimentin images. For each image, the number of fibroblasts per myocyte was calculated as a measure for fibroblast density (Fig. 4). results to data obtained through manual segmentation and measurement. In a first stage, object recognition was tested by quantifying the number of true positive (TP), false positive (FP) and false negative (FN) objects in human atrial samples. True positive denotes the number of manually identified myocytes or capillaries that were recognized by the algorithm. False negative depicts the number of manually identified structures that were not recognized by the algorithm. Performance was analyzed by calculation of sensitivity, precision, false negative rate (FNR) and F1 score, defined by the following formulas: Normal distribution of count data was confirmed with a Shapiro-Wilk's test. The assumption of homoscedasticity was tested by obtaining a spread-versus-level plot in the statistical program R. Next, correlation between the manually obtained and automated count for myocytes and capillaries was tested applying Pearson's correlation test. Further validation of optimal object recognition included a second stage where area and minimal Feret diameter of matched truly positive objects was compared. Each manually detected myocyte was assigned to an automatically detected myocyte based on the minimal distance between centroids (analogous to maximal matching described by graph theory), as measured by the following formula: www.nature.com/scientificreports/ The percentage of deviation of the area and minimal Feret values of automatically recognized objects from manually obtained measurements was calculated and plotted in a Bland-Altman curve. Once optimal myocyte recognition had been achieved, correlation between median inter-myocyte distances obtained manually and by applying the algorithm was tested.
Inter-observer variation. Sampling variation between two observers was quantified by independently taking 10 photographs per cardiac sample of 10 unique patients. Further analysis was carried out using JavaCyte. Variation in inter-myocyte distance was visualized per sample. To compare observers, a two-way mixed, absolute agreement intra-class correlation test was performed.
Statistics. The open source software environment for statistical computing, 'R' (www.r-proje ct.org), was used for all statistical analysis. For each tissue sample, a minimum of three independent images was obtained, while the operator was blinded to the experimental group or patient group. For analysis of endomysial fibrosis, cardiomyocyte size, CDI and capillary size, the median value per image was calculated. Differences were tested using a mixed-effects model. For analysis of goat samples, the models contained the fixed-effect variables 'sublayer (endocardium/epicardium)' , 'group (Sham/ST-AF/LT-AF/AVB)' and the interaction term 'sublayer*group' . The factor 'goat study number' was included as a random-effect variable. For analysis in human samples the models included the fixed-effect factor 'group (CVRP+/CVRP-)' and the random-effect 'matched pair_ID' to identify matched patients.

Results
Workflow. We developed a suite of algorithms for the automated analysis of the previously described features of myocardial tissue structure, JavaCyte, as a plug-in tool for the commonly used image analysis environment Fiji. We recommend that images for analysis are taken at the same magnification (200-400×) and with similar illumination and exposure, preferably using the same microscope and camera for all images. At magnifications below 200×, the resolution of digital images will become inadequate to accurately determine the dimensions of the recognized structures, particularly the thickness of endomysial septae. At magnifications above 400×, fewer structures will be present within an image, increasing possible selection bias of the photographed locations. The program has been successfully tested for jpg, tiff and bmp image formats, but will work in principle for all standard image formats that can be imported into ImageJ. At the start of image analysis, the user is prompted to enter the resolution (in pixels per millimeter). The user can specify entire folders of images to be analyzed per 'image color' (red for WGA, green for CD31/GSIB4, blue for vimentin), and one output folder per analyzed parameter. After specification of the desired analysis, quantification of endomysial fibrosis, CDI, total ECM content, myocyte size and count, capillary size and count, and fibroblast count can be performed simultaneously. The program will produce feedback throughout the analysis phase regarding the percentage of images analyzed. As no manual input is needed during the automated analysis phase, the program can run unattended.
In the output folders, one output image is stored for each original image showing thresholded images of the recognized structures (Fig. 3E). For WGA images, the locations where myocyte size and myocyte-to-myocyte distances were measured are indicated. This allows the user to inspect each analyzed image in order to detect potential recognition problems. In addition, numerical data is written to .csv files, with individual measurements of the location and size of the recognized structures. These files can be directly imported for further statistical analysis in e.g. R or SPSS.
Inter-myocyte distance and myocyte size in goat models of AF. Structural parameters in the epicardial and endocardial layer from the LA free wall of ST-AF (n = 7), LT-AF (n = 6), AVB (n = 6) and sham-operated (n = 6) goats were studied. In agreement with our earlier quantification in the same model 6 , no significant differences in total ECM content were observed between groups in either of the layers (Fig. 5a). Inter-myocyte distances were analyzed as a measure for endomysial fibrosis. In the epicardial layer, there was significantly more endomysial fibrosis in LT-AF goats than in ST-AF goats (+ 0.42 µm, p = 0.01) or Sham-operated goats (+ 0.74 µm, p < 0.001). Endomysial fibrosis was increased in AVB goats compared to Sham-operated goats (+ 0.37 µm, p = 0.02), and in LT-AF goats compared toAVB goats (+ 0.37 µm, p = 0.03).
In the endocardial layer, no changes in inter-myocyte distance (Fig. 5b) or minimal Feret diameters were determined, despite the presence of a trend (Fig. 5c). No changes were observed in capillary density or size in either layer (Fig. 5d), although the number of capillaries per surface area decreased in the endocardium of LT-AF goats compared to sham-operated goats (− 42, p = 0.04, results not shown). Fibroblast density was not quantified for these samples. For all parameters analyzed, the direction of change and effect size agreed well between manual and automated quantification ( Table 2).
Validation of myocyte recognition, myocyte diameter, inter-myocyte distance and capillary count. To validate automated quantification, we compared it to manual quantification of the same images.
Pearson's correlation coefficients were calculated to assess the correlation between automated cardiomyocyte count and manually obtained cardiomyocyte counts from human (n = 10) atrial samples (Fig. 6a,b) www.nature.com/scientificreports/ positive correlation between both counts was observed (r = 0.94, n = 10, p < 0.001). To further evaluate the accuracy of myocyte recognition in human atrial samples, measures of sensitivity (93.9% ± 5.5%), precision (95.4% ± 4.5%), FNR (6.1% ± 5.5%) and F1-score (94.5% ± 3.5%) were calculated. These results show high precision in myocyte detection, while maintaining sensitivity. Next, automatically detected cells were matched with manually recognized cells. Minimal Feret diameter of matched truly positive objects was compared (Fig. 6b). The mean difference between matched manually and automatically obtained cardiomyocyte diameters situates in the 95% confidence interval [− 2.82%, − 1.08%], as shown in a Bland-Altman plot (Fig. 6b). Furthermore, a positive correlation was observed between median (Fig. 6c) inter-myocyte distances measured by the algorithm and manually in human samples (R = 0.98, n = 10, p < 0.001). Comparison of the number of capillaries was studied in CD31 images. A Pearson's correlation coefficient was computed to test the correlation between automated and manually obtained capillary counts, where we also observed a high correlation (R = 0.95; n = 10; p < 0.001). Performance measurements in human atrial samples demonstrated high precision (95.3 ± 3.7%) while

Cardiovascular risk profile as a determinant of atrial tissue structure in patients.
Structural characteristics of cardiac tissue samples of matched patients in the CVRP+ and CVRP-groups were compared. No change in total ECM content was observed (Fig. 7a), in contrast to a significant increase in inter-myocyte distance (Fig. 7b) in the CVRP+ group compared to the CVRP-group (+ 1.90 µm, p < 0.001). Furthermore, myocytes were bigger in CVRP+ patients compared to CVRP-patients (+ 1.60 µm, p = 0.02) (Fig. 7d). On average, a higher CDI was measured in CVRP+ patients (+ 9.40%, p < 0.001). Moreover, the fraction of cells that was at least 50% dissociated is also higher (Fig. 7c) in CVRP+ than CVRP-patients (+ 12.60%, p < 0.001). This expansion of endomysial fibrosis was accompanied by an increase in fibroblast density (+ 9.20%, p = 0.003) (Fig. 7f). No change in capillary density (− 3.70% p = 0.44) was observed (Fig. 7e), although absolute capillary counts were lower in CVRP+ patients (− 15% , p = 0.04). www.nature.com/scientificreports/ Clustering of endomysial fibrosis in patients. Visually, the spatial distribution of fibrous tissue suggested clustering of higher inter-myocyte distances, i.e. endomysial fibrosis (Fig. 8a). As an extension of the automated quantification, the degree of clustering of enhanced inter-myocyte distances was studied in both patient groups. The fraction of expected clustering coefficients that was smaller than the observed clustering coefficient was high in the CVRP-(96.5 ± 1.50%) and the CVRP+ (95.7 ± 1.44%) group. This indicates that high values of endomysial fibrosis appear in clusters, regardless of the phenotype of the patient. However, the relative increase of observed clustering coefficients compared to expected values of clustering (Fig. 8b,c) was larger in the CVRP+ group (+ 14.3 ± 1.26%) than in the CVRP-group (+ 10.0 ± 1.32%, p = 0.02), confirming the larger degree of spatial heterogeneity in transverse myocyte separation.

Discussion
In the present study, simultaneous visualization and automated analysis of multiple features of structural remodeling was successfully applied. Accurate detection of cardiomyocytes and capillaries was confirmed by evaluating performance metrics. Moreover, JavaCyte offers a much faster alternative to characterize myocardial structure objectively, as it no user input is required once it started. In a validation study on goat atrial biopsies, structural properties were visualized in experimental goat models for ST-AF, LT-AF and AV-block. Inter-myocyte distance and myocyte size were increased in LT-AF, validating earlier findings in these goat models 6 . In the AV-block model, an expected increase in myocyte size was observed 19 . Outcomes from the automated quantification agreed well with manual quantification of the same sections. In addition, applying JavaCyte, no significant inter-observer variability in providing input for automated analysis was detected in a study on human biopsies, which show more heterogeneity in tissue structure than biopsies from the goat models. Application of this novel automated analysis made it possible to compare atrial tissue from patients whose clinical profile suggested an increased risk of atrial remodeling and those whose clinical profile did not. Alterations in atrial tissue structure were detected, including more, and more clustered, endomysial fibrosis, more dissociated cardiomyocytes, proliferation of fibroblasts and cellular hypertrophy. Each www.nature.com/scientificreports/ of these factors has been proposed to contribute to AF progression. By contrast, similar degrees of overall fibrosis were observed in both groups.

Advantages over traditional methods and validation in animal models. Fluorescent staining and
automated analysis using JavaCyte offers several advantages over traditional approaches which apply a multistep process involving subjective detection thresholds. Poor color contrast in conventional histology between myocytes and particularly endomysial fibrosis limits digital thresholding of images, complicating automated analysis strategies. Manual quantification of fibrosis is slow and more sensitive to larger areas of fibrosis rather than endomysial fibrosis. As a result, reports on the level of fibrosis in animal studies vary widely between and within species. In this study, fibrotic structures were visualized using WGA, a lectin that binds to sialic acid and N-acetylglucosaminyl residues in the cell membrane. WGA was previously described as a tool to stain cardiac sarcolemma and fibrotic structures 17 , as well as connective tissue and ECM. Many glycosaminoglycans in the ECM contain N-acetylglucosamin, a target of WGA [22][23][24] . Therefore, the use of WGA provides a suitable method to study interstitial fibrosis. This staining enabled the detection of increased endomysial fibrosis in LT-AF goats compared to ST-AF goats, particularly in the epicardium 6 , which may have been missed using Sirius Red or Trichrome staining. In prior studies using optical mapping, observations of enhanced endomysial fibrosis in LT-AF goats were linked to impaired epicardial wavefront expansion in LT-AF goats compared to ST-AF goats 7 .
Applying JavaCyte, we have confirmed our earlier findings of increased endomysial thickness in LT-AF goats compared to sham-operated and ST-AF goats in the epicardial layer. Furthermore, the presence of myocyte hypertrophy was confirmed in LT-AF and AV-block goats compared to Sham-operated animals. This approach to quantifying myocyte size and the distribution of fibrous tissue is fast, relatively inexpensive, reproducible, suitable for cryosections and allows for the simultaneous visualization of additional structures. Conventional fluorescence microscopy is limited to the detection of three different fluorescent labels at sufficiently distinct wavelengths. We used WGA in combination with staining of capillaries and fibroblasts. However, with minor modifications in the staining protocol and analysis algorithms, this method is also suitable for the quantification of other discrete structures and cell types, such as macrophages, intramyocardial smooth muscle cells and myofibroblasts with the appropriate fluorescent labels. The size and positions of all recognized structures is automatically stored, allowing further statistical analysis of the spatial intercorrelations between different structures.
Part of this potential was employed here by normalizing capillary and fibroblast counts to the number of myocytes in an image. Capillary rarefaction, i.e. a loss of the number of capillaries has been implicated in various disease processes. While a reduced capillary count per unit of surface area implies longer diffusion distances, it is an unreliable indicator for capillary rarefaction with concomitant myocyte hypertrophy. Normalization of capillary counts for the number of myocytes therefore provides important additional information on rarefaction/ angiogenesis. Furthermore, it is possible to study inter-capillary distance to investigate oxygen diffusion distances. This parameter was not analyzed in the current manuscript, but it could be calculated in a straightforward manner from the JavaCyte output files.
Moreover, fibroblasts were visualized applying an antibody directed to vimentin, the major protein in the cytoskeleton of mesenchymal cells. Vimentin-positive structures were corrected for cross-reaction with endothelial cells 21 by subtraction. The application of a myofibroblast-specific marker such as alpha smooth muscle actin was outside the scope of this article, but could be useful to study the degree of fibroblast differentiation.
Initially, the algorithm was validated by comparing the number of automatically identified cardiomyocytes and capillaries to manual counts. The sensitivity, precision, false negative rate and F1 score were calculated as measures of precision. JavaCyte was very sensitive in recognizing cardiomyocytes and capillaries, while maintaining precision. Additionally, cardiomyocyte size and median inter-myocyte distance correlated strongly with manual measurements.
Structural remodeling in patient biopsies. Following validation of JavaCyte in previously characterized goat models, the algorithm was applied to a clinical test case. As a result of multiple underlying comorbidities of unknown, varying durations, atrial tissue structure in patients tends to be more variable and extensive, affording a challenge to test the performance of automated quantification. One of the most important attributes of JavaCyte is standardization and reproducibility of data, independent of the operator. This quality was confirmed by studying inter-observer variation between 2 individual observers who individually took 10 photographs per sample of 10 unique patients. The images were then analyzed using JavaCyte, eliminating interobserver variation in the data analysis phase. In this way, the impact of potential bias in area selection during microscopy and photographing of the tissue was assessed. A high degree of similarity between both analysts was observed. Moreover, JavaCyte is capable of analyzing hundreds of images per hour, making it ideally suited for high throughput analysis in large, multi-center trials in a cost-effective and reproducible manner.
In summary, cardiomyocyte size was increased in CVRP+ patients. Enhanced deposition of ECM in between cardiomyocytes was observed in patients with concomitant cardiac conditions that are believed to accelerate structural remodeling of the heart. Organized and accurate quantification of inter-myocyte distance between each pair of myocytes makes it possible to study the spatial distribution of enhanced endomysial fibrosis. In this study, the degree of dissociation of each myocyte from its neighbors was calculated (CDI), reflecting the local amount of surrounding fibrosis. A higher CDI indicated that myocytes are surrounded by more extreme endomysial fibrosis and are thus more isolated from their neighbors. The substantial rise in CDI observed in CVRP+ patients suggests that the observed increase in median inter-myocyte distance results from regions with more extreme endomysial fibrosis, rather than a mild homogenous increase of endomysial fibrosis throughout the tissue. Such a loss of inter-myocyte connections could produce zigzag conduction patterns and promote microreentry 25  www.nature.com/scientificreports/ Such patterns of conduction have also previously been associated with aging 26 . Following these observations, the degree of clustering of large inter-myocyte distances was calculated. In both patient groups, large values of endomysial fibrosis clustered more often than can be expected by chance, suggesting that extensive endomysial fibrosis tends to localize in clusters. The relative degree in observed clustering compared to expected clustering of endomysial fibrosis was higher in the CVRP+ group than the CVRP-group. Moreover, a higher fibroblast/myocyte ratio was observed in CVRP+ patients, which could imply more opportunities for electrotonic interaction between these cell types. Although a smaller number of capillaries was observed in atrial appendages of CVRP+ patients compared to CVRP-patients, the number of capillaries per myocyte and the size of these capillaries did not differ. This suggests that, although oxygen diffusion distances may have increased, capillary rarefaction does not occur under these circumstances.

Conclusion
Here, we provide a flexible and expandable, open source tool that is well-suited for the accurate characterization of myocardial structure including the quantification of fibrous tissue distribution, myocyte hypertrophy, fibroblast density, capillary density and size, and the spatial interrelations between these features. Compared to conventional analysis, our method is highly time-and cost-efficient, and largely eliminates observer bias and inter-observer variability.
Limitations. For experimental work described in this manuscript, frozen cardiac tissue samples were used.
Although JavaCyte is only tested in frozen sections, we expect the program to work for fixed tissue slides as well, provided the staining protocol is optimized. JavaCyte was tested at magnifications ranging from 200 × to 400x. Both magnifications provide ideal cardiomyocyte size and resolution needed for accurate analysis. Depending on the microscope used, smaller magnifications may lack the required resolution to measure distances accurately, while higher magnifications will result in fewer measurements.
The analysis algorithms were developed for the quantification of structural features in regions where myocytes and capillaries are sectioned transversely. Although conduction is most rapid in the longitudinal direction of myocyte bundles, longitudinal conduction is affected less by structural remodeling. Several studies have highlighted the importance of transverse electrical uncoupling resulting from endomysial fibrosis to the discontinuous conduction and microreentry 5,6,25,27 . In addition, interstitial/ endomysial fibrosis is a major determinant for decreased myocardial compliance and diastolic dysfunction 7,8 .
Within the regions used for analysis, myocytes and capillaries were approximately, rather than exactly, transversely sectioned. For these structures, using the maximal width would represent a variable and potentially large overestimation of size. To minimize this inaccuracy, the algorithm uses the minimal Feret diameter as a measure for myocyte and capillary size. This results in a systematic but small underestimation of actual myocyte and capillary sizes, which should be similar between study groups.
Here, we have tested the method in atrial biopsies from diverse animal models (goats, pigs and horses) and human patients, but we expect that the validity and performance will be similar in transversely sectioned tissue from ventricular and skeletal muscle. Optically, the algorithms were developed to differentiate between large cells and intercellular space in transversely cut areas. Other applications of JavaCyte will be possible provided that fluorescently stained objects of interest are clearly identifiable in an image. We have not tested its performance in circumstances with very pronounced replacement fibrosis, such as ventricular infarct zones. Because infarct zones are characterized by replacement fibrosis secondary to myocyte death, we would expect that our algorithms would show more ' overall fibrosis' , with fewer detectable myocytes. In this scenario, the advantage of JavaCyte analysis over conventional histology (e.g. Sirius Red or Masson's Trichrome) may be more limited, but the triple staining analyzed with JavaCyte would still yield the number of and distance between (surviving) myocytes, and the density of capillaries and fibroblasts. CVRP+ patients were diagnosed with both persistent AF and heart failure. The pathologies responsible for heart failure in these patients were variable. It is not possible to disentangle whether the differences in tissue structure compared to CVRP-patients can be attributed to the effects associated with (end-stage) heart failure, underlying pathologies inducing heart failure, AF, or a combined synergistic effect. The impact of varying clinical profiles in distinct groups of patients should be studied in a larger, more extensively subclassified and phenotyped cohort of patients. Furthermore, the tool provided here could be used to study pathogenesis of pro-fibrotic remodeling in such a study, for example by linking histological features to mRNA and protein expression profiles. www.nature.com/scientificreports/ Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article's Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article's Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creat iveco mmons .org/licen ses/by/4.0/.