mnl_sls <- imp_raven(path = "./data/raw/updated_annotations", warbler.format = TRUE, all.data = TRUE, name.from.file = TRUE, ext.case = "upper", unread = TRUE)
unread_l <- lapply(file.path("./data/raw/updated_annotations/", mnl_sls$unread_files), function(x) {
X <- read.table(x, sep = ",", header = TRUE)
X$selec.file <- X$sound.files <- basename(x)
return(X)
})
# remove 4 and 5 as those have only 1 selection and no frequency info
unread_l <- unread_l[1:3]
unread <- do.call(rbind, unread_l)
unread$type <- unread$subtype <- NA
unread <- relabel_colms(unread, hz.to.khz = TRUE)
unread <- sort_colms(unread)
head(unread)
mnl_sls <- sort_colms(mnl_sls$selections)
names(mnl_sls)
names(unread)
mnl_sls$`Begin File` <- NULL
mnl_sls <- rbind(mnl_sls, unread)
mnl_sls$sound.files <- gsub("A_AMPH_15-45_estres_parte2_AUDIO |A_AMPH_15-45_estres_parte2_Audio |A_AMPH_15-45_estres_parte2_AUDIO_", "", mnl_sls$sound.files)
mnl_sls$sound.files <- gsub("T000003.WAV", "T0000003.WAV", mnl_sls$sound.files)
mnl_sls$sound.files <- gsub("T000009.WAV", "T0000009.WAV", mnl_sls$sound.files)
mnl_sls$sound.files <- gsub("T000011.WAV", "T0000011.WAV", mnl_sls$sound.files)
mnl_sls$sound.files <- gsub("T000012.WAV", "T0000012.WAV", mnl_sls$sound.files)
mnl_sls$sound.files <- gsub("T000013.WAV", "T0000013.WAV", mnl_sls$sound.files)
mnl_sls$sound.files <- gsub("T000014.WAV", "T0000014.WAV", mnl_sls$sound.files)
mnl_sls$sound.files <- gsub(".txt$", ".WAV", mnl_sls$sound.files)
unique(mnl_sls$sound.files)
mnl_sls$selec <- 1:nrow(mnl_sls)
cs <- check_sels(mnl_sls)
# unique(cs$sound.files[grep("sound file not found", cs$check.res)])
# table(cs$check.res)
mnl_sls <- mnl_sls[cs$check.res == "OK", ]
cs <- check_sels(mnl_sls)
mnl_sls$bottom.freq[mnl_sls$selec == 2474] <- 48.9885
mnl_sls$top.freq[mnl_sls$selec == 2474] <- 73.8728
mnl_sls$bottom.freq[mnl_sls$selec == 2198] <- 59.6217
mnl_sls$top.freq[mnl_sls$selec == 2198] <- 74311.4
mnl_sls$top.freq[mnl_sls$selec == 1852] <- 111473.9
mnl_sls$top.freq[mnl_sls$top.freq > 100] <- 98
mnl_sls <- mnl_sls[mnl_sls$bottom.freq > 20,]
# export raven file to double check
# exp_raven(mnl_sls, path = "./data/processed", file.name = "pooled_manual_annotations", sound.file.path = .Options$warbleR$path)
# fix_path(path = "./data/processed/", sound.file.col = "Begin File", new.begin.path = "/home/m/Dropbox/Recordings/ratas_cin/full_recs/converted_sound_files")
manual_annot <- imp_raven("./data/processed/", warbler.format = TRUE, files = "fixed_pooled_manual_annotations_JE.txt")
cs <- check_sels(manual_annot, path = "~/Dropbox/Recordings/ratas_cin/recs/original_with_bedding/")
wav_info()
# fix_wavs(samp.rate = 200, bit.depth = 16)
# split in 5 min segments
split_sels <- split_sound_files(sgmt.dur = 5 * 60, only.sels = FALSE, X = manual_annot, parallel = 4)
cs <- check_sels(manual_annot, path = "~/Dropbox/Recordings/ratas_cin/recs/5-min_clips_no_bedding/")
split_sels <- split_sels[cs$check.res == "OK", ]
sp <- spectro_analysis(split_sels, wl = 512, parallel = 10, path = "~/Dropbox/Recordings/ratas_cin/recs/5-min_clips_no_bedding/")
split_sels$peak.freq <- sp$meanpeakf
split_sels$duration <- split_sels$end - split_sels$start
split_sels <- sig2noise(split_sels, mar = 0.005, parallel = 10, path = "~/Dropbox/Recordings/ratas_cin/recs/5-min_clips_no_bedding/")
write.csv(split_sels, "./data/processed/split_manual_annotations_5min.csv", row.names = FALSE)
# export raven file to double check
exp_raven(split_sels, path = "./data/processed", file.name = "split_manual_annotations_5min", sound.file.path = .Options$warbleR$path)
wi <- wav_info(path = "~/Dropbox/Recordings/ratas_cin/recs/5-min_clips_no_bedding/")
datatable(wi, editable = list(
target = 'row'
), rownames = FALSE, style = "bootstrap", filter = 'top', options = list(
pageLength = 100, autoWidth = TRUE, dom = 'ft'
), autoHideNavigation = TRUE, escape = FALSE)
mnl_sls <- imp_raven(path = "./data/raw/with_bedding", warbler.format = TRUE, all.data = TRUE, name.from.file = TRUE, ext.case = "upper", unread = FALSE)
mnl_sls$sound.files <- gsub("\\.WAV", ".wav", mnl_sls$sound.files)
fls <- list.files("~/Dropbox/Recordings/ratas_cin/recs/original_with_bedding/")
file.rename(from = file.path("~/Dropbox/Recordings/ratas_cin/recs/original_with_bedding/", fls), to = file.path("~/Dropbox/Recordings/ratas_cin/recs/original_with_bedding/", paste0(substr(fls, 0, 5), ".wav")))
mnl_sls$sound.files <- paste0(substr(mnl_sls$sound.files, 0, 5), ".wav")
cs <- check_sels(mnl_sls, path = "~/Dropbox/Recordings/ratas_cin/recs/original_with_bedding/")
table(cs$check.res)
mnl_sls <- mnl_sls[cs$check.res == "OK", ]
mnl_sls$top.freq[mnl_sls$top.freq > 100] <- 98
mnl_sls <- mnl_sls[mnl_sls$bottom.freq > 20,]
# export raven file to double check
exp_raven(mnl_sls, path = "./data/processed", file.name = "pooled_manual_annotations_with_bedding", sound.file.path = "~/Dropbox/Recordings/ratas_cin/recs/original_with_bedding/")
wi <- wav_info(path = "~/Dropbox/Recordings/ratas_cin/recs/200_kHz_bedding/")
datatable(wi, editable = list(
target = 'row'
), rownames = FALSE, style = "bootstrap", filter = 'top', options = list(
pageLength = 100, autoWidth = TRUE, dom = 'ft'
), autoHideNavigation = TRUE, escape = FALSE)
Session information
## R version 4.1.0 (2021-05-18)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.2 LTS
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3
## LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3
##
## locale:
## [1] LC_CTYPE=pt_BR.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=es_CR.UTF-8 LC_COLLATE=pt_BR.UTF-8
## [5] LC_MONETARY=es_CR.UTF-8 LC_MESSAGES=pt_BR.UTF-8
## [7] LC_PAPER=es_CR.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=es_CR.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] DT_0.18 Rraven_1.0.13 warbleR_1.1.27 NatureSounds_1.0.4
## [5] knitr_1.33 seewave_2.1.8 tuneR_1.3.3.1 devtools_2.4.2
## [9] usethis_2.0.1
##
## loaded via a namespace (and not attached):
## [1] xfun_0.25 bslib_0.2.5.1 remotes_2.4.0 purrr_0.3.4
## [5] pbapply_1.4-3 testthat_3.0.4 htmltools_0.5.2 yaml_2.2.1
## [9] rlang_0.4.11 pkgbuild_1.2.0 jquerylib_0.1.4 glue_1.4.2
## [13] withr_2.4.2 sessioninfo_1.1.1 lifecycle_1.0.0 stringr_1.4.0
## [17] htmlwidgets_1.5.3 memoise_2.0.0 evaluate_0.14 callr_3.7.0
## [21] fastmap_1.1.0 fftw_1.0-6 crosstalk_1.1.1 ps_1.6.0
## [25] parallel_4.1.0 Rcpp_1.0.7 cachem_1.0.5 desc_1.3.0
## [29] pkgload_1.2.1 jsonlite_1.7.2 fs_1.5.0 rjson_0.2.20
## [33] digest_0.6.27 stringi_1.7.4 processx_3.5.2 dtw_1.22-3
## [37] rprojroot_2.0.2 cli_3.0.1 tools_4.1.0 bitops_1.0-7
## [41] magrittr_2.0.1 sass_0.4.0 RCurl_1.98-1.4 proxy_0.4-26
## [45] crayon_1.4.1 ellipsis_0.3.2 MASS_7.3-54 prettyunits_1.1.1
## [49] rmarkdown_2.10 rstudioapi_0.13 R6_2.5.0 signal_0.7-7
## [53] compiler_4.1.0