implement call detection and create pdfs
This commit is contained in:
BIN
warbleR_xeno-canto/Phaethornis-longirostris-154072-.pdf
Normal file
BIN
warbleR_xeno-canto/Phaethornis-longirostris-154072-.pdf
Normal file
Binary file not shown.
BIN
warbleR_xeno-canto/Phaethornis-longirostris-154072.wav
Normal file
BIN
warbleR_xeno-canto/Phaethornis-longirostris-154072.wav
Normal file
Binary file not shown.
BIN
warbleR_xeno-canto/Phaethornis-longirostris-154129-.pdf
Normal file
BIN
warbleR_xeno-canto/Phaethornis-longirostris-154129-.pdf
Normal file
Binary file not shown.
BIN
warbleR_xeno-canto/Phaethornis-longirostris-154129.wav
Normal file
BIN
warbleR_xeno-canto/Phaethornis-longirostris-154129.wav
Normal file
Binary file not shown.
BIN
warbleR_xeno-canto/Phaethornis-longirostris-154138-.pdf
Normal file
BIN
warbleR_xeno-canto/Phaethornis-longirostris-154138-.pdf
Normal file
Binary file not shown.
BIN
warbleR_xeno-canto/Phaethornis-longirostris-154138.wav
Normal file
BIN
warbleR_xeno-canto/Phaethornis-longirostris-154138.wav
Normal file
Binary file not shown.
@@ -67,4 +67,82 @@ write.csv(Phae.lon.LS, "Phae_lon.LS.csv", row.names = FALSE)
|
|||||||
# to speed up downstream analyses in the vignette series
|
# to speed up downstream analyses in the vignette series
|
||||||
mp32wav(samp.rate = 22.05)
|
mp32wav(samp.rate = 22.05)
|
||||||
# Use checkwavs to see if wav files can be read
|
# Use checkwavs to see if wav files can be read
|
||||||
check_wavs()
|
check_wavs()
|
||||||
|
|
||||||
|
##
|
||||||
|
# Make long spectrograms of whole recordings
|
||||||
|
##
|
||||||
|
|
||||||
|
# Create a vector of all the recordings in the directory
|
||||||
|
wavs <- list.files(pattern = "wav$")
|
||||||
|
# Print this object to see all sound files
|
||||||
|
wavs
|
||||||
|
# How long are these files? this will determine number of pages returned by full_spectrograms
|
||||||
|
duration_wavs(wavs)
|
||||||
|
# ovlp = 10 to speed up function
|
||||||
|
# tiff image files are better quality and are faster to produce
|
||||||
|
full_spectrograms(flist = wavs, ovlp = 10, it = "tiff")
|
||||||
|
# We can zoom in on the frequency axis by changing flim,
|
||||||
|
# the number of seconds per row, and number of rows
|
||||||
|
full_spectrograms(flist = wavs, flim = c(2, 10), sxrow = 6, rows = 15, ovlp = 10, it = "tiff")
|
||||||
|
|
||||||
|
##
|
||||||
|
# Once satisfied with the argument settings we can make long spectrograms for all the sound files.
|
||||||
|
##
|
||||||
|
|
||||||
|
# Make long spectrograms for the xeno-canto sound files
|
||||||
|
full_spectrograms(flim = c(2, 10), ovlp = 10, sxrow = 6, rows = 15, it = "jpeg", flist = wavs)
|
||||||
|
# Concatenate full_spectrograms image files into a single PDF per recording
|
||||||
|
# full_spectrograms images must be jpegs to do this
|
||||||
|
full_spectrogram2pdf(keep.img = FALSE, overwrite = TRUE)
|
||||||
|
|
||||||
|
##
|
||||||
|
# Automatically detect signals with auto_detect
|
||||||
|
##
|
||||||
|
|
||||||
|
# Select a subset of sound files
|
||||||
|
# Reinitialize the wav object
|
||||||
|
wavs <- list.files(pattern = ".wav$", ignore.case = TRUE)
|
||||||
|
# Set a seed so we all have the same results
|
||||||
|
set.seed(1)
|
||||||
|
sub <- wavs[sample(1:length(wavs), 3)]
|
||||||
|
|
||||||
|
##
|
||||||
|
# Run auto_detec() on subset of recordings
|
||||||
|
##
|
||||||
|
|
||||||
|
# Once we’re satisfied with the detection, we can run the auto_detec on all the
|
||||||
|
# recordings, removing the argument flist (so auto_detec runs over all wav files
|
||||||
|
# in the working directory). We will also save the temporal output in an object.
|
||||||
|
# Once we’re satisfied with the detection, we can run the auto_detec on all the
|
||||||
|
# recordings, removing the argument flist (so auto_detec runs over all wav files
|
||||||
|
# in the working directory). We will also save the temporal output in an object.
|
||||||
|
Phae.ad <- auto_detec(
|
||||||
|
path = wd,
|
||||||
|
threshold = 20, # amplitude threshold in %
|
||||||
|
ssmooth = 900, # amplitude envelope with sum smooth
|
||||||
|
bp = c(2, 10), # bandpass filter (between 2 and 10 kHz)
|
||||||
|
wl = 300, # window for ffilter bandpass
|
||||||
|
parallel = 6*2 # how many cores shall be used in parallel (*2 due to hyper threading)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Let’s look at the number of selections per sound file
|
||||||
|
table(Phae.ad$sound.files)
|
||||||
|
|
||||||
|
# create an image with all detections
|
||||||
|
full_spectrograms(flim = c(2, 10),
|
||||||
|
ovlp = 10,
|
||||||
|
sxrow = 6,
|
||||||
|
rows = 15,
|
||||||
|
it = "jpeg",
|
||||||
|
flist = wavs,
|
||||||
|
X = auto_detec(
|
||||||
|
path = wd,
|
||||||
|
threshold = 20,
|
||||||
|
ssmooth = 900,
|
||||||
|
bp = c(2, 10),
|
||||||
|
wl = 300,
|
||||||
|
parallel = 6*2))
|
||||||
|
|
||||||
|
# combine the image into a single pdf per species like before
|
||||||
|
full_spectrogram2pdf(keep.img = FALSE, overwrite = TRUE)
|
||||||
Reference in New Issue
Block a user