ρ -MtreeRing: A Graphical User Interface for X-ray Microdensity Analysis

: Wood microdensitometry provides an integrated measurement of inter and intra-annual changes in wood anatomy and ligniﬁcation. Although it can be acquired through a wide array of techniques, X-ray-based techniques are still the standard. Conversion of a grayscale X-ray image to density and annual ring boundaries delimitation is performed through image analysis software. Proprietary software has dominated these applications, albeit Free Open Source Software (FOSS) has been developed recently. We present ρ -MtreeRing, a user-friendly FOSS that streamlines the entire microdensitometry analysis process through a graphical user interface based on Shiny R Software without any programming knowledge. We compared the results of this program with the most widely used commercial software (WinDendro), showing the validity of the results. ρ -MtreeRing can be personalized and developed by the microdensitometry research community.


Introduction
Xylem cell formation involves sequential processes of cell division, expansion and lignification [1]. The dynamics of these processes are affected by intrinsic and environmental factors leading to differences in xylem structure. Dendrochronology aims at extracting this environmental information from annual ring features. Ring width has been historically the main proxy, since it can be easily measured and checked for quality control through cross-dating. Ring width data basically depends on the cell division process with a minor expansion effect [2]. Wood quantitative anatomy is more effective since it can isolate information from the different xylem development phases, with the ability to extract intra-annual variability [3]. Despite ongoing improvements in lab and computer techniques [4,5], xylem quantitative anatomy is still highly work intensive, and does not capture lignification processes, particularly in the complex xylem of angiosperms [6,7].
Wood microdensitometry synthetizes xylem anatomy properties [8]. In contrast to ring-width and quantitative anatomy, densitometry also captures lignification. The strong link between maximum density and summer temperature in cold and temperate environments has dominated the applications of densitometry [9], albeit maximum density is also a good proxy to reconstruct defoliation events [10][11][12]. The applications of minimum density have been historically neglected despite its high potential to reconstruct spring conditions [13][14][15]. Moreover, studies in microdensitometry are strongly biased to gymnosperms despite the vast potential of this technique in angiosperms.
Although densitometry can be acquired by a wide array of techniques (reviewed in [9]), X-ray-based techniques are still the standard. These techniques produce a grayscale image where density profiles can be extracted from. Digital output is becoming common thanks to recent techniques, although film digitalization is still the standard. Once the gray values are obtained, ring boundaries have to be identified to extract meaningful values for each ring of the core. This step is commonly performed either manually or using a mathematical algorithm to detect the density drop associated with late and earlywood transitions between consecutive years [16,17]. However, this is not always straightforward, particularly in cores with density fluctuations or angiosperms with diffuse xylem, where the density drop is not so sharp and thus requires expert supervision.

