Main Content

Label Radar Signals with Signal Labeler

Since R2021a

This example shows how to label the main time and frequency features of pulse radar signals. This step facilitates the process of creating complete and accurate data sets to train artificial intelligence (AI) models. Signal Labeler eases this task in two ways. In manual mode, synchronized time and time-frequency views help you identify frequency features such as the waveform type, which can be Rectangular, LinearFM, or SteppedFM. In automated mode, you can register functions that measure the pulse repetition frequency (PRF), pulse width, duty cycle, and pulse bandwidth and only correct mistakes instead of labeling all signals from scratch. A built-in dashboard helps track the labeling progress and assess the quality of the labels.

Import Data into Signal Labeler

The radar signals in this example are stored in individual MAT files. Each file contains a data variable x and a corresponding sample rate variable Fs.

Open Signal Labeler. On the Labeler tab, click Import and select From Folders in the Members list. In the dialog box, select the directory with radar signal files. To specify the signal variables that you want to read, click Specify and enter x. Add time information: Choose the Working in option and select Time from the list. Select Sample Rate Variable From File in the list and enter Fs. Click Import. The imported files appear in the Labeled Signal Set Members browser. Plot the first three signals by selecting the check boxes next to their names.

Define Labels

Create a label definition for the signal waveform type.

  1. Click Add on the Labeler tab and select Add Label Definition.

  2. In the dialog box, specify Label Name as WaveFormType. Set Label Type to Attribute and Data Type to string.

  3. Click OK.

Repeat these steps to create attribute label definitions for PRF, duty cycle, and bandwidth. Modify the label name for each and set the data type to numeric.

Create a region-of-interest (ROI) label for pulse width that corresponds to the regions showing initial and final crossings used to compute each pulse width. Specify Label Name as PulseWidth, Label Type as ROI, and Data Type as numeric. The label definitions appear in the Label Definitions browser.

LabelDefinitions.png

Create Custom Autolabeling Functions

Use four Custom Labeling Functions to label the PRF, bandwidth, duty cycle, and pulse width. Code for these functions is given in the Supporting Functions section of the example. To create each function, on the Labeler tab, click Automate Value and select Add Custom Function. Signal Labeler shows a dialog box where you input the name, description, and label type of the function.

  1. For the function that computes the PRF, enter computePRF in the Name field and select Attribute as the Label Type. You can leave the Description field empty or you can enter your own description.

  2. For the function that computes the bandwidth, enter computeBandWidth in the Name field and select Attribute as the Label Type. You can leave the Description field empty or you can enter your own description.

  3. For the function that computes the duty cycle, enter computeDutyCycle in the Name field and select Attribute as the Label Type. You can leave the Description field empty or you can enter your own description.

  4. For the function that computes the pulse width, enter computePulseWidth in the Name field and select ROI as the Label Type. You can leave the Description field empty or you can enter your own description.

If you already have written the functions, and the functions are in the current folder or in the MATLAB® path, Signal Labeler adds the functions to the gallery. If you have not written the functions, Signal Labeler opens blank templates in the Editor for you to type or paste the code. Save the files. Once you save the files, the functions appear in the gallery.

signalLabeler_radar3_22a.png

Label Waveform Type, PRF, Bandwidth, Duty Cycle, and Pulse Width

Set the waveform type of each signal:

  1. In the Labeled Signal Set Members browser, select the check box next to radarData1.

  2. Click the Display tab and select Spectrogram in the Views section. The app displays a set of axes with the signal spectrogram and a Spectrogram tab with options to control the view.

  3. Click the Spectrogram tab, select the Time Resolution section and set the overlap percentage to 99.

  4. The spectrogram shows that the signal waveform is rectangular. In the label viewer attribute table, double-click the cell below WaveFormType and type Rectangular.

  5. Repeat this manual labeling step for all the signals in the data set.

radarData01.png

An example of a LinearFM waveform follows.

radarData11.png

