macaodha / batdetect2

Other
48 stars 9 forks source link

Some questions about the output data #17

Closed Jeff37 closed 1 year ago

Jeff37 commented 1 year ago

Guys, I like a lot using batDetect2, it's open, fast and efficient :-). So I'm developing a shiny app (under R, I plan to upload it on my GitHub soon) that is calling batDetect2 through a convenient GUI. I'm a bit stuck when it come to understand some numbers from the output.

  1. "probability present" (console) I cannot understand how this value is calculated? I've been checking all the numbers from json files and csv table, as well as from the --spec_features table output. I also read -thoroughly enough I think- your paper "Towards a General Approach for Bat Echolocation Detection and Classification" without finding answer. Could you tell me how it is calculated or where I can find the info? In the following chunk of the output, the probability of 0.676 is retunrned for Nnoc, 0.297 for Nleii and 0.026 for Eser but I cannot relate these probabilities to the numbers in the csv files. PaRecAR863806_20230609_214859.wav_spec_features.csv PaRecAR863806_20230609_214859.wav.csv
...
4 /home/jf/tmp/TESTfakeAudiomothFolder/20010911_WTC/A/PaRecAR863806_20230609_214859.wav
10 call(s) detected above the threshold.
species name                  probablity present
Nyctalus noctula              0.676
Nyctalus leisleri             0.297
Eptesicus serotinus           0.026
...

Could you tell me how I can recalculate these numbers by myself or where to find this info?

  1. I'm just wondering what "_bb" stands for in the spec feature csv table? For instance, what is the difference between _max_powerbb and _maxpower ?

Hope you can help me with these points. Best, JF Godeau

macaodha commented 1 year ago

Greetings JF,

Thanks for your words of encouragement!

The probability present value is an attempt to create a summary file-level metric to indicate how likely it is that a species is present in a given file. The code to compute it is here:
https://github.com/macaodha/batdetect2/blob/main/batdetect2/detector/post_process.py#L38

As you can see, it weights the per-call species probability by the detector's confidence, sums these values across all the detect calls for each species, and then normalizes the output so that it sums to one across the species.

As our method reasons at the call-level, and not the file-level, this is an attempt to provide some summary information regarding what species might be present in each file. As you noted, these numbers are currently not saved to the CSV file.

I hope this helps, Oisin

macaodha commented 1 year ago

Regarding your second question.

max_power_bb'is briefly described here:
(https://github.com/macaodha/batdetect2/blob/main/batdetect2/detector/compute_features.py#L82)[https://github.com/macaodha/batdetect2/blob/main/batdetect2/detector/compute_features.py#L82]

and max_power is briefly described here:
(https://github.com/macaodha/batdetect2/blob/main/batdetect2/detector/compute_features.py#L127)[https://github.com/macaodha/batdetect2/blob/main/batdetect2/detector/compute_features.py#L127]

Basically, max_power computes the max power across all frequency bands within the time interval of the detect call, whereas max_power_bb only computes within the range of the detected lower and upper frequency range.

Jeff37 commented 1 year ago

Dear @macaodha , Thank you for your detailed answer. All clear! After looking into the code you pointed, I understand how much trivial was my question if I would know better python functions. The L240-L254 of _computefeatures.py are very informative too. I'll try to look better in the code next time before asking questions ;-) Your answer helped me a lot!

macaodha commented 1 year ago

Great - glad your issues were resolved.

chrmue44 commented 1 year ago

@Jeff37 I am currently developing a software to organize and analyze bat calls (with more or less shiny GUI :-) ) Maybe you are interested : https://github.com/chrmue44/BatInspector

Cheers Christian

Jeff37 commented 1 year ago

@chrmue44 thank you for pointing out your repo. Your app looks gorgeous and very sophisticated compared to my shinyApp. I didn't try it since I'm on Linux but I hope to give it a try in the future. I could see in the readme and the screenshots that you included some features I'm dreaming about, e.g. manual validation of the automated ID's, spectrogram visualisation, browsing through you local database,... It's great to see that several initiatives bloomed and implement batdetect2 engine! Happy to exchange further. JF Godeau

chrmue44 commented 1 year ago

@Jeff37 A nice installer is missing yet, I will hopefully do it in a few weeks. You can contact me directly via email chrmue44 [at) gmail (dot] com if you want to.