Blue Whale Detector - MarineBioAcousticsRC/Triton GitHub Wiki
HOME > REMORAS > BLUE WHALE DETECTOR
Blue whale B call detector
How it works
The blue whale detector detects blue whale B calls by matching spectrograms of the sound recording to a template spectrogram of a blue whale call, called the kernel. This template is a down sweep starting, matching the third harmonic of a typical blue whale B call.
The batch detector divides the sound recordings into blocks of 1 hour, which are then analyzed sequentially. To avoid missing calls that occur on the edges of the blocks, for every next block the last 20 sec of the previous block is added to the recording. Blue whale B calls are typically 10 sec, so this way all calls will be detected. Of course, by adding these 20 seconds there is a possibility of detecting the same call twice: once in the current block and once in the next block. Therefore, all detections that are within 5 seconds of each other will be marked “needs checking”.
How to use it
Step 1: Add Blue Whale Detector Remora to Triton
Learn how to download or clone the Triton repository with the Blue Whale Detector Remora repository and how to add the Remora to Triton in the quick setup section.
Step 2: Create kernels
- Open the LTSA that you want to work on.
- Open Logger and start a new log (for details, see Logger wiki).
- Find a nice B call. Using the cursor, draw a box around the call, press ‘B’ to input timestamps.
- Double check the timestamp. Select ‘Generate kernel’ from the Tools menu in Logger.
- Look at the Current Folder window in Matlab to see the new .mat file created.
- IMPORTANT: manually add a number to the .mat filename, otherwise your next call will overwrite these values. The filename should be of the format: deployment ID_Bcall_kernelnumber.mat
- Check the values to make sure they make sense.
- Don’t forget to log the call. Log AFTER you check the values in case you decide to scrap this call.
- Once you’ve finished logging calls, open ‘Calculate kernel’ in the Blue whale detector remora.
- For ‘input folder’ enter the path to the folder that contains the kernel calls.
- For ‘kernel identifier’ enter the deployment ID that you used in the filenames of the kernel calls.
- Hit ‘calculate kernel’.
- The kernel values will be shown in the command window of Matlab.
Step 3: Make a ground truth
Before you can run the automated detector you will need to have created a ground truth. The ground truth is a section of a dataset from which B calls have been manually picked and logged. Ground truths should ideally be made for October, December and June. The ground truth will serve as a comparison for the detector’s output so that you can get the detector to work optimally for each individual dataset. What you need: • Matlab R2012b or higher • Triton • The Remora “ Logger”
- Open Matlab and start Triton
- In the Control window of Triton, under File, open the LTSA for the dataset you want to make a ground truth for. NB: Optimal window settings to find B calls for the LTSA: 1 hour, 0-300 Hz, Brightness 20 dB, Contrast 250 %. NB2: Optimal window settings for the expanded wav file: plot length 60 s, 0-200 Hz, FFT 2000, Overlap 90%, Brightness 20 dB, Contrast 250 %.
- Find an area that you would like to log (try to find a section with continuous high quality calls, see figure). If you’re making an October ground truth, you will need to log 400 calls, for December/June, you will need to log 200 calls. Note: if there are some low quality calls in between the high quality calls, these can be logged, but make sure the section contains mostly high quality calls.
- Under Remoras, open Logger. If Logger is not there, click “add Remora” and find the folder in which Logger is saved on your computer.
- Log the start time of calls (see the Logger wiki on Github for how to do this).
- After you are done logging, open the xls log you just made. Make a note of the time of the first and last calls you logged. Convert the column containing the start time of your calls into a numbr format with 2 decimals.
-
Save the log as a new file with the following file name: old filename_dnum.xls.
Step 4 Calculate threshold
Once you’ve made a ground truth and have kernel values to set the detector, you can calculate the optimal threshold settings.
- Under Remoras, open ‘Calculate threshold’ of the Blue whale detector.
- For input folder, enter the path to the folder that contains the wav files that you want analyzed for the threshold calculation.
- For output folder, enter the path to the folder in which you would like the files with the various thresholds to end up.
- For ‘start frequencies’ and ‘end frequencies’ enter the kernel values that you calculated in step 1.
- Specify the range of thresholds that should be tried by the program, as well as the interval between each step in the threshold that should be taken. Default is 25 to 35, with a step size of 2, so that thresholds of 25, 27, 29, etc will be used.
- Hit ‘calculate all’. If for some reason you have already calculated the various thresholds previously and just want to see the precision/recall curve, hit ‘plot curve’.
- A prompt will ask you to select the ground truth file that you have created in step 2.
- A second prompt will ask you to select the folder with the detection files with various thresholds.
- The precision/recall curve will pop up to let you decide on the best threshold.
Step 5: Batch detector
This function will run a detector on all the files in the folder of your choice.
-
Enter the path to the folder containing the sound recording files in “Input folder”.
-
Enter the path to the folder that you would like the output to be in in “Output folder”.
-
Check if the date format in the filenames of your wav files matches the ‘Date format file name’. Default settings are yymmddhhmmss. If, for example, your filename contains four digits for year, change the format from ‘\d\d’ to ‘\d\d\d\d’.
-
Set a threshold for detections. Default is 30, but it is important to determine an optimal threshold by first running the detector with various thresholds on a subset of data and determining the percentage of recall and precision. Recall is the percentage of total calls in the subset that was detected by the detector, precision is the percentage of detections that are true detections of calls.
-
Specify the frequency settings for the kernel. These settings should be based on measurements from at least 30 manually selected excellent quality B calls that are spaced at least 24 hours apart. The kernel can be based on calls that were detected on another sensor in the same region as the dataset that the detector will be used for. The calls for the kernel should be recorded within six months of the recording that will be analyzed.
-
Hit “run detector”.
Step 3: Output
The output of the detector is two-fold:
-
For every file that was analyzed, a tlab file is created with the times of each detection. This tlab file can be used in GPLreview to evaluate the automatic detections (see wiki GPLreview on Github for further guidance). Note that durations of the detections are all the same, since the detection is based on the starting point of the call.
-
For the entire folder that was analyzed, a csv file is created with the name of the first file in that folder. The csv file gives the time of each detection, the file in which the call was detected, and whether or not the call should be checked for a possible double detection of the same call (column “check”, 0 = no check needed, 1 = check needed).