├── Web App ├── READ ME.txt ├── img │ ├── home.PNG │ ├── ica │ │ ├── 1.png │ │ ├── 10.png │ │ ├── 11.png │ │ ├── 12.png │ │ ├── 13.png │ │ ├── 14.png │ │ ├── 2.png │ │ ├── 3.png │ │ ├── 4.png │ │ ├── 5.png │ │ ├── 6.png │ │ ├── 7.png │ │ ├── 8.png │ │ └── 9.png │ ├── swt │ │ ├── a5.png │ │ ├── d2.png │ │ ├── d3.png │ │ ├── d4.png │ │ └── d5.png │ ├── class │ │ ├── ha.PNG │ │ ├── hv.PNG │ │ ├── la.PNG │ │ ├── lv.PNG │ │ ├── hahv.PNG │ │ ├── halv.PNG │ │ ├── lahv.PNG │ │ └── lalv.PNG │ ├── fft │ │ ├── alpha.png │ │ ├── beta.png │ │ ├── delta.png │ │ ├── gamma.png │ │ └── theta.png │ ├── raw_data │ │ ├── 1.png │ │ ├── 10.png │ │ ├── 11.png │ │ ├── 12.png │ │ ├── 13.png │ │ ├── 14.png │ │ ├── 2.png │ │ ├── 3.png │ │ ├── 4.png │ │ ├── 5.png │ │ ├── 6.png │ │ ├── 7.png │ │ ├── 8.png │ │ └── 9.png │ └── emotiv_channel.png ├── input.txt ├── css │ ├── accuracy.css │ └── dashboard.css └── cgi-bin │ ├── index.py │ ├── input_predict.py │ └── find_accuracy.py ├── Data Processing ├── Classification │ ├── getTwoClass.m │ ├── getDatasets.m │ ├── getDatasetsPrediction.m │ ├── separateClass.m │ ├── separateClassPrediction.m │ ├── predictClassification.m │ ├── doAccuracy.m │ ├── kNN.m │ ├── saveDatasets.m │ ├── findAccuracy.m │ └── getPrediction.m ├── Global Code │ └── createFolder.m ├── Preprocessing │ ├── ownFFT.m │ ├── computeICAPredict.m │ ├── ownSWT.m │ ├── pca_ica │ │ ├── myCenter.m │ │ ├── myWhiten.m │ │ ├── myCenterAndWhiten.m │ │ ├── myMultiGaussian.m │ │ ├── demo_PCA1.m │ │ ├── demo_ICA.m │ │ ├── demo_PCA2.m │ │ ├── myPCA.m │ │ └── myICA.m │ ├── preProcessingPredict.m │ ├── computeICA.m │ ├── ownFastICA.m │ ├── preProcessing.m │ ├── computeSWTPredict.m │ ├── computeFFTPredict.m │ ├── computeSWT.m │ └── computeFFT.m ├── Process Data │ ├── processData.m │ ├── cutDataPredict.m │ ├── cutData.m │ └── divideFiveSeconds.m └── Statical Analysis │ ├── statisticalAnalysis.m │ ├── correlation.m │ ├── processCorrelation.m │ └── absolute.m ├── .gitattributes ├── .gitignore └── README.md /Web App/READ ME.txt: -------------------------------------------------------------------------------- 1 | python -m CGIHTTPServer 8080 -------------------------------------------------------------------------------- /Web App/img/home.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/home.PNG -------------------------------------------------------------------------------- /Web App/img/ica/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/ica/1.png -------------------------------------------------------------------------------- /Web App/img/ica/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/ica/10.png -------------------------------------------------------------------------------- /Web App/img/ica/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/ica/11.png -------------------------------------------------------------------------------- /Web App/img/ica/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/ica/12.png -------------------------------------------------------------------------------- /Web App/img/ica/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/ica/13.png -------------------------------------------------------------------------------- /Web App/img/ica/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/ica/14.png -------------------------------------------------------------------------------- /Web App/img/ica/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/ica/2.png -------------------------------------------------------------------------------- /Web App/img/ica/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/ica/3.png -------------------------------------------------------------------------------- /Web App/img/ica/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/ica/4.png -------------------------------------------------------------------------------- /Web App/img/ica/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/ica/5.png -------------------------------------------------------------------------------- /Web App/img/ica/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/ica/6.png -------------------------------------------------------------------------------- /Web App/img/ica/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/ica/7.png -------------------------------------------------------------------------------- /Web App/img/ica/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/ica/8.png -------------------------------------------------------------------------------- /Web App/img/ica/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/ica/9.png -------------------------------------------------------------------------------- /Web App/img/swt/a5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/swt/a5.png -------------------------------------------------------------------------------- /Web App/img/swt/d2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/swt/d2.png -------------------------------------------------------------------------------- /Web App/img/swt/d3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/swt/d3.png -------------------------------------------------------------------------------- /Web App/img/swt/d4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/swt/d4.png -------------------------------------------------------------------------------- /Web App/img/swt/d5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/swt/d5.png -------------------------------------------------------------------------------- /Web App/img/class/ha.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/class/ha.PNG -------------------------------------------------------------------------------- /Web App/img/class/hv.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/class/hv.PNG -------------------------------------------------------------------------------- /Web App/img/class/la.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/class/la.PNG -------------------------------------------------------------------------------- /Web App/img/class/lv.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/class/lv.PNG -------------------------------------------------------------------------------- /Web App/img/fft/alpha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/fft/alpha.png -------------------------------------------------------------------------------- /Web App/img/fft/beta.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/fft/beta.png -------------------------------------------------------------------------------- /Web App/img/fft/delta.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/fft/delta.png -------------------------------------------------------------------------------- /Web App/img/fft/gamma.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/fft/gamma.png -------------------------------------------------------------------------------- /Web App/img/fft/theta.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/fft/theta.png -------------------------------------------------------------------------------- /Web App/img/class/hahv.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/class/hahv.PNG -------------------------------------------------------------------------------- /Web App/img/class/halv.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/class/halv.PNG -------------------------------------------------------------------------------- /Web App/img/class/lahv.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/class/lahv.PNG -------------------------------------------------------------------------------- /Web App/img/class/lalv.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/class/lalv.PNG -------------------------------------------------------------------------------- /Web App/img/raw_data/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/raw_data/1.png -------------------------------------------------------------------------------- /Web App/img/raw_data/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/raw_data/10.png -------------------------------------------------------------------------------- /Web App/img/raw_data/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/raw_data/11.png -------------------------------------------------------------------------------- /Web App/img/raw_data/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/raw_data/12.png -------------------------------------------------------------------------------- /Web App/img/raw_data/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/raw_data/13.png -------------------------------------------------------------------------------- /Web App/img/raw_data/14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/raw_data/14.png -------------------------------------------------------------------------------- /Web App/img/raw_data/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/raw_data/2.png -------------------------------------------------------------------------------- /Web App/img/raw_data/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/raw_data/3.png -------------------------------------------------------------------------------- /Web App/img/raw_data/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/raw_data/4.png -------------------------------------------------------------------------------- /Web App/img/raw_data/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/raw_data/5.png -------------------------------------------------------------------------------- /Web App/img/raw_data/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/raw_data/6.png -------------------------------------------------------------------------------- /Web App/img/raw_data/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/raw_data/7.png -------------------------------------------------------------------------------- /Web App/img/raw_data/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/raw_data/8.png -------------------------------------------------------------------------------- /Web App/img/raw_data/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/raw_data/9.png -------------------------------------------------------------------------------- /Web App/img/emotiv_channel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nadzeri/Significant-Preprocessing-Method-In-EEG-Based-Emotion-Classification/HEAD/Web App/img/emotiv_channel.png -------------------------------------------------------------------------------- /Web App/input.txt: -------------------------------------------------------------------------------- 1 | people are not as beautiful as they look, 2 | as they walk or as they talk. 3 | they are only as beautiful as they love, 4 | as they care as they share. -------------------------------------------------------------------------------- /Data Processing/Classification/getTwoClass.m: -------------------------------------------------------------------------------- 1 | function [datasets,label] = getTwoClass(datasets,label) 2 | idx = (label(:)~=2); 3 | label = label(idx); 4 | datasets = datasets(idx,:); 5 | end -------------------------------------------------------------------------------- /Data Processing/Classification/getDatasets.m: -------------------------------------------------------------------------------- 1 | function Datasets = getDatasets(project_path,method,class) 2 | Datasets = csvread(strcat(project_path,'\Metadata\datasets_',method,'_',class,'.csv')); 3 | end -------------------------------------------------------------------------------- /Data Processing/Global Code/createFolder.m: -------------------------------------------------------------------------------- 1 | function createFolder(total_folder,path) 2 | mkdir(path); 3 | for i = 1:total_folder 4 | mkdir(strcat(path,'\',sprintf('S%02d',i))); 5 | end 6 | end -------------------------------------------------------------------------------- /Data Processing/Classification/getDatasetsPrediction.m: -------------------------------------------------------------------------------- 1 | function Datasets = getDatasetsPrediction(project_path,method,class) 2 | Datasets = csvread(strcat(project_path,'\Metadata\datasets_',method,'_',class,'.csv')); 3 | end -------------------------------------------------------------------------------- /Data Processing/Preprocessing/ownFFT.m: -------------------------------------------------------------------------------- 1 | function [xFFT] = ownFFT(X) 2 | X = double(X); 3 | N = length(X); 4 | n = 0:N-1; 5 | k = n'; 6 | M = exp(-2j*pi*k*n/N); 7 | %disp(M); 8 | xFFT = (M*X')'; 9 | end -------------------------------------------------------------------------------- /Data Processing/Process Data/processData.m: -------------------------------------------------------------------------------- 1 | function processData(dataset_path) 2 | dataset_path = 'D:\TUGAS AKHIR\Datasets'; 3 | project_path = strcat(pwd,'\..\..'); 4 | %%%%%%%%%%%%% 5 | 6 | cutData(dataset_path,project_path); 7 | divideFiveSeconds(dataset_path,project_path); 8 | end -------------------------------------------------------------------------------- /Data Processing/Classification/separateClass.m: -------------------------------------------------------------------------------- 1 | function label = separateClass(project_path,method,class) 2 | kelas = csvread(strcat(project_path,'\Metadata\kelas_',method,'_',class,'.csv')); 3 | 4 | for i = 1:length(kelas) 5 | if(kelas(i)<=4) 6 | label(i) = 1; 7 | elseif (kelas(i)>=6) 8 | label(i) = 3; 9 | else 10 | label(i) = 2; 11 | end 12 | end 13 | end 14 | 15 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /Data Processing/Classification/separateClassPrediction.m: -------------------------------------------------------------------------------- 1 | function label = separateClassPrediction(project_path,method,class) 2 | kelas = csvread(strcat(project_path,'\Metadata\kelas_',method,'_',class,'.csv')); 3 | 4 | for i = 1:length(kelas) 5 | if(kelas(i)<=4) 6 | label(i) = 1; 7 | elseif (kelas(i)>=6) 8 | label(i) = 3; 9 | else 10 | label(i) = 2; 11 | end 12 | end 13 | end 14 | 15 | -------------------------------------------------------------------------------- /Data Processing/Classification/predictClassification.m: -------------------------------------------------------------------------------- 1 | function kelas = predictClassification(feature,datasets,label,method) 2 | TrainingSet=datasets; 3 | TestSet=feature; 4 | GroupTrain=label; 5 | 6 | if strcmp(method,'svm') 7 | svmStruct = svmtrain(TrainingSet,GroupTrain); 8 | kelas = svmclassify(svmStruct,TestSet); 9 | elseif strcmp(method,'knn') 10 | kelas = kNN(TrainingSet, GroupTrain, TestSet, 3); 11 | end 12 | end -------------------------------------------------------------------------------- /Data Processing/Classification/doAccuracy.m: -------------------------------------------------------------------------------- 1 | function [jmlBenar,rata_rata,tp,tn,fp,fn] = doAccuracy(method,class,method_classification) 2 | project_path = strcat(pwd,'\..\..'); 3 | % method='ica_swt';%'ica_fft','swt','ica_swt'; 4 | % class='valence';%'valence'; 5 | % method_classification='svm';%'svm'; 6 | 7 | datasets = saveDatasets(project_path,method,class); 8 | label = separateClass(project_path,method,class); 9 | [datasets,label] = getTwoClass(datasets,label); 10 | [jmlBenar,rata_rata,tp,tn,fp,fn] = findAccuracy(datasets,label,method_classification); 11 | end -------------------------------------------------------------------------------- /Data Processing/Process Data/cutDataPredict.m: -------------------------------------------------------------------------------- 1 | function raw_data = cutDataPredict(file_path) 2 | normRows = @(XXX) bsxfun(@times,XXX,1 ./ sqrt(sum(XXX.^2,2))); %Normalisasi Euclidean 3 | len1 = 640; 4 | 5 | dataEEG = csvread(file_path,1,0); 6 | start = mod(length(dataEEG),4)+1; 7 | dataEEG = dataEEG(start:end,3:16); 8 | L = length(dataEEG); 9 | 10 | if L>=len1 11 | used = (L - len1)/2; 12 | end 13 | 14 | start = used+1; 15 | stop = L - used; 16 | 17 | raw_data = transpose(dataEEG(start:stop,:)); 18 | %raw_data = normRows(raw_data); 19 | 20 | for i=1:14 21 | path = strcat('../../Web App/img/raw_data/',num2str(i),'.png'); 22 | 23 | set(gcf,'Visible','off'); 24 | plot(raw_data(i,:)); 25 | print(path,'-dpng'); 26 | end 27 | end -------------------------------------------------------------------------------- /Data Processing/Statical Analysis/statisticalAnalysis.m: -------------------------------------------------------------------------------- 1 | function [sum_ch_arousal,sum_ch_valence,sum_fb_arousal,sum_fb_valence,sum_sb_arousal,sum_sb_valence] = statisticalAnalysis(method) 2 | project_path = strcat(pwd,'\..\..'); 3 | method = 'fft';%'ica_fft','swt','ica_swt'; 4 | %%%%%%%%%%%%%%% 5 | 6 | if strcmp(method,'ica_fft')||strcmp(method,'ica_swt') 7 | if exist(strcat(project_path,'\ICA_EEG'), 'dir')==0 8 | addpath(genpath('..\Preprocessing')); 9 | computeICA(project_path); 10 | end 11 | end 12 | 13 | absolute_power = absolute(project_path,method); 14 | correlation_data = correlation(project_path,absolute_power); 15 | [sum_ch_arousal,sum_ch_valence,sum_fb_arousal,sum_fb_valence,sum_sb_arousal,sum_sb_valence] = processCorrelation(correlation_data); 16 | end -------------------------------------------------------------------------------- /Data Processing/Preprocessing/computeICAPredict.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | %Author : Muhammad Nadzeri Munawar 3 | % 4 | % 5 | %This code is to create absolute_power variable of subject no. 20 such as : 6 | %delta, theta, alpha, beta, gamma with shape 32x5x40. 32 mean total of 7 | %channel, 5 mean total absolute power, 40 mean 40 trial 8 | % 9 | % project_path -> 'D:\TUGAS AKHIR\Progress\24. (08-12-2015)' 10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 11 | 12 | function ica_data = computeICAPredict(raw_data) 13 | addpath(genpath('pca_ica')); 14 | 15 | ica_data = myICA(raw_data,14); 16 | 17 | for i=1:14 18 | path = strcat('../../Web App/img/ica/',num2str(i),'.png'); 19 | 20 | set(gcf,'Visible','off'); 21 | plot(ica_data(i,:)); 22 | print(path,'-dpng'); 23 | end 24 | end -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /Data Processing/Classification/kNN.m: -------------------------------------------------------------------------------- 1 | 2 | function [results] = kNN(TrainingSet,GroupTrain,TestSet,k) 3 | [L,L1] = size(TestSet); 4 | results = zeros(L); 5 | for i = 1:L 6 | [L2,L3] = size(TrainingSet); 7 | data_distance = zeros(L2); 8 | for j = 1:L2 9 | p = TrainingSet(j,:); 10 | q = TestSet(i,:); 11 | 12 | data_distance (j) = sum(abs(p-q)./(abs(p) + abs(q))); 13 | end 14 | 15 | [B,I] = sort(data_distance); 16 | 17 | nearest = GroupTrain(I(1:k)); 18 | nearest_distance = B(1:k); 19 | sse = nearest_distance(1)/nearest_distance(2); 20 | % disp(sse); 21 | % disp(nearest); 22 | if sse<=0.97 23 | results(i)=nearest(1); 24 | else 25 | results(i)=mode(nearest); 26 | end 27 | %results(i)=mode(nearest); 28 | end 29 | end 30 | 31 | -------------------------------------------------------------------------------- /Data Processing/Preprocessing/ownSWT.m: -------------------------------------------------------------------------------- 1 | function [swa,swd] = ownSWT(A,level,wname) 2 | [h,g]=wfilters(wname,'r'); 3 | wLength = length(h)/2-1; 4 | 5 | L = size(A,2); 6 | for i=1:level 7 | shift = 2^(i-1); 8 | start = L-(shift*wLength)+1; 9 | if(i==1) 10 | decompose = A; 11 | else 12 | decompose = swa(i-1,:); 13 | end 14 | 15 | for j=1:L 16 | swa(i,j)=0; 17 | swd(i,j)=0; 18 | shiftIdx=start; 19 | for k=1:length(h) 20 | swa(i,j)=swa(i,j)+decompose(shiftIdx)*h(k); 21 | swd(i,j)=swd(i,j)+decompose(shiftIdx)*g(k); 22 | shiftIdx=shiftIdx+shift; 23 | if(shiftIdx>L) 24 | shiftIdx=shiftIdx-L; 25 | end 26 | end 27 | start=start+1; 28 | if(start>L) 29 | start=start-L; 30 | end 31 | end 32 | end 33 | end -------------------------------------------------------------------------------- /Data Processing/Statical Analysis/correlation.m: -------------------------------------------------------------------------------- 1 | function correlation_data = correlation(project_path,absolute_power) 2 | basePath = strcat(project_path,'\USED_EEG\'); 3 | 4 | kuesioner = csvread(strcat(project_path,'\Metadata\newDataKuesioner.csv')); 5 | kuesioner = transpose(kuesioner); 6 | start = 0; 7 | stop = 0; 8 | 9 | subject = size(absolute_power); 10 | subject = subject(1); 11 | 12 | for h=1:subject 13 | directory = sprintf('S%02d',h); 14 | allList = dir( strcat(basePath,directory )); 15 | allFiles = { allList(3:end).name }; 16 | trial = length(allFiles); 17 | 18 | start = stop+1; 19 | stop = stop + trial; 20 | 21 | for k=1:2 22 | for i=1:14 23 | for j=1:5 24 | temp = corrcoef(kuesioner(k,start:stop), reshape(absolute_power(h,i,j,1:trial),1,trial)); 25 | correlation_data(h,k,i,j) = temp(1,2); 26 | end 27 | end 28 | end 29 | end 30 | end -------------------------------------------------------------------------------- /Data Processing/Preprocessing/pca_ica/myCenter.m: -------------------------------------------------------------------------------- 1 | function [Zc mu] = myCenter(Z) 2 | %-------------------------------------------------------------------------- 3 | % Syntax: Zc = myCenter(Z); 4 | % [Zc mu] = myCenter(Z); 5 | % 6 | % Inputs: Z is an (d x n) matrix containing n samples of a 7 | % d-dimensional random vector 8 | % 9 | % Outputs: Zc is the centered version of Z 10 | % 11 | % mu is the (d x 1) sample mean of Z 12 | % 13 | % Description: This function returns the centered (i.e., zero mean) 14 | % version of the input samples 15 | % 16 | % NOTE: Z = Zc + repmat(mu,1,n); 17 | % 18 | % Author: Brian Moore 19 | % brimoor@umich.edu 20 | % 21 | % Date: April 26, 2015 22 | %-------------------------------------------------------------------------- 23 | 24 | % Compute sample mean 25 | mu = mean(Z,2); 26 | 27 | % Subtract mean 28 | Zc = bsxfun(@minus,Z,mu); 29 | -------------------------------------------------------------------------------- /Data Processing/Preprocessing/pca_ica/myWhiten.m: -------------------------------------------------------------------------------- 1 | function [Zw T] = myWhiten(Z) 2 | %-------------------------------------------------------------------------- 3 | % Syntax: Zw = myWhiten(Z); 4 | % [Zw T] = myWhiten(Z); 5 | % 6 | % Inputs: Z is an (d x n) matrix containing n samples of a 7 | % d-dimensional random vector 8 | % 9 | % Outputs: Zw is the whitened version of Z 10 | % 11 | % T is the (d x d) whitening transformation of Z 12 | % 13 | % Description: This function returns the whitened (identity covariance) 14 | % version of the input samples 15 | % 16 | % NOTE: Must have n >= d to fully whiten Z 17 | % 18 | % NOTE: Z = T \ Zcw; 19 | % 20 | % Author: Brian Moore 21 | % brimoor@umich.edu 22 | % 23 | % Date: April 26, 2015 24 | %-------------------------------------------------------------------------- 25 | 26 | % Compute sample covariance 27 | R = cov(Z'); 28 | 29 | % Whiten data 30 | [U,S,~] = svd(R,'econ'); 31 | T = U * diag(1 ./ sqrt(diag(S))) * U'; 32 | Zw = T * Z; 33 | -------------------------------------------------------------------------------- /Data Processing/Preprocessing/preProcessingPredict.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | %Author : Muhammad Nadzeri Munawar 3 | % 4 | % 5 | %This code is to create absolute_power variable of subject no. 20 such as : 6 | %delta, theta, alpha, beta, gamma with shape 32x5x40. 32 mean total of 7 | %channel, 5 mean total absolute power, 40 mean 40 trial 8 | % 9 | % project_path -> 'D:\TUGAS AKHIR\Progress\24. (08-12-2015)' 10 | % method -> fft;ica_fft;swt;ica_swt 11 | % subject -> [2,4,6,7,8,9,10,13,15,16,21,25,26,28,29,30]; 12 | % channel -> [2,3,4,5,6,7,8,14]; 13 | % fb -> for fft : 1.Delta;2.Theta;3.Alpha;4.Beta;5.Gamma - for swt : 1.A5;2.D5;3.D4;4.D3;5.D2 14 | % features -> 1. Min;2.Max;3.Std;4.Avg;5.Pow;6.Energy 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | 17 | function result = preProcessingPredict(raw_data,preprocessing_method,channel,fb,features) 18 | if strcmp(preprocessing_method,'fft') || strcmp(preprocessing_method,'ica_fft') 19 | result = computeFFTPredict(raw_data,preprocessing_method,channel,fb,features); 20 | elseif strcmp(preprocessing_method,'swt') || strcmp(preprocessing_method,'ica_swt') 21 | result = computeSWTPredict(raw_data,preprocessing_method,channel,fb,features); 22 | end 23 | end -------------------------------------------------------------------------------- /Data Processing/Preprocessing/pca_ica/myCenterAndWhiten.m: -------------------------------------------------------------------------------- 1 | function [Zcw T mu] = myCenterAndWhiten(Z) 2 | %-------------------------------------------------------------------------- 3 | % Syntax: Zcw = myCenterAndWhiten(Z); 4 | % [Zcw T] = myCenterAndWhiten(Z); 5 | % [Zcw T mu] = myCenterAndWhiten(Z); 6 | % 7 | % Inputs: Z is an (d x n) matrix containing n samples of a 8 | % d-dimensional random vector 9 | % 10 | % Outputs: Zcw is the centered and whitened version of Z 11 | % 12 | % T is the (d x d) whitening transformation of Z 13 | % 14 | % mu is the (d x 1) sample mean of Z 15 | % 16 | % Description: This function returns the centered (zero-mean) and whitened 17 | % (identity covariance) version of the input samples 18 | % 19 | % NOTE: Z = T \ Zcw + repmat(mu,1,n); 20 | % 21 | % Author: Brian Moore 22 | % brimoor@umich.edu 23 | % 24 | % Date: April 26, 2015 25 | %-------------------------------------------------------------------------- 26 | 27 | % Center data 28 | [Zc mu] = myCenter(Z); 29 | 30 | % Whiten data 31 | [Zcw T] = myWhiten(Zc); 32 | -------------------------------------------------------------------------------- /Data Processing/Classification/saveDatasets.m: -------------------------------------------------------------------------------- 1 | function Datasets = saveDatasets(project_path,method,class) 2 | if strcmp(method,'fft') 3 | basePath = strcat(project_path,'\FFT_EEG_',upper(class),'\'); 4 | elseif strcmp(method,'swt') 5 | basePath = strcat(project_path,'\SWT_EEG_',upper(class),'\'); 6 | elseif strcmp(method,'ica_fft') 7 | basePath = strcat(project_path,'\ICA_FFT_EEG_',upper(class),'\'); 8 | elseif strcmp(method,'ica_swt') 9 | basePath = strcat(project_path,'\ICA_SWT_EEG_',upper(class),'\'); 10 | end 11 | 12 | all_files = dir(basePath); 13 | all_files = all_files(3:end); 14 | all_dir = all_files([all_files(:).isdir]); 15 | subject = numel(all_dir); 16 | 17 | counterDatasets = 1; 18 | 19 | for h=1:subject 20 | directory = sprintf('S%02d',h); 21 | allList = dir( strcat(basePath,directory )); 22 | allFiles = { allList(3:end).name }; 23 | trial = length(allFiles); 24 | 25 | for i = 1:trial 26 | rawData = csvread(strcat(basePath,directory,'\T',num2str(i),'.csv')); 27 | Datasets(counterDatasets,:) = rawData; 28 | counterDatasets=counterDatasets+1; 29 | end 30 | end 31 | 32 | csvwrite(strcat(project_path,'\Metadata\datasets_',method,'_',class,'.csv'),Datasets); 33 | end -------------------------------------------------------------------------------- /Data Processing/Classification/findAccuracy.m: -------------------------------------------------------------------------------- 1 | function [jmlBenar,rata_rata,tp,tn,fp,fn] = findAccuracy(datasets,label,method) 2 | jmlData = length(label); 3 | %jmlTest = 20; 4 | 5 | tp = 0; 6 | fn = 0; 7 | fp = 0; 8 | tn = 0; 9 | 10 | indices = crossvalind('Kfold',jmlData,10); 11 | for h = 1:10 12 | test = (indices == h); train = ~test; 13 | jmlTest = sum(test); 14 | TrainingSet=datasets(train,:); 15 | TestSet=datasets(test,:); 16 | GroupTrain=label(train); 17 | dataAsli = label(test); 18 | 19 | if strcmp(method,'svm') 20 | svmStruct = svmtrain(TrainingSet,GroupTrain,'kernel_function','rbf'); 21 | results = svmclassify(svmStruct,TestSet); 22 | elseif strcmp(method,'knn') 23 | results = kNN(TrainingSet, GroupTrain, TestSet, 3); 24 | end 25 | 26 | jmlBenar(h) = 0; 27 | for i = 1:jmlTest 28 | if(dataAsli(i)==results(i)) 29 | if dataAsli(i)==3 30 | tp=tp+1; 31 | else 32 | tn=tn+1; 33 | end 34 | jmlBenar(h)=jmlBenar(h)+1; 35 | else 36 | if results(i)==3 37 | fp=fp+1; 38 | else 39 | fn=fn+1; 40 | end 41 | end 42 | end 43 | jmlBenar(h) = jmlBenar(h)/jmlTest; 44 | end 45 | rata_rata = mean2(jmlBenar); 46 | end -------------------------------------------------------------------------------- /Data Processing/Preprocessing/computeICA.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | %Author : Muhammad Nadzeri Munawar 3 | % 4 | % 5 | %This code is to create absolute_power variable of subject no. 20 such as : 6 | %delta, theta, alpha, beta, gamma with shape 32x5x40. 32 mean total of 7 | %channel, 5 mean total absolute power, 40 mean 40 trial 8 | % 9 | % project_path -> 'D:\TUGAS AKHIR\Progress\24. (08-12-2015)' 10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 11 | 12 | function computeICA(project_path) 13 | addpath(genpath('pca_ica')); 14 | addpath(genpath('..\Global Code')); 15 | basePath = strcat(project_path,'\USED_EEG\'); 16 | all_files = dir(basePath); 17 | all_files = all_files(3:end); 18 | all_dir = all_files([all_files(:).isdir]); 19 | subject = numel(all_dir); 20 | 21 | if exist(strcat(project_path,'\ICA_EEG'), 'dir') 22 | system(strcat('rmdir /S /Q "',project_path,'\ICA_EEG"')); 23 | end 24 | 25 | createFolder(subject,strcat(project_path,'\ICA_EEG')); 26 | 27 | for h=1:subject 28 | directory = sprintf('S%02d',h); 29 | allList = dir( strcat(basePath,directory )); 30 | allFiles = { allList(3:end).name }; 31 | trial = length(allFiles); 32 | 33 | for i = 1:trial 34 | rawData = csvread(strcat(basePath,directory,'\T',num2str(i),'.csv')); 35 | rawData = myICA(rawData,14); 36 | csvwrite(strcat(project_path,'\ICA_EEG\',directory,'\T',num2str(i),'.csv'),rawData); 37 | end 38 | end 39 | end -------------------------------------------------------------------------------- /Data Processing/Process Data/cutData.m: -------------------------------------------------------------------------------- 1 | function cutData(dataset_path,project_path) 2 | addpath(genpath('..\Global Code')); 3 | 4 | dataset_eeg_path = strcat(dataset_path,'\EEG'); 5 | 6 | len1 = 640; 7 | len2 = 3200; 8 | 9 | allList = dir(dataset_eeg_path); 10 | allDir = { allList(3:end).name }; 11 | 12 | if exist(strcat(project_path,'\EEG"'), 'dir') 13 | system(strcat('rmdir /S /Q "',project_path,'\EEG"')); 14 | end 15 | createFolder(length(allDir),strcat(project_path,'\EEG')); 16 | 17 | for i=1:length(allDir) 18 | dataOneDir = allDir{i}; 19 | allFileList = dir(strcat(dataset_eeg_path,'\',dataOneDir)); 20 | allFileName = { allFileList(3:end).name }; 21 | 22 | for j = 1:length(allFileName) 23 | dataOneFile = allFileName{j}; 24 | dataEEG = csvread(strcat(dataset_eeg_path,'\',dataOneDir,'\',dataOneFile),1,0); 25 | start = mod(length(dataEEG),4)+1; 26 | dataEEG = dataEEG(start:end,3:16); 27 | L = length(dataEEG); 28 | 29 | if L>=len2 30 | used = (L - len2)/2; 31 | elseif L>=len1 32 | used = (L - len1)/2; 33 | else 34 | continue; 35 | end 36 | 37 | start = used+1; 38 | stop = L - used; 39 | 40 | rawData = transpose(dataEEG(start:stop,:)); 41 | 42 | fileNewName = dataOneFile(5:end-22); 43 | 44 | csvwrite(strcat(project_path,'\EEG\',dataOneDir,'\',fileNewName,'.csv'),rawData); 45 | end 46 | end 47 | end -------------------------------------------------------------------------------- /Data Processing/Preprocessing/pca_ica/myMultiGaussian.m: -------------------------------------------------------------------------------- 1 | function Z = myMultiGaussian(MU,SIGMA,n) 2 | %-------------------------------------------------------------------------- 3 | % Syntax: Z = myMultiGaussian(MU,SIGMA); 4 | % Z = myMultiGaussian(MU,SIGMA,n); 5 | % 6 | % Inputs: MU is the desired (d x 1) mean vector 7 | % 8 | % SIGMA is the desired (d x d) covariance matrix 9 | % 10 | % [OPTIONAL] n is the desired number of samples. The default 11 | % value is n = 1 12 | % 13 | % Outputs: Z is a (d x n) matrix containing n multivariate Gaussian 14 | % samples 15 | % 16 | % Description: This function generates samples from a d-dimensional 17 | % multivariate Gaussian random variable with mean vector MU 18 | % and covariance matrix SIGMA 19 | % 20 | % NOTE: mean(Z,2) ~ MU 21 | % cov(Z') ~ SIGMA 22 | % 23 | % Author: Brian Moore 24 | % brimoor@umich.edu 25 | % 26 | % Date: April 26, 2015 27 | %-------------------------------------------------------------------------- 28 | 29 | % Parse inputs 30 | [d d2] = size(SIGMA); 31 | if (d ~= d2) || (d ~= length(MU)) 32 | % Syntax error 33 | error('Syntax error... Type "help myMultiGaussian" for more info'); 34 | end 35 | if nargin < 3 36 | % Default # samples 37 | n = 1; 38 | end 39 | 40 | % Generate samples 41 | L = chol(SIGMA,'lower'); 42 | Z = repmat(MU,1,n) + L * randn(d,n); 43 | -------------------------------------------------------------------------------- /Data Processing/Preprocessing/pca_ica/demo_PCA1.m: -------------------------------------------------------------------------------- 1 | % 2 | % Name: demo_PCA1.m 3 | % 4 | % Description: Demonstrates the performance of PCA by decomposing 5 | % correlated multivariate Gaussian samples into 6 | % their principal components 7 | % 8 | % When d == r, the PCA reconstruction is *exact*. Thus 9 | % PCA effectively transforms the input data into 10 | % orthogonal, maximal variance components while preserving 11 | % information 12 | % 13 | % Author: Brian Moore 14 | % brimoor@umich.edu 15 | % 16 | % Date: April 26, 2015 17 | % 18 | 19 | rng(1); 20 | 21 | % Knobs 22 | n = 100; % # samples 23 | d = 3; % Sample dimension 24 | r = 2; % # principal components 25 | 26 | % Generate Gaussian data 27 | MU = 10 * rand(d,1); 28 | sigma = (2 * randi([0 1],d) - 1) .* rand(d); 29 | SIGMA = 3 * (sigma * sigma'); 30 | Z = myMultiGaussian(MU,SIGMA,n); 31 | 32 | % Perform PCA 33 | [Zpca T U mu] = myPCA(Z,r); 34 | Zr = U / T * Zpca + repmat(mu,1,n); 35 | 36 | % Plot principal components 37 | figure; 38 | for i = 1:r 39 | subplot(r,1,i); 40 | plot(Zpca(i,:),'b'); 41 | grid on; 42 | ylabel(sprintf('Zpca(%i,:)',i)); 43 | end 44 | subplot(r,1,1); 45 | title('Principal Components'); 46 | 47 | % Plot r-dimensional approximations 48 | figure; 49 | for i = 1:d 50 | subplot(d,1,i); 51 | hold on; 52 | p1 = plot(Z(i,:),'--r'); 53 | p2 = plot(Zr(i,:),'-.b'); 54 | grid on; 55 | ylabel(sprintf('Z(%i,:)',i)); 56 | end 57 | subplot(d,1,1); 58 | title(sprintf('%iD PCA approximation of %iD data',r,d)); 59 | legend([p1 p2],'Z','Zr'); 60 | -------------------------------------------------------------------------------- /Data Processing/Classification/getPrediction.m: -------------------------------------------------------------------------------- 1 | function [valence,arousal] = getPrediction(file_path,preprocessing_method,classification_method) 2 | %%%%%%%%%%%%%% 3 | %file_path = 'D:\5112100136 - Muhammad Nadzeri Munawar\TUGAS AKHIR\Datasets\EEG\S04\S04-T13-10.11.15.11.40.03.csv'; 4 | project_path = strcat(pwd,'\..\..'); 5 | %preprocessing_method='fft';%'ica_fft','swt','ica_swt'; 6 | %classification_method='knn'; 7 | channel_v = [10,3,14,5,1,8,6,4,7,11]; 8 | fb_v = [3,4,5]; 9 | features_v = [2,3]; 10 | 11 | channel_a = [3,13,10,2,1,12,4,7,8,11]; 12 | fb_a = [3,4,5]; 13 | features_a = [2,3]; 14 | %%%%%%%%%%%%%%% 15 | 16 | addpath(genpath('..\Process Data')); 17 | addpath(genpath('..\Preprocessing')); 18 | 19 | raw_data = cutDataPredict(file_path); 20 | preprocessing_result_v = preProcessingPredict(raw_data,preprocessing_method,channel_v,fb_v,features_v); 21 | preprocessing_result_a = preProcessingPredict(raw_data,preprocessing_method,channel_a,fb_a,features_a); 22 | 23 | % Find Valence 24 | datasets = getDatasetsPrediction(project_path,preprocessing_method,'valence'); 25 | label = separateClassPrediction(project_path,preprocessing_method,'valence'); 26 | [datasets,label] = getTwoClass(datasets,label); 27 | valence = predictClassification(preprocessing_result_v,datasets,label,classification_method); 28 | 29 | % Find Arousal 30 | datasets = getDatasetsPrediction(project_path,preprocessing_method,'arousal'); 31 | label = separateClassPrediction(project_path,preprocessing_method,'arousal'); 32 | [datasets,label] = getTwoClass(datasets,label); 33 | arousal = predictClassification(preprocessing_result_a,datasets,label,classification_method); 34 | end -------------------------------------------------------------------------------- /Data Processing/Preprocessing/pca_ica/demo_ICA.m: -------------------------------------------------------------------------------- 1 | % 2 | % Name: demo_ICA.m 3 | % 4 | % Description: Demonstrates the performance of ICA by decomposing 5 | % correlated multivariate Gaussian samples into 6 | % uncorrelated and maximally independent data streams 7 | % 8 | % When d == r, the ICA reconstruction is *exact*. Thus 9 | % ICA effectively transforms the input data into 10 | % uncorrelated, independent components while preserving 11 | % information 12 | % 13 | % Author: Brian Moore 14 | % brimoor@umich.edu 15 | % 16 | % Date: April 26, 2015 17 | % 18 | 19 | rng(1); 20 | 21 | % Knobs 22 | n = 100; % # samples 23 | d = 3; % Sample dimension 24 | r = 2; % # independent components 25 | 26 | % Generate Gaussian data 27 | MU = 10 * rand(d,1); 28 | sigma = (2 * randi([0 1],d) - 1) .* rand(d); 29 | SIGMA = 3 * (sigma * sigma'); 30 | Z = myMultiGaussian(MU,SIGMA,n); 31 | 32 | % Perform ICA 33 | [Zica A T mu] = myICA(Z,r); 34 | Zr = T \ pinv(A) * Zica + repmat(mu,1,n); 35 | 36 | % Plot indpendent components 37 | figure; 38 | for i = 1:r 39 | subplot(r,1,i); 40 | plot(Zica(i,:),'b'); 41 | grid on; 42 | ylabel(sprintf('Zica(%i,:)',i)); 43 | end 44 | subplot(r,1,1); 45 | title('Independent Components'); 46 | 47 | % Plot r-dimensional approximations 48 | figure; 49 | for i = 1:d 50 | subplot(d,1,i); 51 | hold on; 52 | p1 = plot(Z(i,:),'--r'); 53 | p2 = plot(Zr(i,:),'-.b'); 54 | grid on; 55 | ylabel(sprintf('Z(%i,:)',i)); 56 | end 57 | subplot(d,1,1); 58 | title(sprintf('%iD ICA approximation of %iD data',r,d)); 59 | legend([p1 p2],'Z','Zr'); 60 | -------------------------------------------------------------------------------- /Data Processing/Statical Analysis/processCorrelation.m: -------------------------------------------------------------------------------- 1 | function [sum_ch_arousal,sum_ch_valence,sum_fb_arousal,sum_fb_valence,sum_sb_arousal,sum_sb_valence] = processCorrelation(correlation_data) 2 | th = 0.35; 3 | 4 | subjects = size(correlation_data); 5 | subjects = subjects(1); 6 | 7 | fb_valence = zeros(subjects,5); 8 | fb_arousal = zeros(subjects,5); 9 | 10 | ch_valence = zeros(subjects,14); 11 | ch_arousal = zeros(subjects,14); 12 | 13 | correlation_data = abs(correlation_data); 14 | 15 | for i = 1:subjects 16 | correlation_value = reshape(correlation_data(i,1,:,:),14,5); 17 | idx_corr = correlation_valueEigenVector;D->EigenValue) 21 | resultWhitening = E * diag(1 ./ sqrt(diag(D))) * E' * resultCentering; %Main Whitening 22 | %%%%%%%%%%%%%%%%%%%%%%%%%%%% 23 | 24 | %%%%%%%%%% Component Extraction %%%%%%%%%% 25 | % Random initial weights 26 | W = normRows(rand(r,size(resultWhitening,1))); 27 | %W = rand(r,size(resultWhitening,1)); 28 | % Initial looping variable 29 | k = 0; 30 | err = inf; 31 | % Looping until convergen or until maxiter 32 | while (err > eps) && (k < maxIters) 33 | % Increment counter 34 | k = k + 1; 35 | 36 | % Update weights 37 | wLast = W; % Save last weights 38 | Sk = permute(wLast * resultWhitening,[1 3 2]); 39 | G = Sk .* exp(-0.5 * Sk.^2); 40 | Gp = Sk .* G; 41 | W = mean(bsxfun(@times,G,permute(resultWhitening,[3 1 2])),3) + bsxfun(@times,mean(Gp,3),wLast); 42 | W = normRows(W); 43 | 44 | % Decorrelate weights 45 | [U,S,~] = svd(W,'econ'); 46 | W = U * diag(1 ./ diag(S)) * U' * W; 47 | 48 | % Update error 49 | err = max(1 - dot(W,wLast,2)); 50 | end 51 | %%%%%%%%%%%%%%%%%%%%%%%%%%%% 52 | 53 | xICA = W * resultWhitening; 54 | xICA = normRows(xICA); 55 | end -------------------------------------------------------------------------------- /Data Processing/Preprocessing/pca_ica/myPCA.m: -------------------------------------------------------------------------------- 1 | function [Zpca T U mu eigVecs] = myPCA(Z,r) 2 | %-------------------------------------------------------------------------- 3 | % Syntax: Zpca = myPCA(Z,r); 4 | % [Zpca T U mu] = myPCA(Z,r); 5 | % [Zpca T U mu eigVecs] = myPCA(Z,r); 6 | % 7 | % Inputs: Z is an (d x n) matrix containing n samples of a 8 | % d-dimensional random vector 9 | % 10 | % r is the desired number of principal components 11 | % 12 | % Outputs: Zpca is a (r x n) matrix containing the r principal 13 | % components - scaled to variance 1 - of the input samples 14 | % 15 | % U and T are the PCA transformation matrices such that 16 | % Zr = U / T * Zpca + repmat(mu,1,n); 17 | % is the r-dimensional PCA approximation of Z 18 | % 19 | % mu is the (d x 1) sample mean of Z 20 | % 21 | % eigVecs is a (d x r) matrix containing the scaled 22 | % eigenvectors of the sample covariance of Z 23 | % 24 | % Description: This function performs principal component analysis (PCA) 25 | % on the input samples 26 | % 27 | % Author: Brian Moore 28 | % brimoor@umich.edu 29 | % 30 | % Date: April 26, 2015 31 | %-------------------------------------------------------------------------- 32 | 33 | % Center data 34 | [Zc mu] = myCenter(Z); 35 | 36 | % Compute truncated SVD 37 | %[U S V] = svds(Zc,r); % Equivalent, but usually slower than svd() 38 | [U S V] = svd(Zc,'econ'); 39 | U = U(:,1:r); 40 | S = S(1:r,1:r); 41 | V = V(:,1:r); 42 | 43 | % Compute principal components 44 | Zpca = S * V'; 45 | %Zpca = U' * Zc; % Equivalent but slower 46 | 47 | % Whiten data, if desired 48 | %[Zpca T] = myWhiten(Zpca); 49 | T = eye(r); % No whitening 50 | 51 | % Return scaled eigenvectors, if necessary 52 | if (nargout >= 5) 53 | [~,n] = size(Z); 54 | eigVecs = bsxfun(@times,U,diag(S)' / sqrt(n)); 55 | end 56 | -------------------------------------------------------------------------------- /Data Processing/Preprocessing/preProcessing.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | %Author : Muhammad Nadzeri Munawar 3 | % 4 | % 5 | %This code is to create absolute_power variable of subject no. 20 such as : 6 | %delta, theta, alpha, beta, gamma with shape 32x5x40. 32 mean total of 7 | %channel, 5 mean total absolute power, 40 mean 40 trial 8 | % 9 | % project_path -> 'D:\TUGAS AKHIR\Progress\24. (08-12-2015)' 10 | % method -> fft;ica_fft;swt;ica_swt 11 | % subject -> [2,4,6,7,8,9,10,13,15,16,21,25,26,28,29,30]; 12 | % channel -> [2,3,4,5,6,7,8,14]; 13 | % fb -> for fft : 1.Delta;2.Theta;3.Alpha;4.Beta;5.Gamma - for swt : 1.A5;2.D5;3.D4;4.D3;5.D2 14 | % features -> 1. Min;2.Max;3.Std;4.Avg;5.Pow;6.Energy 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | 17 | function preProcessing(project_path,method,class,subject,channel,fb,features) 18 | 19 | %%%%%%%%%%%%%% 20 | project_path = strcat(pwd,'\..\..'); 21 | method='fft';%'ica_fft','swt','ica_swt'; 22 | 23 | % class='arousal';%'valence'; 24 | % subject = 1:34; 25 | fb = 1:5; 26 | features = 3:4; 27 | channel = 1:14; 28 | 29 | %Arousal 30 | class='arousal';%'valence'; 31 | subject = [16,13,10,28,11,7,6,2,20,26,29,15,4,30,5,34,9,24,8,23]; 32 | % fb = [3,4,5]; 33 | % features = [2,3]; 34 | % channel = [3,13,10,2,1,12,4,7,8,11]; 35 | 36 | %Valence 37 | % class='valence';%'valence'; 38 | % subject = [16,25,34,9,5,4,20,28,2,6,32,29,15,10,22,11,8,1,31,13]; 39 | % fb = [3,4,5]; 40 | % features = [2,3]; 41 | % channel = [10,3,14,5,1,8,6,4,7,11]; 42 | 43 | %%%%%%%%%%%%%%% 44 | 45 | if strcmp(method,'fft') 46 | computeFFT(project_path,method,class,subject,channel,fb,features); 47 | elseif strcmp(method,'ica_fft') 48 | if exist(strcat(project_path,'\ICA_EEG'), 'dir')==0 49 | computeICA(project_path); 50 | end 51 | computeFFT(project_path,method,class,subject,channel,fb,features); 52 | elseif strcmp(method,'swt') 53 | computeSWT(project_path,method,class,subject,channel,fb,features); 54 | elseif strcmp(method,'ica_swt') 55 | if exist(strcat(project_path,'\ICA_EEG'), 'dir')==0 56 | computeICA(project_path); 57 | end 58 | computeSWT(project_path,method,class,subject,channel,fb,features); 59 | end 60 | end -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Significant Preprocessing Method in EEG-Based Emotion Classification 2 | EEG preprocessing methods for classifying person emotions have been widely applied. However, there still remain some parts where determining significant preprocessing method can be improved. In this regards, this project proposes a method to determine the most significant preprocessing methods, among them to determine (i) denoising method; (ii) frequency bands; (iii) subjects; (iv) channels; and (v) features. The purposes are to improve the accuracy of emotion classification based on valence and arousal emotion model. EEG data from 34 participants will be recorded with the questionnaires (valence and arousal) that have been taken from the participants when they receive stimuli from picture, music, and video. EEG data will be divided into 5 seconds for each trial. Then, EEG data will be processed using denoising method and feature extraction. After that, the most significant preprocessing methods will be chosen using statistical analysis Pearson-Correlation. The preprocessed EEG data will be categorized. The average accuracy results using SVM are 66.09% (valence) and 75.66% (arousal) while the average accuracy results using KNN are 82.33% (valence) and 87.32% (arousal). For comparison, the average accuracy results without choosing the most significant preprocessing method are 52% (valence) and 49% (arousal) using SVM while the average accuracy results using KNN are 50.13% (valence) and 56% (arousal). 3 | ## Required Library 4 | ### Python 5 | Python is used as Web App GUI.
6 | 1. [Common Gateway Interface](https://docs.python.org/2/library/cgi.html)
7 | 2. [Cgitb](https://docs.python.org/2/library/cgitb.html)
8 | 3. [Matlab Engine for Python](http://www.mathworks.com/help/matlab/matlab-engine-for-python.html)
9 | ### Matlab 10 | Matlab is used as EEG analysis, preprocessing, and classification.
11 | 1. [PCA and ICA Package](http://www.mathworks.com/matlabcentral/fileexchange/38300-pca-and-ica-package)
12 | ## Paper Publication 13 | [JATIT - Significant Preprocessing Method in EEG-Based Emotion Classification](https://drive.google.com/file/d/0B9EQQ4nwB6CbdlpoX0tuSzRxbzg)
14 | 15 | ## Copyright 16 | Copyright (c) 2016 Muhammad Nadzeri Munawar

17 | See my:
18 | 1. Github profile: https://github.com/nadzeri
19 | 2. LinkedIn profile: https://id.linkedin.com/in/nadzeri
20 | -------------------------------------------------------------------------------- /Data Processing/Process Data/divideFiveSeconds.m: -------------------------------------------------------------------------------- 1 | function divideFiveSeconds(dataset_path,project_path) 2 | addpath(genpath('..\Global Code')); 3 | normRows = @(XXX) bsxfun(@times,XXX,1 ./ sqrt(sum(XXX.^2,2))); %Normalisasi Euclidean 4 | 5 | base_path = strcat(project_path,'\EEG'); 6 | base_path2 = strcat(project_path,'\USED_EEG'); 7 | dataKuesioner = csvread(strcat(dataset_path,'\metadata\list questionnairre.csv')); 8 | 9 | counterNewKuesioner=1; 10 | counterKuesioner=1; 11 | newDataKuesioner={}; 12 | allList = dir( base_path ); 13 | allDir = { allList(3:end).name }; 14 | lewat=0; 15 | 16 | if exist(base_path2, 'dir') 17 | system(strcat('rmdir /S /Q "',base_path2,'"')); 18 | end 19 | createFolder(length(allDir),base_path2); 20 | 21 | for i=1:length(allDir) 22 | dataOneDir = allDir{i}; 23 | allFileList = dir(strcat(base_path,'\',dataOneDir)); 24 | allFileName = { allFileList(3:end).name }; 25 | 26 | counter=1; 27 | 28 | for j = 1:length(allFileName) 29 | dataOneFile = allFileName{j}; 30 | dataEEG = csvread(strcat(base_path,'\',dataOneDir,'\',dataOneFile)); 31 | %dataEEG = normRows(dataEEG); 32 | if length(dataEEG(1,:))==640 33 | csvwrite(strcat(base_path2,'\',dataOneDir,'\T',num2str(counter),'.csv'),dataEEG); 34 | newDataKuesioner{counterNewKuesioner} = dataKuesioner(counterKuesioner,:); 35 | counter=counter+1; 36 | counterKuesioner=counterKuesioner+1; 37 | counterNewKuesioner=counterNewKuesioner+1; 38 | elseif length(dataEEG(1,:))==3200 39 | start=1; 40 | stop=640; 41 | for k=1:5 42 | csvwrite(strcat(base_path2,'\',dataOneDir,'\T',num2str(counter),'.csv'),dataEEG(:,start:stop)); 43 | newDataKuesioner{counterNewKuesioner} = dataKuesioner(counterKuesioner,:); 44 | start=stop+1; 45 | stop=stop+640; 46 | counter=counter+1; 47 | counterNewKuesioner=counterNewKuesioner+1; 48 | end 49 | counterKuesioner=counterKuesioner+1; 50 | else 51 | lewat=lewat+1; 52 | end 53 | end 54 | end 55 | newDataKuesioner = reshape(cell2mat(newDataKuesioner),2,[]); 56 | newDataKuesioner = transpose(newDataKuesioner); 57 | 58 | mkdir(strcat(project_path,'\Metadata')); 59 | 60 | csvwrite(strcat(project_path,'\Metadata\newDataKuesioner.csv'),newDataKuesioner); 61 | end -------------------------------------------------------------------------------- /Data Processing/Preprocessing/pca_ica/myICA.m: -------------------------------------------------------------------------------- 1 | function [Zica A T mu] = myICA(Z,r,dispFlag) 2 | %-------------------------------------------------------------------------- 3 | % Syntax: Zica = myICA(Z,r); 4 | % Zica = myICA(Z,r,dispFlag); 5 | % [Zica A T mu] = myICA(Z,r); 6 | % [Zica A T mu] = myICA(Z,r,dispFlag); 7 | % 8 | % Inputs: Z is an (d x n) matrix containing n samples of an 9 | % d-dimensional random vector 10 | % 11 | % r is the desired number of independent components 12 | % 13 | % [OPTIONAL] dispFlag = {true false} sets the stdout print 14 | % state. The default value is dispFlag = true 15 | % 16 | % Outputs: Zica is an (r x n) matrix containing the r independent 17 | % components - scaled to variance 1 - of the input samples 18 | % 19 | % A and T are the ICA transformation matrices such that 20 | % Zr = T \ pinv(A) * Zica + repmat(mu,1,n); 21 | % is the r-dimensional ICA approximation of Z 22 | % 23 | % mu is the (d x 1) sample mean of Z 24 | % 25 | % Description: This function performs independent component analysis (ICA) 26 | % on the input samples using the FastICA algorithm with 27 | % Gaussian negentropy 28 | % 29 | % Author: Brian Moore 30 | % brimoor@umich.edu 31 | % 32 | % Date: April 26, 2015 33 | %-------------------------------------------------------------------------- 34 | 35 | % Knobs 36 | eps = 1e-6; % Convergence criteria 37 | maxSamples = 1000; % Max # data points in sample mean calculation 38 | maxIters = 100; % Maximum # iterations 39 | 40 | % Parse display flag 41 | dispFlag = (nargin < 3) || dispFlag; 42 | 43 | % Center and whiten input data 44 | [Zcw T mu] = myCenterAndWhiten(Z); 45 | 46 | % Parse whitened data 47 | [d n] = size(Zcw); 48 | if (n > maxSamples) 49 | % Truncate data for sample mean calculations 50 | Zcwt = Zcw(:,randperm(n,maxSamples)); 51 | else 52 | % Full data 53 | Zcwt = Zcw; 54 | end 55 | 56 | % Random initial weights 57 | normRows = @(X) bsxfun(@times,X,1 ./ sqrt(sum(X.^2,2))); 58 | W = normRows(rand(r,d)); 59 | 60 | % FastICA w/ Gaussian negentropy 61 | k = 0; 62 | err = inf; 63 | while (err > eps) && (k < maxIters) 64 | % Increment counter 65 | k = k + 1; 66 | 67 | % Update weights 68 | Wlast = W; % Save last weights 69 | Sk = permute(Wlast * Zcwt,[1 3 2]); 70 | G = Sk .* exp(-0.5 * Sk.^2); 71 | Gp = Sk .* G; 72 | W = mean(bsxfun(@times,G,permute(Zcwt,[3 1 2])),3) + bsxfun(@times,mean(Gp,3),Wlast); 73 | W = normRows(W); 74 | 75 | % Decorrelate weights 76 | [U,S,~] = svd(W,'econ'); 77 | W = U * diag(1 ./ diag(S)) * U' * W; 78 | 79 | % Update error 80 | err = max(1 - dot(W,Wlast,2)); 81 | 82 | % Display progress 83 | if dispFlag == true 84 | sprintf('Iteration %i: max(1 - ) = %.4g\n',k,k,k - 1,err); 85 | end 86 | end 87 | 88 | % Transformation matrix 89 | A = W; 90 | 91 | % Independent components 92 | Zica = A * Zcw; 93 | -------------------------------------------------------------------------------- /Data Processing/Statical Analysis/absolute.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | %Author : Muhammad Nadzeri Munawar 3 | % 4 | % 5 | %This code is to create absolute_power variable of subject no. 20 such as : 6 | %delta, theta, alpha, beta, gamma with shape 32x5x40. 32 mean total of 7 | %channel, 5 mean total absolute power, 40 mean 40 trial 8 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 9 | 10 | function absolute_power = absolute(project_path,method) 11 | 12 | % define initial variable 13 | if strcmp(method,'fft') || strcmp(method,'swt') 14 | basePath = strcat(project_path,'\USED_EEG\'); 15 | elseif strcmp(method,'ica_fft') || strcmp(method,'ica_swt') 16 | basePath = strcat(project_path,'\ICA_EEG\'); 17 | end 18 | all_files = dir(basePath); 19 | all_files = all_files(3:end); 20 | all_dir = all_files([all_files(:).isdir]); 21 | subjects = numel(all_dir); 22 | channel = 14;%define total channel 23 | samplingFrequency = 128; 24 | 25 | for h = 1:subjects 26 | directory = sprintf('S%02d',h); 27 | 28 | allList = dir( strcat(basePath,directory )); 29 | allFiles = { allList(3:end).name }; 30 | 31 | %looping trial for define absolut power for each trial 32 | for i = 1:length(allFiles) 33 | 34 | %looping channel for compute absolute power for each channel 35 | for j = 1:channel 36 | 37 | %open spesific file according trial and channel 38 | %Contain each channel per file (In this case subject no. 20) 39 | X = csvread(strcat(basePath,directory,'\T',num2str(i),'.csv')); 40 | X = X(j,:); 41 | 42 | if strcmp(method,'swt')||strcmp(method,'ica_swt') 43 | [swa,swd] = swt(X,5,'db4'); 44 | 45 | d2=swd(2,:); 46 | d3=swd(3,:); 47 | d4=swd(4,:); 48 | d5=swd(5,:); 49 | a5=swa(5,:); 50 | 51 | absolute_power(h,j,1,i) = mean(d2)+std(d2)+min(d2)+max(d2); 52 | absolute_power(h,j,2,i) = mean(d3)+std(d3)+min(d3)+max(d3); 53 | absolute_power(h,j,3,i) = mean(d4)+std(d4)+min(d4)+max(d4); 54 | absolute_power(h,j,4,i) = mean(d5)+std(d5)+min(d5)+max(d5); 55 | absolute_power(h,j,5,i) = mean(a5)+std(a5)+min(a5)+max(a5); 56 | % absolute_power(h,j,1,i) = sum(d2.^2); 57 | % absolute_power(h,j,2,i) = sum(d3.^2); 58 | % absolute_power(h,j,3,i) = sum(d4.^2); 59 | % absolute_power(h,j,4,i) = sum(d5.^2); 60 | % absolute_power(h,j,5,i) = sum(a5.^2); 61 | 62 | elseif strcmp(method,'fft')||strcmp(method,'ica_fft') 63 | Fs = samplingFrequency; % Sampling frequency 64 | L = length(X); % Length of signal 65 | 66 | %compute fft from channel 67 | Y = fft(X); 68 | 69 | %Divide fft to get frequency 70 | P2 = abs(Y/L); 71 | P1 = P2(1:L/2+1); 72 | P1(2:end-1) = 2*P1(2:end-1); 73 | 74 | %divide froquency to get delta, theta, alpha, beta, gamma 75 | %And average all of each range (delta, theta, alpha, beta, gamma) 76 | delta = P1(L*1/Fs:L*4/Fs); 77 | theta = P1(L*4/Fs:L*8/Fs); 78 | alpha = P1(L*8/Fs:L*13/Fs); 79 | beta = P1(L*13/Fs:L*30/Fs); 80 | gamma = P1(L*30/Fs:L*50/Fs); 81 | 82 | delta = mean(delta)+std(delta)+min(delta)+max(delta); 83 | theta = mean(theta)+std(theta)+min(theta)+max(theta); 84 | alpha = mean(alpha)+std(alpha)+min(alpha)+max(alpha); 85 | beta = mean(beta)+std(beta)+min(beta)+max(beta); 86 | gamma = mean(gamma)+std(gamma)+min(gamma)+max(gamma); 87 | 88 | % delta = max(delta)+std(delta); 89 | % theta = max(delta)+std(theta); 90 | % alpha = max(delta)+std(alpha); 91 | % beta = max(delta)+std(beta); 92 | % gamma = max(delta)+std(gamma); 93 | 94 | %Create absolute power 95 | %Each channel create absolute power (delta,theta,alpha,beta,gamma) 96 | %from each trial 97 | absolute_power(h,j,1,i) = delta; 98 | absolute_power(h,j,2,i) = theta; 99 | absolute_power(h,j,3,i) = alpha; 100 | absolute_power(h,j,4,i) = beta; 101 | absolute_power(h,j,5,i) = gamma; 102 | end 103 | end 104 | end 105 | end 106 | end -------------------------------------------------------------------------------- /Data Processing/Preprocessing/computeSWTPredict.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | %Author : Muhammad Nadzeri Munawar 3 | % 4 | % 5 | %This code is to create absolute_power variable of subject no. 20 such as : 6 | %delta, theta, alpha, beta, gamma with shape 32x5x40. 32 mean total of 7 | %channel, 5 mean total absolute power, 40 mean 40 trial 8 | % 9 | % project_path -> 'D:\TUGAS AKHIR\Progress\24. (08-12-2015)' 10 | % method -> swt;ica_swt 11 | % subject -> [2,4,6,7,8,9,10,13,15,16,21,25,26,28,29,30]; 12 | % channel -> [2,3,4,5,6,7,8,14]; 13 | % fb -> 1.A5;2.D5;3.D4;4.D3;5.D2 14 | % features -> 1. Min;2.Max;3.Std;4.Avg;5.Pow;6.Energy 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | 17 | function data = computeSWTPredict(raw_data,preprocessing_method,channel,fb,features) 18 | %define variable 19 | if strcmp(preprocessing_method,'ica_swt') 20 | raw_data = computeICAPredict(raw_data); 21 | end 22 | 23 | counter=1; 24 | data=[]; 25 | for j = channel 26 | [swa,swd] = swt(raw_data(j,:),5,'db4'); 27 | d2=swd(2,:); 28 | d3=swd(3,:); 29 | d4=swd(4,:); 30 | d5=swd(5,:); 31 | a5=swa(5,:); 32 | 33 | if counter==1 34 | set(gcf,'Visible','off'); 35 | plot(a5); 36 | print -dpng '../../Web App/img/swt/a5.png'; 37 | 38 | set(gcf,'Visible','off'); 39 | plot(d5); 40 | print -dpng '../../Web App/img/swt/d5.png'; 41 | 42 | set(gcf,'Visible','off'); 43 | plot(d4); 44 | print -dpng '../../Web App/img/swt/d4.png'; 45 | 46 | set(gcf,'Visible','off'); 47 | plot(d3); 48 | print -dpng '../../Web App/img/swt/d3.png'; 49 | 50 | set(gcf,'Visible','off'); 51 | plot(d2); 52 | print -dpng '../../Web App/img/swt/d2.png'; 53 | end 54 | 55 | counter=2; 56 | 57 | data_feature = []; 58 | 59 | if ismember(1,fb) 60 | if ismember(1,features) 61 | data_feature = [data_feature,min(a5)]; 62 | end 63 | if ismember(2,features) 64 | data_feature = [data_feature,max(a5)]; 65 | end 66 | if ismember(3,features) 67 | data_feature = [data_feature,std(a5)]; 68 | end 69 | if ismember(4,features) 70 | data_feature = [data_feature,mean(a5)]; 71 | end 72 | if ismember(5,features) 73 | data_feature = [data_feature,mean(a5.^2)]; 74 | end 75 | if ismember(6,features) 76 | data_feature = [data_feature,sum(a5.^2)]; 77 | end 78 | end 79 | if ismember(2,fb) 80 | if ismember(1,features) 81 | data_feature = [data_feature,min(d5)]; 82 | end 83 | if ismember(2,features) 84 | data_feature = [data_feature,max(d5)]; 85 | end 86 | if ismember(3,features) 87 | data_feature = [data_feature,std(d5)]; 88 | end 89 | if ismember(4,features) 90 | data_feature = [data_feature,mean(d5)]; 91 | end 92 | if ismember(5,features) 93 | data_feature = [data_feature,mean(d5.^2)]; 94 | end 95 | if ismember(6,features) 96 | data_feature = [data_feature,sum(d5.^2)]; 97 | end 98 | end 99 | if ismember(3,fb) 100 | if ismember(1,features) 101 | data_feature = [data_feature,min(d4)]; 102 | end 103 | if ismember(2,features) 104 | data_feature = [data_feature,max(d4)]; 105 | end 106 | if ismember(3,features) 107 | data_feature = [data_feature,std(d4)]; 108 | end 109 | if ismember(4,features) 110 | data_feature = [data_feature,mean(d4)]; 111 | end 112 | if ismember(5,features) 113 | data_feature = [data_feature,mean(d4.^2)]; 114 | end 115 | if ismember(6,features) 116 | data_feature = [data_feature,sum(d4.^2)]; 117 | end 118 | end 119 | if ismember(4,fb) 120 | if ismember(1,features) 121 | data_feature = [data_feature,min(d3)]; 122 | end 123 | if ismember(2,features) 124 | data_feature = [data_feature,max(d3)]; 125 | end 126 | if ismember(3,features) 127 | data_feature = [data_feature,std(d3)]; 128 | end 129 | if ismember(4,features) 130 | data_feature = [data_feature,mean(d3)]; 131 | end 132 | if ismember(5,features) 133 | data_feature = [data_feature,mean(d3.^2)]; 134 | end 135 | if ismember(6,features) 136 | data_feature = [data_feature,sum(d3.^2)]; 137 | end 138 | end 139 | if ismember(5,fb) 140 | if ismember(1,features) 141 | data_feature = [data_feature,min(d2)]; 142 | end 143 | if ismember(2,features) 144 | data_feature = [data_feature,max(d2)]; 145 | end 146 | if ismember(3,features) 147 | data_feature = [data_feature,std(d2)]; 148 | end 149 | if ismember(4,features) 150 | data_feature = [data_feature,mean(d2)]; 151 | end 152 | if ismember(5,features) 153 | data_feature = [data_feature,mean(d2.^2)]; 154 | end 155 | if ismember(6,features) 156 | data_feature = [data_feature,sum(d2.^2)]; 157 | end 158 | end 159 | data = horzcat(data,data_feature); 160 | end 161 | end -------------------------------------------------------------------------------- /Data Processing/Preprocessing/computeFFTPredict.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | %Author : Muhammad Nadzeri Munawar 3 | % 4 | % 5 | %This code is to create absolute_power variable of subject no. 20 such as : 6 | %delta, theta, alpha, beta, gamma with shape 32x5x40. 32 mean total of 7 | %channel, 5 mean total absolute power, 40 mean 40 trial 8 | % 9 | % project_path -> 'D:\TUGAS AKHIR\Progress\24. (08-12-2015)' 10 | % method -> fft;ica_fft 11 | % subject -> [2,4,6,7,8,9,10,13,15,16,21,25,26,28,29,30]; 12 | % channel -> [2,3,4,5,6,7,8,14]; 13 | % fb -> 1.Delta;2.Theta;3.Alpha;4.Beta;5.Gamma 14 | % features -> 1. Min;2.Max;3.Std;4.Avg;5.Pow;6.Energy 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | 17 | function data = computeFFTPredict(raw_data,preprocessing_method,channel,fb,features) 18 | %define variable 19 | if strcmp(preprocessing_method,'ica_fft') 20 | raw_data = computeICAPredict(raw_data); 21 | end 22 | samplingFrequency=128; 23 | 24 | data = []; 25 | counter=1; 26 | for j = channel 27 | X = raw_data(j,:); 28 | 29 | Fs = samplingFrequency; % Sampling frequency 30 | L = length(X); % Length of signal 31 | 32 | %compute fft from channel 33 | Y = fft(X); 34 | 35 | %Divide fft to get frequency 36 | P2 = abs(Y/L); 37 | P1 = P2(1:L/2+1); 38 | P1(2:end-1) = 2*P1(2:end-1); 39 | 40 | %divide froquency to get delta, theta, alpha, beta, gamma 41 | %And average all of each range (delta, theta, alpha, beta, gamma) 42 | delta = P1(L*1/Fs:L*4/Fs); 43 | theta = P1(L*4/Fs:L*8/Fs); 44 | alpha = P1(L*8/Fs:L*13/Fs); 45 | beta = P1(L*13/Fs:L*30/Fs); 46 | gamma = P1(L*30/Fs:L*50/Fs); 47 | 48 | if counter==1 49 | set(gcf,'Visible','off'); 50 | plot(delta); 51 | print -dpng '../../Web App/img/fft/delta.png'; 52 | 53 | set(gcf,'Visible','off'); 54 | plot(theta); 55 | print -dpng '../../Web App/img/fft/theta.png'; 56 | 57 | set(gcf,'Visible','off'); 58 | plot(alpha); 59 | print -dpng '../../Web App/img/fft/alpha.png'; 60 | 61 | set(gcf,'Visible','off'); 62 | plot(beta); 63 | print -dpng '../../Web App/img/fft/beta.png'; 64 | 65 | set(gcf,'Visible','off'); 66 | plot(gamma); 67 | print -dpng '../../Web App/img/fft/gamma.png'; 68 | end 69 | 70 | counter = 2; 71 | data_feature = []; 72 | if ismember(1,fb) 73 | if ismember(1,features) 74 | data_feature = [data_feature,min(delta)]; 75 | end 76 | if ismember(2,features) 77 | data_feature = [data_feature,max(delta)]; 78 | end 79 | if ismember(3,features) 80 | data_feature = [data_feature,std(delta)]; 81 | end 82 | if ismember(4,features) 83 | data_feature = [data_feature,mean(delta)]; 84 | end 85 | if ismember(5,features) 86 | data_feature = [data_feature,mean(delta.^2)]; 87 | end 88 | if ismember(6,features) 89 | data_feature = [data_feature,sum(delta.^2)]; 90 | end 91 | end 92 | if ismember(2,fb) 93 | if ismember(1,features) 94 | data_feature = [data_feature,min(theta)]; 95 | end 96 | if ismember(2,features) 97 | data_feature = [data_feature,max(theta)]; 98 | end 99 | if ismember(3,features) 100 | data_feature = [data_feature,std(theta)]; 101 | end 102 | if ismember(4,features) 103 | data_feature = [data_feature,mean(theta)]; 104 | end 105 | if ismember(5,features) 106 | data_feature = [data_feature,mean(theta.^2)]; 107 | end 108 | if ismember(6,features) 109 | data_feature = [data_feature,sum(theta.^2)]; 110 | end 111 | end 112 | if ismember(3,fb) 113 | if ismember(1,features) 114 | data_feature = [data_feature,min(alpha)]; 115 | end 116 | if ismember(2,features) 117 | data_feature = [data_feature,max(alpha)]; 118 | end 119 | if ismember(3,features) 120 | data_feature = [data_feature,std(alpha)]; 121 | end 122 | if ismember(4,features) 123 | data_feature = [data_feature,mean(alpha)]; 124 | end 125 | if ismember(5,features) 126 | data_feature = [data_feature,mean(alpha.^2)]; 127 | end 128 | if ismember(6,features) 129 | data_feature = [data_feature,sum(alpha.^2)]; 130 | end 131 | end 132 | if ismember(4,fb) 133 | if ismember(1,features) 134 | data_feature = [data_feature,min(beta)]; 135 | end 136 | if ismember(2,features) 137 | data_feature = [data_feature,max(beta)]; 138 | end 139 | if ismember(3,features) 140 | data_feature = [data_feature,std(beta)]; 141 | end 142 | if ismember(4,features) 143 | data_feature = [data_feature,mean(beta)]; 144 | end 145 | if ismember(5,features) 146 | data_feature = [data_feature,mean(beta.^2)]; 147 | end 148 | if ismember(6,features) 149 | data_feature = [data_feature,sum(beta.^2)]; 150 | end 151 | end 152 | if ismember(5,fb) 153 | if ismember(1,features) 154 | data_feature = [data_feature,min(gamma)]; 155 | end 156 | if ismember(2,features) 157 | data_feature = [data_feature,max(gamma)]; 158 | end 159 | if ismember(3,features) 160 | data_feature = [data_feature,std(gamma)]; 161 | end 162 | if ismember(4,features) 163 | data_feature = [data_feature,mean(gamma)]; 164 | end 165 | if ismember(5,features) 166 | data_feature = [data_feature,mean(gamma.^2)]; 167 | end 168 | if ismember(6,features) 169 | data_feature = [data_feature,sum(gamma.^2)]; 170 | end 171 | end 172 | data = horzcat(data,data_feature); 173 | end 174 | end -------------------------------------------------------------------------------- /Web App/css/accuracy.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Start Bootstrap - SB Admin 2 Bootstrap Admin Theme (http://startbootstrap.com) 3 | * Code licensed under the Apache License v2.0. 4 | * For details, see http://www.apache.org/licenses/LICENSE-2.0. 5 | */ 6 | 7 | body { 8 | background-color: #f8f8f8; 9 | } 10 | 11 | #wrapper { 12 | width: 100%; 13 | } 14 | 15 | #page-wrapper { 16 | padding: 0 15px; 17 | min-height: 568px; 18 | background-color: #fff; 19 | } 20 | 21 | .text-center { 22 | text-align: center; 23 | } 24 | 25 | @media(min-width:768px) { 26 | #page-wrapper { 27 | position: inherit; 28 | margin: 0 00px; 29 | padding: 0 30px; 30 | border-left: 1px solid #e7e7e7; 31 | border-right: 1px solid #e7e7e7; 32 | } 33 | } 34 | 35 | .navbar-top-links { 36 | margin-right: 0; 37 | } 38 | 39 | .navbar-top-links li { 40 | display: inline-block; 41 | } 42 | 43 | .navbar-top-links li:last-child { 44 | margin-right: 15px; 45 | } 46 | 47 | .navbar-top-links li a { 48 | padding: 15px; 49 | min-height: 50px; 50 | } 51 | 52 | .navbar-top-links .dropdown-menu li { 53 | display: block; 54 | } 55 | 56 | .navbar-top-links .dropdown-menu li:last-child { 57 | margin-right: 0; 58 | } 59 | 60 | .navbar-top-links .dropdown-menu li a { 61 | padding: 3px 20px; 62 | min-height: 0; 63 | } 64 | 65 | .navbar-top-links .dropdown-menu li a div { 66 | white-space: normal; 67 | } 68 | 69 | .navbar-top-links .dropdown-messages, 70 | .navbar-top-links .dropdown-tasks, 71 | .navbar-top-links .dropdown-alerts { 72 | width: 310px; 73 | min-width: 0; 74 | } 75 | 76 | .navbar-top-links .dropdown-messages { 77 | margin-left: 5px; 78 | } 79 | 80 | .navbar-top-links .dropdown-tasks { 81 | margin-left: -59px; 82 | } 83 | 84 | .navbar-top-links .dropdown-alerts { 85 | margin-left: -123px; 86 | } 87 | 88 | .navbar-top-links .dropdown-user { 89 | right: 0; 90 | left: auto; 91 | } 92 | 93 | .sidebar .sidebar-nav.navbar-collapse { 94 | padding-right: 0; 95 | padding-left: 0; 96 | } 97 | 98 | .sidebar .sidebar-search { 99 | padding: 15px; 100 | } 101 | 102 | .sidebar ul li { 103 | border-bottom: 1px solid #e7e7e7; 104 | } 105 | 106 | .sidebar ul li a.active { 107 | background-color: #eee; 108 | } 109 | 110 | .sidebar .arrow { 111 | float: right; 112 | } 113 | 114 | .sidebar .fa.arrow:before { 115 | content: "\f104"; 116 | } 117 | 118 | .sidebar .active>a>.fa.arrow:before { 119 | content: "\f107"; 120 | } 121 | 122 | .sidebar .nav-second-level li, 123 | .sidebar .nav-third-level li { 124 | border-bottom: 0!important; 125 | } 126 | 127 | .sidebar .nav-second-level li a { 128 | padding-left: 37px; 129 | } 130 | 131 | .sidebar .nav-third-level li a { 132 | padding-left: 52px; 133 | } 134 | 135 | @media(min-width:768px) { 136 | .sidebar { 137 | z-index: 1; 138 | position: absolute; 139 | width: 250px; 140 | margin-top: 51px; 141 | } 142 | 143 | .navbar-top-links .dropdown-messages, 144 | .navbar-top-links .dropdown-tasks, 145 | .navbar-top-links .dropdown-alerts { 146 | margin-left: auto; 147 | } 148 | } 149 | 150 | .btn-outline { 151 | color: inherit; 152 | background-color: transparent; 153 | transition: all .5s; 154 | } 155 | 156 | .btn-primary.btn-outline { 157 | color: #428bca; 158 | } 159 | 160 | .btn-success.btn-outline { 161 | color: #5cb85c; 162 | } 163 | 164 | .btn-info.btn-outline { 165 | color: #5bc0de; 166 | } 167 | 168 | .btn-warning.btn-outline { 169 | color: #f0ad4e; 170 | } 171 | 172 | .btn-danger.btn-outline { 173 | color: #d9534f; 174 | } 175 | 176 | .btn-primary.btn-outline:hover, 177 | .btn-success.btn-outline:hover, 178 | .btn-info.btn-outline:hover, 179 | .btn-warning.btn-outline:hover, 180 | .btn-danger.btn-outline:hover { 181 | color: #fff; 182 | } 183 | 184 | .chat { 185 | margin: 0; 186 | padding: 0; 187 | list-style: none; 188 | } 189 | 190 | .chat li { 191 | margin-bottom: 10px; 192 | padding-bottom: 5px; 193 | border-bottom: 1px dotted #999; 194 | } 195 | 196 | .chat li.left .chat-body { 197 | margin-left: 60px; 198 | } 199 | 200 | .chat li.right .chat-body { 201 | margin-right: 60px; 202 | } 203 | 204 | .chat li .chat-body p { 205 | margin: 0; 206 | } 207 | 208 | .panel .slidedown .glyphicon, 209 | .chat .glyphicon { 210 | margin-right: 5px; 211 | } 212 | 213 | .chat-panel .panel-body { 214 | height: 350px; 215 | overflow-y: scroll; 216 | } 217 | 218 | .login-panel { 219 | margin-top: 25%; 220 | } 221 | 222 | .flot-chart { 223 | display: block; 224 | height: 400px; 225 | } 226 | 227 | .flot-chart-content { 228 | width: 100%; 229 | height: 100%; 230 | } 231 | 232 | .dataTables_wrapper { 233 | position: relative; 234 | clear: both; 235 | } 236 | 237 | table.dataTable thead .sorting, 238 | table.dataTable thead .sorting_asc, 239 | table.dataTable thead .sorting_desc, 240 | table.dataTable thead .sorting_asc_disabled, 241 | table.dataTable thead .sorting_desc_disabled { 242 | background: 0 0; 243 | } 244 | 245 | table.dataTable thead .sorting_asc:after { 246 | content: "\f0de"; 247 | float: right; 248 | font-family: fontawesome; 249 | } 250 | 251 | table.dataTable thead .sorting_desc:after { 252 | content: "\f0dd"; 253 | float: right; 254 | font-family: fontawesome; 255 | } 256 | 257 | table.dataTable thead .sorting:after { 258 | content: "\f0dc"; 259 | float: right; 260 | font-family: fontawesome; 261 | color: rgba(50,50,50,.5); 262 | } 263 | 264 | .btn-circle { 265 | width: 30px; 266 | height: 30px; 267 | padding: 6px 0; 268 | border-radius: 15px; 269 | text-align: center; 270 | font-size: 12px; 271 | line-height: 1.428571429; 272 | } 273 | 274 | .btn-circle.btn-lg { 275 | width: 50px; 276 | height: 50px; 277 | padding: 10px 16px; 278 | border-radius: 25px; 279 | font-size: 18px; 280 | line-height: 1.33; 281 | } 282 | 283 | .btn-circle.btn-xl { 284 | width: 70px; 285 | height: 70px; 286 | padding: 10px 16px; 287 | border-radius: 35px; 288 | font-size: 24px; 289 | line-height: 1.33; 290 | } 291 | 292 | .show-grid [class^=col-] { 293 | padding-top: 10px; 294 | padding-bottom: 10px; 295 | border: 1px solid #ddd; 296 | background-color: #eee!important; 297 | } 298 | 299 | .show-grid { 300 | margin: 15px 0; 301 | } 302 | 303 | .huge { 304 | font-size: 40px; 305 | } 306 | 307 | .panel-green { 308 | border-color: #5cb85c; 309 | } 310 | 311 | .panel-green .panel-heading { 312 | border-color: #5cb85c; 313 | color: #fff; 314 | background-color: #5cb85c; 315 | } 316 | 317 | .panel-green a { 318 | color: #5cb85c; 319 | } 320 | 321 | .panel-green a:hover { 322 | color: #3d8b3d; 323 | } 324 | 325 | .panel-red { 326 | border-color: #d9534f; 327 | } 328 | 329 | .panel-red .panel-heading { 330 | border-color: #d9534f; 331 | color: #fff; 332 | background-color: #d9534f; 333 | } 334 | 335 | .panel-red a { 336 | color: #d9534f; 337 | } 338 | 339 | .panel-red a:hover { 340 | color: #b52b27; 341 | } 342 | 343 | .panel-yellow { 344 | border-color: #f0ad4e; 345 | } 346 | 347 | .panel-yellow .panel-heading { 348 | border-color: #f0ad4e; 349 | color: #fff; 350 | background-color: #f0ad4e; 351 | } 352 | 353 | .panel-yellow a { 354 | color: #f0ad4e; 355 | } 356 | 357 | .panel-yellow a:hover { 358 | color: #df8a13; 359 | } -------------------------------------------------------------------------------- /Web App/css/dashboard.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Start Bootstrap - SB Admin 2 Bootstrap Admin Theme (http://startbootstrap.com) 3 | * Code licensed under the Apache License v2.0. 4 | * For details, see http://www.apache.org/licenses/LICENSE-2.0. 5 | */ 6 | 7 | body { 8 | background-color: #f8f8f8; 9 | } 10 | 11 | #wrapper { 12 | width: 100%; 13 | } 14 | 15 | #page-wrapper { 16 | padding: 0 15px; 17 | min-height: 568px; 18 | background-color: #fff; 19 | } 20 | 21 | .text-center { 22 | text-align: center; 23 | } 24 | 25 | @media(min-width:768px) { 26 | #page-wrapper { 27 | position: inherit; 28 | margin: 0 200px; 29 | padding: 0 30px; 30 | border-left: 1px solid #e7e7e7; 31 | border-right: 1px solid #e7e7e7; 32 | } 33 | } 34 | 35 | .navbar-top-links { 36 | margin-right: 0; 37 | } 38 | 39 | .navbar-top-links li { 40 | display: inline-block; 41 | } 42 | 43 | .navbar-top-links li:last-child { 44 | margin-right: 15px; 45 | } 46 | 47 | .navbar-top-links li a { 48 | padding: 15px; 49 | min-height: 50px; 50 | } 51 | 52 | .navbar-top-links .dropdown-menu li { 53 | display: block; 54 | } 55 | 56 | .navbar-top-links .dropdown-menu li:last-child { 57 | margin-right: 0; 58 | } 59 | 60 | .navbar-top-links .dropdown-menu li a { 61 | padding: 3px 20px; 62 | min-height: 0; 63 | } 64 | 65 | .navbar-top-links .dropdown-menu li a div { 66 | white-space: normal; 67 | } 68 | 69 | .navbar-top-links .dropdown-messages, 70 | .navbar-top-links .dropdown-tasks, 71 | .navbar-top-links .dropdown-alerts { 72 | width: 310px; 73 | min-width: 0; 74 | } 75 | 76 | .navbar-top-links .dropdown-messages { 77 | margin-left: 5px; 78 | } 79 | 80 | .navbar-top-links .dropdown-tasks { 81 | margin-left: -59px; 82 | } 83 | 84 | .navbar-top-links .dropdown-alerts { 85 | margin-left: -123px; 86 | } 87 | 88 | .navbar-top-links .dropdown-user { 89 | right: 0; 90 | left: auto; 91 | } 92 | 93 | .sidebar .sidebar-nav.navbar-collapse { 94 | padding-right: 0; 95 | padding-left: 0; 96 | } 97 | 98 | .sidebar .sidebar-search { 99 | padding: 15px; 100 | } 101 | 102 | .sidebar ul li { 103 | border-bottom: 1px solid #e7e7e7; 104 | } 105 | 106 | .sidebar ul li a.active { 107 | background-color: #eee; 108 | } 109 | 110 | .sidebar .arrow { 111 | float: right; 112 | } 113 | 114 | .sidebar .fa.arrow:before { 115 | content: "\f104"; 116 | } 117 | 118 | .sidebar .active>a>.fa.arrow:before { 119 | content: "\f107"; 120 | } 121 | 122 | .sidebar .nav-second-level li, 123 | .sidebar .nav-third-level li { 124 | border-bottom: 0!important; 125 | } 126 | 127 | .sidebar .nav-second-level li a { 128 | padding-left: 37px; 129 | } 130 | 131 | .sidebar .nav-third-level li a { 132 | padding-left: 52px; 133 | } 134 | 135 | @media(min-width:768px) { 136 | .sidebar { 137 | z-index: 1; 138 | position: absolute; 139 | width: 250px; 140 | margin-top: 51px; 141 | } 142 | 143 | .navbar-top-links .dropdown-messages, 144 | .navbar-top-links .dropdown-tasks, 145 | .navbar-top-links .dropdown-alerts { 146 | margin-left: auto; 147 | } 148 | } 149 | 150 | .btn-outline { 151 | color: inherit; 152 | background-color: transparent; 153 | transition: all .5s; 154 | } 155 | 156 | .btn-primary.btn-outline { 157 | color: #428bca; 158 | } 159 | 160 | .btn-success.btn-outline { 161 | color: #5cb85c; 162 | } 163 | 164 | .btn-info.btn-outline { 165 | color: #5bc0de; 166 | } 167 | 168 | .btn-warning.btn-outline { 169 | color: #f0ad4e; 170 | } 171 | 172 | .btn-danger.btn-outline { 173 | color: #d9534f; 174 | } 175 | 176 | .btn-primary.btn-outline:hover, 177 | .btn-success.btn-outline:hover, 178 | .btn-info.btn-outline:hover, 179 | .btn-warning.btn-outline:hover, 180 | .btn-danger.btn-outline:hover { 181 | color: #fff; 182 | } 183 | 184 | .chat { 185 | margin: 0; 186 | padding: 0; 187 | list-style: none; 188 | } 189 | 190 | .chat li { 191 | margin-bottom: 10px; 192 | padding-bottom: 5px; 193 | border-bottom: 1px dotted #999; 194 | } 195 | 196 | .chat li.left .chat-body { 197 | margin-left: 60px; 198 | } 199 | 200 | .chat li.right .chat-body { 201 | margin-right: 60px; 202 | } 203 | 204 | .chat li .chat-body p { 205 | margin: 0; 206 | } 207 | 208 | .panel .slidedown .glyphicon, 209 | .chat .glyphicon { 210 | margin-right: 5px; 211 | } 212 | 213 | .chat-panel .panel-body { 214 | height: 350px; 215 | overflow-y: scroll; 216 | } 217 | 218 | .login-panel { 219 | margin-top: 25%; 220 | } 221 | 222 | .flot-chart { 223 | display: block; 224 | height: 400px; 225 | } 226 | 227 | .flot-chart-content { 228 | width: 100%; 229 | height: 100%; 230 | } 231 | 232 | .dataTables_wrapper { 233 | position: relative; 234 | clear: both; 235 | } 236 | 237 | table.dataTable thead .sorting, 238 | table.dataTable thead .sorting_asc, 239 | table.dataTable thead .sorting_desc, 240 | table.dataTable thead .sorting_asc_disabled, 241 | table.dataTable thead .sorting_desc_disabled { 242 | background: 0 0; 243 | } 244 | 245 | table.dataTable thead .sorting_asc:after { 246 | content: "\f0de"; 247 | float: right; 248 | font-family: fontawesome; 249 | } 250 | 251 | table.dataTable thead .sorting_desc:after { 252 | content: "\f0dd"; 253 | float: right; 254 | font-family: fontawesome; 255 | } 256 | 257 | table.dataTable thead .sorting:after { 258 | content: "\f0dc"; 259 | float: right; 260 | font-family: fontawesome; 261 | color: rgba(50,50,50,.5); 262 | } 263 | 264 | .btn-circle { 265 | width: 30px; 266 | height: 30px; 267 | padding: 6px 0; 268 | border-radius: 15px; 269 | text-align: center; 270 | font-size: 12px; 271 | line-height: 1.428571429; 272 | } 273 | 274 | .btn-circle.btn-lg { 275 | width: 50px; 276 | height: 50px; 277 | padding: 10px 16px; 278 | border-radius: 25px; 279 | font-size: 18px; 280 | line-height: 1.33; 281 | } 282 | 283 | .btn-circle.btn-xl { 284 | width: 70px; 285 | height: 70px; 286 | padding: 10px 16px; 287 | border-radius: 35px; 288 | font-size: 24px; 289 | line-height: 1.33; 290 | } 291 | 292 | .show-grid [class^=col-] { 293 | padding-top: 10px; 294 | padding-bottom: 10px; 295 | border: 1px solid #ddd; 296 | background-color: #eee!important; 297 | } 298 | 299 | .show-grid { 300 | margin: 15px 0; 301 | } 302 | 303 | .huge { 304 | font-size: 40px; 305 | } 306 | 307 | .panel-green { 308 | border-color: #5cb85c; 309 | } 310 | 311 | .panel-green .panel-heading { 312 | border-color: #5cb85c; 313 | color: #fff; 314 | background-color: #5cb85c; 315 | } 316 | 317 | .panel-green a { 318 | color: #5cb85c; 319 | } 320 | 321 | .panel-green a:hover { 322 | color: #3d8b3d; 323 | } 324 | 325 | .panel-red { 326 | border-color: #d9534f; 327 | } 328 | 329 | .panel-red .panel-heading { 330 | border-color: #d9534f; 331 | color: #fff; 332 | background-color: #d9534f; 333 | } 334 | 335 | .panel-red a { 336 | color: #d9534f; 337 | } 338 | 339 | .panel-red a:hover { 340 | color: #b52b27; 341 | } 342 | 343 | .panel-yellow { 344 | border-color: #f0ad4e; 345 | } 346 | 347 | .panel-yellow .panel-heading { 348 | border-color: #f0ad4e; 349 | color: #fff; 350 | background-color: #f0ad4e; 351 | } 352 | 353 | .panel-yellow a { 354 | color: #f0ad4e; 355 | } 356 | 357 | .panel-yellow a:hover { 358 | color: #df8a13; 359 | } -------------------------------------------------------------------------------- /Web App/cgi-bin/index.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Import modules for CGI handling 4 | import cgi, cgitb 5 | 6 | 7 | print "Content-type: text/html\n" 8 | 9 | print ''' 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | EEG Emotion Recognition 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 46 | 47 | 48 | 49 | 50 | 51 |
52 |
53 |
54 | 57 | 58 |
59 | 60 |
61 |
62 |
63 | 64 |
65 |
66 |
67 | 68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 | 76 |
77 |
78 |
......
79 |
Accuracy !
80 |
81 |
82 |
83 | 84 | 89 | 90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 | 98 |
99 |
100 |
......
101 |
Prediction !
102 |
103 |
104 |
105 | 106 | 111 | 112 |
113 |
114 |
115 |
116 | 117 |
118 | 119 | 120 |
121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | ''' 143 | -------------------------------------------------------------------------------- /Data Processing/Preprocessing/computeSWT.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | %Author : Muhammad Nadzeri Munawar 3 | % 4 | % 5 | %This code is to create absolute_power variable of subject no. 20 such as : 6 | %delta, theta, alpha, beta, gamma with shape 32x5x40. 32 mean total of 7 | %channel, 5 mean total absolute power, 40 mean 40 trial 8 | % 9 | % project_path -> 'D:\TUGAS AKHIR\Progress\24. (08-12-2015)' 10 | % method -> swt;ica_swt 11 | % subject -> [2,4,6,7,8,9,10,13,15,16,21,25,26,28,29,30]; 12 | % channel -> [2,3,4,5,6,7,8,14]; 13 | % fb -> 1.A5;2.D5;3.D4;4.D3;5.D2 14 | % features -> 1. Min;2.Max;3.Std;4.Avg;5.Pow;6.Energy 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | 17 | function computeSWT(project_path,method,class,subject,channel,fb,features) 18 | addpath(genpath('..\Global Code')); 19 | 20 | %define variable 21 | if strcmp(method,'swt') 22 | basePath = strcat(project_path,'\USED_EEG\'); 23 | destination = strcat(project_path,'\SWT_EEG_',upper(class)); 24 | elseif strcmp(method,'ica_swt') 25 | basePath = strcat(project_path,'\ICA_EEG\'); 26 | destination = strcat(project_path,'\ICA_SWT_EEG_',upper(class)); 27 | end 28 | kuesioner = csvread(strcat(project_path,'\Metadata\newDataKuesioner.csv')); 29 | kuesioner = transpose(kuesioner); 30 | samplingFrequency=128; 31 | counter =1; 32 | start = 1; 33 | stop = 0; 34 | kelas = []; 35 | 36 | if strcmp(class,'valence') 37 | kuesioner = kuesioner(1,:); 38 | elseif strcmp(class,'arousal') 39 | kuesioner = kuesioner(2,:); 40 | end 41 | 42 | if exist(destination, 'dir') 43 | system(strcat('rmdir /S /Q "',destination,'"')); 44 | end 45 | 46 | createFolder(length(subject),destination); 47 | 48 | all_files = dir(basePath); 49 | all_files = all_files(3:end); 50 | all_dir = all_files([all_files(:).isdir]); 51 | totalSubject = numel(all_dir); 52 | 53 | for h=1:totalSubject 54 | directory = sprintf('S%02d',h); 55 | direc = sprintf('S%02d',counter); 56 | allList = dir( strcat(basePath,directory )); 57 | allFiles = { allList(3:end).name }; 58 | trial = length(allFiles); 59 | 60 | if h>1 61 | start = stop + 1; 62 | end 63 | stop = start + trial - 1; 64 | 65 | if ismember(h,subject)==0 66 | continue; 67 | end 68 | 69 | kelas = horzcat(kelas,kuesioner(start:stop)); 70 | 71 | for i = 1:trial 72 | rawData = csvread(strcat(basePath,directory,'\T',num2str(i),'.csv')); 73 | data = []; 74 | for j = channel 75 | [swa,swd] = swt(rawData(j,:),5,'db4'); 76 | d2=swd(2,:); 77 | d3=swd(3,:); 78 | d4=swd(4,:); 79 | d5=swd(5,:); 80 | a5=swa(5,:); 81 | 82 | data_feature = []; 83 | 84 | if ismember(1,fb) 85 | if ismember(1,features) 86 | data_feature = [data_feature,min(a5)]; 87 | end 88 | if ismember(2,features) 89 | data_feature = [data_feature,max(a5)]; 90 | end 91 | if ismember(3,features) 92 | data_feature = [data_feature,std(a5)]; 93 | end 94 | if ismember(4,features) 95 | data_feature = [data_feature,mean(a5)]; 96 | end 97 | if ismember(5,features) 98 | data_feature = [data_feature,mean(a5.^2)]; 99 | end 100 | if ismember(6,features) 101 | data_feature = [data_feature,sum(a5.^2)]; 102 | end 103 | end 104 | if ismember(2,fb) 105 | if ismember(1,features) 106 | data_feature = [data_feature,min(d5)]; 107 | end 108 | if ismember(2,features) 109 | data_feature = [data_feature,max(d5)]; 110 | end 111 | if ismember(3,features) 112 | data_feature = [data_feature,std(d5)]; 113 | end 114 | if ismember(4,features) 115 | data_feature = [data_feature,mean(d5)]; 116 | end 117 | if ismember(5,features) 118 | data_feature = [data_feature,mean(d5.^2)]; 119 | end 120 | if ismember(6,features) 121 | data_feature = [data_feature,sum(d5.^2)]; 122 | end 123 | end 124 | if ismember(3,fb) 125 | if ismember(1,features) 126 | data_feature = [data_feature,min(d4)]; 127 | end 128 | if ismember(2,features) 129 | data_feature = [data_feature,max(d4)]; 130 | end 131 | if ismember(3,features) 132 | data_feature = [data_feature,std(d4)]; 133 | end 134 | if ismember(4,features) 135 | data_feature = [data_feature,mean(d4)]; 136 | end 137 | if ismember(5,features) 138 | data_feature = [data_feature,mean(d4.^2)]; 139 | end 140 | if ismember(6,features) 141 | data_feature = [data_feature,sum(d4.^2)]; 142 | end 143 | end 144 | if ismember(4,fb) 145 | if ismember(1,features) 146 | data_feature = [data_feature,min(d3)]; 147 | end 148 | if ismember(2,features) 149 | data_feature = [data_feature,max(d3)]; 150 | end 151 | if ismember(3,features) 152 | data_feature = [data_feature,std(d3)]; 153 | end 154 | if ismember(4,features) 155 | data_feature = [data_feature,mean(d3)]; 156 | end 157 | if ismember(5,features) 158 | data_feature = [data_feature,mean(d3.^2)]; 159 | end 160 | if ismember(6,features) 161 | data_feature = [data_feature,sum(d3.^2)]; 162 | end 163 | end 164 | if ismember(5,fb) 165 | if ismember(1,features) 166 | data_feature = [data_feature,min(d2)]; 167 | end 168 | if ismember(2,features) 169 | data_feature = [data_feature,max(d2)]; 170 | end 171 | if ismember(3,features) 172 | data_feature = [data_feature,std(d2)]; 173 | end 174 | if ismember(4,features) 175 | data_feature = [data_feature,mean(d2)]; 176 | end 177 | if ismember(5,features) 178 | data_feature = [data_feature,mean(d2.^2)]; 179 | end 180 | if ismember(6,features) 181 | data_feature = [data_feature,sum(d2.^2)]; 182 | end 183 | end 184 | data = horzcat(data,data_feature); 185 | end 186 | csvwrite(strcat(destination,'\',direc,'\T',num2str(i),'.csv'),data); 187 | end 188 | counter=counter+1; 189 | end 190 | if strcmp(method,'swt') 191 | csvwrite(strcat(project_path,'\Metadata\kelas_swt_',class,'.csv'),kelas); 192 | elseif strcmp(method,'ica_swt') 193 | csvwrite(strcat(project_path,'\Metadata\kelas_ica_swt_',class,'.csv'),kelas); 194 | end 195 | end -------------------------------------------------------------------------------- /Web App/cgi-bin/input_predict.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Import modules for CGI handling 4 | import cgi, cgitb 5 | 6 | 7 | print "Content-type: text/html\n" 8 | 9 | print ''' 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | EEG Emotion Recognition 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 46 | 47 | 48 | 49 | 50 | 51 |
52 | 53 | 54 | 55 |
56 |
57 | 60 | 61 |
62 | 63 |
64 |
65 |
66 |
67 |
68 | Input File 69 |
70 |
71 |
72 |
73 | 74 | 75 |
76 |
77 | 78 |
79 | 82 |
83 |
84 | 87 |
88 |
89 | 92 |
93 |
94 | 97 |
98 |
99 |
100 | 101 |
102 | 105 |
106 |
107 | 110 |
111 |
112 | 113 |
114 |
115 |
116 |
117 | 118 |
119 |
120 | 121 | 122 | 123 |
124 | 125 | 126 |
127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | ''' 149 | -------------------------------------------------------------------------------- /Data Processing/Preprocessing/computeFFT.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | %Author : Muhammad Nadzeri Munawar 3 | % 4 | % 5 | %This code is to create absolute_power variable of subject no. 20 such as : 6 | %delta, theta, alpha, beta, gamma with shape 32x5x40. 32 mean total of 7 | %channel, 5 mean total absolute power, 40 mean 40 trial 8 | % 9 | % project_path -> 'D:\TUGAS AKHIR\Progress\24. (08-12-2015)' 10 | % method -> fft;ica_fft 11 | % subject -> [2,4,6,7,8,9,10,13,15,16,21,25,26,28,29,30]; 12 | % channel -> [2,3,4,5,6,7,8,14]; 13 | % fb -> 1.Delta;2.Theta;3.Alpha;4.Beta;5.Gamma 14 | % features -> 1. Min;2.Max;3.Std;4.Avg;5.Pow;6.Energy 15 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 | 17 | function computeFFT(project_path,method,class,subject,channel,fb,features) 18 | addpath(genpath('..\Global Code')); 19 | 20 | %define variable 21 | if strcmp(method,'fft') 22 | basePath = strcat(project_path,'\USED_EEG\'); 23 | destination = strcat(project_path,'\FFT_EEG_',upper(class)); 24 | elseif strcmp(method,'ica_fft') 25 | basePath = strcat(project_path,'\ICA_EEG\'); 26 | destination = strcat(project_path,'\ICA_FFT_EEG_',upper(class)); 27 | end 28 | kuesioner = csvread(strcat(project_path,'\Metadata\newDataKuesioner.csv')); 29 | kuesioner = transpose(kuesioner); 30 | samplingFrequency=128; 31 | counter =1; 32 | start = 1; 33 | stop = 0; 34 | kelas = []; 35 | 36 | if strcmp(class,'valence') 37 | kuesioner = kuesioner(1,:); 38 | elseif strcmp(class,'arousal') 39 | kuesioner = kuesioner(2,:); 40 | end 41 | 42 | if exist(destination, 'dir') 43 | system(strcat('rmdir /S /Q "',destination,'"')); 44 | end 45 | 46 | createFolder(length(subject),destination); 47 | 48 | all_files = dir(basePath); 49 | all_files = all_files(3:end); 50 | all_dir = all_files([all_files(:).isdir]); 51 | total_subject = numel(all_dir); 52 | 53 | for h=1:total_subject 54 | directory = sprintf('S%02d',h); 55 | direc = sprintf('S%02d',counter); 56 | allList = dir( strcat(basePath,directory )); 57 | allFiles = { allList(3:end).name }; 58 | trial = length(allFiles); 59 | 60 | if h>1 61 | start = stop + 1; 62 | end 63 | stop = start + trial - 1; 64 | 65 | if ismember(h,subject)==0 66 | continue; 67 | end 68 | 69 | kelas = horzcat(kelas,kuesioner(start:stop)); 70 | 71 | for i = 1:trial 72 | rawData = csvread(strcat(basePath,directory,'\T',num2str(i),'.csv')); 73 | data = []; 74 | for j = channel 75 | X = rawData(j,:); 76 | 77 | Fs = samplingFrequency; % Sampling frequency 78 | L = length(X); % Length of signal 79 | 80 | %compute fft from channel 81 | Y = fft(X); 82 | 83 | %Divide fft to get frequency 84 | P2 = abs(Y/L); 85 | P1 = P2(1:L/2+1); 86 | P1(2:end-1) = 2*P1(2:end-1); 87 | 88 | %divide froquency to get delta, theta, alpha, beta, gamma 89 | %And average all of each range (delta, theta, alpha, beta, gamma) 90 | delta = P1(L*1/Fs:L*4/Fs); 91 | theta = P1(L*4/Fs:L*8/Fs); 92 | alpha = P1(L*8/Fs:L*13/Fs); 93 | beta = P1(L*13/Fs:L*30/Fs); 94 | gamma = P1(L*30/Fs:L*50/Fs); 95 | 96 | data_feature = []; 97 | 98 | if ismember(1,fb) 99 | if ismember(1,features) 100 | data_feature = [data_feature,min(delta)]; 101 | end 102 | if ismember(2,features) 103 | data_feature = [data_feature,max(delta)]; 104 | end 105 | if ismember(3,features) 106 | data_feature = [data_feature,std(delta)]; 107 | end 108 | if ismember(4,features) 109 | data_feature = [data_feature,mean(delta)]; 110 | end 111 | if ismember(5,features) 112 | data_feature = [data_feature,mean(delta.^2)]; 113 | end 114 | if ismember(6,features) 115 | data_feature = [data_feature,sum(delta.^2)]; 116 | end 117 | end 118 | if ismember(2,fb) 119 | if ismember(1,features) 120 | data_feature = [data_feature,min(theta)]; 121 | end 122 | if ismember(2,features) 123 | data_feature = [data_feature,max(theta)]; 124 | end 125 | if ismember(3,features) 126 | data_feature = [data_feature,std(theta)]; 127 | end 128 | if ismember(4,features) 129 | data_feature = [data_feature,mean(theta)]; 130 | end 131 | if ismember(5,features) 132 | data_feature = [data_feature,mean(theta.^2)]; 133 | end 134 | if ismember(6,features) 135 | data_feature = [data_feature,sum(theta.^2)]; 136 | end 137 | end 138 | if ismember(3,fb) 139 | if ismember(1,features) 140 | data_feature = [data_feature,min(alpha)]; 141 | end 142 | if ismember(2,features) 143 | data_feature = [data_feature,max(alpha)]; 144 | end 145 | if ismember(3,features) 146 | data_feature = [data_feature,std(alpha)]; 147 | end 148 | if ismember(4,features) 149 | data_feature = [data_feature,mean(alpha)]; 150 | end 151 | if ismember(5,features) 152 | data_feature = [data_feature,mean(alpha.^2)]; 153 | end 154 | if ismember(6,features) 155 | data_feature = [data_feature,sum(alpha.^2)]; 156 | end 157 | end 158 | if ismember(4,fb) 159 | if ismember(1,features) 160 | data_feature = [data_feature,min(beta)]; 161 | end 162 | if ismember(2,features) 163 | data_feature = [data_feature,max(beta)]; 164 | end 165 | if ismember(3,features) 166 | data_feature = [data_feature,std(beta)]; 167 | end 168 | if ismember(4,features) 169 | data_feature = [data_feature,mean(beta)]; 170 | end 171 | if ismember(5,features) 172 | data_feature = [data_feature,mean(beta.^2)]; 173 | end 174 | if ismember(6,features) 175 | data_feature = [data_feature,sum(beta.^2)]; 176 | end 177 | end 178 | if ismember(5,fb) 179 | if ismember(1,features) 180 | data_feature = [data_feature,min(gamma)]; 181 | end 182 | if ismember(2,features) 183 | data_feature = [data_feature,max(gamma)]; 184 | end 185 | if ismember(3,features) 186 | data_feature = [data_feature,std(gamma)]; 187 | end 188 | if ismember(4,features) 189 | data_feature = [data_feature,mean(gamma)]; 190 | end 191 | if ismember(5,features) 192 | data_feature = [data_feature,mean(gamma.^2)]; 193 | end 194 | if ismember(6,features) 195 | data_feature = [data_feature,sum(gamma.^2)]; 196 | end 197 | end 198 | data = horzcat(data,data_feature); 199 | end 200 | csvwrite(strcat(destination,'\',direc,'\T',num2str(i),'.csv'),data); 201 | end 202 | counter=counter+1; 203 | end 204 | if strcmp(method,'fft') 205 | csvwrite(strcat(project_path,'\Metadata\kelas_fft_',class,'.csv'),kelas); 206 | elseif strcmp(method,'ica_fft') 207 | csvwrite(strcat(project_path,'\Metadata\kelas_ica_fft_',class,'.csv'),kelas); 208 | end 209 | 210 | end -------------------------------------------------------------------------------- /Web App/cgi-bin/find_accuracy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Import modules for CGI handling 4 | import cgi, cgitb 5 | import matlab.engine 6 | 7 | 8 | print "Content-type: text/html\n" 9 | 10 | # Create matlab file 11 | eng = matlab.engine.start_matlab() 12 | 13 | # Classification matlab path 14 | function_path = 'D:/TUGAS AKHIR/Progress/SIDANG/Source Code/Classification' 15 | 16 | # Call matlab function 17 | eng.eval("cd '"+function_path+"';",nargout=0) 18 | 19 | #Valence FFT 20 | (t,r,tp_valence_fft_knn,tn_valence_fft_knn,fp_valence_fft_knn,fn_valence_fft_knn) = eng.eval("doAccuracy('fft','valence','knn');",nargout=6); 21 | (t,r,tp_valence_fft_svm,tn_valence_fft_svm,fp_valence_fft_svm,fn_valence_fft_svm) = eng.eval("doAccuracy('fft','valence','svm');",nargout=6); 22 | 23 | #Valence ICA + FFT 24 | (t,r,tp_valence_ica_fft_knn,tn_valence_ica_fft_knn,fp_valence_ica_fft_knn,fn_valence_ica_fft_knn) = eng.eval("doAccuracy('ica_fft','valence','knn');",nargout=6); 25 | (t,r,tp_valence_ica_fft_svm,tn_valence_ica_fft_svm,fp_valence_ica_fft_svm,fn_valence_ica_fft_svm) = eng.eval("doAccuracy('ica_fft','valence','svm');",nargout=6); 26 | 27 | #Valence SWT 28 | (t,r,tp_valence_swt_knn,tn_valence_swt_knn,fp_valence_swt_knn,fn_valence_swt_knn) = eng.eval("doAccuracy('swt','valence','knn');",nargout=6); 29 | (t,r,tp_valence_swt_svm,tn_valence_swt_svm,fp_valence_swt_svm,fn_valence_swt_svm) = eng.eval("doAccuracy('swt','valence','svm');",nargout=6); 30 | 31 | #Valence ICA + SWT 32 | (t,r,tp_valence_ica_swt_knn,tn_valence_ica_swt_knn,fp_valence_ica_swt_knn,fn_valence_ica_swt_knn) = eng.eval("doAccuracy('ica_swt','valence','knn');",nargout=6); 33 | (t,r,tp_valence_ica_swt_svm,tn_valence_ica_swt_svm,fp_valence_ica_swt_svm,fn_valence_ica_swt_svm) = eng.eval("doAccuracy('ica_swt','valence','svm');",nargout=6); 34 | 35 | #Arousal FFT 36 | (t,r,tp_arousal_fft_knn,tn_arousal_fft_knn,fp_arousal_fft_knn,fn_arousal_fft_knn) = eng.eval("doAccuracy('fft','arousal','knn');",nargout=6); 37 | (t,r,tp_arousal_fft_svm,tn_arousal_fft_svm,fp_arousal_fft_svm,fn_arousal_fft_svm) = eng.eval("doAccuracy('fft','arousal','svm');",nargout=6); 38 | 39 | #Arousal ICA + FFT 40 | (t,r,tp_arousal_ica_fft_knn,tn_arousal_ica_fft_knn,fp_arousal_ica_fft_knn,fn_arousal_ica_fft_knn) = eng.eval("doAccuracy('ica_fft','arousal','knn');",nargout=6); 41 | (t,r,tp_arousal_ica_fft_svm,tn_arousal_ica_fft_svm,fp_arousal_ica_fft_svm,fn_arousal_ica_fft_svm) = eng.eval("doAccuracy('ica_fft','arousal','svm');",nargout=6); 42 | 43 | #Arousal SWT 44 | (t,r,tp_arousal_swt_knn,tn_arousal_swt_knn,fp_arousal_swt_knn,fn_arousal_swt_knn) = eng.eval("doAccuracy('swt','arousal','knn');",nargout=6); 45 | (t,r,tp_arousal_swt_svm,tn_arousal_swt_svm,fp_arousal_swt_svm,fn_arousal_swt_svm) = eng.eval("doAccuracy('swt','arousal','svm');",nargout=6); 46 | 47 | #Arousal ICA + SWT 48 | (t,r,tp_arousal_ica_swt_knn,tn_arousal_ica_swt_knn,fp_arousal_ica_swt_knn,fn_arousal_ica_swt_knn) = eng.eval("doAccuracy('ica_swt','arousal','knn');",nargout=6); 49 | (t,r,tp_arousal_ica_swt_svm,tn_arousal_ica_swt_svm,fp_arousal_ica_swt_svm,fn_arousal_ica_swt_svm) = eng.eval("doAccuracy('ica_swt','arousal','svm');",nargout=6); 50 | 51 | print ''' 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | EEG Emotion Recognition 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 88 | 89 | 90 | 91 | 92 | 93 |
94 |
95 |
96 | 99 | 100 |
101 | 102 |
103 |
104 |
105 |
106 | Fast Fourier Transformation 107 |
108 |
109 |
110 |
111 | K-Neirest Neighbord 112 |
113 | 114 |
115 |
116 |
117 | Valence 118 |
119 | 120 |
121 |
122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 |
#12
1TP : '''+str(tp_valence_fft_knn)+'''FP : '''+str(fp_valence_fft_knn)+'''
2TN : '''+str(tn_valence_fft_knn)+'''FN : '''+str(fn_valence_fft_knn)+'''
143 |
144 | 145 |

Accuracy :

146 |
147 |

Acc = (TP + TN) / Total Population

148 |

Acc = ('''+str(tp_valence_fft_knn)+''' + '''+str(tn_valence_fft_knn)+''') / '''+str(tp_valence_fft_knn+fp_valence_fft_knn+tn_valence_fft_knn+fn_valence_fft_knn)+'''

149 |

Acc = '''+str((tp_valence_fft_knn+tn_valence_fft_knn)/(tp_valence_fft_knn+tn_valence_fft_knn+fp_valence_fft_knn+fn_valence_fft_knn))+'''

150 |
151 |
152 | 153 |
154 | 155 | 156 |
157 |
158 | Arousal 159 |
160 | 161 |
162 |
163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 |
#12
1TP : '''+str(tp_arousal_fft_knn)+'''FP : '''+str(fp_arousal_fft_knn)+'''
2TN : '''+str(tn_arousal_fft_knn)+'''FN : '''+str(fn_arousal_fft_knn)+'''
184 |
185 | 186 |

Accuracy :

187 |
188 |

Acc = (TP + TN) / Total Population

189 |

Acc = ('''+str(tp_arousal_fft_knn)+''' + '''+str(tn_arousal_fft_knn)+''') / '''+str(tp_arousal_fft_knn+fp_arousal_fft_knn+tn_arousal_fft_knn+fn_arousal_fft_knn)+'''

190 |

Acc = '''+str((tp_arousal_fft_knn+tn_arousal_fft_knn)/(tp_arousal_fft_knn+tn_arousal_fft_knn+fp_arousal_fft_knn+fn_arousal_fft_knn))+'''

191 |
192 |
193 | 194 |
195 | 196 |
197 | 198 |
199 | 200 | 201 |
202 |
203 | Support Vector Machine 204 |
205 | 206 |
207 |
208 |
209 | Valence 210 |
211 | 212 |
213 |
214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 |
#12
1TP : '''+str(tp_valence_fft_svm)+'''FP : '''+str(fp_valence_fft_svm)+'''
2TN : '''+str(tn_valence_fft_svm)+'''FN : '''+str(fn_valence_fft_svm)+'''
235 |
236 | 237 |

Accuracy :

238 |
239 |

Acc = (TP + TN) / Total Population

240 |

Acc = ('''+str(tp_valence_fft_svm)+''' + '''+str(tn_valence_fft_svm)+''') / '''+str(tp_valence_fft_svm+fp_valence_fft_svm+tn_valence_fft_svm+fn_valence_fft_svm)+'''

241 |

Acc = '''+str((tp_valence_fft_svm+tn_valence_fft_svm)/(tp_valence_fft_svm+tn_valence_fft_svm+fp_valence_fft_svm+fn_valence_fft_svm))+'''

242 |
243 |
244 | 245 |
246 | 247 | 248 |
249 |
250 | Arousal 251 |
252 | 253 |
254 |
255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 |
#12
1TP : '''+str(tp_arousal_fft_svm)+'''FP : '''+str(fp_arousal_fft_svm)+'''
2TN : '''+str(tn_arousal_fft_svm)+'''FN : '''+str(fn_arousal_fft_svm)+'''
276 |
277 | 278 |

Accuracy :

279 |
280 |

Acc = (TP + TN) / Total Population

281 |

Acc = ('''+str(tp_arousal_fft_svm)+''' + '''+str(tn_arousal_fft_svm)+''') / '''+str(tp_arousal_fft_svm+fp_arousal_fft_svm+tn_arousal_fft_svm+fn_arousal_fft_svm)+'''

282 |

Acc = '''+str((tp_arousal_fft_svm+tn_arousal_fft_svm)/(tp_arousal_fft_svm+tn_arousal_fft_svm+fp_arousal_fft_svm+fn_arousal_fft_svm))+'''

283 |
284 |
285 | 286 |
287 | 288 |
289 | 290 |
291 | 292 |
293 |
294 |
295 | 296 |
297 |
298 |
299 | ICA + Fast Fourier Transformation 300 |
301 |
302 |
303 |
304 | K-Neirest Neighbord 305 |
306 | 307 |
308 |
309 |
310 | Valence 311 |
312 | 313 |
314 |
315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 |
#12
1TP : '''+str(tp_valence_ica_fft_knn)+'''FP : '''+str(fp_valence_ica_fft_knn)+'''
2TN : '''+str(tn_valence_ica_fft_knn)+'''FN : '''+str(fn_valence_ica_fft_knn)+'''
336 |
337 | 338 |

Accuracy :

339 |
340 |

Acc = (TP + TN) / Total Population

341 |

Acc = ('''+str(tp_valence_ica_fft_knn)+''' + '''+str(tn_valence_ica_fft_knn)+''') / '''+str(tp_valence_ica_fft_knn+fp_valence_ica_fft_knn+tn_valence_ica_fft_knn+fn_valence_ica_fft_knn)+'''

342 |

Acc = '''+str((tp_valence_ica_fft_knn+tn_valence_ica_fft_knn)/(tp_valence_ica_fft_knn+tn_valence_ica_fft_knn+fp_valence_ica_fft_knn+fn_valence_ica_fft_knn))+'''

343 |
344 |
345 | 346 |
347 | 348 | 349 |
350 |
351 | Arousal 352 |
353 | 354 |
355 |
356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 |
#12
1TP : '''+str(tp_arousal_ica_fft_knn)+'''FP : '''+str(fp_arousal_ica_fft_knn)+'''
2TN : '''+str(tn_arousal_ica_fft_knn)+'''FN : '''+str(fn_arousal_ica_fft_knn)+'''
377 |
378 | 379 |

Accuracy :

380 |
381 |

Acc = (TP + TN) / Total Population

382 |

Acc = ('''+str(tp_arousal_ica_fft_knn)+''' + '''+str(tn_arousal_ica_fft_knn)+''') / '''+str(tp_arousal_ica_fft_knn+fp_arousal_ica_fft_knn+tn_arousal_ica_fft_knn+fn_arousal_ica_fft_knn)+'''

383 |

Acc = '''+str((tp_arousal_ica_fft_knn+tn_arousal_ica_fft_knn)/(tp_arousal_ica_fft_knn+tn_arousal_ica_fft_knn+fp_arousal_ica_fft_knn+fn_arousal_ica_fft_knn))+'''

384 |
385 |
386 | 387 |
388 | 389 |
390 | 391 |
392 | 393 | 394 |
395 |
396 | Support Vector Machine 397 |
398 | 399 |
400 |
401 |
402 | Valence 403 |
404 | 405 |
406 |
407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 |
#12
1TP : '''+str(tp_valence_ica_fft_svm)+'''FP : '''+str(fp_valence_ica_fft_svm)+'''
2TN : '''+str(tn_valence_ica_fft_svm)+'''FN : '''+str(fn_valence_ica_fft_svm)+'''
428 |
429 | 430 |

Accuracy :

431 |
432 |

Acc = (TP + TN) / Total Population

433 |

Acc = ('''+str(tp_valence_ica_fft_svm)+''' + '''+str(tn_valence_ica_fft_svm)+''') / '''+str(tp_valence_ica_fft_svm+fp_valence_ica_fft_svm+tn_valence_ica_fft_svm+fn_valence_ica_fft_svm)+'''

434 |

Acc = '''+str((tp_valence_ica_fft_svm+tn_valence_ica_fft_svm)/(tp_valence_ica_fft_svm+tn_valence_ica_fft_svm+fp_valence_ica_fft_svm+fn_valence_ica_fft_svm))+'''

435 |
436 |
437 | 438 |
439 | 440 | 441 |
442 |
443 | Arousal 444 |
445 | 446 |
447 |
448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 |
#12
1TP : '''+str(tp_arousal_ica_fft_svm)+'''FP : '''+str(fp_arousal_ica_fft_svm)+'''
2TN : '''+str(tn_arousal_ica_fft_svm)+'''FN : '''+str(fn_arousal_ica_fft_svm)+'''
469 |
470 | 471 |

Accuracy :

472 |
473 |

Acc = (TP + TN) / Total Population

474 |

Acc = ('''+str(tp_arousal_ica_fft_svm)+''' + '''+str(tn_arousal_ica_fft_svm)+''') / '''+str(tp_arousal_ica_fft_svm+fp_arousal_ica_fft_svm+tn_arousal_ica_fft_svm+fn_arousal_ica_fft_svm)+'''

475 |

Acc = '''+str((tp_arousal_ica_fft_svm+tn_arousal_ica_fft_svm)/(tp_arousal_ica_fft_svm+tn_arousal_ica_fft_svm+fp_arousal_ica_fft_svm+fn_arousal_ica_fft_svm))+'''

476 |
477 |
478 | 479 |
480 | 481 |
482 | 483 |
484 | 485 |
486 |
487 |
488 | 489 |
490 |
491 |
492 | Stationery Wavelet Transformation 493 |
494 |
495 |
496 |
497 | K-Neirest Neighbord 498 |
499 | 500 |
501 |
502 |
503 | Valence 504 |
505 | 506 |
507 |
508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 |
#12
1TP : '''+str(tp_valence_swt_knn)+'''FP : '''+str(fp_valence_swt_knn)+'''
2TN : '''+str(tn_valence_swt_knn)+'''FN : '''+str(fn_valence_swt_knn)+'''
529 |
530 | 531 |

Accuracy :

532 |
533 |

Acc = (TP + TN) / Total Population

534 |

Acc = ('''+str(tp_valence_swt_knn)+''' + '''+str(tn_valence_swt_knn)+''') / '''+str(tp_valence_swt_knn+fp_valence_swt_knn+tn_valence_swt_knn+fn_valence_swt_knn)+'''

535 |

Acc = '''+str((tp_valence_swt_knn+tn_valence_swt_knn)/(tp_valence_swt_knn+tn_valence_swt_knn+fp_valence_swt_knn+fn_valence_swt_knn))+'''

536 |
537 |
538 | 539 |
540 | 541 | 542 |
543 |
544 | Arousal 545 |
546 | 547 |
548 |
549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 |
#12
1TP : '''+str(tp_arousal_swt_knn)+'''FP : '''+str(fp_arousal_swt_knn)+'''
2TN : '''+str(tn_arousal_swt_knn)+'''FN : '''+str(fn_arousal_swt_knn)+'''
570 |
571 | 572 |

Accuracy :

573 |
574 |

Acc = (TP + TN) / Total Population

575 |

Acc = ('''+str(tp_arousal_swt_knn)+''' + '''+str(tn_arousal_swt_knn)+''') / '''+str(tp_arousal_swt_knn+fp_arousal_swt_knn+tn_arousal_swt_knn+fn_arousal_swt_knn)+'''

576 |

Acc = '''+str((tp_arousal_swt_knn+tn_arousal_swt_knn)/(tp_arousal_swt_knn+tn_arousal_swt_knn+fp_arousal_swt_knn+fn_arousal_swt_knn))+'''

577 |
578 |
579 | 580 |
581 | 582 |
583 | 584 |
585 | 586 | 587 |
588 |
589 | Support Vector Machine 590 |
591 | 592 |
593 |
594 |
595 | Valence 596 |
597 | 598 |
599 |
600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 |
#12
1TP : '''+str(tp_valence_swt_svm)+'''FP : '''+str(fp_valence_swt_svm)+'''
2TN : '''+str(tn_valence_swt_svm)+'''FN : '''+str(fn_valence_swt_svm)+'''
621 |
622 | 623 |

Accuracy :

624 |
625 |

Acc = (TP + TN) / Total Population

626 |

Acc = ('''+str(tp_valence_swt_svm)+''' + '''+str(tn_valence_swt_svm)+''') / '''+str(tp_valence_swt_svm+fp_valence_swt_svm+tn_valence_swt_svm+fn_valence_swt_svm)+'''

627 |

Acc = '''+str((tp_valence_swt_svm+tn_valence_swt_svm)/(tp_valence_swt_svm+tn_valence_swt_svm+fp_valence_swt_svm+fn_valence_swt_svm))+'''

628 |
629 |
630 | 631 |
632 | 633 | 634 |
635 |
636 | Arousal 637 |
638 | 639 |
640 |
641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 |
#12
1TP : '''+str(tp_arousal_swt_svm)+'''FP : '''+str(fp_arousal_swt_svm)+'''
2TN : '''+str(tn_arousal_swt_svm)+'''FN : '''+str(fn_arousal_swt_svm)+'''
662 |
663 | 664 |

Accuracy :

665 |
666 |

Acc = (TP + TN) / Total Population

667 |

Acc = ('''+str(tp_arousal_swt_svm)+''' + '''+str(tn_arousal_swt_svm)+''') / '''+str(tp_arousal_swt_svm+fp_arousal_swt_svm+tn_arousal_swt_svm+fn_arousal_swt_svm)+'''

668 |

Acc = '''+str((tp_arousal_swt_svm+tn_arousal_swt_svm)/(tp_arousal_swt_svm+tn_arousal_swt_svm+fp_arousal_swt_svm+fn_arousal_swt_svm))+'''

669 |
670 |
671 | 672 |
673 | 674 |
675 | 676 |
677 | 678 |
679 |
680 |
681 | 682 |
683 |
684 |
685 | ICA + Stationery Wavelet Transformation 686 |
687 |
688 |
689 |
690 | K-Neirest Neighbord 691 |
692 | 693 |
694 |
695 |
696 | Valence 697 |
698 | 699 |
700 |
701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 |
#12
1TP : '''+str(tp_valence_ica_swt_knn)+'''FP : '''+str(fp_valence_ica_swt_knn)+'''
2TN : '''+str(tn_valence_ica_swt_knn)+'''FN : '''+str(fn_valence_ica_swt_knn)+'''
722 |
723 | 724 |

Accuracy :

725 |
726 |

Acc = (TP + TN) / Total Population

727 |

Acc = ('''+str(tp_valence_ica_swt_knn)+''' + '''+str(tn_valence_ica_swt_knn)+''') / '''+str(tp_valence_ica_swt_knn+fp_valence_ica_swt_knn+tn_valence_ica_swt_knn+fn_valence_ica_swt_knn)+'''

728 |

Acc = '''+str((tp_valence_ica_swt_knn+tn_valence_ica_swt_knn)/(tp_valence_ica_swt_knn+tn_valence_ica_swt_knn+fp_valence_ica_swt_knn+fn_valence_ica_swt_knn))+'''

729 |
730 |
731 | 732 |
733 | 734 | 735 |
736 |
737 | Arousal 738 |
739 | 740 |
741 |
742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 |
#12
1TP : '''+str(tp_arousal_ica_swt_knn)+'''FP : '''+str(fp_arousal_ica_swt_knn)+'''
2TN : '''+str(tn_arousal_ica_swt_knn)+'''FN : '''+str(fn_arousal_ica_swt_knn)+'''
763 |
764 | 765 |

Accuracy :

766 |
767 |

Acc = (TP + TN) / Total Population

768 |

Acc = ('''+str(tp_arousal_ica_swt_knn)+''' + '''+str(tn_arousal_ica_swt_knn)+''') / '''+str(tp_arousal_ica_swt_knn+fp_arousal_ica_swt_knn+tn_arousal_ica_swt_knn+fn_arousal_ica_swt_knn)+'''

769 |

Acc = '''+str((tp_arousal_ica_swt_knn+tn_arousal_ica_swt_knn)/(tp_arousal_ica_swt_knn+tn_arousal_ica_swt_knn+fp_arousal_ica_swt_knn+fn_arousal_ica_swt_knn))+'''

770 |
771 |
772 | 773 |
774 | 775 |
776 | 777 |
778 | 779 | 780 |
781 |
782 | Support Vector Machine 783 |
784 | 785 |
786 |
787 |
788 | Valence 789 |
790 | 791 |
792 |
793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 |
#12
1TP : '''+str(tp_valence_ica_swt_svm)+'''FP : '''+str(fp_valence_ica_swt_svm)+'''
2TN : '''+str(tn_valence_ica_swt_svm)+'''FN : '''+str(fn_valence_ica_swt_svm)+'''
814 |
815 | 816 |

Accuracy :

817 |
818 |

Acc = (TP + TN) / Total Population

819 |

Acc = ('''+str(tp_valence_ica_swt_svm)+''' + '''+str(tn_valence_ica_swt_svm)+''') / '''+str(tp_valence_ica_swt_svm+fp_valence_ica_swt_svm+tn_valence_ica_swt_svm+fn_valence_ica_swt_svm)+'''

820 |

Acc = '''+str((tp_valence_ica_swt_svm+tn_valence_ica_swt_svm)/(tp_valence_ica_swt_svm+tn_valence_ica_swt_svm+fp_valence_ica_swt_svm+fn_valence_ica_swt_svm))+'''

821 |
822 |
823 | 824 |
825 | 826 | 827 |
828 |
829 | Arousal 830 |
831 | 832 |
833 |
834 | 835 | 836 | 837 | 838 | 839 | 840 | 841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 |
#12
1TP : '''+str(tp_arousal_ica_swt_svm)+'''FP : '''+str(fp_arousal_ica_swt_svm)+'''
2TN : '''+str(tn_arousal_ica_swt_svm)+'''FN : '''+str(fn_arousal_ica_swt_svm)+'''
855 |
856 | 857 |

Accuracy :

858 |
859 |

Acc = (TP + TN) / Total Population

860 |

Acc = ('''+str(tp_arousal_ica_swt_svm)+''' + '''+str(tn_arousal_ica_swt_svm)+''') / '''+str(tp_arousal_ica_swt_svm+fp_arousal_ica_swt_svm+tn_arousal_ica_swt_svm+fn_arousal_ica_swt_svm)+'''

861 |

Acc = '''+str((tp_arousal_ica_swt_svm+tn_arousal_ica_swt_svm)/(tp_arousal_ica_swt_svm+tn_arousal_ica_swt_svm+fp_arousal_ica_swt_svm+fn_arousal_ica_swt_svm))+'''

862 |
863 |
864 | 865 |
866 | 867 |
868 | 869 |
870 | 871 |
872 |
873 |
874 |
875 |
876 | 877 | 878 |
879 | 880 | 881 | 882 | 883 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 892 | 893 | 894 | 895 | 896 | 897 | 898 | 899 | 900 | ''' 901 | --------------------------------------------------------------------------------