TITLE: Extracting shape and size information from fungal spores
AUTHORS: Alexander Ordynets, Sarah Keßler, Christina Willemsens

[DESCRIPTION]
<div class = "text-blocks"><div class = "text-block">The protocol explains extracting and quantifying the shape and size information from the fungal spores. The complex information about the outline will be transformed into few values that can be used as shape descriptors in comparative analyses. </div><div class = "text-block">The photos of spores from the light microscopy serve as input data. The shape information is processed with the elliptic Fourier analysis and afterward with the principal component analysis (PCA). The size information is captured as linear measurements of length and width. The average per specimen values for shape and size traits are then calculated in R computing environment. </div><div class = "text-block">The protocol can be also applied to the images from other kinds of microscopy or to images of macroscopic objects (plants, animals, or their organs). The protocol contains example files and screenshots that should assist in the processing of own data. See "Materials" for the list of used software and "Guidelines and Warnings" for the flowchart illustrating the protocol. </div></div>

[STEPS]
?. [SHAPE: ChainCoder]
Select files containing all pictures for one specimen. They are BMPs located in their own folder, according to the instructions above.Then proceed the furtherpictures one-by-one.Click "Load Image".Click 'Select Area' to crop the image and leave just the area of interest.
?. [SHAPE: ChainCoder]
Turn the image to grayscale by using the green channel. It is a "G" option right to the "Gray Scale" button. Green works better than other channels for the spores that are colored in pink hues with Phloxine.
?. [SHAPE: ChainCoder]
Click 'Make Histogram' which will propose the threshold for identifying the pixels as belonging to the object vs. belonging to the background. The threshold that ChainCoder proposes itself usually works well. For the pictures with lower contrast, selecting the value slightly smaller than proposed by ChainCoder can help. A binary (black and white) image will be created.
?. [SHAPE: ChainCoder]
Click the button "Labeling Object" to select the objects that are larger than the specified number of pixels. The default 500 works for most cases but for specimens with small spores (Click "Chain Coding" to get the chain codes for the spores. Chain code is  a sequence of x and y coordinates describing the outline of an object.Write the chain codes from the given image to a file ("Save to File") and proceed with the next image of this specimen. When ready with all images for one specimen, close ChainCoder. The ready .chc file with the chain codes for one specimen is attached below.
?. [SHAPE: Chc2Nef]
Press the "Start" button to check one by one all objects stored in the .chc file.  When confident that the object is an intact spore (and not some cell fragment of the fungal fruiting body or not a crystal) and object orientation is correct (spore's hilar appendix is in the upper left quarter - already now or after 180-degree rotation (button "Turn 180deg" ), and spore outline does not contain artifacts, send the NEFD data on this spore to the .nef file with the "Save/Next Obj." button. Proceed until all objects in the .chc file will be examined and good spores will be sent to a .nef file.Ready  .nef file with all spores of one specimen is attached below.
?. [SHAPE: PrinComp+PrinPrint]
Open PrinComp program to perform a Principal Component Analysis. Import the combined.nef file from the previous step.
?. [Image capture]
Prepare a microscope slide. Place small pieces of fungal dried herbarium specimen in a drop of 3% aqueous solution of potassium hydroxide (KOH) mixed with 1% aqueous solution of Phloxine. The volume proportions of KOH vs. Phloxine in a mixed drop should be approximately 3:1. Examine squash preparations at 1000× magnification and find the places, if possible, with numerous spores in a view field. Capture the image, e.g. as JPEG file.
?. [Image pre-processing]
For further processing, select images that contain one or several healthy (not broken, with intact cell wall) mature (not attached to basidia) and well-focused spores. Focus only on spores that lay clearly in lateral projection, i.e. so that hilar appendix (approximate locus of attachment to basidia) is directed to the side as far as possible from the longest axis of the spore. Furthermore, for meaningful shape analysis, spores have to be alignable, i.e. with hilar appendix stretched to the same direction if the spores are aligned. We agreed that the same direction means the upper left corner if the spore is placed strictly horizontally and with the base at the left and apex to the right. Some images have to be mirrored (reversed along the horizontal axis) to meet this criterion. This can be done with a built-in photo editor of Windows 10. It can be that some spores are usable from the image before reversing, and some - after. In such cases, both image versions are kept for analysis but have to be marked correspondingly (see the next protocol step for details of naming the images).Additional manual adjustments can be applied to some images to enhance the clarity of spore outlines and prevent the overlap with the structures that are not spores (crystals or hyphae). These adjustments are made with the Paint 3D or classical Paint tool of Windows 10. These adjustments do not affect the geometric properties of the spore outlines but make spore contour extraction more efficient.
?. [Image pre-processing]
Create a third folder and move there the ready JPEGs (i.e. that are edited and re-named). Bulk-convert the JPEGs into BMP files with ImageMagick. For this,  open Windows PowerShell in this folder and type:magick mogrify -format bmp *.jpgAfter BMP files were created, remove the JPEGs from this folder.
?. [Image pre-processing]
For each specimen, keep the uniform folder structure. Keep the original JPEGs and processed JPEGs and BMPs in separate folders.
?. [SHAPE: ChainCoder]
Open ChainCoder program of the SHAPE package.When configuring ChainCoder, for proper capturing of objects from the very first one, specify that the scale is missing on the pictures. Otherwise, the first spore will be considered as a scale.
?. [SHAPE: ChainCoder]
To remove the shape artefacts like protrusions, apply erosion-dilation filter, the option "Ero Dil Filter", with number iterations set to one. To remove shape artefacts like cavities, if such are present, use the dilation-erosion filter, "Dil Ero Filter", with iteration specified arbitrarily as one or two, very rarely three to four per image. In most cases, "Dil Ero Filter" will not be necessary.
?. [Command prompt and text editor]
When all NEF files for separate specimens are obtained, place their copies in one folder and combine them into a single file in Windows PowerShell. Open PowerShell in the folder where .nef files for separate specimens are placed and type:Get-Content *.nef | Set-Content 30specimens_raw.nef"30specimens.nef" is the arbitrary name of the resulting file, which informs of the amount of data in it.Access the file here:
?. [Shape data processing: PCA]
Average the PCA scores of individual spores at specimen level in R (R Core Team 2020). If more than one PCA analysis was performed (e.g. separately for symmetric and asymmetric variation), apply this operation to each PCA outcome separately.R code for the case of symmetric variation is below.library(here)scores_symm_raw # add column to be filled in later with specimen IDsscores_symm_raw # fill in column specimen_ID based on content of the column DATA_NAME library(stringr)strings scores_symm_raw$Specimen_ID library(dplyr)scores_symm_summ %   group_by(Specimen_ID) %>%   summarise(PC1_symm_mean=mean(PC1), .groups = 'drop')
?. [PCA: PrinPrint]
For those spores for which NEFD were successfully obtained, take also the linear measurements. Measure spore length and width with Fiji distribution of ImageJ version 2.1.0/1.53c that used Java 1.8.0_172 [64-bit] (Schindelin et al. 2012).As Fiji does not differentiate whether the measurement is of category “length” or “width”, measure constantly for each spore firstly length and then width. Check the total number of measurements in the table is an even number, which ensures that length and width were measured for each spore. When all measurements are done, export them as a .csv file.
?. [PCA: PrinPrint]
We then split the resulting measurements into length and width columns in R (R Core Team 2020). Based on length and width values, we also derived their ratio and used it as an additional variable in statistical analyses. Spore length to width ratio is used frequently in the taxonomy of fungi, especially Agaricomycetes (Parmasto et al. 1987). R  code to proceed .csv measurement files stored in a single directory.  library(readr) import.size library(dplyr) data_size_raw_odd % dplyr::slice(which(row_number() %% 2 == 1)) colnames(data_size_raw_odd)[which(names(data_size_raw_odd) == "Label")] % dplyr::slice(which(row_number() %% 2 == 0)) colnames(data_size_raw_even)[which(names(data_size_raw_even) == "Length")] data_size_tiny_simple data_size_tiny_simple$Length_to_width_ratio data_size_tiny_simplelibrary(tidyverse)strings size_summ %    group_by(Specimen_ID) %>%    summarise(Length_mean=mean(Length),             Width_mean=mean(Width),             Length_to_width_ratio_mean=mean(Length_to_width_ratio), .groups = 'drop')
?. [References]
?. [Fiji: linear measurements]
For exactly those spores for which NEFD were successfully obtained, take also the linear measurements.Measure spore length and width with Fiji distribution of ImageJ .Open Fiji. Open the picture and set the scale (Analyze > Set Scale). In our lab, we know that full image width equals 129 mkm. However, an image can be of different sizes in pixels. In our dataset, it is either 1024 or 2048. This has to be accounted for in the "Set Scale" window. Tick the box "Global" to make the scaling valid for all images from this specimen if you are sure they are all of the same sizes.
?. [R: size data summary]
Move the resulting measurements into separate length and width columns in R. R code:library(dplyr)# get odd valuesdata_size_raw_odd % dplyr::slice(which(row_number() %% 2 == 1))colnames(data_size_raw_odd)[which(names(data_size_raw_odd) == "Label")] # get even valuesdata_size_raw_even % dplyr::slice(which(row_number() %% 2 == 0)) colnames(data_size_raw_even)[which(names(data_size_raw_even) == "Length")] # bind the columnsdata_size_tiny # rename the columnsdata_size_tiny_simple
?. [Shape data processing: PCA]
Open PrinPrint of the SHAPE package (Iwata and Ukai 2002). Load the .pcs file with the  will be automatically executed, showing the principal component contours# (optional) If changing options for contour drawing in the Draw Option Box, click 'Redraw' for them to be appliedthe shape variation accounted for by each principal component with PrinPrint software. Mean shape and plus and minus two times the standard deviation shape for each principal component were reconstructed
?. [SHAPE: Chc2Nef]
Open Chc2Nef program of the SHAPE package. Select the chain-code file (.chc) to work on and create a NEF file (.nef) where the Normalized Elliptic Fourier Descriptors (NEFD) will be saved. Please note that .nef format used by Ch2Nef is not related to the Nikon Electronic Format that is abbreviated in the same way.  In the field for "Max Harmonic No" stay with the default value of 20. Each harmonic is a level of detalization of the contour information. Twenty harmonics represent the shape of the object very well, as authors of SHAPE package show in their tutorial (see the Reference to Iwata and Ukai 2002 in "Materials" panel). As a normalization method,  use the approach based on the first harmonic.
?. [Image pre-processing]
For each of the captured images, the default file name should be modified to include the specimen name. This is necessary for further correct summarizing of information at the specimen level.Make bulk photo file renaming with Bulk Rename Utility  AB1Raw file nameEdited file name2image001.jpgKHL_14355_01.jpg
AB1Raw file nameEdited file name2image001.jpgKHL_14355_01.jpg
?. [Image pre-processing]
Place raw JPEG files with images from a single specimen into one folder. Create a copy of this folder and further work only with the copy. In this way, the original JPEGs will stay unchanged and serve as a backup.
?. [SHAPE: ChainCoder]
If the ChainCoder crashes at the step "Labeling Object",  it is probably due to the difficulty to select the spores because of their small size. If this is the first image in the given specimen, restart ChainCoder and use a smaller value next to the "Labeling Object" button, e.g. 200 or 100. If ChainCoder crashes not on the first image that is analyzed for the given specimen but later, be aware of the following. The chain codes from previous images (processed before the crash) are successfully written to .chc file and remain unaffected. The chain code(-s) for the image on which the crash happened will not be saved to .chc file. To solve the problem, close and then re-open ChainCoder. Import the image on which the crash happened and all subsequent images. Save the chain codes with a smaller value for "Labeling Object" button, e.g. 200 or 100. Write the chain codes to a new .chc file. After all images for the given specimen are processed, combine manually the contents of two .chc files. In this way, the chain codes obtained before the program crash and after the crash will be in a single file.
?. [R: size data summary]
Summarize the data on a specimen level, by averaging, if you need a single trait value per specimen. R code:library(dplyr)size_summ %   group_by(Specimen_ID) %>%   summarise(Length_mean=mean(Length),            Width_mean=mean(Width),            Length_to_width_ratio_mean=mean(Length_to_width_ratio),             .groups = 'drop')
?. [Size data processing]
For exactly those spores for which NEFD were successfully obtained, take also the linear measurements. Measure spore length and width with Fiji distribution of ImageJ version 2.1.0/1.53c (Schindelin et al. 2012) that requires Java for working. Open Fiji. Start with the calibration. Open the picture and set the scale. In our lab, we know that full image width equals 129 mkm. However, an image can be of different size in pixels. In our dataset, it is either 1024 or 2048. This has to be accounted for in the calibration window. Tick the box "Global" to make the scaling valid for all images from this specimen.
?. [Size data processing]
Split the resulting measurements into length and width columns in R. Based on length and width values, we also derived their ratio and use it as an additional variable in statistical analyses. R code:library(dplyr)data_size_raw_odd % dplyr::slice(which(row_number() %% 2 == 1))colnames(data_size_raw_odd)[which(names(data_size_raw_odd) == "Label")] data_size_raw_even % dplyr::slice(which(row_number() %% 2 == 0)) colnames(data_size_raw_even)[which(names(data_size_raw_even) == "Length")] data_size_tiny data_size_tiny_simple data_size_tiny_simple data_size_tiny_simple$Length_to_width_ratio data_size_tiny_simple## code that using regex is based on the solution for gsub ## ## https://stackoverflow.com/questions/39366759/regex-to-extract-values-between-2-underscores-including-a-value-that-is-an-unde## https://stackoverflow.com/questions/7449564/regex-return-all-before-the-second-occurrencelibrary(stringr)strings data_size_tiny_simple$Specimen_ID size_summ %   group_by(Specimen_ID) %>%   summarise(Length_mean=mean(Length),            Width_mean=mean(Width),            Length_to_width_ratio_mean=mean(Length_to_width_ratio), .groups = 'drop')
?. 
?. 
?. 
?. [References]
?. [References]
?. [Image pre-processing]
Careful naming of the images allows keeping track of the target spores and distinguishing them from the rest of the information in the image. Below is the general pattern for naming the edited JPEGs and an example of a whole set of images for one specimen.  A1VoucherID_ImageNr_ rev[if made]_ NrOfSporesxLocation_paint[if made]  AB1KHL_14355_01_1xT_paint.jpgimage #1 with one "good" spore at the top, Paint 3D tool was applied2KHL_14355_02_2xC_paint.jpgimage #2 with two spores at the center, Paint 3D was applied3KHL_14355_06_1xC_paint.jpgimage #6 with one spore at the centre, Paint 3D was applied4KHL_14355_06_rev_1xL.jpgimage #6, reversed version, with one spore in the left part5KHL_14355_07_3x_paint.jpgimage #7 with three spores, no reversing or adjusting with Paint 3D made6KHL_14355_08_1xTR_paint.jpgimage #8 at the top-right, Paint 3D was applied7KHL_14355_13_rev_2x_R_B.jpgimage #13, usable after reversing, with two spores one of which at the right and one at the bottom part of the image8KHL_14355_14_4x.jpgimage #14 with four spores, usable "as is"9KHL_14355_21_1xCL_paint.jpgimage #21 with one spore at the center-left, Paint tool was applied10KHL_14355_21_rev_1xBR_paint.jpgimage #21 after reversing, with one spore at the bottom-right, Paint 3D was appliedTen edited images mentioned just above can be accessed from the attached archive. The pattern
A1VoucherID_ImageNr_ rev[if made]_ NrOfSporesxLocation_paint[if made]
AB1KHL_14355_01_1xT_paint.jpgimage #1 with one "good" spore at the top, Paint 3D tool was applied2KHL_14355_02_2xC_paint.jpgimage #2 with two spores at the center, Paint 3D was applied3KHL_14355_06_1xC_paint.jpgimage #6 with one spore at the centre, Paint 3D was applied4KHL_14355_06_rev_1xL.jpgimage #6, reversed version, with one spore in the left part5KHL_14355_07_3x_paint.jpgimage #7 with three spores, no reversing or adjusting with Paint 3D made6KHL_14355_08_1xTR_paint.jpgimage #8 at the top-right, Paint 3D was applied7KHL_14355_13_rev_2x_R_B.jpgimage #13, usable after reversing, with two spores one of which at the right and one at the bottom part of the image8KHL_14355_14_4x.jpgimage #14 with four spores, usable "as is"9KHL_14355_21_1xCL_paint.jpgimage #21 with one spore at the center-left, Paint tool was applied10KHL_14355_21_rev_1xBR_paint.jpgimage #21 after reversing, with one spore at the bottom-right, Paint 3D was applied
?. [NefViewer]
Open NefViewer to check that .nef file contains only "good" spores and only properly aligned spores. If some not-spore or "bad" spore was mistakenly saved to the .nef file during the work in Ch2Nef, it is possible to open the .nef file in the text editor, to find the block of text that corresponds to NEFD of not target object and remove it.This is how the NEFD code of the spore shown just above looks. The name allows identifying the piece of .nef file that corresponds to a spore as shown in the NefViewer.KHL_14355_13_rev_2x_R_B_1  1.0000000e+00  2.1160887e-17 -2.4515702e-17  1.3371701e-01  1.1878045e-03  2.8494892e-04 -2.8696282e-02 -9.3624850e-03  1.1043572e-01  8.9990081e-04  4.9820320e-03  1.6446673e-02  6.1344530e-04  1.3195405e-04 -1.0501531e-02 -4.7999060e-03  3.9693850e-02  5.3018451e-04 -7.9845890e-03  1.0748659e-02  3.3567316e-04  7.2965502e-05 -1.7759919e-03 -3.2183380e-03  1.9871497e-02  3.8722821e-04 -8.8202003e-04  8.0072021e-03  2.0927678e-04  4.0102762e-05  2.0974518e-03 -2.4564797e-03  1.1833938e-02  3.9541219e-04 -1.6406683e-03  3.8397591e-03  2.5905899e-04  1.9414425e-05  3.3191499e-04 -2.0674836e-03  7.7229891e-03  3.0094319e-04 -5.4529650e-04  4.4606975e-03  2.7419533e-04 -3.9919521e-06 -3.6893713e-04 -1.5747850e-03  5.3438975e-03  2.8856453e-04  6.8803535e-04  3.2827272e-03  2.7557006e-04 -1.6574449e-05 -6.6664217e-04 -1.4059339e-03  3.8668808e-03  2.8037904e-04  1.1016597e-03  2.4471208e-03  2.3571746e-04 -7.9720335e-05  3.1456216e-04  3.9309737e-04  2.9183263e-03  2.6148980e-04  2.8826305e-04  2.2490390e-03  2.3599510e-04 -9.3077036e-05 -8.5402535e-06  6.3461805e-04  2.2447106e-03  2.5143066e-04  1.2153733e-04  1.9634976e-03  2.3956809e-04 -6.8605422e-05 -4.6178449e-04 -2.9917648e-04
?. [Size data processing]
Select measuring mode "Straight".
?. [Size data processing]
NB! If you keep Fiji open and go on with the next specimen, check whether the image size in pixels differs there. If yes, make the calibration again.
?. [Size data processing]
Fiji does not differentiate whether the measurement is a category “length” or “width”. It will actually call all the measurements "Length" and will put them to a single column. To cope with it, measure constantly firstly length and then width of each spore. Later, it will be possible to split the measurements like we need because the length will always be in an odd place in a column and width - in an even place. Start with the length. Connect the farthermost points along the long spore axis by holding a left mouse button pressed. If the line was drawn not as you expected, make it again - measurement has not been made yet. If the line is fine, click Ctrl+M, and a table with pop up. The rightmost column will contain a value in micrometers. Now measure the width - it will be a second measurement for this spore.After another spore is measured, the table will contain four values
?. [Size data processing]
Repeat the procedure for all target spores of the given specimen. This will mean close the processed image and open one by one the others. The measurements will be put to a single table that has to be saved as a .csv file.
?. [Size data processing]
Pool data for separate specimens in Rlibrary(here)library(readr)import.size data_size_raw
?. [Shape data processing: PCA]
Open PrinComp program. Import the combined.nef file from the previous step. PrinComp program can perform three types of Principal Component Analysis:i) considering only the symmetric shape variation (leave selected only coefficients a and d);ii) considering only the asymmetric shape variation (leave selected only coefficients b and c); iii) considering total shape variation not differentiated into symmetric and asymmetric (keep selected a, b, c and d). This protocol demonstrates the analysis of symmetric shape variation, i.e. the case when coefficients a and b will be selected.Click the button for Principal Component Analysis, choosing the number of analyzed harmonics.Click "Make Report", selecting output components, and save to file.Click "Calculate Principal Component Scores", choose .nef file and type a file name for the resulting principal component score (.pcs) file.Click "Reconstruct Principal Component Contours" and choose a file name for the resulting .pcc file.By default, PronComp will export the scores of the PC axes that have an eigenvalue >1 (as reported by PrinComp).
?. [SHAPE: PrinComp+PrinPrint]
If PrinComp successfully reads the file in, the windows as shown below will appear. Note the three first coefficients that PrinComp selects itself as constant: a1, b1, and c1. Here, nothing has to be changed.
?. [SHAPE: PrinComp+PrinPrint]
?. [SHAPE: PrinComp+PrinPrint]
The window with general information on the analysis will appear. At this moment, the file of the format .txt will be saved that contains general information about the performed analysis. It is good to keep the results from PCA in a separate folder. In the different panels, various elements of the output can be checked. For example, in the panel "Eigenvalues" one can see how much variation in % each principal component can explain:
?. [SHAPE: PrinComp+PrinPrint]
Start Principal Component Analysis by clicking the respective icon (with a plot).The program can perform three versions of the analysis:i) considering only the symmetric shape variation (leave selected only coefficients a and d);ii) considering only the asymmetric shape variation (leave selected only coefficients b and c); iii) considering total shape variation not differentiated into symmetric and asymmetric (keep selected a, b, c, and d). This will be called hereinafter a global variation.This protocol demonstrates the analysis of global shape variation, i.e. the case when all four coefficients a, b, c and d will be selected for analyses.
?. [SHAPE: PrinComp+PrinPrint]
Click "Make Report", agree with the output components that the program offers to select.A file of the format .pcr will be exported with the detailed results. It can be opened in the text editor.
?. [SHAPE: PrinComp+PrinPrint]
Click "Reconstruct Principal Component Contours" (icon with a hand and pencil) and propose a file name for the resulting .pcc file.
?. [SHAPE: PrinComp+PrinPrint]
On the main panel of PrinComp, click "Calculate Principal Component Scores" (calculator icon). To export ONLY the scores of the PC axes that have an eigenvalue >1, select the box "Only On Effective Components". In this example, there are two effective components. A file of the format .pcs will be exported with the principal component scores for each spore.Access the file with score here:
?. [SHAPE: PrinComp+PrinPrint]
The program "PrinPrint" will be launched automatically and will display the information stored in the .pcc file. Mean and plus and minus two standard deviations of the shape for each effective principal component will be displayed. Print this graphical output to the .pdf file (via printer icon). Note that you can play with the position, line thickness, and colors of the displayed outlines (tools icon) before printing to a file.
?. [SHAPE: PrinComp+PrinPrint]
As an outcome, you should have a folder with five files: .txt, .pcr, .pcs, .pcc, and .pdf. Keep the file names identical for simplicity. All files are anyway of different formats but all (except pdf) can be viewed in the text editor. The .pcs is the most important for further analyses.
?. [R: shape data summary]
Average the PCA scores of individual spores at the specimen level in R. Do this step if you need a single trait value for a specimen and not interested in the shape variation between the spores of a single specimen. If more than one PCA analysis was performed (e.g. separately for symmetric and asymmetric variation), apply this operation to each PCA outcome separately.R code for the case of global shape variation is provided below.# load pca scoreslibrary(here)scores_glob_raw # add column to be filled in later with specimen IDs scores_glob_raw# create the "strings" object:library(stringr) strings # fill in the column "Specimen_ID" using the content of DATA_NAME and regular expressionsscores_glob_raw$Specimen_ID # summarize global variation at the specimen levellibrary(dplyr) scoresglobsumm %    group_by(Specimen_ID) %>%    summarise(PC1_glob_mean=mean(PC1),                PC2_glob_mean=mean(PC2),           .groups = 'drop')
?. [Fiji: linear measurements]
Select measuring mode "Straight".
?. [Fiji: linear measurements]
Fiji does not differentiate whether the measurement is of a category “length” or “width”. It will actually call all themeasurements "Length" and will put them in a single column. To cope with it, measure constantly firstly the length andthen the width of each spore. Later, it will be possible to split the measurements like we need because the length will always be in an odd place in a column and width - in an even place.Start with the length. Connect the farthermost points along the long spore axis by holding a left mouse button pressed.If the line was drawn not as you expected, make it again - measurement has not been saved yet. If the line is fine, clickCtrl+M, and a table "Results" will pop up. The rightmost column will contain a value in micrometers (because we set the scale earlier).
?. [Fiji: linear measurements]
Now measure the width - it will be a second measurement for this spore, i.e. recorded in the second row of the "Results" table.
?. [Fiji: linear measurements]
After another spore is measured (again: first length, then width), the table will contain four values in the "Length" column.
?. [Fiji: linear measurements]
Repeat the procedure for all target spores of the given specimen. This means closing the processed image and opening one by one the others. The measurements will be put to a single table that has to be saved as a .csv file.
?. [Fiji: linear measurements]
NB! If you keep Fiji open and go on with the next specimen, check whether the image size in pixels differs there. If yes, re-do the calibration (Analyze > Set Scale).
?. [R: size data summary]
Pool data for separate specimens in R. The pre-requisite is that .csv files are placed in a single folder.R code:library(here)library(readr)import.size data_size_raw
?. [R: shape data summary]
The resulting data frame should look as follows:
?. [R: size data summary]
Based on length and width values,  calculate their ratio to use it as an additional variable in comparative analyses. R code:data_size_tiny_simple data_size_tiny_simple$Length_to_width_ratio
?. [R: size data summary]
Create the new column "Specimen_ID" and fill it using the information from the column "Photo_ID" and regular expressions.The challenge in this case is that some Specimen IDs will inherit from Photo IDs a part of the string before the second underscore while some - before the third underscore. R code:data_size_tiny_simple library(stringr)strings data_size_tiny_simple$Specimen_ID For those wishing more details, the R code above using regex is based on the solution from:## https://stackoverflow.com/questions/39366759/regex-to-extract-values-between-2-underscores-including-a-value-that-is-an-unde## https://stackoverflow.com/questions/7449564/regex-return-all-before-the-second-occurrence
?. [R: size data summary]
The resulting data frame should look as follows:The averaged per specimen values of traits (in our example spore shape PC scores and size linear measurements) can be used in further analyses in R or beyond.End of the protocol.
?. [Command prompt and text editor]
After the combined .nef is ready, remove the repeated text (three lines, the first line is empty) which was present at the top of each individual file from the previous step: #CONST 1 1 1 0 #HARMO 20I use Notepad to remove the specified text (literally replace with nothing). Thus, the resulting .nef file will have this text string only at the top of the file, i.e. two first lines, but nowhere else. The adjusted .nef file should get another name, e.g. "30specimens_cleaned.nef".If the replacement does not work in a single step, make it in two steps: first for the row starting as "'#CONST" and then for the row starting with "#HARMO". NB! Remember that at the top of the file, these two lines have to be kept. Access the file here:
?. [Fiji: linear measurements]
In Analyze > Set Measurements, specify which measurements exactly have to be saved. Select "Min and max grey value" and "Display label". In this way, the program will save starting and ending points of the line to calculate the length, and labels will be kept for each measurement, to be able to understand from which image and for which specimen the measurement was taken