Skip to content
Alba Solsona edited this page Jan 10, 2020 · 87 revisions

HOME > REMORAS > SHIP DETECTOR

The Ship Detector Remora is a repository with user-friendly interfaces to detect ship passages and weather events from Long-Term Spectral Averages (LTSAs). This package was initially developed for this Ph.D. thesis and since then has been expanded for the Sound Monitoring Project to support Marine Protected Area management, as well as additional monitoring projects.

  1. How It Works
  2. How To Use It

How It Works

Events are identified from Long-Term Spectral Averages (LTSA). LTSAs are averaged spectra of a specified time bin and frequency range and aligned over time, resulting in a long-term spectrogram which preserves the temporal-spectral resolution of the acoustic data. The LTSA is analyzed in blocks of data (windows), where the power spectral density estimates (PSD) are averaged in three frequency bands. The three frequency bands are referred to as low-, medium-, and high-frequency bands (see Figure 1). Start and end times of the ship passages and weather events are detected and stored if the three averaged PSD meet multiple conditions:

  • Condition 1: Amplitude is above a time-dependent amplitude threshold (thr_line). The threshold is computed using a histogram method of the averaged PSD, where the histogram is divided into two equal regions, and the mode of each region is taken as the lower and upper levels. The time-dependent threshold is calculated as the mean of the lower- and upper-levels.

  • Condition 2: The event duration above the threshold in the three bands must be longer than a specified time, referred to as Close Passage Duration Threshold. Additionally, the duration in the higher band must be shorter than the medium band, which allows discarding dolphin detections. Or, the event duration above the threshold in the lower and medium band must be longer than a specified time, referred to as Distant Passage Duration Threshold. Additionally, the duration in the medium band must be shorter than the lower band, which allows discarding sperm whale detections.

  • Condition 3: Ship passages are distinguished from weather events when averaged received levels of the event in the lower band is above a specified percentage of the background noise in the window.

To ensure that events on the edges of the analysis window are detected, an overlapping sliding window is applied. Sliding time and length of the window can be defined by the user to improve the performance of the detector on different acoustic data sets.

ship_freq_bands

How To Use It

Step 1: Add Ship Detector Remora to Triton

Learn how to download or clone the Triton repository with the Ship Detector Remora repository in the quick setup section and how to add the Remora to Triton.

Step 2: Create LTSA file

In the Control Window, use Tools pull-down menu, and select Make LTSA from Directory of Files.

make_ltsa_small

First, it will prompt you to select file type: use 1 for WAV files or 2 for XWAV files and specify folder containing audio files. After, it will prompt you to set the LTSA parameters:

  • Time Average: length of time for each spectral average
  • Frequency Bin Size for LTSA (Hz)

Since these parameters are data sample rate dependent, setup with caution. The default parameters for broad-band HARP data sampled at 200 kHz are usually 5s averages and 200 Hz frequency bins. For lower sample rate such as Soundtrap data (i.e., 48 kHz or 96 kHz), the default parameters are usually 5s averages and 48 Hz frequency bins.

After, select the folder to save the LTSA. It is recommended to choose the same folder as the audio files so that the LTSA can provide a link and index to these fine-scale data files.

❗ The amount of time required to create the LTSA is over several hours, so it is recommended to run overnight, or take time to enjoy a ☕.

Step 3: Interactive Detector

The goal behind the Interactive Detector is to test different settings used by the Batch Detector to improve the performance of the detector.

First, load the LTSA file (.ltsa) from the Control Window, use File pull-down menu, and select Open LTSA File.

open_ltsa

Adjust the brightness and contrast of the LTSA plot from the Control Window which are usually set to 40 dB brightness and 100% dB contrast.

After the LTSA file (.ltsa) is loaded in the Triton Plot Window, launch the Interactive Detector from the Control Window by using Remoras pull-down menu and selecting Interactive detector (LTSA).

interactive_pulldown

It will display the Ship Detector Motion Control Window where settings can be loaded from existing files, modified and/or saved.

motion_control

The Ship Detector Motion Control Window contains all the adjustable parameters of the detector. You can load one of the existing settings file from Load/Save Settings pull-down menu, and select Load Detector Settings File. After, select the Refresh button to plot the results of the detector from the current LTSA window.

Ship_detector_big

