batchCorMatch error

I'm a PhD student, and I've been using MonitoR in RStudio to classify pumpkin toadlets vocalizations obtained with Audiomoth.

Although it is possible to classify vocalizations file by file using MonitoR, it would be very time saving if I could use the batchCorMatch function. Unfortunately, it is not working for me and I'm emailing you to know if you can enlighten me.

Here is my code.

##Working lines


viewSpec("20221025_100000.WAV", wl = 1024, ovlp = 80, frq.lim = c(5, 8))

t1 <- makeCorTemplate("20221025_100000.WAV", t.lim = c(3.7, 4.1), frq.lim = c(5.5, 8), name = "t1") #Zoom on the first note of the first recording
t5 <- makeCorTemplate("20221025_100000.WAV", t.lim = c(6.5, 6.8), frq.lim = c(5.5, 8), name = "t5") #Zoom on the last note of the second recording

ctemps <- combineCorTemplates(t1,t5)

cscores <- corMatch("20221025_100000.WAV", ctemps) #Correlation scores

pdetects <- findPeaks(cscores)

templateCutoff(pdetects) <- c(default = 0.07)



templateCutoff(ctemps) <- c(t1 = 0.07, t5 = 0.08)

##The following line doesn't work

detects <- batchCorMatch(dir.template = ctemps, dir.survey = "surv", warn = FALSE)

###The error

Reading in templates. . . done. Calling corMatch for NA . . . Error in getOneClip(clip, name, output, write.wav) :

clip argument seems to be a file name but no file with the name NA exists.

"surv" is a folder inside my directory with the recordings. I also tried to select the directory folder itself, but it still gave me this error. When I try corMatch it works, but not when I try batchCorMatch.

The function signature is

batchCorMatch(dir.template, dir.survey = ".", ext.template = "ct", ext.survey = "wav", templates, parallel = FALSE, show.prog = FALSE, cor.method = "pearson", warn = TRUE, time.source = "filename", fd.rat = 1, ...)

As applied,

the first two arguments, which have no defaults and the warn argument was set to TRUE

The error message

indicates that the first argument was (probably) successful and the second argument dir.survey = "surv" was given to corMatch to do the processing, calling

to do the processing of the file and to write a wav file. The most likely place for the breakdown is

where NA indicates not the name of a file but its missingness. Because

the issue is probably that surv is not a folder inside the current working directory. This is a common headache.

The best way to manage is

  1. Install {here}
  2. Create an RStudio project
  3. Place the directory surv in the project folder
  4. Open the project
  5. Create a script

to confirm that your files will be accessible to a script in the same directory or in a subdirectory of that directory, such as code by using

detects <- batchCorMatch(dir.template = ctemps, dir.survey = here("surv"), warn = FALSE)

Hi. technocrat!
Apparently the issue was because my files was in ".WAV" extension and not ".wav" extension. Upper case matters in this case. It worked fine after I renamed it.

However, I didn't know about here library, and it will indeed be very useful. Thank you so much.

1 Like

Case matters not only with file names but across the board. For example functions and variables. Glad you found it.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.