monitoR corMatch getOneClip error

Trying this loop:
I am trying to run corMatch for a directory of survey files (I could not get batchCorMatch to work so was recommended to try a custom loop). I have templates of species created with makeCorTemplate (monitoR), and can successfully use them with individual survey files to search for matches and output .csv of verified results. I need to take a batch of templates and run it through a directory of many .wav files, ideally it is one survey folder containing 8 subfolders with 14-20 691.2MB .wav files each (one for each AudioMoth device used).

Initially when I tested the loop below, it worked! Now I keep getting the same error message again and again. In list.files, all the .wav files in the directory appear as they should. I had this same issue when trying to use batchCorMatch, same error, except it would say " file with the name NA exists." Help getting some kind of loop to work would be MUCH appreciated, and I would credit you in the report for this project. I've been struggling with this error for months and have resorted to manually running corMatch survey file by survey file, which takes 12-14 hours per species, and I have to be present the entire time. It is still less time than listening second for second, but doing this as a batch would make this data processing possible and more affordable. We are working collaboratively with conservation teams in Sarawak, Borneo to analyze results from bird surveys last September, and to develop workflows for ongoing acoustic surveys (I'm an undergraduate student about to graduate, Evergreen State College, WA, USA). This is the persistent error message, and the code for the loop is below that (I can send sample project folders or whatever you'd want to check it out):

Error in getOneClip(clip, name, output, write.wav) :
clip argument seems to be a file name but no file with the name 20190920_163000_ABBY_A8C.WAV exists.

surveyfilestest27 <- list.files(path = "SurveyDir", pattern = '\\.WAV')
templatestest <- readCorTemplates(dir = "Templates")
#> Error in readCorTemplates(dir = "Templates"): could not find function "readCorTemplates"
for(i in surveyfilestest27) {
  cscoreslooptest4 <- corMatch(survey = i, templates = templatestest, time.source = "filename")
  temppeakslooptest4 <- findPeaks(score.obj = cscoreslooptest4)
  detectionslooptest4 <- getDetections(temppeakslooptest4)
  detectionslooptest4 <- cbind(survey =surveyfiles[1], detectionslooptest4)
  no.ext <- gsub("\\.wav", "", i)
  write.csv(detectionslooptest4, paste0('detections/', no.ext, '.csv'), row.names = FALSE)

Created on 2020-05-25 by the reprex package (v0.3.0)

also the error under "readcorTemplates" "could not find function readCorTemplates" is odd, that has never been an issue before, because I load monitoR maybe some issue with the reprex process..

This loop works if the folder containing the survey files is set as the working directory. This works for now!

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.