Based on the detector thresholds being triggered (see Detectors' Conditions), the results are displayed in different colors and symbols:

  • Ship passages are shown in green.
  • Weather events or others are shown blue as ambient.
  • Events that triggered the Close Passage Duration Threshold are shown as a circle.
  • Events that triggered the Distant Passage Duration Threshold are shown as a cross.

ship_window_small ambient_window_small

Once you have found the best parameters for your data, save the settings to a file in the Ship Detector Motion Control Window, use the Load/Save Settings pull-down menu, and select Save Detector Settings File.

Step 4: Batch Detector

Run the detector on the entire LTSA file by selecting the Batch run detector from the Ship-Detector in the Remoras pull-down menu.

batch

It will display the Ship Detector Batch Window where you can load the settings file, verify all the parameters, and modify them if needed before running the detector. A common parameter to modify in this window is the transfer function, which may vary from one recording to another.

batch

Then, click the Run Detector button to start the detector. The processing time will vary based on the LTSA parameters, from a couple of minutes to a maximum of 20 minutes.

The detector stores the start and end times of the detections, the corresponding labels, and settings in a .mat file in the specified output folder. It also creates a .tlab file, which contains the same information but in the format that Triton reads detection labels file.

Step 5: Visualize Detections

Visualize the detections in the Triton Plot Window by loading the .tlab file from the Control Window, use Remoras pull-down menu, and select Visualize detections & Open LTSA File.

visualize_pulldown_small

It will display the Visualize labels Window, where you can load a maximum of two .tlab files if you want to compare results. From the Visualize labels Window, you can control the movement of the LTSA plot forwards or backward, and the display of the detections. Labels from the first file are displayed in white and the second file in red.

visualize

If you have other detection files, such as manual detection files that you want to compare with the ship detector results. You can create a .tlab file by selecting Visualize detections & Create labels from text file. .txt files format accepted:

  • Text file from Raven software.
  • Text file with three columns: real start time (serial date number), real end time (serial date number), labels.

Raven selection table format

Raven selection table is expected to have 13 columns. The first 7 columns are Raven’s default measurements, the next 4 columns are additional Raven measurements, and the last 2 columns are Annotation columns. Columns can be labeled anything, for this build, the column header names are:

Selection View Channel BeginTimes EndTimes LowFreqHz HighFreqHz BeginDate BeginClockTime EndClockTime DeltaTimes Behavior Notes

However, only column 8-10 and 12 are read to create the .tlab, which corresponds to the column header names: BeginDate, BeginClockTime, EndClockTime, and Behavior.

Begin Date must be of the format mm/dd/yyyy. Raven’s default is yyyy/mm/dd so make sure you convert to the mm/dd/yyyy format. The clock times can be in the format hh:mm:ss.ssss or h:mm:ss.ssss. An example of this is shown below:

Begin Date	Begin Clock Time	End Clock Time
10/04/2019	9:30:00.5123	        10:00:30.1234

⚠️: If selection tables were opened with Excel at any point in time you may run into formatting issues. Please make sure that your Begin Date column is of the mm/dd/yyyy format and that your times have the decimal seconds (tends to be dropped in Excel). Your selection table must encompass the same time period as your .ltsa file. If you have multiple selection tables within the LTSA timespan, you will need to concatenate your Raven selection tables (making sure to only have the header on the first line).

Three column text file

If you do not have a Raven selection table as input, or would like to bypass the formatting issues, you can simply use a three column text file as input (without headers), with start time (in serial date number), end time (in serial date number), and notes.

Click here to see example text in '.txt' file
737301.257199074 737301.262376993 ship  
737301.285584111 737301.286192383 ambient
737301.309148587 737301.312769330 ship
737301.330624409 737301.332742718 ship

Step 6: Evaluate and Modify Detector Labels

  1. Modify Detector Labels
  2. Performance Evaluation of Ship Detector

The goal behind the use of the Evaluation Interface is to evaluate and/or modify the output from the Batch Detector. The user can evaluate random subsamples of detections, or correct false detections of ship passages using this interface, where snippets of LTSAs for each detection are displayed consecutively for easier evaluation.

Launch the Evaluation Interface from the Control Window by using the Remoras pull-down menu, Ship-detector, and selecting Evaluate detections.

eval_pulldown

The following interface will be displayed:

Evaluate_start

Load the detection .mat file by selecting the detection folder in the interface, D_L_small, followed by the corresponding .ltsa file by selecting the ltsa folder.

Press the green Plot button to start to visualize the detections:

Evaluate_plotted

Detections labeled as ship passages are displayed with a green line on top of the plot, and red if labeled as ambient.

The size of the window, frequency ranges and brightness can be adjusted. Also, you can use Start Detection to jump to the desired detection.

Modify Detector Labels

Any modification done with the Evaluation Interface will update the corresponding .mat file and .tlab file. If the user had specified in the settings file to store detections to a '.csv' file, this file will be updated as well.

The modification process can be done by annotating the entire window once or by selecting detections using the buttons in the Modify Label Detections section in the interface, as follows:

modify_labels

Performance Evaluation of Ship Detector

Evaluate a subsample of detections by selecting the Evaluate Random Subsamples button in the interface, and specify the number of subsamples you want to evaluate, as follows: evaluate_detections

In this example, the user evaluates 20 subsamples from a total of 121 detections. Use the Modify Label Detections section in the interface to modify the false detection to the correct label. All modifications are evaluated and stored in a '.csv' file to compute the performance metrics of the detector. The performance metrics are true positives, false positives, true negatives, false negatives, precision, and recall.

The '.csv' file is stored in the same folder as the loaded '.mat' detection file and it is named according to the number of subsamples selected. In this case, the '.csv' file is named 'Eval_20_Ship_detections_GofMX_GC05_disk09_5s_100Hz.csv'.

Click here to see example text in '.csv' file
ISOStartTime	ISOEndTime	StartTime	EndTime	DetectorLabels	Detector	UserEval	TP	FP	FN	TN	Precision	Recall	Comments
2012-07-22T07:33:40.000Z	2012-07-22T08:19:05.000Z	41112.31505	41112.34659	ambient	0	0	0	0	0	1	0.857142857	1	Caveat! False Negative does not include the missed detections by the thresholds of the detector. Mannually review the missed detections using the Visualize Detections interface and add them to the total number of False Negative
2012-07-23T08:58:05.000Z	2012-07-23T09:22:25.000Z	41113.37367	41113.39057	ship	1	1	1	0	0	0	NaN	NaN	
2012-07-24T00:43:05.000Z	2012-07-24T01:22:45.000Z	41114.02992	41114.05747	ship	1	1	1	0	0	0	NaN	NaN	
2012-07-24T08:24:25.000Z	2012-07-24T09:46:10.000Z	41114.35029	41114.40706	ambient	0	0	0	0	0	1	NaN	NaN	
2012-07-27T09:24:15.000Z	2012-07-27T10:05:15.000Z	41117.39184	41117.42031	ship	1	1	1	0	0	0	NaN	NaN	
2012-07-27T18:33:50.000Z	2012-07-27T19:01:30.000Z	41117.7735	41117.79271	ambient	0	0	0	0	0	1	NaN	NaN	
2012-07-28T12:47:00.000Z	2012-07-28T13:19:35.000Z	41118.53264	41118.55527	ship	1	1	1	0	0	0	NaN	NaN	
2012-07-28T18:47:20.000Z	2012-07-28T19:10:15.000Z	41118.78287	41118.79878	ship	1	1	1	0	0	0	NaN	NaN	
2012-07-30T13:06:10.000Z	2012-07-30T13:39:50.000Z	41120.54595	41120.56933	ship	1	0	0	1	0	0	NaN	NaN	
2012-08-01T22:02:20.000Z	2012-08-01T22:35:50.000Z	41122.91829	41122.94155	ship	1	1	1	0	0	0	NaN	NaN	
2012-08-02T12:58:25.000Z	2012-08-02T13:27:00.000Z	41123.54057	41123.56042	ship	1	1	1	0	0	0	NaN	NaN	
2012-08-02T19:43:10.000Z	2012-08-02T20:25:30.000Z	41123.82164	41123.85104	ship	1	1	1	0	0	0	NaN	NaN	
2012-08-02T23:31:10.000Z	2012-08-03T00:44:10.000Z	41123.97998	41124.03067	ship	1	1	1	0	0	0	NaN	NaN	
2012-08-03T05:57:15.000Z	2012-08-03T06:37:25.000Z	41124.24809	41124.27598	ambient	0	0	0	0	0	1	NaN	NaN	
2012-08-03T20:58:35.000Z	2012-08-03T22:45:15.000Z	41124.87402	41124.94809	ship	1	1	1	0	0	0	NaN	NaN	
2012-08-05T13:54:15.000Z	2012-08-05T14:17:15.000Z	41126.57934	41126.59531	ship	1	1	1	0	0	0	NaN	NaN	
2012-08-05T16:44:20.000Z	2012-08-05T18:19:05.000Z	41126.69745	41126.76325	ambient	0	0	0	0	0	1	NaN	NaN	
2012-08-07T04:50:35.000Z	2012-08-07T05:21:30.000Z	41128.20179	41128.22326	ship	1	1	1	0	0	0	NaN	NaN	
2012-08-08T02:16:20.000Z	2012-08-08T02:50:15.000Z	41129.09468	41129.11823	ship	1	0	0	1	0	0	NaN	NaN	
2012-08-08T13:27:30.000Z	2012-08-08T14:34:40.000Z	41129.56076	41129.60741	ambient	0	0	0	0	0	1	NaN	NaN