Use Signal Feature Extractor App
App Workflow
A typical workflow for labeling signals using the Signal Feature Extractor app is:
Import Data into Signal Feature Extractor — Select any real or complex signal available in the MATLAB® Workspace. The app accepts numeric arrays, MATLAB timetables, and
labeledSignalSet
objects. Read data from files or usesignalDatastore
objects as input.Feature Extraction Using Signal Feature Extractor — Extract time-domain or frequency-domain features from members in a labeled signal set or unlabeled signals. Accelerate feature extraction with parallel computing.
Rank Features Using Signal Feature Extractor — Use supervised ranking with labeled features to determine which features are most likely to discriminate behavioral differences for machine learning and deep learning workflows.
Export Labeled Signal Sets and Features — Export labeled signal sets to the MATLAB Workspace or to MAT files. Export features to the MATLAB workspace or the Classification Learner (Statistics and Machine Learning Toolbox) app.
Example: Extract Signal Features from Data Set
Extract time-domain and frequency-domain features from electromyographic (EMG) data to use later in a machine learning workflow to classify forearm motions. The files are available at this location: https://ssd.mathworks.com/supportfiles/SPT/data/MyoelectricData.zip.
Generate Labeled Signal Set
This example uses EMG signals collected from the forearms of 30 subjects [1]. The data set consists of 720 files. Each subject participated in four testing sessions and performed six trials of different forearm motions per session. Download and unzip the files into your temporary directory.
localfile = matlab.internal.examples.downloadSupportFile( ... "SPT","data/MyoelectricData.zip"); datasetFolder = fullfile(tempdir,"MyoelectricData"); unzip(localfile,datasetFolder)
Each file contains an eight-channel EMG signal that represents the activation of eight forearm muscles during a series of motions. The sample rate is 1000 Hz. Create a signalDatastore
object that points to the data set folder.
fs = 1000; sds = signalDatastore(datasetFolder,IncludeSubfolders=true);
For this example, analyze only the last (sixth) trial of the third session. Use the endsWith
function to find the indices that correspond to these files. Create a new datastore that contains this subset of signals. Use the subset datastore as the source for a labeledSignalSet
object.
idSession = 3; idTrial = 6; idSuffix = "S"+idSession+"T"+idTrial+"d.mat"; p = endsWith(sds.Files,idSuffix); sdssub = subset(sds,p); lss = labeledSignalSet(sdssub)
lss = labeledSignalSet with properties: Source: [1×1 signalDatastore] NumMembers: 30 TimeInformation: "inherent" Labels: [30×0 table] Description: "" Use labelDefinitionsHierarchy to see a list of labels and sublabels. Use setLabelValue to add data to the set.
Define a categorical response label by assigning a subject number to each member of the labeled signal set.
Group = categorical("Subject_"+(1:30)');
Import Data into Signal Feature Extractor
Open Signal Feature Extractor. Import the labeled signal set and the response label. On the Extract Features tab, click New, select From Workspace
in the Members list, select the lss
labeledSignalSet
object in the dialog box that appears, and click Import and Close. To import the label response, click Import Response, select the Group
categorical vector in the dialog box that appears, and click Import.
Extract Multidomain Features with Parallel Computation
Add time-domain features to extract, enable parallel computing, and extract features.
Add time-domain features to extract. On the Feature Generation section, click Time-Domain . Then, select
Shape Factor
,Crest factor
,Impulse Factor
,Clearance Factor
, andTHD
, and click Add Features.Add frequency-domain features to extract. On the Feature Generation section, click Frequency-Domain . Then, select
Occupied Bandwidth
, andPower Bandwidth
, and click Add Features.To perform feature extraction in parallel, click Use Parallel . Then, click Extract to extract the selected signal features. Signal Feature Extractor starts a parallel pool of workers and extracts the features for all the members and channels.
Signal Feature Extractor generates a feature table and lists the extracted features in the table FeatureTable1
. Each row represents a subject, and each column represents a feature type and member channel. The feature group name, FeatureTable1
, also appears in the Feature Definitions browser.
Rank Features and Export Top-Ranked Features
You can rank extracted features and export the top- ranked features.
In the Ranking section, click Rank Features . By default, Signal Feature extractor selects the response label from and feature group from the imported response and generated feature table, respectively. If you have multiple response labels and feature groups, select each item from the Response Label and Group Name drop-down lists, respectively, and click Apply .
To rank signal features, select a feature ranking algorithm. Signal Feature extractor ranks the 56 features using the selected ranking algorithm and displays a bar plot with the importance scores for each feature sorted in descending order. The app also sorts the table of features by importance scores.
To export the top-ranked features to the MATLAB® workspace as a matrix or table, click Export , and select Workspace
from the drop-down list. Select the top-10 features to export and click Export. To complete the feature export, specify a name and format for the output and click Export.
Export All Extracted Features from Current Session
To export all the features generated in this session to the MATLAB® workspace as a matrix, close the Ranking mode. In the Extract Features toolstrip, click Export , and select Workspace
from the drop-down list. In the Export Features to Workspace dialog box, select the response label and all feature labels. Then, click Export. To complete the feature export, specify a name and format for the output and click Export.
References
[1] Chan, Adrian D.C., and Geoffrey C. Green. 2007. "Myoelectric Control Development Toolbox." Paper presented at 30th Conference of the Canadian Medical & Biological Engineering Society, Toronto, Canada, 2007.
See Also
Apps
- Signal Feature Extractor | Signal Labeler | Classification Learner (Statistics and Machine Learning Toolbox)