TITLE: Phenotyping 3D coral models in MeshLab
AUTHORS: Wyatt Million, Carly Kenkel

[DESCRIPTION]
<div class = "text-blocks"><div class = "text-block"><span>This protocol describes the process of phenotyping branching coral using the 3D model editing software, MeshLab. MeshLab is a free, straightforward software to analyze 3D models of corals that is especially useful in its ability to import color from Agisoft Metashape models. This protocol outlines the steps used by the Kenkel lab to noninvasively phenotype </span><span style = "font-style:italic;">Acropora cervicornis</span><span> colonies for total linear extension (TLE), surface area, volume, and volume of interstitial space. We incorporate Agisoft Metashape markers with our Tomahawk scaling system (see </span><a href="http://Wyatt C Million, Carly Kenkel . Image capture and pre-filtering for 3D photogrammetry of coral colonies. protocols.io https://protocols.io/view/image-capture-and-pre-filtering-for-3d-photogramme-bgdcjs2w" style = "text-decoration:underline;color:blue;cursor:pointer;"><span style = ":;">Image Capture Protocol</span></a><span>) in our workflow which is useful for scaling and to improve model building. Other scaling objects can be used, however these markers provide a consistent scale that do not obstruct the coral during image capture. MeshLab measurements of TLE have been groundtruthed to field measures of TLE. 3D surface area and volume have not yet been compared to traditional methods of wax dipping, for surface area, and water displacement, for volume. However, in tests with shapes of known dimensions, i.e. cubes, MeshLab produced accurate measures of 3D surface area and volume when compared to calculated surface area and volume.</span></div><div class = "text-block"><span>For directions to photograph coral for 3D photogrammetry see our </span><a href="http://Wyatt C Million, Carly Kenkel . Image capture and pre-filtering for 3D photogrammetry of coral colonies. protocols.io https://protocols.io/view/image-capture-and-pre-filtering-for-3d-photogramme-bgdcjs2w" style = "text-decoration:underline;color:blue;cursor:pointer;"><span style = ":;">Image Capture Protocol</span></a><span>. For a walkthrough and scripts to run Agisoft Metashape on the command line, see </span><a href="https://github.com/wyattmillion/Coral3DPhotogram" style = "text-decoration:underline;color:blue;cursor:pointer;"><span style = ":;">https://github.com/wyattmillion/Coral3DPhotogram</span></a><span>. </span></div><div class = "text-block">These protocols, while created for branching coral, can be applied to 3D models of any coral morphology or any object really. Our goal is to make easy-to-use protocols using accessible softwares in the hopes of creating a standardized method for 3D photogrammetry in coral biology. </div><div class = "text-block"><span>Go to </span><a href="http://www.meshlab.net/#download" style = "text-decoration:underline;color:blue;cursor:pointer;"><span style = ":;">http://www.meshlab.net/#download</span></a><span> to download the appropriate software for your operating system.</span></div><div class = "text-block">P. Cignoni, M. Callieri, M. Corsini, M. Dellepiane, F. Ganovelli, G. Ranzuglia</div><div class = "text-block">MeshLab: an Open-Source Mesh Processing Tool</div><div class = "text-block">Sixth Eurographics Italian Chapter Conference, page 129-136, 2008</div></div>

