eigensound {SoundShape} | R Documentation |
Sound waves onto morphometric data
Description
eigensound
is the main feature of SoundShape
package. For each ".wav"
file on a given folder, the fuction will compute spectrogram data and acquire semilandmarks using a 3D representation of sound (analysis.type = "threeDshape"
), allowing its users to acquire, and simultaneously store point coordinates (i.e. semilandmarks) as an R object, and/or in TPS format – the native file format of James Rohlf’s TPS series (Rohlf, 2015).
Moreover, eigensound
also allow its user to export 2D and 3D spectrogram images (plot.exp = TRUE
) that are helpful during the protocol for error verification and for illustrative purposes (see Rocha & Romano in prep). Alternativaly, eigensound
feature the option of acquiring semilandmarks as the cross-correlation between energy quantiles and a curve of relative amplitude from 2D spectrograms (analysis.type = "twoDshape"
; see Details
section).
Usage
eigensound(
analysis.type = NULL,
wav.at = NULL,
store.at = wav.at,
dBlevel = 25,
flim = c(0, 10),
tlim = c(0, 1),
x.length = 80,
y.length = 60,
log.scale = TRUE,
back.amp = 35,
add.points = FALSE,
add.contour = TRUE,
lwd = 1,
EQ = c(0.05, 0.15, 0.3, 0.5, 0.7, 0.85, 0.95),
mag.time = 1,
f = 44100,
wl = 512,
ovlp = 70,
plot.exp = TRUE,
plot.as = "jpeg",
plot.type = "surface",
rotate.Xaxis = 60,
rotate.Yaxis = 40,
TPS.file = NULL
)
Arguments
analysis.type |
type of analysis intended. If |
wav.at |
filepath to the folder where |
store.at |
filepath to the folder where spectrogram plots and |
dBlevel |
absolute amplitude value to be used as relative amplitude contour, which will serve as reference for semilandmark acquisition in both |
flim |
modifications of the frequency limits (Y-axis). Vector with two values in kHz. By default: |
tlim |
modifications of the time limits (X-axis). Vector with two values in seconds. By default: |
x.length |
only applies when |
y.length |
only applies when |
log.scale |
only applies when |
back.amp |
only applies when |
add.points |
only applies when |
add.contour |
only applies when |
lwd |
only applies when |
EQ |
only applies when |
mag.time |
only applies when |
f |
sampling frequency of |
wl |
length of the window for the analysis. By default: |
ovlp |
overlap between two successive windows (in %) for increased spectrogram resolution. By default: |
plot.exp |
a logical. If |
plot.as |
only applies when |
plot.type |
only applies when |
rotate.Xaxis |
only applies when |
rotate.Yaxis |
only applies when |
TPS.file |
Desired name for the |
Details
When analysis.type = "twoDshape"
and add.points = TRUE
, eigensound
will compute semilandmarks acquired by cross-correlation between energy quantiles (i.e. EQ
) and a curve of relative amplitude (i.e. dBlevel
). However, this is often subtle and prone to incur in errors (e.g. bad alignment of acoustic units; inappropriate X and Y coordinates for the sound window; narrow banded calls). Therefore, a more robust protocol of error verification is achieved using add.points = FALSE
and add.contour = TRUE
(default), which allow for quick verification of acoustic units alignment and the shape of each curve of relative amplitude (specified by dBlevel
).
Note
In order to store the results from eigensound
function and proceed with the Geometric Morphometric steps of the analysis (e.g. geomorph
package; Adams et al., 2017), one can simultaneosly assign the function's output to an R
object and/or store them as a tps
file to be used by numerous softwares of geometric analysis of shape, such as the TPS series (Rohlf, 2015).
Additionally, one may also export 2D or 3D plots as jpeg
(compressed image) or tiff
(uncompressed image) file formats, which can be edited for publication purposes.
Author(s)
Pedro Rocha
References
Adams, D. C., M. L. Collyer, A. Kaliontzopoulou & Sherratt, E. (2017) Geomorph: Software for geometric morphometric analyses. R package version 3.0.5. https://cran.r-project.org/package=geomorph.
MacLeod, N., Krieger, J. & Jones, K. E. (2013). Geometric morphometric approaches to acoustic signal analysis in mammalian biology. Hystrix, the Italian Journal of Mammalogy, 24(1), 110-125.
Rocha, P. & Romano, P. (2021) The shape of sound: A new R
package that crosses the bridge between Bioacoustics and Geometric Morphometrics. Methods in Ecology and Evolution, 12(6), 1115-1121.
Rohlf, F.J. (2015) The tps series of software. Hystrix 26, 9-12.
See Also
Useful links:
Examples
library(seewave)
library(tuneR)
# Create temporary folder to store ".wav" files
wav.at <- file.path(base::tempdir(), "eigensound")
if(!dir.exists(wav.at)) dir.create(wav.at)
# Create temporary folder to store results
store.at <- file.path(base::tempdir(), "eigensound-output")
if(!dir.exists(store.at)) dir.create(store.at)
# Cut acoustic units from original Wave
cut.cuvieri <- cutw(cuvieri, f=44100, from=0, to=0.9, output = "Wave")
cut.centralis <- cutw(centralis, f=44100, from=0, to=0.9, output = "Wave")
cut.kroyeri <- cutw(kroyeri, f=44100, from=0.2, to=1.1, output = "Wave")
# Export ".wav" files containing acoustic units and store on previosly created folder
writeWave(cut.cuvieri, filename = file.path(wav.at, "cut.cuvieri.wav"), extensible = FALSE)
writeWave(cut.centralis, filename = file.path(wav.at, "cut.centralis.wav"), extensible = FALSE)
writeWave(cut.kroyeri, filename = file.path(wav.at, "cut.kroyeri.wav"), extensible = FALSE)
# Create 2D spectrograms using analysis.type = "twoDshape"
eigensound(analysis.type = "twoDshape", flim=c(0, 4), tlim=c(0, 0.8),
plot.exp=TRUE, wav.at = wav.at, store.at = store.at)
# Create 3D spectrograms using analysis.type = "threeDshape" and store point coordinates
eig.data <- eigensound(analysis.type = "threeDshape", plot.exp=TRUE,
wav.at = wav.at, store.at = store.at, flim=c(0, 4), tlim=c(0, 0.8))