Package 'patternator'

Title: Feature Extraction from Female Brown Anole Lizard Dorsal Patterns
Description: Provides a set of functions to efficiently recognize and clean the continuous dorsal pattern of a female brown anole lizard (Anolis sagrei) traced from 'ImageJ', an open platform for scientific image analysis (see <https://imagej.net> for more information), and extract common features such as the pattern sinuosity indices, coefficient of variation, and max-min width.
Authors: Seong Hyun Hwang, Rachel Myoung Moon
Maintainer: Seong Hyun Hwang <[email protected]>
License: GPL (>= 2)
Version: 0.1.0
Built: 2025-03-13 03:30:22 UTC
Source: https://github.com/cran/patternator

Help Index


Dorsal pattern image of a female brown anole lizard

Description

A sample dorsal pattern pixel image of a female brown anole lizard traced from the ImageJ software.

Usage

anole

Format

A data.table with 1675 rows and 2 variables:

x

x-coordinate of a pixel

y

y-coordinate of a pixel

References

Moon and Kamath (2016), Examining the Ecological, Morphological, and Behavioral Correlates of Dorsal Pattern Variations in Female Brown Anole Lizards (Anolis sagrei).


Automatically recognize, clean and label the pixels of a dorsal pattern image traced from ImageJ

Description

The function clean_patterns implements a k-means clustering-based automatic cleaning of the continuous dorsal pattern of a female brown anole lizard traced from the ImageJ software.

Usage

clean_patterns(data, kmeans = TRUE, seed = 123, outliers = TRUE)

Arguments

data

a data.table or data.frame: an input data should have two columns x and y in that order, indicating the x-coordinates and the y-coordinates, respectively. The columns should be of type "numeric".

kmeans

logical, whether to use k-means clustering to eliminate a reference pixel, if any. Defaults to TRUE. See the details below.

seed

a single value, interpreted as an integer with the default set to 123.

outliers

logical, whether to eliminate potential outliers in the x-coordinate even after removing the 1cm reference line with k-means clustering. Defaults to TRUE.

Details

clean_patterns implements a k-means clustering-based automatic cleaning of the continuous dorsal pattern of a female brown anole lizard, Anolis sagrei, traced from ImageJ, an open source image processing program designed for scientific multidimensional images. The function efficiently

  • eliminates the 1cm reference pixel and possible outliers in the x direction,

  • randomly chooses a mid-dorsal axis if there exist more than one,

  • chooses the largest x-coordinate if multiple x-coordinates are given per y-coordinate,

  • manages left or right dorsal pattern that heavily crosses over the mid-dorsal axis by first removing the mid-dorsal axis and then regrouping left and right pattern,

  • removes pixels through which left or right pattern crosses over since empirically it has little impact on the values of the extracted features, see extract_features function,

  • handles left or right dorsal pattern broken with a gap

Value

Returns a data.table object with the following three columns:

x, y

the xy-coordinate of a pixel; type "numeric"

loc

the location label of a pixel, one of LEFT, RIGHT, MID; type "character"

Author(s)

Seong Hyun Hwang, Rachel Myoung Moon

Examples

# load the sample dorsal pattern image
data(anole)

# plot of the pattern shows it contains the reference pixel
plot(anole$x, anole$y)

# remove the reference pixel, possible outliers and ambiguities
cleaned <- clean_patterns(anole)

# check the plot again
plot(cleaned$x, cleaned$y)

Extract quantitative features from the continuous dorsal pattern of a female brown anole lizard

Description

The function extract_features efficiently extracts various features such as the pattern sinuosity indices, coefficient of variation, and max-min width from the output of clean_patterns.

Usage

extract_features(data)

Arguments

data

a data.table or data.frame object with three columns x, y, and loc in that order, indicating the x-coordinate, the y-coordinate, and the location of a pixel (LEFT, RIGHT, or MID), respectively, preferably from an output of clean_patterns. The xy-coordinates should be of type "numeric", whereas the location should be of type "character" and capitalized.

Details

extract_features efficiently extracts common features from the continuous dorsal pattern of a female brown anole lizard, Anolis sagrei, such as the pattern sinuosity indices, coefficient of variation, and max-min width. The input data should either be a data.table or data.frame object with the columns indicating the xy-coordinates and the location of the pixels.

Value

Returns a data.table object with the following columns:

lt_psi, rt_psi

left/right pattern sinuosity index (PSI), computed as lt_len / md_len and rt_len / md_len, respectively

av_psi

average pattern sinuosity index (PSI), (ls_ind + rs_ind) / 2

lt_pcv, rt_pcv

left/right pattern coefficient of variation (PCV), computed by dividing the standard deviation of the distance values between mid-dorsal axis and left/right pattern by the average distance.

av_pcv

average pattern coefficient of variation (PCV), (lt_pcv + rt_pcv) / 2

max_width, min_width

the maximum and the minimum width between the left and the right pattern

av_width

average width between the left and the right pattern

pmm

pattern max-min width (PMM), (max_width - min_width) / av_width

pasy

pattern asymmetry index (PASY), computed by first subtracting the distance between mid-dorsal axis and left pattern from the corresponding distance between mid-dorsal axis and right pattern and then taking the average of the resulting differences; the closer to zero it is, the more symmetric the dorsal pattern is on average

lt_len, rt_len, md_len

the length (the count of pixels) of the left pattern, the right pattern, and the mid-dorsal axis, respectively

Author(s)

Seong Hyun Hwang, Rachel Myoung Moon

Examples

# load the sample dorsal pattern image
data(anole)

# clean the dorsal pattern and extract quantitative features
features <- extract_features(clean_patterns(anole))