label radar signals with signal labeler -凯发k8网页登录
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. 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 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.
click add on the labeler tab and select
add label definition
.in the dialog box, specify label name as
waveformtype
. set label type toattribute
and data type tostring
.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.
create custom autolabeling functions
use four 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.
for the function that computes the prf, enter 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.for the function that computes the bandwidth, enter 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.for the function that computes the duty cycle, enter 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.for the function that computes the pulse width, enter 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.
label waveform type, prf, bandwidth, duty cycle, and pulse width
set the waveform type of each signal:
in the labeled signal set browser, select the check box next to
radardata1
.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.
click the spectrogram tab and set the overlap percentage to
99
.the spectrogram shows that the signal waveform is rectangular. in the label viewer attribute table, double-click the cell below waveformtype and type
rectangular
.repeat this manual labeling step for all the signals in the data set.
an example of a linearfm
waveform follows.
an example of a steppedfm
waveform follows.
compute and label the prf of the input signals.
select
prf
in the label definitions browser.in the automate value gallery, select
computeprf
.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.
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.
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
.
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