An example of a SteppedFM waveform follows.

radarData12.png

Compute and label the PRF of the input signals.

  1. Select PRF in the Label Definitions browser.

  2. In the Automate Value gallery, select computePRF.

  3. Click Auto-Label and select Auto-Label All Signals. In the dialog box that appears, click OK.

Repeat the above steps for bandwidth, duty cycle, and pulse width by selecting the corresponding label definition and autolabeling function.

Signal Labeler computes and labels all signals, but displays labels only for the signals whose check boxes are selected. Plot the signals from the first five members.

Labels.png

Validate Labeled Signals

View your labeling progress and verify that the computed label values are correct. Select WaveFormType in the Label Definitions browser and click Dashboard in the Labeler tab.

The plot on the left shows the labeling progress, which is 100% as all signals are labeled with the WaveFormType label. The plot on the right shows the number of signals with labels for each label value. You can use the Label Distribution pie chart to assess the accuracy of your labeling and confirm the results are as expected.

LabelDashboard.png

Next, validate that all pulse width label values are distributed around 5e-5. To look at the time distribution of the pulse width label values, click Definition Selection on the Dashboard tab and select PulseWidth. Click on the time distribution plot and on the Dashboard tab, set Bins to 3, X Min to 4e-5 and X Max to 6e-5. All signals have a pulse width distributed around 5e-5.

LabelDashboardValidation.png

Close the dashboard.

Export Labeled Signals

Export the labeled signals to train AI models. On the Labeler tab, click Export and select Labeled Signal Set To File. In the dialog box that appears, give the name radarDataLss.mat to the labeled signal set and add an optional short description. Click Export.

Go back to the MATLAB® Command Window. Load the labeled signal set and create signal and label datastores from the labeled signal set. Create a combined datastore with the signal and label datastores. Use read or readall to get signal-label pairs that you can use to train AI models.

load radarDataLss.mat
[signalDS,labelDs] = ls.createDatastores("WaveFormType");
combineDs = combine(signalDS,labelDs);

Supporting Functions

computePRF Function: Calculate the pulse repetition frequency

The computePRF function computes and labels the PRF of the input signal. It uses the pulseperiod function.

function [labelVal,labelLoc] = computePRF(x,t,parentLabelVal,parentLabelLoc,varargin)
% Function to calculate pulse repetition frequency of a radar pulse

if~isreal(x)
    x = abs(x);
end
pri = pulseperiod(x,t);
labelVal = 1/pri(1);
labelLoc = [];
end

computeBandWidth Function: Calculate the pulse bandwidth

The computeBandWidth function computes and labels the bandwidth of the input signal. It uses the obw function.

function [labelVal,labelLoc] = computeBandWidth(x,t,parentLabelVal,~,varargin)
% Function to calculate occupied bandwidth of a radar pulse
if~isreal(x)
    x = abs(x);
end
fs = 1/mean(diff(t));
labelVal = obw(x,fs);
labelLoc = [];
end

computeDutyCycle Function: Calculate the pulse duty cycle

The computeDutyCycle function computes and labels the duty cycle of the input signal. It uses the dutycycle function.

function [labelVal,labelLoc] = computeDutyCycle(x,t,parentLabelVal,parentLabelLoc,varargin)
% Function to calculate duty cycle of a radar pulse
if~isreal(x)
    x = abs(x);
end
labelVal = dutycycle(x,t);
labelLoc = [];
end

computePulseWidth Function: Calculate the pulse width

The computePulseWidth function computes and labels the pulse width of the input signal. It uses the pulsewidth function.

function [labelVal,labelLoc] = computePulseWidth(x,t,parentLabelVal,parentLabelLoc,varargin)
% Function to calculate pulse width of a radar pulse
if~isreal(x)
    x = abs(x);
end
[pw,ic,fc] = pulsewidth(x,t);
labelVal = pw(1);
labelLoc = [ic(1) fc(1)];
end

See Also

Apps

Functions

Related Topics