MicroWeaR: A new R package for dental microwear analysis

Abstract Mastication of dietary items with different mechanical properties leaves distinctive microscopic marks on the surface of tooth enamel. The inspection of such marks (dental microwear analysis) is informative about the dietary habitus in fossil as well as in modern species. Dental microwear analysis relies on the morphology, abundance, direction, and distribution of these microscopic marks. We present a new freely available software implementation, MicroWeaR, that, compared to traditional dental microwear tools, allows more rapid, observer error free, and inexpensive quantification and classification of all the microscopic marks (also including for the first time different subtypes of scars). Classification parameters and graphical rendering of the output are fully settable by the user. MicroWeaR includes functions to (a) sample the marks, (b) classify features into categories as pits or scratches and then into their respective subcategories (large pits, coarse scratches, etc.), (c) generate an output table with summary information, and (d) obtain a visual surface‐map where marks are highlighted. We provide a tutorial to reproduce the steps required to perform microwear analysis and to test tool functionalities. Then, we present two case studies to illustrate how MicroWeaR works. The first regards a Miocene great ape obtained from through environmental scanning electron microscope, and other a Pleistocene cervid acquired by a stereomicroscope.


| 7023
STRANI eT Al. and paleontologists to gain insights into the diet of several extinct groups, such as primates, including humans and hominins (DeSantis, 2016;Scott et al., 2005;Teaford & Walker, 1984), ungulates (DeMiguel, Fortelius, Azanza, & Morales, 2008;Kaiser & Brinkmann, 2006;Mihlbachler, Campbell, Ayoub, Chen, & Ghani, 2016;Semprebon & Rivals, 2007;Solounias & Hayek, 1993;Solounias & Semprebon, 2002), and carnivores (Schubert, Ungar, & DeSantis, 2010;Van Valkenburgh, Teaford, & Walker, 1990). Dental microwear analysis relies on the microscopic marks on the occlusal surfaces of tooth enamel (and/or dentin), left by the food chewed by an individual up to a few hours, days, or weeks before its death-a phenomenon referred to as the "Last Supper effect"-, depending on the rate of turnover in dental microwear of a particular consumer and food (Grine, 1986). The abundance, morphology, size, distribution, and orientation of marks are a consequence of the mechanic abrasion produced by mastication and are distinctive between different diets, depending on the fracture properties of the food items. In ungulates, a higher number of scratches over pits indicate tough-food (e.g., grasses) consumption. In contrast, a high number of pits indicate consumption of brittle, soft material such as leaves, fruits, and seeds (Solounias & Semprebon, 2002). In primates, a high occurrence of pits and coarse scratches is typical of hard-object feeders (which primarily feed on nuts and roots, and unripe fruits). Conversely, diet rich in leaves and soft fruits, which is typical of folivorous and frugivorous primates, is characterized by a low percentage of pits and narrower scratches (King, Aiello, & Andrews, 1999;Teaford, 1988).
The most common way to observe and study enamel marks is using high definition, two-dimensional pictures of a selected tooth crown region under either low or high magnification. The former, well-established approach, known as Low magnification microwear (LMM), employs high-precision casts of enamel surfaces observed by a standard stereomicroscope at 35× or 100× (for small mammals) magnification. Because it is fast and relatively low-cost, LMM is probably the most common dental microwear method today (Bastl, Semprebon, & Nagel, 2012;Rivals & Athanassiou, 2008;Rodrigues, Merceron, & Viriot, 2009;Semprebon, Taob, Hasjanova, & Solounias, 2016;Solounias & Semprebon, 2002). High magnification microwear (HMM) relies instead on pictures obtained through scanning electron microscope (SEM;DeMiguel et al., 2008;Galbany, Martínez, & Pérez-Pérez, 2004;King et al., 1999;Solounias, McGraw, Hayek, & Werdelin, 2000;Solounias & Moelleken, 1994), typically at 500× magnification. With environmental SEM (ESEM) devices, teeth can be observed directly without any damage, avoiding the risk of losing fine details during cast preparation. The downside of HMM is that it is more expensive and slower than LMM. Under both methods, enamel marks are classified, counted, and measured on a standard square area, whose size depends on the specific magnification adopted.
The recently introduced Dental microwear texture analysis (DMTA) Scott, Teaford, & Ungar, 2012;Scott et al., 2005;Ungar, Krueger, Blumenschine, Njau, & Scott, 2012) provides an alternative to both LMM and HMM. DMTA works with 3D surfaces and scale-sensitive fractal data. Unlike the traditional methods, DMTA does not require the identification of any individual feature, and the analysis is automated, thus being faster and less affected by observer error than more traditional methods (Scott et al., 2005). However, DMTA is an expensive method, as it requires the use of white-light scanning confocal microscopes (rather than simple 2D micrographs), and uses specific commercial software (Surfract ® , ©2007; http://www.surfract.com/) and additional plugins (e.g., ToothFrax and SFrax) that increase the economic burden of the approach. Moreover, whereas traditional approaches record individual wear features to better understand individual morphologies and their orientations, DMTA focuses only on the overall pattern.
Both traditional (LMM and HMM) methods and DMTA require a software application to count and score enamel marks. Such software, except for Microware (Ungar, 1995), has never been specifically designed for microwear analysis and usually requires a costly license.
In the case of Microware, one disadvantage is that it cannot discern between different subtypes of microscopic marks (e.g., large pits, coarse scratches). We therefore feel it is time to develop a freely available tool, specifically designed for microwear analysis, which allows for a more in-depth and complete investigation of the tooth occlusal features.
Here, we introduce MicroWeaR, a new free, open-access tool stored as an R package (Profico, Strani, Raia, & DeMiguel, 2018) that examines and scores microwear marks in a semiautomatic way.
The method is designed to optimize sampling and classification of microscopic marks on high-resolution pictures of tooth surfaces, under different magnification levels. Using a picture of a dental surface (provided with a metric reference for the definition of the scale factor) as the input, the operator defines the size and position of a working area first, and then tracks the microwear features. Each mark is automatically classified into one of the two main categories, either "scratch" or "pit." It is important that, for each of these two categories, the tool recognizes two subcategories "small" and "large" pits, and "fine" and "coarse" scratches, and provides the user with summary statistics for each category and subcategory (count, mean, and standard deviation). We also provide MicroWeaR R code (R Development Core Team, 2009)

| DE SCRIP TI ON: M ICROWE AR A S A TOOL FOR E S TIMATING MAMMAL D IE TS
MicroWeaR has been developed to sample and semiautomatically classify multiple features from a picture at once. The tool functions (Table 1) support a variety of image file formats (i.e., "bmp," "png," "jpg," and "tif") and convert the input image into an .Ico object. The R code provides the user with an interactive plot to scale the .Ico object to its original size using a metric reference that should be embedded in the picture. For each microscopic feature sampling is achieved by recording two distances using the left-click: the first one records the mark length, and the second its width. During the sampling procedure, the user may use the undo command to revert to a previous step and to zoom the picture in or out.
At the end of the sampling session, the function autom_class provides an automatic classification of the marks as either pits or scratches. In turn, each pit is categorized as either "large" or "small" and each scratch is classified as either "fine" or "coarse." Automatic classification parameters can also be set manually to customize the sampling procedure. The tool provides an additional function of direction to detect pairs of "parallel" and "crisscross" scratches. The autom_class function outputs a summary statistics table that can be exported in different format files (.txt, .sav for SPSS Statistics software, .csv for Excel spreadsheet), which includes the number of features of each type, the standard deviation and mean diameter of the pit, fine and coarse scratch lengths, and coarse scratch widths. Using the function autom_class, the user is able to save the original picture overlaid by a transparent layer of the identified microscopic marks highlighted with a distinctive, user-defined color. The graphical rendering of the final output is itself fully customizable.

| APPLI C ATI ON OF THE M ICROWE AR PRO CEDURE US ING RE AL C A S E S TUD IE S
We provide two case studies as examples of the step-by-step application of MicroWeaR. These are the enamel occlusal surfaces of a lower left second molar (m2) ("Phase II" crushing/grinding facet 9) of the Miocene great ape A. brevirostris (see DeMiguel et al., 2014) and an upper right first molar (M1) (antero-lingual enamel band of the paracone) of the Middle Pleistocene cervid C. e. eostephanoceros (see Strani et al., 2018). The photomicrograph of the former was acquired through ESEM (at ×500 magnification) on the original specimen (Figure 1a), whereas the image of the latter was obtained using a stereomicroscope (×35 magnification) from a cast (Figure 1b). The mold and the cast of the molar tooth crown of C. e. eostephanoceros were prepared following standard procedures (Semprebon, Godfrey, Solounias, Sutherland, & Jungers, 2004;Solounias & Semprebon, 2002). The impression was made using high-resolution Elite HD+ polysiloxane for the mold, and Araldite epoxy polymer for the cast. The MicroWeaR package supports the file formats "bmp," "jpg," "tif," and "png." As the first step, the MicroWeaR library is loaded into the R workspace. All the dependencies will be automatically installed or loaded as well. To begin the session, the user specifies the arguments path and image.type to import the image specifying where the file is located and its file format respectively.

class.Ico
Convert an image into an object of class Ico. At present, the formats "jpeg," "png," and "tiff" are supported. Limited to grayscale images plot_Ico Plot an image of class Ico. Setting the matrix that contains the coordinates of the microwear marks as set, the function returns to the image scale_Ico Scale an image of Ico class by an interactive plot selecting two points on the metric reference and defining the length of the latter After the manual sampling, the tool automatically classifies each mark within one of the two categories of features: "scratch" and "pit" ( Figure 2d). The classification is based on the length/width ratio; by default, this is set to 4 μm (≤4 for Pit and >4 for Scratch as proposed by Ungar, 1995). For each of these two categories, the tool recognizes different subcategories based on the diameter (for pits) and width (for scratches): "small" and "large" for pits (by default diameter ≤8 and >8 μm, respectively), and "fine" and "coarse" for scratches (by default the width ≤3 and <3 μm, respectively In addition, MicroWeaR provides a summary statistics report for each category and subcategory (including count, mean, and standard deviation) and the input picture with the sampled marks that can be We provide a video tutorial as Supporting Information (Video S1) for the application of the tool in R environment.

| Case studies interpretation
Regarding the occurrence of pits (N = 17), A. brevirostris resembles extant frugivores/mixed feeders such as Cebus nigrivittatus. It further displays somewhat wide scratches (Mean_width = 2.77 μm), in the Step-by-step summary of semiautomatic enamel mark recognition performed using MicroWeaR. (a) Selection of two points on the reference metric scale to scale the image (top left). (b) Selection of the working area and size ("×1": the size of the working area corresponds to the size of the input image; "select": by selecting this option, the user can customize the size of the working area). (c) Sampling session (the "next" command allows to sample a new feature, the "cancel" command undoes the last sampling step, the "stop" command stops the sampling session, the "zoom" command allows to zoom in and out). range of Pan troglodytes (Mean_width = 2.6 μm) and Pongo pygmaeus (Mean_width = 2.8 μm), which suggests a certain degree of sclerocarpy.
The results obtained by DeMiguel et al. (2014) show that, on average,

A. brevirostris diet is somewhat intermediate in between P. pygmaeus
and extant frugivores/mixed feeders such as P. troglodytes in terms of pitting incidence (N = 22), whereas it is similar to extant frugivores/ mixed feeders in scratch width (Mean_width = 1.98 μm). These results confirm a soft-fruit diet (albeit with some sclerocarpic components) and are fully consistent with those obtained using MicroWeaR (Table 2).
The dental microwear pattern of the Pleistocene deer C. e. eostephanoceros has a similar amount of pits (N = 21) and scratches (N = 25) according to the MicroWeaR semiautomatic classification (Table 3).
Most scratches are short and finely textured with a few long coarse scratches (Mean_length = 415.92 μm). Cross scratches are also detected (N = 15). Small pits are more abundant than larger ones (N = 13 and N = 8, respectively). A high number of pits and scratches with a prevalence of finely textured features indicates that C. e. eostephanoceros fed on a variety of plant types (both soft and abrasive), as commonly observed in modern mixed feeders (Solounias & Semprebon, 2002). The findings obtained using MicroWeaR are thus consistent with those obtained by Strani et al. (2018) where a larger, more indicative sample of C. e. eostephanoceros studied using both LMM and dental mesowear analysis, indicated a mixed feeder diet for this species.

| S I G NIFI C AN CE OF THE TOOL
Using traditional LMM and HMM methods, one key factor affects the validity of the results, that is how different operators count and discriminate among microscopic marks (DeSantis et al., 2013;Mihlbachler, Beatty, Caldera-Siu, Chan, & Lee, 2012). The use of a semiautomatic approach minimizes the intraobserver error because the only manual step in the whole procedure is the definition of the initial and the end point of each enamel mark. The automatic differentiation between subcategories also helps to reduce interobserver error rates when it comes to detailed interpretation of microwear features, which are usually high with traditional semiautomatic approaches (Galbany et al., 2005;Grine, Ungar, & Teaford, 2002;Mihlbachler et al., 2012). Given that MicroWeaR can be used for the analysis of any 2D image containing scars, it is also useful for recording lineal striations (i.e., number, length and breadth of scratches) in micrographs taken on nonocclusal tooth surfaces and, therefore, extensible to buccal enamel microwear quantification Pérez-Pérez, Lalueza, & Turbón, 1994;Puech, 1981) as well.
Since the creation of the R platform, libraries addressing natural science applications have rapidly increased (R Core Team, 2000). The open-access nature of the R platform allows tools to be rapidly improved, by introducing new functionalities that are under immediate diffusion and testing through the R community.
According to that, we designed MicroWeaR in order to work under different operating systems (i.e., Windows, OSX, Linux).
MicroWeaR allows the automatic classification of the marks left on the enamel surface by the last foods (Grine, 1986) processed.
Such automaticity helps keeping inter-and intraobserver error low (categories automatically assigned to each mark can be nonetheless manually edited using the mw.check function; Figure 4)  the dental microwear analysis faster, more robust, and cheaper than with any other comparable application.

| CON CLUS IONS
A new software implementation for dental microwear analysis, image containing microwear scars. Thus, it is useful for the quantification of marks as observed under either high or low magnification, on both occlusal and nonocclusal (e.g., buccal) tooth surfaces (dentin or enamel), and from either tooth originals or replicas. MicroWeaR is designed to work in different operating systems (e.g., Windows, OSX, Linux) and due to its intrinsic characteristics, it is unique to be developed further. Roma) for providing access to the laboratory facilities where the dental cast has been analyzed. We are grateful to three anonymous reviewers for providing insightful comments on the earlier version of the manuscript.

CO N FLI C T O F I NTE R E S T
None declared.

AUTH O R S' CO NTR I B UTI O N S
F.S., A.P., P.R., and D.DM. conceived the ideas and designed methodology; D.DM. and F.S. collected the data; F.S. and A.P.
wrote the R code with the contribution of P.R. and D.DM.; F.S., A.P., P.R., and D.DM. led the writing of the manuscript and contributed to the implementation of example analyses. D.P., R.S., and G.M. contributed helpful comments and provided inputs for the manuscript. All authors revised the manuscript and gave final approval.