macaodha / batdetect2

Other
48 stars 9 forks source link

annotations created above recording's max frequency #22

Closed kdarras closed 10 months ago

kdarras commented 10 months ago

When running batdetect2 on this file: 20230322_172000_selec2.zip

at the default threshold, Rhinolophus hipposideros annotations are created above the maximal frequency of the recording.

Maybe it would be better to truncate the max frequency and insert a comment in the output?

macaodha commented 10 months ago

Hi there,

Are there only pipistrelle calls in that file?

spectrogram

kdarras commented 10 months ago

I think so. This is probably a case where the pipistrelle was so close that its harmonic was picked up by batdetect2 as a Rhinolophus call: https://ecosound-web.de/ecosound_web/recording/show/525233 recorded with Audiomoth 1.2

macaodha commented 10 months ago

I tried the file using our online demo and it did not flag any Rhinolophus using the default threshold of 0.3. https://huggingface.co/spaces/macaodha/batdetect2

bat_ex

kdarras commented 10 months ago

I probably ran it at 0.1

macaodha commented 10 months ago

Got it. In general, things can be very sensitive to the threshold. Lower is better for recall, but will introduce mistakes. We have some evaluation of this in the paper.

There is no single threshold that currently works best for all species - a question that requires further investigation.

mbsantiago commented 10 months ago

Hi @kdarras!

I've did see the presence of unexpected predictions above the Nyquist frequency when using the default threshold (0.01). My hypothesis is that this issue is related to our decision to resample of all incoming audio to 256kHz. Given that your recording was made at 192kHz, the upsampling process may be generating high-frequency artifacts resembling harmonics of the Pips calls.

The model takes into account the frequency position of each detection in its class prediction. This may explain why these high-frequency calls appear to be misidentified as Rhinolophus, which is consistent with Rhinolophus calls being the highest among UK species. Fortunately, the assigned probability to these detections is quite low (<0.2), hopefully minimizing the potential impact on downstream analysis.

image

In this specific case, these predictions can be discarded as artifacts of the upsampling process. We'll try to address this by introducing a filtering layer to dismiss these nonsensical detections.

Thanks for the heads-up.

Cheers, Santiago

kdarras commented 10 months ago

Hello to both, thanks for your explanations! I am not worried about the performance and am well aware of the recall-precision trade-off. I would just like to suggest that batdetect2 should be prevented from creating output above the Nyquist frequency with an additional post-processing step to avoid confusion among users (we had observed this a few times with colleagues). all the best

mbsantiago commented 10 months ago

Can I put the audio file you shared in the repository under a test/audio folder for testing purposes? The caveat is that this would make the file available to all under a Creative Commons Attribution-NonCommercial licence.

kdarras commented 10 months ago

You are welcome to do so. Let me know if you need further Audiomoth test samples from Germany.

mbsantiago commented 10 months ago

This issue has been resolved in version 1.0.7