Import Data into Signal Feature Extractor
Import members into Signal Feature Extractor in one of these ways.
Import Signals from the MATLAB Workspace — Import each signal as a member, or import a labeled signal set.
Import Signals from Files — Import each file as a member to extract features of all the signals contained in a file together.
Import Response Label from the MATLAB Workspace — Import the member labels into Signal Feature Extractor stored in the MATLAB® workspace as a categorical vector.
Supported Signal Types
The Signal Feature Extractor app works with real- or complex-valued
vectors, matrices, MATLAB timetables, labeledSignalSet
objects, and signalDatastore
objects. The app also supports MAT files and CSV files.
Note
The members you import to Signal Feature Extractor must meet the following requirements:
All members must have the same sample rate.
If you select a
labeledSignalSet
to import as a member, do not select other variables.
Signal Feature Extractor does not support:
Signals with
Inf
orNaN
values, multidimensional arrays, or sparse matrices.Multiple
labeledSignalSet
objects. You can only import onelabeledSignalSet
object in the current session.labeledSignalSet
objects containing complex-valued labels or labels with LabelDataType specified as"table"
or"timetable"
.
If any member is complex valued, Signal Feature Extractor does not support extraction of these time-domain features: mean, standard deviation, SNR, SINAD, and THD.
Example: Numeric Arrays
specifies a two-channel signal consisting of sinusoids embedded in white noise. The signal does not contain time information unless you specify it. In Signal Feature Extractor, you can import the signal in samples, or you can add time information when you import it.num = cos(pi./[4;2]*(0:159))'+randn(160,2);
Example: MATLAB Timetables
both specify that the noisy two-channel sinusoid is sampled at 100 Hz. For more information, see thett1 = timetable(num,SampleRate=100); tt2 = timetable(seconds((0:159)'/100),num);
timetable
documentation.Example:
labeledSignalSet
Objectsspecifies that the noisy sinusoid is in samples.lss = labeledSignalSet(num);
Example:
labeledSignalSet
Objects with Time Informationboth specify that the noisy sinusoid is sampled at 100 Hz.lst1 = labeledSignalSet(num,SampleRate=100); lst2 = labeledSignalSet(timetable(seconds((0:159)'/100),num));
Example: Multisignal Members
has two members. The first member contains three 10-sample signals. The second member contains nine 17-sample signals.msn = labeledSignalSet({randn(10,3),randn(17,9)});
has two members. The first member contains three signals sampled at 1 Hz for 10 seconds. The second member contains two signals sampled at 1 Hz for 7 seconds and one 30-sample signal sampled at 100 Hz.mst = labeledSignalSet({{timetable(seconds(1:10)',randn(10,3))}, ... {timetable(seconds(1:7)',randn(7,2)), ... timetable(randn(30,1),'SampleRate',100)}});
Example:
signalDatastore
Object Pointing to FilesSpecify the path to a set of sample sound signals included as MAT files with MATLAB®. Each file contains a signal variable and a sample rate. List the names of the files.
folder = fullfile(matlabroot,"toolbox","matlab","audiovideo"); lst = dir(append(folder,"/*.mat")); nms = {lst(:).name}'
nms = 7×1 cell {'chirp.mat' } {'gong.mat' } {'handel.mat' } {'laughter.mat'} {'mtlb.mat' } {'splat.mat' } {'train.mat' }
Create a signal datastore that points to the specified folder. Set the sample rate variable name to
Fs
, which is common to all files. Generate a subset of the datastore that excludes the filemtlb.mat
, which differs from the other files in that the signal variable is not calledy
.sds = signalDatastore(folder,"SampleRateVariableName","Fs"); sdss = subset(sds,~strcmp(nms,"mtlb.mat"));
Use the subset datastore as the source for a
labeledSignalSet
object.lss = labeledSignalSet(sdss)
lss = labeledSignalSet with properties: Source: [1×1 signalDatastore] NumMembers: 6 TimeInformation: "inherent" Labels: [6×0 table] Description: "" Use labelDefinitionsHierarchy to see a list of labels and sublabels. Use setLabelValue to add data to the set.
Specify Time Information
The signals you import into Signal Feature Extractor can be labeled in samples or in time. This specification stays fixed to ensure consistent feature extraction. You cannot mix signals in samples and signals with time information in the same session.
When specifying the time information for a set of signals that do not have it, select a time specification option in the import dialog box.
Note
Once a signal or set of signals has been imported into Signal Feature Extractor, the chosen time specification stays fixed throughout the labeling session.
Time Specification Option | Description |
---|---|
Samples | This option enables you to process signals without the need to specify a sample rate or a sample time. |
Sample Rate | Use this option when you know the rate at which the signal has been sampled. The sample rate can be expressed in Hz, kHz, MHz, or GHz. To specify the sample rate, you can use a numeric value, the name of a scalar variable in the MATLAB Workspace, or any valid MATLAB expression. |
Sample Rate Variable From File | Use this option when the sample rate is saved as a variable in the file being imported. |
Sample Time | Use this option when you know the time interval between samples. The sample time can be expressed in seconds, years, days, hours, minutes, milliseconds, microseconds, or nanoseconds. To specify the sample time, you can use a numeric value, the name of a scalar variable in the MATLAB Workspace, or any valid MATLAB expression. |
Sample Time Variable From File | Use this option when the sample time is saved as a variable in the file being imported. |
Time Values | Use this option when you know the time value corresponding
to each sample. Specify the time values using a valid
MATLAB expression or the name of a variable in the
MATLAB Workspace. The time values can be stored in a
numeric or In all cases, the app derives a sample rate from the time values and displays it in the status bar of the app. |
Time Values Variable From File | Use this option when the time values are saved as a variable in the file being imported. |
Import Signals from the MATLAB Workspace
To import signals to Signal Feature Extractor from the MATLAB Workspace, on the Extract Features tab, click
New and select From Workspace
in
the Members list. In the dialog box, select the signals you want to
import.
Each signal variable is treated as a member of the labeled signal set and you can extract features to all the members at once.
Note
You cannot modify the time information of a labeledSignalSet
object from within Signal Feature Extractor. If the labeled signal
set has no time information, the app treats its members as being in samples. If
the labeled signal set has time information, the app incorporates this
information when it imports the signals. For more information, see the labeledSignalSet
documentation.
To successfully import labeled signal sets, they must meet these additional rules:
If the selection includes two or more labeled signal sets, the labeled signal sets must have unique member names. You cannot change member names from within Signal Feature Extractor. To change the name of a member of a labeled signal set, use
setMemberNames
at the command line.Label values in
labeledSignalSet
objects must be scalars. Signal Feature Extractor ignores those labels which do not have scalar values.
Import Signals from Files
To import signals to Signal Feature Extractor from files, on the
Extract Features tab, click New and
select From Files
in the Members list.
In the dialog box, browse to select the files that contain the signals you want to import.
Note
Signal Feature Extractor supports MAT files and CSV files. All values in a CSV file other than headers must be numeric.
To import signals from multiple files in a folder, on the Extract
Features tab, click New and select
From Folders
in the Members list. In
the dialog box, browse to select the folder that contains the files you want to import
signals from. You can also choose to include subfolders.
Each file is treated as a member of the labeled signal set. All the signals contained in a file belong to a single member and are labeled together. You can also import other files with the same signal variables as members of the same labeled signal set. All members to import must have the same extension and the same variables.
By default, Signal Feature Extractor reads the first signal variable of
each file. To determine the name of the first variable in a file,
signalDatastore
follows these steps:
For MAT files:
s = load(fileName); varNames = fieldnames(s); firstVar = s.(varNames{1});
For CSV files:
opts = detectImportOptions(fileName,'PreserveVariableNames',true); varNames = opts.VariableNames; firstVar = string(varNames{1});
To specify the signal variables that you want to read, click Specify and enter a comma-separated list of signal variable names.
Tip
If a CSV file does not have variable names specified in a header line, then
the variables are called Var1
for the first column,
Var2
for the second column, and so on.
Import Response Label from the MATLAB Workspace
To import response label to Signal Feature Extractor from files, on the Extract Features tab, click Import Response. In the dialog box, select the variable that contain the response label you want to import. The variable must be a categorical vector with as many elements as members you imported into Signal Feature Extractor.
Tip
You can import multiple response labels into Signal Feature Extractor, but you must import one response label at a time. Each response label must be unique. When you import a new response label, Signal Feature Extractor adds a column in the Member Browser table.