-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from tools.reader import * | ||
from tools.featureExtract import FeatureExtractor | ||
import os | ||
import matplotlib.pyplot as plt | ||
# load FilesReader and FeatureExtractor class | ||
path = os.getcwd()+"\data" | ||
print(path) | ||
reader = FilesReader(8,path) | ||
extractor = FeatureExtractor(reader.fileNumber, 60, 10) | ||
# init Mat: | ||
feats = np.array([]) | ||
labels = np.array([]) | ||
|
||
for classIndex, fileName in enumerate(reader.files): | ||
# load file: | ||
dataMat = reader.loadFile(fileName) | ||
# gesture segmentation: | ||
segMat = extractor.segmentation(dataMat, classIndex) | ||
# init: | ||
featMat = np.array([]) | ||
for segIndex, seg in enumerate(segMat): | ||
# extract RMS, ZC, ARC features: | ||
RMSfeat = extractor.RMSfeat(seg) | ||
ZCfeat = extractor.ZCfeat(seg) | ||
ARCfeat = extractor.ARCfeat(seg) | ||
featVector = np.hstack((RMSfeat,ZCfeat,ARCfeat)) | ||
# feats splice: | ||
featMat = extractor.dynamicSplice(featMat, featVector, segIndex) | ||
# generate labels: | ||
tempLabels = extractor.creatLabels(classIndex, len(featMat)) | ||
# feat array and label array splice: | ||
feats = extractor.dynamicSplice(feats, featMat, classIndex) | ||
labels = extractor.dynamicSplice(labels, tempLabels, classIndex, axis = 1) | ||
|
||
print(feats[0]) | ||
print(labels[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# -*- coding: gbk -*- | ||
from tools.reader import * | ||
from tools.featureExtract import FeatureExtractor | ||
import pandas as pd | ||
import matplotlib.pyplot as plt | ||
import seaborn as sns | ||
from tools.MyPlot import DataPlotter | ||
import os | ||
slice = [600,1400] | ||
ChanList = ['Raw-c0','Raw-c1','Raw-c2','Raw-c3','Raw-c4','Raw-c5','Raw-c6','Raw-c7'] | ||
featList = ['RMS','ZC','ARC0','ARC1','ARC2','ARC3'] | ||
path = os.getcwd()+'/data' | ||
channels = 8 | ||
|
||
reader = FilesReader(channels, path) | ||
extractor = FeatureExtractor(reader.fileNumber, slice[1]-slice[0], 10, featRavel = False) | ||
emg = reader.loadFile('1.txt') | ||
print(reader.filesLength) | ||
sliceData = emg[slice[0]:slice[1],:] | ||
rawFrame = pd.DataFrame(sliceData, columns = ChanList) | ||
|
||
RMSfeat = extractor.RMSfeat(sliceData) | ||
ZCfeat = extractor.ZCfeat(sliceData) | ||
ARCfeat = extractor.ARCfeat(sliceData, False) | ||
zipfeat = [RMSfeat,ZCfeat] | ||
zipfeat.extend(ARCfeat) | ||
columns = extractor.creatFeatName(featList, 8) | ||
featplot = DataPlotter(np.hstack(zipfeat), columns, 431) | ||
|
||
|
||
selectFeat = ['RMS-c0', 'RMS-c5', 'RMS-c7',\ | ||
'ZC-c0', 'ZC-c5', 'ZC-c7',\ | ||
'ARC1-c0','ARC1-c5','ARC1-c7'] | ||
selectChan = ['Raw-c0','Raw-c5','Raw-c7'] | ||
|
||
|
||
for i in range(len(selectChan)): | ||
featplot.newSubplot(431+i, rawFrame[selectChan[i]],xylabel=[u'²ÉÑùµã',selectChan[i]]) | ||
#plt.title('ÌâÄ¿',fontproperties='SimHei') | ||
|
||
for j in range(len(selectFeat)): | ||
featplot.subplot([4,3,4+j], [selectFeat[j]], xylabel=[u'²ÉÑùµã',selectFeat[j]]) | ||
|
||
plt.show() | ||
|