Available Software
Acquisition of density profiles has been commonly performed by using proprietary software such as WinDENDRO™ [18], LignoVision™ (Rinntech ® ) or CooRecorder™ [19]. These commercial tools developed for dendrochronological studies present valuable graphical and statistical options and support by a private company who keeps the program stable. However, many labs could not bear costs mainly for the two first software and, in addition, proprietary licenses avoid customization through code modification by the user. Proprietary software hampers covering specific needs and requires the software upgrade by the proprietary company or the use of third software to fill up this lack, e.g., exporting data in a certain format.
Recently, some Open Source Software (OSS) have been released for dendrometry tasks [20][21][22][23]. OSS lacks the feasibility and support of the commercial one but shows high potential for the scientific community because of its result reproducibility, cooperative and shared knowledge, and the possibility of code modification by community members to cope with the specific requirements of each lab or research objective. Moreover, most of those are released as Free Open Source Software (FOSS), removing economic barriers of access. Thus, among other programming languages, R [24], with a GNU license, appears as one of the most used languages for scientific OSS due to its simplicity as an interpreted language, its possibility of implementation through a graphical user interface, (GUI) making it easier to use, and its availability for the most used operating systems.
Microdensity profile analysis can be approached by the R package xRing [21]. This software offers multiple options in a sequential pipeline, including density calibration, automatic ring detection, user correction and density data exportation. However, it lacks a GUI for the whole process, resulting a critical limitation for those researchers unfamiliar with programming. An adequate GUI for the entire analysis process could help to ease and speed the process of microdensity profiles extraction up. Furthermore, algorithms for ring auto-detection perform weakly for angiosperms with diffuse porous wood due to their wood features and the associated time-consuming process of manual correction, which can be reduced using a graphical effective tool.
There is a trend of measuring wood rings using digital images [19,[25][26][27][28]. Recently, Shi et al. [23] developed MtreeRing, a friendly user interface, for dendrometric studies from RGB or grayscale images with ring detection algorithms, which can be customized according to sample characteristics. In addition, the whole process can be carried through a Shiny [29] interface, removing entry barriers for people without programming abilities. However, its use is limited to ring width measurements without options for densitometry analysis or saving the project to reopen it later on. In order to fill this gap, we have developed ρ-MtreeRing, combining the strengths of MtreeRing GUI and microdensity methods. Thus, the entire densitometry analysis process from X-ray image loading, density calibration, automatic ring detection and correction and data exportation can be reached using a GUI, enabling its implementation in a user-friendly software, which saves time at various steps of the process and can be used by any layman in programming matters. In this manuscript, we present ρ-MtreeRing and compare its results with the most widely used commercial software WinDENDRO™.

Software Description
The ρ-MtreeRing interface is based on MtreeRing [30], built using the Shiny package, and therefore inherits most of its functionality. The Shiny package provides a server that allows interaction between the R framework and a web browser (e.g., Chrome, Firefox, Safari) to display the graphical interface. This interface is almost entirely written in R, with small parts in Javascript and CSS. ρ-MtreeRing code is available through GitHub (https://github.com/CambiumRG/rhoMtreeRing) (accessed on 2 August 2021). The main new features of the ρ-MtreeRing interface are described in the subsequent sections.

Light Calibration
High-resolution X-ray, the most used technique for wood density [31], outputs a grayscale digital image or a radiographic film, which is usually digitalized into 256 levels in 8 bit images but sometimes in 16 bit. Thereafter, light calibration correlates the grayscale values from the stepped calibration wedge, captured simultaneously with the sample, with its known density and thickness values.
Reference data from a stepped calibration wedge can be entered by hand or loaded from a text file at the ρ-MtreeRing first section, Data Loading. Afterward, the user selects the most suitable regression method, Local Regression or Cubic Smoothing Spline, to visualize the Light Calibration, i.e., the curve that relates each gray value in the image to the optical density of the calibration wedge, Figure 1.

Sample Info
The analysis of concrete elements from digital images needs to link digital features with real features, e.g., the number of pixels and known distance. Thus, ρ-MtreeRing requires spatial dot density from the image at the scanning process to measure the ring width and the sample thickness for wood density calculation. Therefore, in the Analysis section, the user completes Sample Info with those concrete values in dots per inch and millimeters, respectively.

Density Profile
Density values are obtained from the path set by the user and converted into density values according to the Light Calibration Curve. The user sets a path with customized length and width according to the characteristics of the sample. Moreover, contiguous segments can be settled orthogonally to ring growth to prevent blurring, and dummy values can be used in case fiber tilt is recommended.
After length delimitation, the path width value can be adjusted and the density value extraction varies accordingly. Thus, wider path widths minimize the effect of outliers on density values but increase computing costs. In the case of inclined paths, the software internally adjusts the image to extract the density value of the pixels perpendicular to the marked path line. As a user-friendly interface, ρ-MtreeRing simultaneously shows the obtained density profile and the real image of the sample, including zooming options to check the extraction process robustness, Figure 2.

Ring Detection and Editing
The wood microdensity value is relevant at an inter-annual level, which depends on ring border segmentation. In the density profile, ring borders are commonly detected by a steep drop in the transition from latewood to earlywood of the most recent year [21]. ρ-MtreeRing allows automatic ring detection using the same detection algorithms as MtreeRing, which are two classic image processing methods such as watershed, and Canny edge detector, as well as measuRing linear detector [25]. However, to detect the rings with these methods in X-ray images, it is necessary to apply a pre-processing step consisting of the inversion of the gray values of the image, i.e., light pixels are mapped to dark, and dark pixels are mapped to light.
However, ring differentiation is never an easy task, mainly when transitions between late and earlywood density are not sharp enough to be detected. Once the automatic detection is launched in ρ-MtreeRing, ring borders are shown as dots in the real image and, in parallel, as division lines in the density profile. This simultaneous view enables the researcher to check if ring borders were properly detected or not at a glance. Additionally, the user can check and correct, if necessary, that automatic detection, adjusting ring limits on the sample image through an interactive mode with the mouse cursor.

Early and Latewood
Wood density information is meaningful not only at the inter-annual perspective but also in its intra-annual variations. For these studies, early and latewood must be discerned. Therefore, ρ-MtreeRing incorporates automatic identification and correction options for early-latewood based on the ring detection methods (watershed, Canny edge and measuRing). Thus, the user can select different methods for ring or early-latewood identification, Figure 2.

Exporting Results
Once the ring or early-latewood borders are set, the researcher can incorporate Optional Sample Information in the Results section related to location, species or lead researcher, inter alia. This kind of information associated with the specimen origin is, as an afterthought, compiled with the Sample Info required for the density analysis.
ρ-MtreeRing collects data of the microdensity analysis on an eight-column dataset according to the features of year, x and y position of the ring border, ring width, mean density value, intra-annual density standard deviation, and the maximum and minimum density. In the case of intra-annual studies, earlywood and latewood features are incorporated. It should be noted that the maximum and minimum density values exported correspond, respectively, to the average of 5% of the pixels with the highest and lowest density values in the region under analysis (e.g., earlywood, latewood). This is intended to reduce the effect of possible spurious pixels that could produce unusual density values. Meanwhile, the number of rows is equal to the number of years detected. All these values can be exported in a Comma Separated Values (CSV) format file or in Excel (XLSX) and, using dplR [32], Ring Width Length (RWL) files, which both include Sample Info for dendrochronological analysis.
Project exportation in R Data Format (RDS) allows to reopen the complete project in ρ-MtreeRing further on from the Data Loading section and modify the analysis at any of its steps.

Comparison with Commercial Software
The ρ-MtreeRing effectiveness was checked based on WinDENDRO™ results. This is a widely used proprietary software, considered a robust tool for microdensity studies [33,34]. Wood cores were collected at breast height with a Pressler borer from six Austrian pines (Pinus nigra Arn.) in Sierra de Cazorla (Jaén, Spain) in the framework of a research project evaluating the variability in the climate response of this species. Pinus nigra is a circummediteranean mountain species with a remarkable longevity with strong potential for microdensity analysis [35]. Increment cores were air dried and sawed obtaining uniform cross-sections of 2 mm thickness. Furthermore, cross-sections were resin-extracted with a 72-h penthane bath and air dried before the X-ray film was obtained, according to Polge [16] procedures. Finally, X-ray films were scanned at 1000 dpi, obtaining digital images for further software analysis.
Individual images were analyzed independently with ρ-MtreeRing, according to the user manual (Supplementary Materials) at the Botany Lab of the University of Valladolid (Soria, Spain), and WinDENDRO™ at INRA GENOBOIS (Orleans, France), where the two density parameters were calculated at the ring level using routines written in R [24]. The calibration parameters selected were following standard procedures for each software, "spline" in WinDENDRO™ and "local regression" in ρ-MtreeRing. Two ring level density parameters were calculated: minimum ring density (Dmin, kg·dm −3 ), and maximum ring density (Dmax, kg·dm −3 ).

Results and Discussion
We analyzed a total of 529 rings from the six cores, obtaining minimum and maximum density values for each ring. The values obtained by ρ-MtreeRing and WinDENDRO™ were highly correlated for both parameters (maximum density r = 0.966, p < 0.0001; minimum density r = 0.962, p < 0.001), Figure 3A,B. Slight differences can be attributed to small disagreements in ring delimitation.
The curve value comparison in Figure 3C attests to subtle variations of density measurements between the ρ-MtreeRing and WinDENDRO™ output. Since minimum density value extraction is close to the lowest calibration limit, Figure 1, by extracting the mean of the 5% lowest values in each ring, ρ-MtreeRing minimizes the effect of extreme values. This results in slightly large minimum density values in ρ-MtreeRing, although it matches the same trajectory as the WinDENDRO™ output, Figure 3C. Maximum density results are extracted essentially from latewood. The wood samples present homogeneous and sufficient latewood that reflects robust density values in the light calibration curve, Figure 1. Consequently, the maximum density output is less sensitive to outliers, and both software outputs are almost identical, Figure 3C. Therefore, ρ-MtreeRing fulfills the same performance as WinDENDRO™ .

Conclusions
ρ-MtreeRing is a user-friendly software for microdensitometry analyses from X-ray images. This free tool includes density calibration, rings, early and latewood detection, the editing process, data importation and exportation in different formats. Its friendly interface for the whole microdensity extraction process and the simultaneous display of the density profile and the original sample image streamlines the ring limit supervision and data extraction against other available software. Furthermore, ρ-MtreeRing has been tested through 80 hours of density profile extraction for bug detection resulting in a stable and reliable software. The software, as well as a complete manual (Supplementary Materials) with sample material, is provided on GitHub (https://github.com/CambiumRG/rhoMtreeRing) (accessed on 17 September 2021). As a GUI, ρ-MtreeRing allows its standard use by researchers not trained in programming; meanwhile, as a FOSS, it shatters economic barriers for this kind of tool and sets the scene for its evolution or customization according to different lab-specific requirements.