[STEPS]
?. Open your 3D model file in MeshLab. Wavefront (.obj) is one 3D file format that can be exported by Metashape. We recommend using this format because .obj files can be exported with color included. Having color in the models is especially important when cropping the model down to just the coral. You can test out this protocol using one of our previously built models which can be downloaded here: https://github.com/wyattmillion/Coral3DPhotogram/tree/master/ExampleFile > Import mesh > select file and open
?. Generate a scale factor for a model using scaling markers/objects. This process can be completed using any object of known size that is built into the model. It is helpful to take replicate measures for different scaling objects. I use the 12 bit, 2mm sized "markers" provided by Metashape. These markers are unique targets that aid in model building as well as in scaling. For directions on where to find and how to include the markers in your models, see our Image Capture Protocol.
?. Measure 3 separate radii on the markers starting from the center of the inner black circle to the outside edge of the outer black ring (see below). The radius of the markers in our test model is 0.6 cm.a) Select the Measuring Tool and click once to set the start point for a measure then move the mouse to make the measurement and click again. The measurement will appear in the top lefthand corner of the working space. b) Press ESC to make another measurement. You can also press ESC in the middle of a measurement to rotate/zoom the model.
?. Calculate a scale factor from your measurements of the scaling object. In this case, because all of the scaling objects have identitcal dimensions you can average these lengths before creating a scale factor. For the test model, you can use the following equation:0.6 cm /(average of radii)=scale factorIn general, you can determine the scale factor with: (actual measure of scaling object/ (average of replicate 3D measures of scaling object))= scale factor*Note the units you are measuring in
?. Apply the scale factor to the model. a) Filters > Normals, Curvatures, and Orientation > Transform: Scale, Normalizeb) Enter the scale factor into X Axis box, making sure 'Uniform Scaling', 'Freeze Matrix', and 'Apply to All Visible Layers' are all checkedc) Click “Apply” to scale your model Verify the model is the appropriate size by remeasuring your scaling object, ensuring it is now equal to the real-life size.
?. If you have not already removed the background from your model in Metashape, you can now crop out anything besides the coral, including the scaling object. Remove all non-coral background by highlighting the area to be removed with the Select Vertices tool (square selection tool along top toolbar) then deleting the selected area from the mesh.Note: Including color in your models is important in this step to help visualize background to be removed.
?. We measure the surface area of the model first because subsequent steps require adding surface area to the mesh.However, if there are holes in the coral itself you can fill these holes to approximate the missing surface area of the coral. To do this, go to:a) Filters > Remeshing, Simplification, and Reconstruction > Close Holes.b) Set the "Max size to be closed" to increasingly larger sizes in increments of 50 until the hole(s) is closed. c) Uncheck all boxes below "Max size to be closed" and click applyBe careful here, setting the value too high can add surface area to the mesh that is not necessarily part of the coral (e.g. along the bottom of the model). If this happens, the surface area will be overestimated.
?. In order to determine the volume of the coral, we need to fill holes to close the mesh and make it “watertight”. Usually, this means closing the bottom of the mesh where the coral meets the substrate. If the mesh is not watertight, the software output box will tell you. To close holes:a) Filters > Remeshing, Simplification, and Reconstruction > Close Holesb) Set "Max size to be closed" to be large enough to encompass the hole (usually >3000) and uncheck all boxes belowc) Apply the Close Holes filter`
?. If a non-manifold edges/vertices error pops up you must select then delete manifold edges/vertices.To do this:a) Filters > Cleaning and Repair > Select non Manifold edges or Select non Manifold verticesb) Use Delete Selected Area tool to remove the selected edges/vertices
?. Measure linear extension of all coral branches.a) For the main axial branch, measure from the tip to the base using the newly created base from Step 6 as the endpoint.b) For remaining branches, measure from the tip to the point where the middle of the secondary branch joins with the main branch. See Below.
?. Measure volume of closed mesha) Filters > Quality Measure and Computations > Compute Geometric Measuresb) Look at software output on bottom right panel, scroll through to find the volume measurement in cm3
?. Determine the volume of interstitial space between branches of the colony by finding the volume of the model's convex hull. Interstitial space of a colony provides a potential measure of the reef complexity and habitat space that is a critical characteristic for branching corals.
?. Apply a convex hull over the coral model to create a new mesh overlayed over the most extreme points of the model.a) Filters > Remeshing, Simplification, and Reconstruction > Convex Hull b) Make sure to check "Re-orient all faces coherently", then click apply.The resulting convex hull should look like the images below. You can change the view of the convex hull by clicking viewing options for a mesh in the Layer Dialog Box on the right of the MeshLab window.
?. Measure the volume of convex hulla) Filters > Quality Measure and Computations > Compute Geometric Measuresb) Scroll through the software output box to find volume (and surface area) of the convex hull. These values will not indicate that they are associated with the convex hulll so be careful not to record the measurements produced earlier.Note: A negative volume simply means the faces of the convex hull are oriented inward; this will not change the size of the convex hull.  If you re-oriented all faces coherently when applying the convex hull, you can take the absolute value of the volume given in the software output box.
?. Measure the mesh surface area using the Compute Geometric Measure Filtera) Filters > Quality Measure and Computations > Compute Geometric Measuresb) The output will be located in the software output panel on the bottom right of the MeshLab window.  You can scroll through the output to find the surface area measurement in cm2 .
?. Calculate the volume of interstitial space by subtracting the volume of the coral from the volume of the convex hull.