Skip to contents

Shape Analysis of Fish Otoliths
Anàlisi de FORmes d’Otòlits in R


Version License: MIT R Version Documentation R-CMD-check DOI


Overview

aforoR is an R package designed for high-precision Shape Analysis of Fish Otoliths. It implements the methodology established by the AFORO team (Parisi-Baradad et al., 2005), providing a complete workflow from image preprocessing to advanced morphometric descriptors.

While specifically optimized for otoliths, the package is equally powerful for analyzing other closed biological structures such as leaves, statoliths, beaks, and shells.

Key Features

  • Automatic Scale Detection: Automatically identifies 1mm scale bars in images to convert pixel measurements to physical units (mm).
  • 📐 Advanced Morphometrics: Comprehensive calculation of geometric indices:
    • Basic: Area, Perimeter, Length, Width.
    • Indices: Roundness, Form Factor, Circularity, Rectangularity, Ellipticity, and Aspect Ratio.
  • 🌊 Multi-scale Wavelet Analysis: Decomposition of contours using discrete wavelet transforms for detailed frequency-based shape characterization.
  • 🎯 Elliptic Fourier Descriptors (EFDs): Standard Fourier-based shape analysis.
  • 📈 Curvature Scale Space (CSS): Geometric approach for detecting inflection points and lobes at multiple smoothing scales.
  • 📍 Optimal Point Selection: Implementation of the Hall & Bathia (2012) algorithm for identifying the most discriminative points in functional data.
  • 📦 Batch Processing: Efficiently process entire directories of images with automated output generation.

Installation

# Install development version from GitHub
if (!require("devtools")) install.packages("devtools")
devtools::install_github("oterium/aforoR")

# Load the package
library(aforoR)

Quick Start

The easiest way to use aforoR is the process_images function, which automates the entire analysis pipeline for a folder containing .jpg images.

library(aforoR)

# 1. Define your working directory with images
my_images <- "path/to/your/images"

# 2. Run the automated pipeline
# This will perform: Preprocessing -> Scale Detection -> Contour -> Wavelets -> Morphometrics
process_images(
  folder = my_images,
  detect_scale = TRUE,   # Automatically find 1mm scale bars
  wavelets = TRUE,       # Compute wavelet coefficients
  ef = TRUE,             # Compute Elliptic Fourier Descriptors
  save = TRUE,           # Export results as CSV files
  testing = TRUE         # Generate diagnostic visualizations
)

Learning Resources (Vignettes)

The package includes detailed tutorials (vignettes) to guide you through different analytical scenarios:

Tutorial Description
Obtaining Contour Introduction to the core image processing and contour extraction workflow.
Otolith Morphology Introduction to otolith structures and orientation.
Otolith Morphometry Guide to calculating shape indices and modeling allometric relationships (fish-otolith).
Knowing Wavelets Technical background on wavelet transform and scales.
Working Wavelets Deep dive into wavelet-based population comparison, PCA, and classification models.
Analyzing Lobes Specialized analysis of specific morphological features (lobes).
Shape Descriptors Comparison between EFD, Wavelets, and CSS for otolith analysis.
Point Selection Sequential point selection for classification using the Hall & Bathia algorithm.
Phenotypes Detection of different phenotypes based on shape.
References Bibliography and datasets used in the package.

Citation

If you use aforoR in your research, please cite it as:

Otero-Ferrer, J.L., Tuset, V.M., Manjabacas, A., Lombarte, A. (2025). aforoR: Anàlisi de FORmes d’Otòlits / Shape Analysis of Fish Otoliths. R package version 0.1.0. https://github.com/oterium/aforoR

Acknowledgments

Developed by JLOF, VMT, AM, and AL. Based on the AFORO methodology for marine science and morphological research.


🐟 Happy Otolith Analysis! 🐟

Made with ❤️ for the fisheries science community

GitHub stars