├── .gitattributes ├── .gitignore ├── Code-A New Structure of the Focal Element in Object ├── BPA_Conductivity.m ├── BPA_Project.m ├── Divergence.m ├── Experiment_No_1.m ├── FocalDivergence.m ├── Murphy_evidMerge.m ├── Murphy_evidMerge_trad.m ├── PL.eps ├── PL.tif ├── PW.eps ├── PW.tif ├── SL.eps ├── SL.tif ├── SW.eps ├── SW.tif ├── adult.data ├── adult.names ├── adult.test ├── aggregateDimension.m ├── beliefEntropy.m ├── conductivity.m ├── coreEntropy.m ├── createBPA.m ├── createBasicElement.m ├── createElement.m ├── createEvidence.m ├── createFocalElement.m ├── createKnowledgeLib.m ├── credible_degree.m ├── crediblity.eps ├── demo.m ├── demo_classical.m ├── demo_iris.m ├── demo_newStructure.m ├── demo_tradition.m ├── ds_conflictCoeff.m ├── ds_conflictCoeff_trad.m ├── ds_evidMerge.m ├── evid_set.mat ├── focalElements.eps ├── importfile_ionosphere.m ├── importfile_sonar.m ├── importfile_wdbc.m ├── innerEntropy.m ├── interactionDimension.m ├── ionosphere.data ├── ionosphere.names ├── iris.csv ├── iris_matlab.txt ├── jpg │ ├── PL-mistake.eps │ ├── PW-mistake.eps │ ├── SL-mistake.eps │ └── SW-mistake.eps ├── lib │ ├── DBSCAN.m │ ├── computeFoldSizes.m │ ├── demo_kfoldValidation.m │ ├── getFoldVectors.m │ ├── getVecsPerCat.m │ └── randSortAndGroup.m ├── loadIRIS_new.m ├── loadIRIS_tradition.m ├── loadSonar_new.m ├── loadSonar_tradition.m ├── loadWDBC_new.m ├── loadWDBC_tradition.m ├── loadWine.m ├── loadWine_new.m ├── loadWine_tradition.m ├── pignistic_prop_trans.m ├── sonar.csv ├── sonar.txt ├── wdbc.data ├── wdbc.names ├── wine.data ├── wine.names ├── winequality-red.txt ├── winequality-white.txt ├── wpbc.data ├── wpbc.names └── 属性值-正态分布.vsdx ├── Code-Accuracy Enhancement for Noninvasive Glucose Estimation ├── KernelCalibration_predict.m ├── KernelCalibration_train.m └── demo.m ├── Code-Adaptive local contrast measure based on local steering kernel ├── 2.bmp ├── 4.bmp ├── LSK.m ├── demo.m ├── derivative5.m ├── derivative7.m ├── normalise.m ├── pointVector.m ├── pp.jpg └── pp2.jpg ├── Code-Bayesian inference for adaptive low rank ├── arllr.m ├── arllre.m ├── gen_patch_img.m ├── main.m ├── proximal_log.m └── res_patch_img_mean.m ├── Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal ├── 3000mg_ST.eps ├── 3000mg_STFT.eps ├── 3000mg_WVD.eps ├── 3000mg_simulated.eps ├── FAG_curve.png ├── IBW_curve.png ├── RMSF_curve.png ├── TKME_curve.png ├── acoustic_skin.mat ├── compare_demo.m ├── compare_real.m ├── evaluation │ ├── Bland-Altman-Analysis-master │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── Bland JM, Altman DG 1999 - Measuring agreement in method comparison studies.url │ │ ├── README.md │ │ ├── ba.m │ │ ├── ba1999demo.m │ │ ├── bpdata.mat │ │ ├── demo.m │ │ ├── fitting_data.mat │ │ └── lib │ │ │ ├── Ninv.m │ │ │ ├── Tinv.m │ │ │ ├── baloa.m │ │ │ ├── dcStruct.m │ │ │ ├── dcUpdateFcn.m │ │ │ ├── dcXY.m │ │ │ ├── isaxes.m │ │ │ ├── isfigure.m │ │ │ ├── s2v.m │ │ │ ├── validatePlotArgs.m │ │ │ └── validatelogical.m │ ├── BlandAltman.zip │ ├── BlandAltman │ │ ├── BlandAltman.m │ │ ├── BlandAltmanDemo.m │ │ ├── correlationPlot.m │ │ ├── mynum2str.m │ │ └── polyfitZero.m │ ├── Clarke_EGA.emf │ ├── Clarke_EGA.png │ ├── clarke.m │ ├── clarke.zip │ ├── example_data.mat │ └── license.txt ├── fitting_data.mat ├── lib │ ├── centerFreq.m │ ├── divideDataset.m │ ├── energyop.m │ ├── freqAttenGrad.m │ ├── linspecer.m │ ├── lrm.m │ ├── normalization.m │ ├── st.m │ ├── svr.m │ ├── teagerEnergy.m │ ├── teagerEnergyImproved.m │ ├── test_regression.m │ ├── tfrgabor.m │ └── timedepthConvert.m ├── real-data.mat ├── real_final2.eps ├── signal_model_demo.m ├── signal_model_real.m ├── simulate_code │ ├── blood_model.m │ ├── simulate_result │ │ ├── ReadME.txt │ │ ├── acoustic │ │ │ └── acoustic_skin.mat │ │ ├── linspecer.m │ │ ├── optical │ │ │ └── optical_skin.mat │ │ ├── show_model.m │ │ └── show_result.m │ └── skin_model_simulation.m ├── tkme_ST.eps ├── tkme_STFT.eps └── tkme_WVD.eps ├── Code-Dual-Threshold Computation Method ├── 4.bmp ├── demo.m └── dualThreshold.m ├── Code-Kernel Regression for Image Processing and Reconstruction ├── demo.m ├── experiment_1.m └── support │ ├── EdgeMirror.m │ ├── derivative7.m │ ├── downsample2.m │ ├── mymse.m │ ├── round0_255.m │ ├── skr2_regular.m │ └── steering.m ├── Code-Multiscale local homogeneity measure ├── 2.bmp ├── 4.bmp ├── LHM.m ├── demo.m ├── impad.m ├── pp.jpg └── pp2.jpg ├── Code-Unsupervised ridge detection ├── 4.bmp ├── 7.bmp ├── checkattributes.m ├── demo.m ├── getAnisotropyKernel.m ├── getKernelParameter.m ├── gradients_n.m ├── gsmoothn.m ├── hystThresh.m └── nonmaxSuppress.m ├── Code-WaveFeature and evidential regression for blood glucose detection ├── RegressionTest.m ├── RegressionTest_kcross.m ├── demo.m ├── demo_kcross.m ├── extractWaveFeature.m ├── lib │ ├── centerFreq.m │ ├── computeFoldSizes.m │ ├── error_reg.m │ ├── freqAttenGrad.m │ ├── getFoldVectors.m │ ├── linspecer.m │ ├── lssvr_predict.m │ ├── lssvr_train.m │ ├── randSortAndGroup.m │ ├── st.m │ ├── tbmreg_fit.m │ ├── tbmreg_val.m │ └── teagerEnergy.m ├── real-data.mat ├── real-data2.mat ├── real-data_total.mat ├── result_data_Long.mat └── result_data_chen.mat └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /un-push 2 | /test-data 3 | /other 4 | /result/* 5 | Ghent_University_Fungal_Images_I/ 6 | *.rar 7 | *asv 8 | *.bmp 9 | *.jpg -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/BPA_Conductivity.m: -------------------------------------------------------------------------------- 1 | function [ bpa, save_interDim ] = BPA_Conductivity( evid_c, evid_un, aggre_dim ) 2 | %% BPA_CONDUCTIVITY: the function to compute the BPA based on conductivity 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: evid_c --> all evidence sets (a cell array for all evidence set) 7 | evid_un --> the unknown class evidence 8 | aggre_dim --> the aggregate dimension(for all evidence set) 9 | Output: bpa --> the BPA based on conductivity 10 | save_interDim --> used to save the interDim 11 | [Tips]: This function is based on the special design of the system to 12 | calculate some parameters. So this function only can be used under the data 13 | structure in this system. 14 | %} 15 | % evid_c = [Pyramid, Lshape, Handle, Cylinder]; 16 | Pyra_evid = evid_c{1}; 17 | Lshape_evid = evid_c{2}; 18 | Handle_evid = evid_c{3}; 19 | Cylin_evid = evid_c{4}; 20 | 21 | InterDim_Pyra = interactionDimension(Pyra_evid, evid_un); % Pyramid evidence 22 | InterDim_Lshape = interactionDimension(Lshape_evid, evid_un); % L shape evidence 23 | InterDim_Handle = interactionDimension(Handle_evid, evid_un); % Handle evidence 24 | InterDim_Cylin = interactionDimension(Cylin_evid, evid_un); % Cylinder evidence 25 | 26 | % save the intermediate result 27 | save_interDim.Pyra = InterDim_Pyra; 28 | save_interDim.Lshape = InterDim_Lshape; 29 | save_interDim.Handle = InterDim_Handle; 30 | save_interDim.Cylin = InterDim_Cylin; 31 | 32 | % compute the conductivity of Y1 in class Pyramid 33 | % aggre_dim = [Pyramid, Lshape, Handle, Cylinder]; 34 | cond_y1_Pyra = conductivity(Pyra_evid, InterDim_Pyra, aggre_dim(1)); 35 | cond_y1_Lshape = conductivity(Lshape_evid, InterDim_Lshape, aggre_dim(2)); 36 | cond_y1_Handle = conductivity(Handle_evid, InterDim_Handle, aggre_dim(3)); 37 | cond_y1_Cylin = conductivity(Cylin_evid, InterDim_Cylin, aggre_dim(4)); 38 | 39 | y1_BPA = [cond_y1_Pyra, cond_y1_Lshape, cond_y1_Handle, cond_y1_Cylin]; 40 | bpa = y1_BPA/sum(y1_BPA); 41 | 42 | end 43 | 44 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/BPA_Project.m: -------------------------------------------------------------------------------- 1 | function [ bpa, save_interDim ] = BPA_Project( evid_c, evid_un, aggre_dim ) 2 | %% BPA_PROJECT 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: evid_c --> all evidence sets (a cell array for all evidence set) 7 | evid_un --> the unknown class evidence 8 | aggre_dim --> the aggregate dimension(for all evidence set) 9 | Output: bpa --> the BPA based on conductivity 10 | save_interDim --> used to save the interDim 11 | [Tips]: This function is based on the special design of the system to 12 | calculate some parameters. So this function only can be used under the data 13 | structure in this system. 14 | %} 15 | % evid_c = [Pyramid, Lshape, Handle, Cylinder]; 16 | Pyra_evid = evid_c{1}; 17 | Lshape_evid = evid_c{2}; 18 | Handle_evid = evid_c{3}; 19 | Cylin_evid = evid_c{4}; 20 | 21 | InterDim_Pyra = interactionDimension(Pyra_evid, evid_un); % Pyramid evidence 22 | InterDim_Lshape = interactionDimension(Lshape_evid, evid_un); % L shape evidence 23 | InterDim_Handle = interactionDimension(Handle_evid, evid_un); % Handle evidence 24 | InterDim_Cylin = interactionDimension(Cylin_evid, evid_un); % Cylinder evidence 25 | % save the intermediate result 26 | save_interDim.Pyra = InterDim_Pyra; 27 | save_interDim.Lshape = InterDim_Lshape; 28 | save_interDim.Handle = InterDim_Handle; 29 | save_interDim.Cylin = InterDim_Cylin; 30 | % compute the conductivity of Y1 in class Pyramid 31 | % aggre_dim = [Pyramid, Lshape, Handle, Cylinder]; 32 | weight = 1- (abs(InterDim_Pyra - aggre_dim(1))/aggre_dim(1)); 33 | proj_dim_Pyra = weight.*InterDim_Pyra; 34 | cond_y1_Pyra = mean(proj_dim_Pyra); 35 | 36 | weight = 1- (abs(InterDim_Lshape - aggre_dim(2))/aggre_dim(2)); 37 | proj_dim_Lshape = weight.*InterDim_Lshape; 38 | cond_y1_Lshape = mean(proj_dim_Lshape); 39 | 40 | weight = 1- (abs(InterDim_Handle - aggre_dim(3))/aggre_dim(3)); 41 | proj_dim_Handle = weight.*InterDim_Handle; 42 | cond_y1_Handle = mean(proj_dim_Handle); 43 | 44 | weight = 1- (abs(InterDim_Cylin - aggre_dim(4))/aggre_dim(4)); 45 | proj_dim_Cylin = weight.*InterDim_Cylin; 46 | cond_y1_Cylin = mean(proj_dim_Cylin); 47 | 48 | y1_BPA = [cond_y1_Pyra, cond_y1_Lshape, cond_y1_Handle, cond_y1_Cylin]; 49 | bpa = y1_BPA/sum(y1_BPA); 50 | 51 | end 52 | 53 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/Divergence.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-A New Structure of the Focal Element in Object/Divergence.m -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/Experiment_No_1.m: -------------------------------------------------------------------------------- 1 | %% Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 2 | % This script is designed to test the information fractals for evidential 3 | % pattern classification 4 | % Author: MarkLHF 5 | % Date: 2020-3-13(first version) 6 | clear; clc; close all; 7 | %% create the full library 8 | lib.num_planes_select = 1:8; 9 | % [Tips]: must convert the cell array to char array 10 | lib.type_select = char({'t', 's', 'r', 'b', 'c', 'd'}); 11 | lib.curvature_select = char({'p', 'q'}); 12 | 13 | total_num = length(lib.num_planes_select) * ... 14 | length(lib.curvature_select) * ... 15 | length(lib.type_select); 16 | 17 | Know_lib = createKnowledgeLib(lib); 18 | %% class: Pyramid 19 | % vector: {(4,T,P) (1,S,P) (1,R,P) FF} 20 | p_4tp = createBasicElement(4, 't', 'p'); 21 | p_1sp = createBasicElement(1, 's', 'p'); 22 | p_1rp = createBasicElement(1, 'r', 'p'); 23 | 24 | pf_4tp = createFocalElement(p_4tp, 0.5); 25 | pf_1sp = createFocalElement(p_1sp, 0.3); 26 | % --> generate a1 27 | a1 = createEvidence([pf_4tp, pf_1sp], Know_lib); 28 | 29 | pf_1rp = createFocalElement(p_1rp, 0.25); 30 | % --> generate a2 31 | a2 = createEvidence([pf_4tp, pf_1rp], Know_lib); 32 | 33 | pf_4tp = createFocalElement(p_4tp, 0.7); 34 | % --> generate a3 35 | a3 = createEvidence(pf_4tp, Know_lib); 36 | 37 | % p_2cp = createBasicElement(2, 'c', 'p'); 38 | % p_1rc = createBasicElement(1, 'r', 'c'); 39 | % pf_2cp = createFocalElement(p_2cp, 0.4); 40 | % pf_1rc = createFocalElement(p_1rc, 0.4); 41 | % a4 = createEvidence([pf_2cp, pf_1rc], Know_lib); 42 | 43 | p_6rp = createBasicElement(6, 'r', 'p'); 44 | pf_6rp = createFocalElement(p_6rp, 0.5); 45 | a4 = createEvidence(pf_6rp, Know_lib); 46 | 47 | p_2bp = createBasicElement(2, 'b', 'p'); 48 | p_2sp = createBasicElement(2, 's', 'p'); 49 | pf_2bp = createFocalElement(p_2bp, 0.4); 50 | pf_6rp = createFocalElement(p_6rp, 0.2); 51 | pf_2sp = createFocalElement(p_2sp, 0.2); 52 | a5 = createEvidence([pf_2bp, pf_6rp, pf_2sp], Know_lib); 53 | 54 | % create a evidence cell array 55 | % <1> Pyramid 56 | Pyra_evid_1 = {a1, a2, a3}; 57 | Pyra_evid_2 = {a1, a2, a3, a4, a5}; 58 | %% generate 3 types evidence 59 | p_2tp = createBasicElement(2, 't', 'p'); 60 | p_5rp = createBasicElement(5, 'r', 'p'); 61 | p_6rp = createBasicElement(6, 'r', 'p'); 62 | 63 | pf_4tp = createFocalElement(p_4tp, 0.4); 64 | pf_1sp = createFocalElement(p_1sp, 0.4); 65 | evid_r = createEvidence([pf_4tp, pf_1sp], Know_lib); % right evidence 66 | 67 | pf_2tp = createFocalElement(p_2tp, 0.4); 68 | pf_1sp = createFocalElement(p_1sp, 0.2); 69 | pf_5rp = createFocalElement(p_5rp, 0.1); 70 | evid_pr = createEvidence([pf_2tp, pf_1sp, pf_5rp], Know_lib); % partly right evidence 71 | 72 | pf_6rp = createFocalElement(p_6rp, 0.5); 73 | evid_w = createEvidence(pf_6rp, Know_lib); % wrong evidence 74 | %% compute the correlation 75 | 76 | % aggregateDimension(Pyra_evid_1); 77 | % aggregateDimension(Pyra_evid_2); 78 | 79 | cred_vec = credible_degree(Pyra_evid_2); 80 | 81 | 82 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/FocalDivergence.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-A New Structure of the Focal Element in Object/FocalDivergence.m -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/PL.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-A New Structure of the Focal Element in Object/PL.tif -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/PW.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-A New Structure of the Focal Element in Object/PW.tif -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/SL.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-A New Structure of the Focal Element in Object/SL.tif -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/SW.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-A New Structure of the Focal Element in Object/SW.tif -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/aggregateDimension.m: -------------------------------------------------------------------------------- 1 | function [ dim ] = aggregateDimension( evid ) 2 | %% AGGREGATEDIMENSION: this function is used to compute the aggregate dimension(class) 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: evid --> a class evidence information(a cell array) 7 | Output: dim --> the aggregate dimension of evidence 8 | 9 | [Tips]: This function is based on the special design of the system to 10 | calculate some parameters. So this function only can be used under the data 11 | structure in this system. 12 | %} 13 | 14 | len = length(evid); 15 | belief_E_Pyra = zeros(1, len); % belief entropy 16 | core_E_Pyra = zeros(1, len); % core entropy 17 | Fdiv_Pyra = zeros(1, len); % focal divergence 18 | 19 | In_E_Pyra = zeros(1, len); % inner entropy 20 | for n = 1:len 21 | belief_E_Pyra(n) = beliefEntropy(evid{n}); 22 | core_E_Pyra(n) = coreEntropy(evid{n}); 23 | Fdiv_Pyra(n) = FocalDivergence(evid{n}); 24 | 25 | within_Entropy = belief_E_Pyra(n) + core_E_Pyra(n); 26 | In_E_Pyra(n) = within_Entropy + Fdiv_Pyra(n); 27 | end 28 | 29 | Div_mat = zeros(len, len); % divergence matrix of belief functions 30 | for nrow = 1:len 31 | for ncol = 1:len 32 | q1 = evid{nrow}; 33 | q2 = evid{ncol}; 34 | 35 | Div_mat(nrow, ncol) = Divergence(q1, q2); 36 | end 37 | end 38 | tt = Div_mat - diag(diag(Div_mat)); % remove the diagonal element 39 | Div_Pypr = sum(tt(:))/2 ; 40 | % compute the aggregate dimension of the evidence 41 | dim_Pypr = sum(In_E_Pyra)/(sum(In_E_Pyra)+Div_Pypr); 42 | dim = dim_Pypr; 43 | 44 | end 45 | 46 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/beliefEntropy.m: -------------------------------------------------------------------------------- 1 | function [ belE ] = beliefEntropy( evidence ) 2 | %% BELIEFENTROPY: this function is used to compute the belief entropy of a evidence 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: evid --> the evidence information(a struct array) 7 | Output: belE --> the belief entropy of this evidence 8 | [Tips]: This function is based on the special design of the system to 9 | calculate some parameters. So this function only can be used under the data 10 | structure in this system. 11 | %} 12 | [~, N] = size(evidence); 13 | 14 | belE = 0; 15 | for n = 1:N 16 | tmp = evidence(n).bpa; 17 | 18 | if tmp == 0 19 | continue; 20 | end 21 | belE = belE + tmp*log(tmp); 22 | end 23 | belE = -belE; 24 | end 25 | 26 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/conductivity.m: -------------------------------------------------------------------------------- 1 | function [ cond ] = conductivity( evid_c, inter_dim, aggre_dim) 2 | %% CONDUCTIVITY: a function is used to compute the conductivity of evidence in a evidence set 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: evid_c --> a evidence set (a cell array) 7 | inter_dim --> the interaction dimension(evidence and evidence set) 8 | aggre_dim --> the aggregate dimension(evidence set) 9 | Output: cond --> the conductivity 10 | 11 | [Tips]: This function is based on the special design of the system to 12 | calculate some parameters. So this function only can be used under the data 13 | structure in this system. 14 | %} 15 | 16 | len = length(inter_dim); 17 | loc = inter_dim > aggre_dim; 18 | cond_y1_vec = zeros(1, len); 19 | for n = 1:len 20 | if loc(n) 21 | % --> if interaction dimension > aggregate dimension 22 | % compute the proj[interaction dim] 23 | cap = 1/innerEntropy(evid_c); 24 | proj_dim = inter_dim(n)*cap; 25 | 26 | if proj_dim > aggre_dim 27 | cond_y1_vec(n) = 0; 28 | else 29 | cond_y1_vec(n) = proj_dim; 30 | end 31 | else 32 | % --> if interaction dimension <= aggregate dimension 33 | cond_y1_vec(n) = inter_dim(n); 34 | end 35 | end 36 | cond = sum(cond_y1_vec); 37 | 38 | end 39 | 40 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/coreEntropy.m: -------------------------------------------------------------------------------- 1 | function [ corE ] = coreEntropy( evid ) 2 | %% COREENTROPY: this function is used to compute the core entropy of a evidence 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: evid --> the evidence information(a struct array) 7 | Output: corE --> the core entropy of this evidence 8 | [Tips]: This function is based on the special design of the system to 9 | calculate some parameters. So this function only can be used under the data 10 | structure in this system. 11 | %} 12 | [~,N] = size(evid); 13 | 14 | tmp_evid = evid; loc = true(N,1); 15 | for n = 1:N 16 | if tmp_evid(n).bpa == 0 17 | loc(n) = false; 18 | end 19 | end 20 | tmp_evid(~loc) = []; 21 | 22 | [~,N] = size(tmp_evid); 23 | h_vec = zeros(1, N); 24 | 25 | for n = 1:N 26 | [~, h_vec(n)] = size(tmp_evid(n).basicElement); 27 | end 28 | h_vec(h_vec == 0) = []; % remove the [] focal elements 29 | 30 | 31 | total_FE = sum(h_vec); 32 | h_vec = h_vec/total_FE; 33 | 34 | corE = -sum(h_vec.*log(h_vec)); 35 | end 36 | 37 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/createBPA.m: -------------------------------------------------------------------------------- 1 | function [ output_args ] = createBPA( input_args ) 2 | %% CREATEBPA: create a BPA vector according element list 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: input_args --> the element list (the elements created by createElement function); 7 | Output: output_args --> the bpa of this evidence; 8 | %} 9 | N = length(input_args); 10 | total_prob = 0; 11 | 12 | for n = 1:N 13 | 14 | end 15 | 16 | end 17 | 18 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/createBasicElement.m: -------------------------------------------------------------------------------- 1 | function [ output_args ] = createBasicElement( num_planes, type, curvature ) 2 | %% CREATEELEMENT: the function of creating a basic element 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: num_planes --> the number of this type planes (a integer) 7 | type --> the type of planes 8 | curvature --> the curvature of planes 9 | prob --> the BPA of this element 10 | Output: output_args --> the basic element 11 | [Tips]: "type" only have 6 classes: 12 | (1) T: Triangle; (2) S: Square; (3) R: rectangle; (4) B: Bracket; 13 | (5) C: circle; (6) D: disk; 14 | "curvature" only have 2 classes: 15 | (1) P: planes; (2) C: curved; 16 | [Tips]: this element is the one part of focal elements 17 | %} 18 | output_args.num_planes = num_planes; 19 | output_args.type = upper(type); 20 | output_args.curvature = upper(curvature); 21 | end 22 | 23 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/createElement.m: -------------------------------------------------------------------------------- 1 | function [ output_args ] = createElement( num_planes, type, curvature, prob ) 2 | %% CREATEELEMENT: the function of creating a element 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: num_planes --> the number of this type planes (a integer) 7 | type --> the type of planes 8 | curvature --> the curvature of planes 9 | prob --> the BPA of this element 10 | Output: tk --> the teager energy 11 | [Tips]: "type" only have 6 classes: 12 | (1) T: Triangle; (2) S: Square; (3) R: rectangle; (4) B: Bracket; 13 | (5) C: circle; (6) D: disk; 14 | "curvature" only have 2 classes: 15 | (1) P: planes; (2) C: curved; 16 | %} 17 | output_args.num_planes = num_planes; 18 | output_args.type = lower(type); 19 | output_args.curvature = lower(curvature); 20 | output_args.prob = prob 21 | end 22 | 23 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/createEvidence.m: -------------------------------------------------------------------------------- 1 | function [ output_args ] = createEvidence( fe_array, lib ) 2 | %% CREATEEVIDENCE: the function of creating an evidence 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: fe_array --> the array of the focal elements 7 | lib --> a library of all possible options 8 | Output: output_args --> the evidence 9 | [Tips]: "type" only have 6 classes: 10 | (1) T: Triangle; (2) S: Square; (3) R: rectangle; (4) B: Bracket; 11 | (5) C: circle; (6) D: disk; 12 | "curvature" only have 2 classes: 13 | (1) P: planes; (2) C: curved; 14 | %} 15 | [~, N] = size(fe_array); 16 | 17 | % [Tips]: the F represent the full set 18 | % compute the BPA of F 19 | tmpFE.basicElement = lib; 20 | tmpFE.bpa = 0; 21 | for n = 1:N 22 | tmpFE.bpa = tmpFE.bpa + fe_array(n).bpa; 23 | end 24 | tmpFE.bpa = 1 - tmpFE.bpa; 25 | 26 | % integrate all focal element to form the evidence 27 | output_args = [fe_array, tmpFE]; 28 | end 29 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/createFocalElement.m: -------------------------------------------------------------------------------- 1 | function [ output_args ] = createFocalElement( be_array, prop ) 2 | %% CREATEFORCEELEMENT: the function of creating a focus element 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: be_array --> the array of basic elements 7 | prob --> the BPA of this focal element 8 | Output: output_args --> the focal element 9 | [Tips]: "type" only have 6 classes: 10 | (1) T: Triangle; (2) S: Square; (3) R: rectangle; (4) B: Bracket; 11 | (5) C: circle; (6) D: disk; 12 | "curvature" only have 2 classes: 13 | (1) P: planes; (2) C: curved; 14 | [Example]: 15 | pf1 = createFocalElement(p_4tp, 0.5); 16 | pf1 = createFocalElement([p_4tp, p_1sp], 0.5); 17 | %} 18 | output_args.basicElement = be_array; 19 | output_args.bpa = prop; 20 | end 21 | 22 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/createKnowledgeLib.m: -------------------------------------------------------------------------------- 1 | function [ output_args ] = createKnowledgeLib( typeClass, num_attr ) 2 | %% CREATEKNOWLEDGELIB: the function to create the knowledge library 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: typeClass --> the type of species 7 | num_attr --> the number of attributes 8 | Output: output_args --> the universal set 9 | [Tips]: "typeClass" the type of species({'setosa'}; {'versicolor'}; {'virginica'}) 10 | "num_attr" the number of attributes(for IRIS dataset is 4) 11 | (SL, SW, PL, PW) 12 | %} 13 | 14 | output_args = []; % allocate the variant 15 | 16 | num_class = length(typeClass); 17 | tmp_fe = cell(1, num_attr); 18 | 19 | for n1 = 1:num_class % for SL 20 | tmp_fe(1) = typeClass(n1); 21 | for n2 = 1:num_class % for SW 22 | tmp_fe(2) = typeClass(n2); 23 | for n3 = 1:num_class % for PL 24 | tmp_fe(3) = typeClass(n3); 25 | for n4 = 1:num_class % for PW 26 | tmp_fe(4) = typeClass(n4); 27 | output_args = [output_args; {tmp_fe}]; 28 | end 29 | end 30 | end 31 | end 32 | % the number of planes 33 | % for n = 1:length(lib.num_planes_select) 34 | % % the all possible type selection 35 | % for m = 1:length(lib.type_select) 36 | % % the all possible curvature selection 37 | % for l = 1:length(lib.curvature_select) 38 | % % setting 39 | % num_planes = lib.num_planes_select(n); 40 | % type = lib.type_select(m); 41 | % curvature = lib.curvature_select(l); 42 | % 43 | % tmp_element = createBasicElement(num_planes, type, curvature); 44 | % output_args = [output_args, tmp_element]; 45 | % end 46 | % end 47 | % end 48 | 49 | end 50 | 51 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/credible_degree.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-A New Structure of the Focal Element in Object/credible_degree.m -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/demo.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-A New Structure of the Focal Element in Object/demo.m -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/demo_iris.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-A New Structure of the Focal Element in Object/demo_iris.m -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/ds_conflictCoeff.m: -------------------------------------------------------------------------------- 1 | function [ coeff ] = ds_conflictCoeff( evid1, evid2 ) 2 | %% DS_CONFLICTCOEFF: this function is used to compute the conflict coefficient(DS evidence) 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: evid1,evid2 --> the evidence information(a struct array) 7 | Output: coeff --> the conflict coefficient 8 | [Tips]: This function is based on the special design of the system to 9 | calculate some parameters. So this function only can be used under the data 10 | structure in this system. 11 | %} 12 | len_evid1 = length(evid1); 13 | len_evid2 = length(evid2); 14 | coeff = 0; 15 | % extract the focal elements 16 | for n = 1:len_evid1 17 | fe1 = evid1(n).basicElement; 18 | for m = 1:len_evid2 19 | fe2 = evid2(m).basicElement; 20 | 21 | % judge whether it is the same 22 | if FocalElementMixed(fe1, fe2) 23 | continue; 24 | else 25 | tmp = evid1(n).bpa * evid2(m).bpa; 26 | coeff = coeff + tmp; 27 | end 28 | end 29 | end 30 | coeff = coeff; 31 | end 32 | 33 | function res = FocalElementMixed(fe1, fe2) 34 | %{ 35 | detail: to judge the two focal elements have same basic elements 36 | Input: fe1,fe2 --> the focal elements(a struct array) 37 | Output: res --> true/false 38 | %} 39 | len1 = length(fe1); len2 = length(fe2); 40 | % if fe1 == fe2 == [] 41 | if (len1 == 0)&&(len2 == 0) 42 | res = true;return; 43 | elseif (len1 == 0)&&~(len2 == 0) 44 | res = false;return; 45 | elseif ~(len1 == 0)&&(len2 == 0) 46 | res = false;return; 47 | end 48 | 49 | for n = 1:len1 50 | tmp_be1 = fe1(n); 51 | for m = 1:len2 52 | tmp_be2 = fe2(m); 53 | 54 | if IsSameBasicElement(tmp_be1, tmp_be2) 55 | res = true; 56 | return; 57 | else 58 | res = false; 59 | end 60 | end 61 | end 62 | 63 | end 64 | 65 | function res = IsSameBasicElement(be1, be2) 66 | %{ 67 | detail: to judge the two basic elements are same 68 | Input: be1,be2 --> the basic elements(a struct array) 69 | Output: res --> true/false 70 | %} 71 | N = length(be1{1}); 72 | flag = false(N,1); 73 | for n = 1:N 74 | if strcmpi(be1{1}{n}, be2{1}{n}) 75 | flag(n) = true; 76 | end 77 | end 78 | if sum(flag) == N 79 | res = true; 80 | else 81 | res = false; 82 | end 83 | end 84 | 85 | %{ 86 | function res = IsSameBasicElement(be1, be2) 87 | %{ 88 | detail: to judge the two basic elements are same 89 | Input: be1,be2 --> the basic elements(a struct array) 90 | Output: res --> true/false 91 | %} 92 | flag_num_planes = false; 93 | flag_type = false; 94 | flag_curvatrue = false; 95 | 96 | if be1.num_planes == be2.num_planes 97 | flag_num_planes = true; 98 | end 99 | if be1.type == be2.type 100 | flag_type = true; 101 | end 102 | if be1.curvature == be2.curvature 103 | flag_curvatrue = true; 104 | end 105 | res = flag_num_planes & flag_type & flag_curvatrue; 106 | end 107 | %} -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/ds_conflictCoeff_trad.m: -------------------------------------------------------------------------------- 1 | function [ coeff ] = ds_conflictCoeff_trad( evid1, evid2 ) 2 | %% DS_CONFLICTCOEFF: this function is used to compute the conflict coefficient(DS evidence) 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: evid1,evid2 --> the evidence information(a struct array) 7 | Output: coeff --> the conflict coefficient 8 | [Tips]: This function is based on the special design of the system to 9 | calculate some parameters. So this function only can be used under the data 10 | structure in this system. 11 | %} 12 | len_evid1 = length(evid1); 13 | len_evid2 = length(evid2); 14 | coeff = 0; 15 | % extract the focal elements 16 | for n = 1:len_evid1 17 | fe1 = evid1(n).basicElement; 18 | for m = 1:len_evid2 19 | fe2 = evid2(m).basicElement; 20 | 21 | % judge whether it is the same 22 | if FocalElementMixed(fe1, fe2) 23 | continue; 24 | else 25 | tmp = evid1(n).bpa * evid2(m).bpa; 26 | coeff = coeff + tmp; 27 | end 28 | end 29 | end 30 | coeff = coeff; 31 | end 32 | 33 | function res = FocalElementMixed(fe1, fe2) 34 | %{ 35 | detail: to judge the two focal elements have same basic elements 36 | Input: fe1,fe2 --> the focal elements(a struct array) 37 | Output: res --> true/false 38 | %} 39 | len1 = length(fe1); len2 = length(fe2); 40 | for n = 1:len1 41 | tmp_be1 = fe1(n); 42 | for m = 1:len2 43 | tmp_be2 = fe2(m); 44 | 45 | if IsSameBasicElement(tmp_be1, tmp_be2) 46 | res = true; 47 | return; 48 | else 49 | res = false; 50 | end 51 | end 52 | end 53 | 54 | end 55 | 56 | function res = IsSameBasicElement(be1, be2) 57 | %{ 58 | detail: to judge the two basic elements are same 59 | Input: be1,be2 --> the basic elements(a struct array) 60 | Output: res --> true/false 61 | %} 62 | N = length(be1); 63 | flag = false(N,1); 64 | for n = 1:N 65 | if strcmpi(be1{n}, be2{n}) 66 | flag(n) = true; 67 | end 68 | end 69 | if sum(flag) == N 70 | res = true; 71 | else 72 | res = false; 73 | end 74 | end 75 | 76 | %{ 77 | function res = IsSameBasicElement(be1, be2) 78 | %{ 79 | detail: to judge the two basic elements are same 80 | Input: be1,be2 --> the basic elements(a struct array) 81 | Output: res --> true/false 82 | %} 83 | flag_num_planes = false; 84 | flag_type = false; 85 | flag_curvatrue = false; 86 | 87 | if be1.num_planes == be2.num_planes 88 | flag_num_planes = true; 89 | end 90 | if be1.type == be2.type 91 | flag_type = true; 92 | end 93 | if be1.curvature == be2.curvature 94 | flag_curvatrue = true; 95 | end 96 | res = flag_num_planes & flag_type & flag_curvatrue; 97 | end 98 | %} -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/evid_set.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-A New Structure of the Focal Element in Object/evid_set.mat -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/importfile_ionosphere.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-A New Structure of the Focal Element in Object/importfile_ionosphere.m -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/importfile_sonar.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-A New Structure of the Focal Element in Object/importfile_sonar.m -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/importfile_wdbc.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-A New Structure of the Focal Element in Object/importfile_wdbc.m -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/innerEntropy.m: -------------------------------------------------------------------------------- 1 | function [ innE ] = innerEntropy( evid_c ) 2 | %% WITHINENTROPY: this function is used to compute the within entropy of a evidence class 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: evid_c --> a evidence class (a cell array) 7 | Output: innE --> the within entropy of this evidence class 8 | [Tips]: This function is based on the special design of the system to 9 | calculate some parameters. So this function only can be used under the data 10 | structure in this system. 11 | %} 12 | len = length(evid_c); 13 | belief_E_Pyra = zeros(1, len); % belief entropy 14 | core_E_Pyra = zeros(1, len); % core entropy 15 | Fdiv_Pyra = zeros(1, len); % focal divergence 16 | 17 | In_E_Pyra = zeros(1, len); % inner entropy 18 | for n = 1:len 19 | belief_E_Pyra(n) = beliefEntropy(evid_c{n}); 20 | core_E_Pyra(n) = coreEntropy(evid_c{n}); 21 | Fdiv_Pyra(n) = FocalDivergence(evid_c{n}); 22 | 23 | within_Entropy = belief_E_Pyra(n) + core_E_Pyra(n); 24 | In_E_Pyra(n) = within_Entropy + Fdiv_Pyra(n); 25 | end 26 | 27 | innE = sum(In_E_Pyra); 28 | end 29 | 30 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/interactionDimension.m: -------------------------------------------------------------------------------- 1 | function [ dim ] = interactionDimension( evid_c, evid ) 2 | %% INTERACTIONDIMENSION: this function is used to compute the aggregate dimension(evidence and class) 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: evid_c --> a class evidence information(a cell array) 7 | evid --> a unknown class evidence 8 | Output: dim --> the interaction dimension between evidence and class 9 | 10 | [Tips]: This function is based on the special design of the system to 11 | calculate some parameters. So this function only can be used under the data 12 | structure in this system. 13 | %} 14 | 15 | len = length(evid_c); 16 | dim = zeros(1, len); 17 | 18 | parfor n = 1:len 19 | evid_tmp = evid_c{n}; 20 | 21 | dim(n) = interactDim(evid, evid_tmp); 22 | end 23 | 24 | end 25 | 26 | function dim = interactDim(evid1, evid2) 27 | %{ 28 | detail: to calculate the interaction dimension between two evidence. 29 | Input: evid1,evid2 --> the evidence 30 | Output: dim --> the interaction dimension 31 | %} 32 | belief_e1 = beliefEntropy(evid1); 33 | belief_e2 = beliefEntropy(evid2); 34 | 35 | core_e1 = coreEntropy(evid1); 36 | core_e2 = coreEntropy(evid2); 37 | 38 | FocalDiv_1 = FocalDivergence(evid1); 39 | FocalDiv_2 = FocalDivergence(evid2); 40 | 41 | % within set entropy 42 | within_e1 = belief_e1 + core_e1 + FocalDiv_1; 43 | within_e2 = belief_e2 + core_e2 + FocalDiv_2; 44 | 45 | % divergence between two evidence 46 | div_e1e2 = Divergence(evid1, evid2); 47 | 48 | dim = (within_e1 + within_e2)/(within_e1 + within_e2 + div_e1e2); 49 | end 50 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/ionosphere.names: -------------------------------------------------------------------------------- 1 | 1. Title: Johns Hopkins University Ionosphere database 2 | 3 | 2. Source Information: 4 | -- Donor: Vince Sigillito (vgs@aplcen.apl.jhu.edu) 5 | -- Date: 1989 6 | -- Source: Space Physics Group 7 | Applied Physics Laboratory 8 | Johns Hopkins University 9 | Johns Hopkins Road 10 | Laurel, MD 20723 11 | 12 | 3. Past Usage: 13 | -- Sigillito, V. G., Wing, S. P., Hutton, L. V., \& Baker, K. B. (1989). 14 | Classification of radar returns from the ionosphere using neural 15 | networks. Johns Hopkins APL Technical Digest, 10, 262-266. 16 | 17 | They investigated using backprop and the perceptron training algorithm 18 | on this database. Using the first 200 instances for training, which 19 | were carefully split almost 50% positive and 50% negative, they found 20 | that a "linear" perceptron attained 90.7%, a "non-linear" perceptron 21 | attained 92%, and backprop an average of over 96% accuracy on the 22 | remaining 150 test instances, consisting of 123 "good" and only 24 "bad" 23 | instances. (There was a counting error or some mistake somewhere; there 24 | are a total of 351 rather than 350 instances in this domain.) Accuracy 25 | on "good" instances was much higher than for "bad" instances. Backprop 26 | was tested with several different numbers of hidden units (in [0,15]) 27 | and incremental results were also reported (corresponding to how well 28 | the different variants of backprop did after a periodic number of 29 | epochs). 30 | 31 | David Aha (aha@ics.uci.edu) briefly investigated this database. 32 | He found that nearest neighbor attains an accuracy of 92.1%, that 33 | Ross Quinlan's C4 algorithm attains 94.0% (no windowing), and that 34 | IB3 (Aha \& Kibler, IJCAI-1989) attained 96.7% (parameter settings: 35 | 70% and 80% for acceptance and dropping respectively). 36 | 37 | 4. Relevant Information: 38 | This radar data was collected by a system in Goose Bay, Labrador. This 39 | system consists of a phased array of 16 high-frequency antennas with a 40 | total transmitted power on the order of 6.4 kilowatts. See the paper 41 | for more details. The targets were free electrons in the ionosphere. 42 | "Good" radar returns are those showing evidence of some type of structure 43 | in the ionosphere. "Bad" returns are those that do not; their signals pass 44 | through the ionosphere. 45 | 46 | Received signals were processed using an autocorrelation function whose 47 | arguments are the time of a pulse and the pulse number. There were 17 48 | pulse numbers for the Goose Bay system. Instances in this databse are 49 | described by 2 attributes per pulse number, corresponding to the complex 50 | values returned by the function resulting from the complex electromagnetic 51 | signal. 52 | 53 | 5. Number of Instances: 351 54 | 55 | 6. Number of Attributes: 34 plus the class attribute 56 | -- All 34 predictor attributes are continuous 57 | 58 | 7. Attribute Information: 59 | -- All 34 are continuous, as described above 60 | -- The 35th attribute is either "good" or "bad" according to the definition 61 | summarized above. This is a binary classification task. 62 | 63 | 8. Missing Values: None 64 | 65 | 66 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/iris_matlab.txt: -------------------------------------------------------------------------------- 1 | 1 5.1 3.5 1.4 0.2 setosa 2 | 2 4.9 3 1.4 0.2 setosa 3 | 3 4.7 3.2 1.3 0.2 setosa 4 | 4 4.6 3.1 1.5 0.2 setosa 5 | 5 5 3.6 1.4 0.2 setosa 6 | 6 5.4 3.9 1.7 0.4 setosa 7 | 7 4.6 3.4 1.4 0.3 setosa 8 | 8 5 3.4 1.5 0.2 setosa 9 | 9 4.4 2.9 1.4 0.2 setosa 10 | 10 4.9 3.1 1.5 0.1 setosa 11 | 11 5.4 3.7 1.5 0.2 setosa 12 | 12 4.8 3.4 1.6 0.2 setosa 13 | 13 4.8 3 1.4 0.1 setosa 14 | 14 4.3 3 1.1 0.1 setosa 15 | 15 5.8 4 1.2 0.2 setosa 16 | 16 5.7 4.4 1.5 0.4 setosa 17 | 17 5.4 3.9 1.3 0.4 setosa 18 | 18 5.1 3.5 1.4 0.3 setosa 19 | 19 5.7 3.8 1.7 0.3 setosa 20 | 20 5.1 3.8 1.5 0.3 setosa 21 | 21 5.4 3.4 1.7 0.2 setosa 22 | 22 5.1 3.7 1.5 0.4 setosa 23 | 23 4.6 3.6 1 0.2 setosa 24 | 24 5.1 3.3 1.7 0.5 setosa 25 | 25 4.8 3.4 1.9 0.2 setosa 26 | 26 5 3 1.6 0.2 setosa 27 | 27 5 3.4 1.6 0.4 setosa 28 | 28 5.2 3.5 1.5 0.2 setosa 29 | 29 5.2 3.4 1.4 0.2 setosa 30 | 30 4.7 3.2 1.6 0.2 setosa 31 | 31 4.8 3.1 1.6 0.2 setosa 32 | 32 5.4 3.4 1.5 0.4 setosa 33 | 33 5.2 4.1 1.5 0.1 setosa 34 | 34 5.5 4.2 1.4 0.2 setosa 35 | 35 4.9 3.1 1.5 0.2 setosa 36 | 36 5 3.2 1.2 0.2 setosa 37 | 37 5.5 3.5 1.3 0.2 setosa 38 | 38 4.9 3.6 1.4 0.1 setosa 39 | 39 4.4 3 1.3 0.2 setosa 40 | 40 5.1 3.4 1.5 0.2 setosa 41 | 41 5 3.5 1.3 0.3 setosa 42 | 42 4.5 2.3 1.3 0.3 setosa 43 | 43 4.4 3.2 1.3 0.2 setosa 44 | 44 5 3.5 1.6 0.6 setosa 45 | 45 5.1 3.8 1.9 0.4 setosa 46 | 46 4.8 3 1.4 0.3 setosa 47 | 47 5.1 3.8 1.6 0.2 setosa 48 | 48 4.6 3.2 1.4 0.2 setosa 49 | 49 5.3 3.7 1.5 0.2 setosa 50 | 50 5 3.3 1.4 0.2 setosa 51 | 51 7 3.2 4.7 1.4 versicolor 52 | 52 6.4 3.2 4.5 1.5 versicolor 53 | 53 6.9 3.1 4.9 1.5 versicolor 54 | 54 5.5 2.3 4 1.3 versicolor 55 | 55 6.5 2.8 4.6 1.5 versicolor 56 | 56 5.7 2.8 4.5 1.3 versicolor 57 | 57 6.3 3.3 4.7 1.6 versicolor 58 | 58 4.9 2.4 3.3 1 versicolor 59 | 59 6.6 2.9 4.6 1.3 versicolor 60 | 60 5.2 2.7 3.9 1.4 versicolor 61 | 61 5 2 3.5 1 versicolor 62 | 62 5.9 3 4.2 1.5 versicolor 63 | 63 6 2.2 4 1 versicolor 64 | 64 6.1 2.9 4.7 1.4 versicolor 65 | 65 5.6 2.9 3.6 1.3 versicolor 66 | 66 6.7 3.1 4.4 1.4 versicolor 67 | 67 5.6 3 4.5 1.5 versicolor 68 | 68 5.8 2.7 4.1 1 versicolor 69 | 69 6.2 2.2 4.5 1.5 versicolor 70 | 70 5.6 2.5 3.9 1.1 versicolor 71 | 71 5.9 3.2 4.8 1.8 versicolor 72 | 72 6.1 2.8 4 1.3 versicolor 73 | 73 6.3 2.5 4.9 1.5 versicolor 74 | 74 6.1 2.8 4.7 1.2 versicolor 75 | 75 6.4 2.9 4.3 1.3 versicolor 76 | 76 6.6 3 4.4 1.4 versicolor 77 | 77 6.8 2.8 4.8 1.4 versicolor 78 | 78 6.7 3 5 1.7 versicolor 79 | 79 6 2.9 4.5 1.5 versicolor 80 | 80 5.7 2.6 3.5 1 versicolor 81 | 81 5.5 2.4 3.8 1.1 versicolor 82 | 82 5.5 2.4 3.7 1 versicolor 83 | 83 5.8 2.7 3.9 1.2 versicolor 84 | 84 6 2.7 5.1 1.6 versicolor 85 | 85 5.4 3 4.5 1.5 versicolor 86 | 86 6 3.4 4.5 1.6 versicolor 87 | 87 6.7 3.1 4.7 1.5 versicolor 88 | 88 6.3 2.3 4.4 1.3 versicolor 89 | 89 5.6 3 4.1 1.3 versicolor 90 | 90 5.5 2.5 4 1.3 versicolor 91 | 91 5.5 2.6 4.4 1.2 versicolor 92 | 92 6.1 3 4.6 1.4 versicolor 93 | 93 5.8 2.6 4 1.2 versicolor 94 | 94 5 2.3 3.3 1 versicolor 95 | 95 5.6 2.7 4.2 1.3 versicolor 96 | 96 5.7 3 4.2 1.2 versicolor 97 | 97 5.7 2.9 4.2 1.3 versicolor 98 | 98 6.2 2.9 4.3 1.3 versicolor 99 | 99 5.1 2.5 3 1.1 versicolor 100 | 100 5.7 2.8 4.1 1.3 versicolor 101 | 101 6.3 3.3 6 2.5 virginica 102 | 102 5.8 2.7 5.1 1.9 virginica 103 | 103 7.1 3 5.9 2.1 virginica 104 | 104 6.3 2.9 5.6 1.8 virginica 105 | 105 6.5 3 5.8 2.2 virginica 106 | 106 7.6 3 6.6 2.1 virginica 107 | 107 4.9 2.5 4.5 1.7 virginica 108 | 108 7.3 2.9 6.3 1.8 virginica 109 | 109 6.7 2.5 5.8 1.8 virginica 110 | 110 7.2 3.6 6.1 2.5 virginica 111 | 111 6.5 3.2 5.1 2 virginica 112 | 112 6.4 2.7 5.3 1.9 virginica 113 | 113 6.8 3 5.5 2.1 virginica 114 | 114 5.7 2.5 5 2 virginica 115 | 115 5.8 2.8 5.1 2.4 virginica 116 | 116 6.4 3.2 5.3 2.3 virginica 117 | 117 6.5 3 5.5 1.8 virginica 118 | 118 7.7 3.8 6.7 2.2 virginica 119 | 119 7.7 2.6 6.9 2.3 virginica 120 | 120 6 2.2 5 1.5 virginica 121 | 121 6.9 3.2 5.7 2.3 virginica 122 | 122 5.6 2.8 4.9 2 virginica 123 | 123 7.7 2.8 6.7 2 virginica 124 | 124 6.3 2.7 4.9 1.8 virginica 125 | 125 6.7 3.3 5.7 2.1 virginica 126 | 126 7.2 3.2 6 1.8 virginica 127 | 127 6.2 2.8 4.8 1.8 virginica 128 | 128 6.1 3 4.9 1.8 virginica 129 | 129 6.4 2.8 5.6 2.1 virginica 130 | 130 7.2 3 5.8 1.6 virginica 131 | 131 7.4 2.8 6.1 1.9 virginica 132 | 132 7.9 3.8 6.4 2 virginica 133 | 133 6.4 2.8 5.6 2.2 virginica 134 | 134 6.3 2.8 5.1 1.5 virginica 135 | 135 6.1 2.6 5.6 1.4 virginica 136 | 136 7.7 3 6.1 2.3 virginica 137 | 137 6.3 3.4 5.6 2.4 virginica 138 | 138 6.4 3.1 5.5 1.8 virginica 139 | 139 6 3 4.8 1.8 virginica 140 | 140 6.9 3.1 5.4 2.1 virginica 141 | 141 6.7 3.1 5.6 2.4 virginica 142 | 142 6.9 3.1 5.1 2.3 virginica 143 | 143 5.8 2.7 5.1 1.9 virginica 144 | 144 6.8 3.2 5.9 2.3 virginica 145 | 145 6.7 3.3 5.7 2.5 virginica 146 | 146 6.7 3 5.2 2.3 virginica 147 | 147 6.3 2.5 5 1.9 virginica 148 | 148 6.5 3 5.2 2 virginica 149 | 149 6.2 3.4 5.4 2.3 virginica 150 | 150 5.9 3 5.1 1.8 virginica 151 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/lib/DBSCAN.m: -------------------------------------------------------------------------------- 1 | function Clust = DBSCAN(DistMat,Eps,MinPts) 2 | %A simple DBSCAN implementation of the original paper: 3 | %"A Density-Based Algorithm for Discovering Clusters in Large Spatial 4 | %Databases with Noise" -- Martin Ester et.al. 5 | %Since no spatial access method is implemented, the run time complexity 6 | %will be N^2 rather than N*logN 7 | %************************************************************************** 8 | %Input: DistMat, Eps, MinPts 9 | %DistMat: A N*N distance matrix, the (i,j) element contains the distance 10 | %from point-i to point-j. 11 | 12 | %Eps: A scalar value for Epsilon-neighborhood threshold. 13 | 14 | %MinPts: A scalar value for minimum points in Eps-neighborhood that holds 15 | %the core-point condition. 16 | %************************************************************************** 17 | %Output: Clust 18 | %Clust: A N*1 vector describes the cluster membership for each point. 0 is 19 | %reserved for NOISE. 20 | %************************************************************************** 21 | %Written by Tianxiao Jiang, jtxinnocence@gmail.com 22 | %Nov-4-2015 23 | %************************************************************************** 24 | 25 | %Initialize Cluster membership as -1, which means UNCLASSIFIED 26 | Clust=zeros(size(DistMat,1),1)-1; 27 | ClusterId=1; 28 | 29 | %randomly choose the visiting order 30 | VisitSequence=randperm(length(Clust)); 31 | 32 | for i=1:length(Clust) 33 | % For each point, check if it is not visited yet (unclassified) 34 | pt=VisitSequence(i); 35 | if Clust(pt)==-1 36 | %Iteratively expand the cluster through density-reachability 37 | [Clust,isnoise]=ExpandCluster(DistMat,pt,ClusterId,Eps,MinPts,Clust); 38 | if ~isnoise 39 | ClusterId=ClusterId+1; 40 | end 41 | end 42 | end 43 | 44 | end 45 | 46 | function [Clust,isnoise]=ExpandCluster(DistMat,pt,ClusterId,Eps,MinPts,Clust) 47 | 48 | %region query 49 | seeds=find(DistMat(:,pt)<=Eps); 50 | 51 | if length(seeds)=MinPts 64 | for i=1:length(result) 65 | resultP=result(i); 66 | if Clust(resultP)==-1||Clust(resultP)==0 % unclassified or noise 67 | if Clust(resultP)==-1 %unclassified 68 | seeds=[seeds(:);resultP]; 69 | end 70 | Clust(resultP)=ClusterId; 71 | end 72 | 73 | end 74 | end 75 | seeds=setxor(seeds,currentP); 76 | end 77 | isnoise=false; 78 | return 79 | end 80 | end 81 | 82 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/lib/computeFoldSizes.m: -------------------------------------------------------------------------------- 1 | function [foldSizes] = computeFoldSizes(vecsPerCat, numFolds) 2 | %COMPUTEFOLDSIZES Compute the fold sizes for the provided data set. 3 | % [foldSizes] = computeFoldSizes(vecsPerCat, numFolds); 4 | % 5 | % Part of performing n-fold cross-validation. See 'getFoldVectors'. 6 | % 7 | % Parameters: 8 | % vecsPerCat - Column vector with the number of vectors in the data set for 9 | % each category. 10 | % numFolds - The number of folds you'll be using for cross validation. 11 | % 12 | % Returns: 13 | % A matrix (with size numCategories x numFolds) containing the number of 14 | % vectors to include in each of the 'numFolds' folds for each category. 15 | 16 | % $Author: ChrisMcCormick $ $Date: 2013/07/31 22:00:00 $ $Revision: 1.0 $ 17 | 18 | % Get the number of categories present. 19 | numCats = numel(vecsPerCat); 20 | 21 | % For each category... 22 | for (i = 1 : numCats) 23 | 24 | % Get the number of vectors for this category; 25 | numVecs = vecsPerCat(i, 1); 26 | 27 | % Verify that there are at least 'numFolds' samples. 28 | if (numVecs < numFolds) 29 | disp("ERROR! Each category must have at least 'numFolds' samples."); 30 | return; 31 | end 32 | end 33 | 34 | % foldSizes will be a matrix holding the number of vectors to place in each fold 35 | % for each category. The number of folds may not divide evenly into the number 36 | % of vectors, so we need to distribute the remainder. 37 | foldSizes = zeros(numCats, numFolds); 38 | 39 | % For each category... 40 | for (i = 1 : numCats) 41 | 42 | % Get the the number of vectors for this category. 43 | numVecs = vecsPerCat(i, 1); 44 | 45 | % For each of the ten folds... 46 | for (fold = 1 : numFolds) 47 | 48 | % Divide the remaining number of vectors by the remaining number of folds. 49 | foldSize = ceil(numVecs / (numFolds - fold + 1)); 50 | 51 | % Store the fold size. 52 | foldSizes(i, fold) = foldSize; 53 | 54 | % Update the number of remaining vectors for this category. 55 | numVecs = numVecs - foldSize; 56 | end 57 | end 58 | 59 | % Verify the fold sizes sum up correctly. 60 | if (any(sum(foldSizes, 2) ~= vecsPerCat)) 61 | disp("ERROR! The sum of fold sizes did not equal the number of category vectors."); 62 | return; 63 | end 64 | 65 | end 66 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/lib/demo_kfoldValidation.m: -------------------------------------------------------------------------------- 1 | data=load('wine.data'); 2 | [N, cols] = size(data); Num_Attr = cols - 1; 3 | X = data(:,2:cols); y = data(:,1); 4 | % List out the category values in use. 5 | % categories = [0; 1]; 6 | categories = unique(y); 7 | 8 | % Get the number of vectors belonging to each category. 9 | vecsPerCat = getVecsPerCat(X, y, categories); 10 | 11 | % Compute the fold sizes for each category. 12 | k = 3; 13 | foldSizes = computeFoldSizes(vecsPerCat, k); 14 | 15 | % Randomly sort the vectors in X, then organize them by category. 16 | [X_sorted, y_sorted] = randSortAndGroup(X, y, categories); 17 | 18 | % For each round of cross-validation... 19 | for (roundNumber = 1 : k) 20 | 21 | % Select the vectors to use for training and cross validation. 22 | [X_train, y_train, X_val, y_val] = getFoldVectors(X_sorted, y_sorted, categories, vecsPerCat, foldSizes, roundNumber); 23 | 24 | % Train the classifier on the training set, X_train y_train 25 | % ..................... 26 | 27 | % Measure the classification accuracy on the validation set. 28 | % ..................... 29 | 30 | end -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/lib/getFoldVectors.m: -------------------------------------------------------------------------------- 1 | function [X_train, y_train, X_val, y_val] = getFoldVectors(X_sorted, y_sorted, ... 2 | categories, vecsPerCat, ... 3 | foldSizes, roundNumber) 4 | %GETFOLDVECTORS Selects the vectors to use for training and validation for the 5 | % specified round number. 6 | % [X_train, y_train, X_val, y_val] = getFoldVectors(X_sorted, y_sorted, ... 7 | % categories, vecsPerCat, ... 8 | % foldSizes, roundNumber) 9 | % 10 | % With n-fold cross-validation, the data set is divided into n folds, and then 11 | % training and validation are performed in 'n' separate rounds. In each round, 12 | % 1 fold is used for validation while the remaining n - 1 folds are used for 13 | % training. 14 | % 15 | % Parameters: 16 | % X_sorted - The matrix of input vectors, one per row, grouped by 17 | % category. 18 | % y_sorted - The category or class label of the associated input vector. 19 | % categories - A column vector listing the category values in use by this 20 | % data set. 21 | % vecsPerCat - Column vector listing the number of vectors in the dataset 22 | % for each category. 23 | % foldSizes - The precomputed fold sizes for each category. 24 | % roundNumber - The current round of validation (a value between 1 and the 25 | % number of folds). 26 | % 27 | % Returns: 28 | % Vectors to use for training in this round (with their associated 29 | % categories) and vectors to use for validation in this round (also with 30 | % their associated categories). 31 | 32 | % $Author: ChrisMcCormick $ $Date: 2013/07/31 22:00:00 $ $Revision: 1.0 $ 33 | 34 | X_train = []; 35 | y_train = []; 36 | X_val = []; 37 | y_val = []; 38 | 39 | % ================================ 40 | % Verify Sorting 41 | % ================================ 42 | 43 | % Verify the vectors are properly sorted. 44 | catStart = 1; 45 | 46 | % For each category... 47 | for (i = 1 : numel(categories)) 48 | 49 | % Compute the index of the last vector of this category. 50 | catEnd = catStart + vecsPerCat(i) - 1; 51 | 52 | % Verify that all of the vectors in the range catStart : catEnd have 53 | % the expected category. 54 | if (any(y_sorted(catStart : catEnd) ~= categories(i))) 55 | disp("Input vectors are not properly sorted!"); 56 | return; 57 | end 58 | 59 | % Set the starting index of the next category. 60 | catStart = catEnd + 1; 61 | end 62 | 63 | % ================================== 64 | % Select Vectors 65 | % ================================== 66 | 67 | % Get the number of folds from the foldSizes matrix. 68 | [~,numFolds] = size(foldSizes); 69 | 70 | catStart = 1; 71 | 72 | % For each category... 73 | for (catIndex = 1 : numel(categories)) 74 | 75 | % Get the list of fold sizes for this category as a column vector. 76 | catFoldSizes = foldSizes(catIndex, :)'; 77 | 78 | % Set the starting index of the first fold for this category. 79 | foldStart = catStart; 80 | 81 | % For each fold... 82 | for (foldIndex = 1 : numFolds) 83 | 84 | % Compute the index of the last vector in this fold. 85 | foldEnd = foldStart + catFoldSizes(foldIndex) - 1; 86 | 87 | % Select all of the vectors in this fold. 88 | foldVectors = X_sorted(foldStart : foldEnd, :); 89 | foldCats = y_sorted(foldStart : foldEnd, :); 90 | 91 | % If this fold is to be used for validation in this round... 92 | if (foldIndex == roundNumber) 93 | % Append the vectors to the validation set. 94 | X_val = [X_val; foldVectors]; 95 | y_val = [y_val; foldCats]; 96 | % Otherwise, use the fold for training. 97 | else 98 | % Append the vectors to the training set. 99 | X_train = [X_train; foldVectors]; 100 | y_train = [y_train; foldCats]; 101 | end 102 | 103 | % Update the starting index of the next fold. 104 | foldStart = foldEnd + 1; 105 | end 106 | 107 | % Set the starting index of the next category. 108 | catStart = catStart + vecsPerCat(catIndex); 109 | end 110 | 111 | end 112 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/lib/getVecsPerCat.m: -------------------------------------------------------------------------------- 1 | function [vecsPerCat] = getVecsPerCat(X, y, categories) 2 | %GETVECSPERCAT Get the number of vectors in X belonging to each category. 3 | % vecsPerCat = getVecsPerCat(X, y, categories); 4 | % 5 | % The vectors may be supplied in any order (they don't need to be grouped by 6 | % category) and the category values do not have to be contiguous (you could 7 | % have categories 1, 2 and 5, for example). 8 | % 9 | % Parameters: 10 | % X - The matrix of input vectors, one per row. 11 | % y - The category or class label of the associated input vector. 12 | % categories - A column vector listing the category values in use by this 13 | % data set. 14 | % 15 | % Returns: 16 | % A column vector containing the number of vectors in X belonging to each 17 | % category. 18 | 19 | % $Author: ChrisMcCormick $ $Date: 2013/07/31 22:00:00 $ $Revision: 1.0 $ 20 | 21 | % Get the number of categories present. 22 | numCats = length(categories); 23 | 24 | % 'vecsPerCat' will store the number of input vectors belonging to each category. 25 | vecsPerCat = zeros(numCats, 1); 26 | 27 | % For each category... 28 | for (i = 1 : numCats) 29 | 30 | % Get the ith category; store the category value in column 1. 31 | cat = categories(i); 32 | 33 | % Count the number of input vectors with that category. 34 | vecsPerCat(i, 1) = sum(y == cat); 35 | end 36 | 37 | end -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/lib/randSortAndGroup.m: -------------------------------------------------------------------------------- 1 | function [X_sorted, y_sorted] = randSortAndGroup(X, y, categories) 2 | %RANDSORTANDGROUP Randomly sort the vectors in X, then group them by category. 3 | % [X_sorted, y_sorted] = randSortAndGroup(X, y, categories); 4 | % 5 | % Parameters: 6 | % X - The matrix of input vectors, one per row. 7 | % y - The category or class label of the associated input vector. 8 | % categories - A column vector listing the category values in use by this data set. 9 | % 10 | % Returns: 11 | % The inputs X and y but with the vectors grouped by category and in a random 12 | % order within their category. 13 | 14 | % $Author: ChrisMcCormick $ $Date: 2013/07/31 22:00:00 $ $Revision: 1.0 $ 15 | 16 | % ====================================== 17 | % Randomly Sort The Vectors 18 | % ====================================== 19 | 20 | % Get the total number of input vectors. 21 | [totalVecs,~] = size(X); 22 | 23 | % Get a random order of the indeces. 24 | randOrder = randperm(totalVecs)'; 25 | 26 | % Sort the vectors and categories with the random order. 27 | randVecs = X(randOrder, :); 28 | randCats = y(randOrder, :); 29 | 30 | X_sorted = []; 31 | y_sorted = []; 32 | 33 | % ======================================= 34 | % Group The Vectors By Category 35 | % ======================================= 36 | 37 | % Re-group the vectors according to category. 38 | Num_categories = numel(categories); 39 | for (i = 1 : Num_categories) 40 | 41 | % Get the next category value. 42 | cat = categories(i); 43 | 44 | % Select all of the vectors for this category. 45 | catVecs = randVecs((randCats == cat), :); 46 | catCats = randCats((randCats == cat), :); 47 | 48 | % Append the vectors for this category. 49 | X_sorted = [X_sorted; catVecs]; 50 | y_sorted = [y_sorted; catCats]; 51 | end 52 | 53 | end 54 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/loadIRIS_new.m: -------------------------------------------------------------------------------- 1 | function [ evid_set ] = loadIRIS_new( data, TotalNum, typeClass ) 2 | %% basic information 3 | Num_class = length(typeClass); 4 | [N, tt] = size(data); 5 | Num_Attr = tt-1; % The first is class; 6 | %% create the full library(transform the source data to BPA) 7 | % calculate the mean and std of every attributes of every class 8 | mean_mat = zeros(Num_class, Num_Attr); % row: same class; col: same attribute 9 | std_mat = zeros(Num_class, Num_Attr); 10 | record_mat = cell(Num_class, Num_Attr); 11 | for m = 1:Num_Attr % for each attribute 12 | 13 | for k = 1:Num_class 14 | tmp_vec = zeros(TotalNum(k),1); t=1; 15 | for n = 1:N % for each sample 16 | tmp_attr = data(n,m+1); 17 | if k == data(n,1) 18 | tmp_vec(t) = tmp_attr; 19 | t = t+1; 20 | end 21 | end 22 | record_mat(k,m) = {tmp_vec}; 23 | % calcualte the mean and std value 24 | mean_mat(k,m) = mean(tmp_vec); 25 | std_mat(k,m) = std(tmp_vec); 26 | end 27 | end 28 | 29 | %% generator the BPA for each samples -- new structure 30 | evid_set = cell(N, 1); 31 | for k = 1:N % for each sample 32 | tmp_samples = data(k,2:Num_Attr+1); 33 | tmp_vec = zeros(Num_Attr, 1); 34 | fe_vec = cell(Num_class, Num_Attr); % each row is a focal elements 35 | fe_bpa = zeros(Num_class, Num_Attr); 36 | for m = 1:Num_Attr 37 | % generate the BPA for each attributes 38 | tmp_attr = tmp_samples(m); 39 | tmp_bpa_vec = zeros(Num_class, 1); 40 | for n = 1:Num_class 41 | mu = mean_mat(n,m); s = std_mat(n,m); 42 | tmp_func = @(x)(1/sqrt(2*pi*s^2)*exp(-(x-mu)^2/(2*s^2))); 43 | 44 | tt = tmp_func(tmp_attr); 45 | if (tmp_attrmu+3*s) 46 | tt = 0; 47 | end 48 | tmp_bpa_vec(n) = tt; 49 | end 50 | tmp_bpa_vec = tmp_bpa_vec/(sum(tmp_bpa_vec)+eps); % for No.44 51 | tt = [tmp_bpa_vec, (1:Num_class)']; 52 | 53 | % allocate the basic element 54 | tt2 = sortrows(tt, 1, 'descend'); 55 | for n = 1:Num_class 56 | fe_vec(n,m) = typeClass(tt2(n,2)); 57 | fe_bpa(n,m) = tt2(n,1); 58 | end 59 | end 60 | % construct the focal element 61 | tmp_evid = [];tt = 0;uni_set = createKnowledgeLib(typeClass, Num_Attr); 62 | for n = 1:Num_class 63 | tmp_bpa = mean(fe_bpa(n,:)); 64 | tmp_fe.basicElement = {fe_vec(n,:)}; 65 | tmp_fe.bpa = tmp_bpa; 66 | tmp_evid = [tmp_evid, tmp_fe]; tt = tt + tmp_bpa; 67 | end 68 | % for universal set 69 | tmp_fe.basicElement = uni_set; 70 | if tt > 1 71 | for n = 1:Num_class 72 | tmp_evid(n).bpa = tmp_evid(n).bpa/tt; 73 | end 74 | tmp_fe.bpa = 0; 75 | else 76 | tmp_fe.bpa = 1-tt; 77 | end 78 | tmp_evid = [tmp_evid, tmp_fe]; 79 | evid_set(k) = {tmp_evid}; 80 | end 81 | 82 | end 83 | 84 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/loadIRIS_tradition.m: -------------------------------------------------------------------------------- 1 | function [ evid_set ] = loadIRIS_tradition( data, TotalNum, typeClass) 2 | %% basic information 3 | Num_class = length(typeClass); 4 | [N, tt] = size(data); 5 | Num_Attr = tt-1; % The first is class; 6 | %% create the full library(transform the source data to BPA) 7 | % calculate the mean and std of every attributes of every class 8 | mean_mat = zeros(Num_class, Num_Attr); % row: same class; col: same attribute 9 | std_mat = zeros(Num_class, Num_Attr); 10 | record_mat = cell(Num_class, Num_Attr); 11 | for m = 1:Num_Attr % for each attribute 12 | 13 | for k = 1:Num_class 14 | tmp_vec = zeros(TotalNum(k),1); t=1; 15 | for n = 1:N % for each sample 16 | tmp_attr = data(n,m+1); 17 | if k == data(n,1) 18 | tmp_vec(t) = tmp_attr; 19 | t = t+1; 20 | end 21 | end 22 | record_mat(k,m) = {tmp_vec}; 23 | % calcualte the mean and std value 24 | mean_mat(k,m) = mean(tmp_vec); 25 | std_mat(k,m) = std(tmp_vec); 26 | end 27 | end 28 | 29 | %% generator the BPA for each samples -- traditional structure 30 | evid_set = cell(N, 1); 31 | for k = 1:N % for each sample 32 | tmp_samples = data(k,2:Num_Attr+1); 33 | tmp_vec = zeros(Num_Attr, 1); 34 | fe_vec = cell(Num_class, Num_Attr); % each row is a focal elements 35 | fe_bpa = zeros(Num_class, Num_Attr); 36 | 37 | tt_evid = []; 38 | for m = 1:Num_Attr 39 | % generate the BPA for each attributes 40 | tmp_attr = tmp_samples(m); 41 | tmp_bpa_vec = zeros(Num_class, 1); 42 | for n = 1:Num_class 43 | mu = mean_mat(n,m); s = std_mat(n,m); 44 | tmp_func = @(x)(1/sqrt(2*pi*s^2)*exp(-(x-mu)^2/(2*s^2))); 45 | 46 | tt = tmp_func(tmp_attr); 47 | if (tmp_attrmu+3*s) 48 | tt = 0; 49 | end 50 | tmp_bpa_vec(n) = tt; 51 | end 52 | tmp_bpa_vec = tmp_bpa_vec/(sum(tmp_bpa_vec)+eps); % for No.44 53 | tt = [tmp_bpa_vec, (1:Num_class)']; 54 | 55 | % allocate the basic element 56 | tt2 = sortrows(tt, 1, 'descend'); 57 | for n = 1:Num_class 58 | fe_vec(n,m) = typeClass(tt2(n,2)); 59 | fe_bpa(n,m) = tt2(n,1); 60 | end 61 | % construct the focal element 62 | tmp_evid = [];tt = 0; tmp_fe.basicElement = {}; 63 | for n = 1:Num_class 64 | tmp_fe.basicElement = [tmp_fe.basicElement, fe_vec(n,m)]; 65 | tmp_fe.bpa = fe_bpa(n,m); 66 | tmp_evid = [tmp_evid, tmp_fe]; tt = tt + tmp_fe.bpa; 67 | end 68 | % normalization 69 | for n = 1:Num_class 70 | tmp_evid(n).bpa = tmp_evid(n).bpa/tt; 71 | end 72 | tt_evid = [tt_evid, {tmp_evid}]; 73 | end 74 | evid_set(k) = {tt_evid}; 75 | end 76 | 77 | 78 | end 79 | 80 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/loadSonar_new.m: -------------------------------------------------------------------------------- 1 | function [ evid_set ] = loadSonar_new( data, typeClass ) 2 | 3 | [ evid_set ] = loadWine_new( data, typeClass ); 4 | 5 | end 6 | 7 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/loadSonar_tradition.m: -------------------------------------------------------------------------------- 1 | function [ evid_set ] = loadSonar_tradition( data, typeClass ) 2 | % the implement is same 3 | evid_set = loadWine_tradition(data, typeClass); 4 | 5 | end 6 | 7 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/loadWDBC_new.m: -------------------------------------------------------------------------------- 1 | function [ evid_set ] = loadWDBC_new( data, typeClass ) 2 | Num_class = length(typeClass); 3 | [N, tt] = size(data); 4 | Num_Attr = tt-1; % The first is class; 5 | %% create the full library(transform the source data to BPA) 6 | % simple statistics 7 | tt = data(:,1); TotalNum = zeros(Num_class, 1); 8 | for n = 1:Num_class 9 | TotalNum(n) = length(find(tt == n)); 10 | end 11 | % calculate the mean and std of every attributes of every class 12 | mean_mat = zeros(Num_class, Num_Attr); % row: same class; col: same attribute 13 | std_mat = zeros(Num_class, Num_Attr); 14 | record_mat = cell(Num_class, Num_Attr); 15 | for m = 1:Num_Attr % for each attribute 16 | 17 | for k = 1:Num_class 18 | tmp_vec = zeros(TotalNum(k),1); t=1; 19 | for n = 1:N % for each sample 20 | tmp_attr = data(n,m+1); 21 | if k == data(n,1) 22 | tmp_vec(t) = tmp_attr; 23 | t = t+1; 24 | end 25 | end 26 | record_mat(k,m) = {tmp_vec}; 27 | % calcualte the mean and std value 28 | mean_mat(k,m) = mean(tmp_vec); 29 | std_mat(k,m) = std(tmp_vec); 30 | end 31 | end 32 | 33 | %% generator the BPA for each samples -- traditional structure 34 | evid_set = cell(N, 1); 35 | for k = 1:N % for each sample 36 | tmp_samples = data(k,2:Num_Attr+1); 37 | tmp_vec = zeros(Num_Attr, 1); 38 | fe_vec = cell(Num_class, Num_Attr); % each row is a focal elements 39 | fe_bpa = zeros(Num_class, Num_Attr); 40 | 41 | tt_evid = []; 42 | for m = 1:Num_Attr 43 | % generate the BPA for each attributes 44 | tmp_attr = tmp_samples(m); 45 | tmp_bpa_vec = zeros(Num_class, 1); 46 | for n = 1:Num_class 47 | mu = mean_mat(n,m); s = std_mat(n,m); 48 | tmp_func = @(x)(1/sqrt(2*pi*s^2)*exp(-(x-mu)^2/(2*s^2))); 49 | 50 | tt = tmp_func(tmp_attr); 51 | if (tmp_attrmu+3*s) 52 | tt = 0; 53 | end 54 | tmp_bpa_vec(n) = tt; 55 | end 56 | tmp_bpa_vec = tmp_bpa_vec/(sum(tmp_bpa_vec)+eps); % for No.44 57 | tt = [tmp_bpa_vec, (1:Num_class)']; 58 | 59 | % allocate the basic element 60 | tt2 = sortrows(tt, 1, 'descend'); 61 | for n = 1:Num_class 62 | fe_vec(n,m) = typeClass(tt2(n,2)); 63 | fe_bpa(n,m) = tt2(n,1); 64 | end 65 | end 66 | % construct the focal element 67 | tmp_evid = [];tt = 0;uni_set = [];% createKnowledgeLib(typeClass, Num_Attr); 68 | for n = 1:Num_class 69 | tmp_bpa = mean(fe_bpa(n,:)); 70 | tmp_fe.basicElement = {fe_vec(n,:)}; 71 | tmp_fe.bpa = tmp_bpa; 72 | tmp_evid = [tmp_evid, tmp_fe]; tt = tt + tmp_bpa; 73 | end 74 | % for universal set 75 | tmp_fe.basicElement = uni_set; 76 | if tt > 1 77 | for n = 1:Num_class 78 | tmp_evid(n).bpa = tmp_evid(n).bpa/tt; 79 | end 80 | tmp_fe.bpa = 0; 81 | else 82 | tmp_fe.bpa = 1-tt; 83 | end 84 | tmp_evid = [tmp_evid, tmp_fe]; 85 | evid_set(k) = {tmp_evid}; 86 | end 87 | 88 | end 89 | 90 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/loadWDBC_tradition.m: -------------------------------------------------------------------------------- 1 | function [ evid_set ] = loadWDBC_tradition( data, typeClass ) 2 | % the implement is same 3 | evid_set = loadWine_tradition(data, typeClass); 4 | end 5 | 6 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/loadWine.m: -------------------------------------------------------------------------------- 1 | clc;clear all;close all; 2 | 3 | typeClass = [{'c1'}; {'c2'}; {'c3'}]; 4 | Num_class = length(typeClass); 5 | 6 | data=load('wine.data'); 7 | [N, tt] = size(data); 8 | Num_Attr = tt-1; % The first is class; 9 | %% create the full library(transform the source data to BPA) 10 | % simple statistics 11 | tt = data(:,1); TotalNum = zeros(Num_class, 1); 12 | for n = 1:Num_class 13 | TotalNum(n) = length(find(tt == n)); 14 | end 15 | % calculate the mean and std of every attributes of every class 16 | mean_mat = zeros(Num_class, Num_Attr); % row: same class; col: same attribute 17 | std_mat = zeros(Num_class, Num_Attr); 18 | record_mat = cell(Num_class, Num_Attr); 19 | for m = 1:Num_Attr % for each attribute 20 | 21 | for k = 1:Num_class 22 | tmp_vec = zeros(TotalNum(k),1); t=1; 23 | for n = 1:N % for each sample 24 | tmp_attr = data(n,m+1); 25 | if k == data(n,1) 26 | tmp_vec(t) = tmp_attr; 27 | t = t+1; 28 | end 29 | end 30 | record_mat(k,m) = {tmp_vec}; 31 | % calcualte the mean and std value 32 | mean_mat(k,m) = mean(tmp_vec); 33 | std_mat(k,m) = std(tmp_vec); 34 | end 35 | end 36 | 37 | %% generator the BPA for each samples -- traditional structure 38 | evid_set = cell(N, 1); 39 | for k = 1:N % for each sample 40 | tmp_samples = data(k,2:Num_Attr+1); 41 | tmp_vec = zeros(Num_Attr, 1); 42 | fe_vec = cell(Num_class, Num_Attr); % each row is a focal elements 43 | fe_bpa = zeros(Num_class, Num_Attr); 44 | 45 | tt_evid = []; 46 | for m = 1:Num_Attr 47 | % generate the BPA for each attributes 48 | tmp_attr = tmp_samples(m); 49 | tmp_bpa_vec = zeros(Num_class, 1); 50 | for n = 1:Num_class 51 | mu = mean_mat(n,m); s = std_mat(n,m); 52 | tmp_func = @(x)(1/sqrt(2*pi*s^2)*exp(-(x-mu)^2/(2*s^2))); 53 | 54 | tt = tmp_func(tmp_attr); 55 | if (tmp_attrmu+3*s) 56 | tt = 0; 57 | end 58 | tmp_bpa_vec(n) = tt; 59 | end 60 | tmp_bpa_vec = tmp_bpa_vec/(sum(tmp_bpa_vec)+eps); % for No.44 61 | tt = [tmp_bpa_vec, (1:Num_class)']; 62 | 63 | % allocate the basic element 64 | tt2 = sortrows(tt, 1, 'descend'); 65 | for n = 1:Num_class 66 | fe_vec(n,m) = typeClass(tt2(n,2)); 67 | fe_bpa(n,m) = tt2(n,1); 68 | end 69 | % construct the focal element 70 | tmp_evid = [];tt = 0; tmp_fe.basicElement = {}; 71 | for n = 1:Num_class 72 | tmp_fe.basicElement = [tmp_fe.basicElement, fe_vec(n,m)]; 73 | tmp_fe.bpa = fe_bpa(n,m); 74 | tmp_evid = [tmp_evid, tmp_fe]; tt = tt + tmp_fe.bpa; 75 | end 76 | % normalization 77 | for n = 1:Num_class 78 | tmp_evid(n).bpa = tmp_evid(n).bpa/tt; 79 | end 80 | tt_evid = [tt_evid, {tmp_evid}]; 81 | end 82 | evid_set(k) = {tt_evid}; 83 | end 84 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/loadWine_new.m: -------------------------------------------------------------------------------- 1 | function [ evid_set ] = loadWine_new( data, typeClass ) 2 | Num_class = length(typeClass); 3 | [N, tt] = size(data); 4 | Num_Attr = tt-1; % The first is class; 5 | %% create the full library(transform the source data to BPA) 6 | % simple statistics 7 | tt = data(:,1); TotalNum = zeros(Num_class, 1); 8 | for n = 1:Num_class 9 | TotalNum(n) = length(find(tt == n)); 10 | end 11 | % calculate the mean and std of every attributes of every class 12 | mean_mat = zeros(Num_class, Num_Attr); % row: same class; col: same attribute 13 | std_mat = zeros(Num_class, Num_Attr); 14 | record_mat = cell(Num_class, Num_Attr); 15 | for m = 1:Num_Attr % for each attribute 16 | 17 | for k = 1:Num_class 18 | tmp_vec = zeros(TotalNum(k),1); t=1; 19 | for n = 1:N % for each sample 20 | tmp_attr = data(n,m+1); 21 | if k == data(n,1) 22 | tmp_vec(t) = tmp_attr; 23 | t = t+1; 24 | end 25 | end 26 | record_mat(k,m) = {tmp_vec}; 27 | % calcualte the mean and std value 28 | mean_mat(k,m) = mean(tmp_vec); 29 | std_mat(k,m) = std(tmp_vec); 30 | end 31 | end 32 | 33 | %% generator the BPA for each samples -- traditional structure 34 | evid_set = cell(N, 1); 35 | for k = 1:N % for each sample 36 | tmp_samples = data(k,2:Num_Attr+1); 37 | tmp_vec = zeros(Num_Attr, 1); 38 | fe_vec = cell(Num_class, Num_Attr); % each row is a focal elements 39 | fe_bpa = zeros(Num_class, Num_Attr); 40 | 41 | tt_evid = []; 42 | for m = 1:Num_Attr 43 | % generate the BPA for each attributes 44 | tmp_attr = tmp_samples(m); 45 | tmp_bpa_vec = zeros(Num_class, 1); 46 | for n = 1:Num_class 47 | mu = mean_mat(n,m); s = std_mat(n,m)+eps; 48 | tmp_func = @(x)(1/sqrt(2*pi*s^2)*exp(-(x-mu)^2/(2*s^2))); 49 | 50 | tt = tmp_func(tmp_attr); 51 | if (tmp_attrmu+3*s) 52 | tt = 0; 53 | end 54 | tmp_bpa_vec(n) = tt; 55 | end 56 | tmp_bpa_vec = tmp_bpa_vec/(sum(tmp_bpa_vec)+eps); % for No.44 57 | tt = [tmp_bpa_vec, (1:Num_class)']; 58 | 59 | % allocate the basic element 60 | tt2 = sortrows(tt, 1, 'descend'); 61 | for n = 1:Num_class 62 | fe_vec(n,m) = typeClass(tt2(n,2)); 63 | fe_bpa(n,m) = tt2(n,1); 64 | end 65 | end 66 | % construct the focal element 67 | tmp_evid = [];tt = 0;uni_set = [];% createKnowledgeLib(typeClass, Num_Attr); 68 | for n = 1:Num_class 69 | tmp_bpa = mean(fe_bpa(n,:)); 70 | tmp_fe.basicElement = {fe_vec(n,:)}; 71 | tmp_fe.bpa = tmp_bpa; 72 | tmp_evid = [tmp_evid, tmp_fe]; tt = tt + tmp_bpa; 73 | end 74 | % for universal set 75 | tmp_fe.basicElement = uni_set; 76 | if tt > 1 77 | for n = 1:Num_class 78 | tmp_evid(n).bpa = tmp_evid(n).bpa/tt; 79 | end 80 | tmp_fe.bpa = 0; 81 | else 82 | tmp_fe.bpa = 1-tt; 83 | end 84 | tmp_evid = [tmp_evid, tmp_fe]; 85 | evid_set(k) = {tmp_evid}; 86 | end 87 | 88 | end 89 | 90 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/loadWine_tradition.m: -------------------------------------------------------------------------------- 1 | function [ evid_set ] = loadWine_tradition( data, typeClass ) 2 | Num_class = length(typeClass); 3 | [N, tt] = size(data); 4 | Num_Attr = tt-1; % The first is class; 5 | %% create the full library(transform the source data to BPA) 6 | % simple statistics 7 | tt = data(:,1); TotalNum = zeros(Num_class, 1); 8 | for n = 1:Num_class 9 | TotalNum(n) = length(find(tt == n)); 10 | end 11 | % calculate the mean and std of every attributes of every class 12 | mean_mat = zeros(Num_class, Num_Attr); % row: same class; col: same attribute 13 | std_mat = zeros(Num_class, Num_Attr); 14 | record_mat = cell(Num_class, Num_Attr); 15 | for m = 1:Num_Attr % for each attribute 16 | 17 | for k = 1:Num_class 18 | tmp_vec = zeros(TotalNum(k),1); t=1; 19 | for n = 1:N % for each sample 20 | tmp_attr = data(n,m+1); 21 | if k == data(n,1) 22 | tmp_vec(t) = tmp_attr; 23 | t = t+1; 24 | end 25 | end 26 | if isempty(tmp_vec) 27 | mean_mat(k,m) = 0; 28 | std_mat(k,m) = 0; 29 | continue; 30 | end 31 | 32 | record_mat(k,m) = {tmp_vec}; 33 | % calcualte the mean and std value 34 | mean_mat(k,m) = mean(tmp_vec); 35 | std_mat(k,m) = std(tmp_vec); 36 | end 37 | end 38 | 39 | %% generator the BPA for each samples -- traditional structure 40 | evid_set = cell(N, 1); 41 | for k = 1:N % for each sample 42 | tmp_samples = data(k,2:Num_Attr+1); 43 | tmp_vec = zeros(Num_Attr, 1); 44 | fe_vec = cell(Num_class, Num_Attr); % each row is a focal elements 45 | fe_bpa = zeros(Num_class, Num_Attr); 46 | 47 | tt_evid = []; 48 | for m = 1:Num_Attr 49 | % generate the BPA for each attributes 50 | tmp_attr = tmp_samples(m); 51 | tmp_bpa_vec = zeros(Num_class, 1); 52 | for n = 1:Num_class 53 | mu = mean_mat(n,m); s = std_mat(n,m)+eps; 54 | tmp_func = @(x)(1/sqrt(2*pi*s^2)*exp(-(x-mu)^2/(2*s^2))); 55 | 56 | tt = tmp_func(tmp_attr); 57 | if (tmp_attrmu+3*s) 58 | tt = 0; 59 | end 60 | tmp_bpa_vec(n) = tt; 61 | end 62 | tmp_bpa_vec = tmp_bpa_vec/(sum(tmp_bpa_vec)+eps); % for No.44 63 | tt = [tmp_bpa_vec, (1:Num_class)']; 64 | 65 | % allocate the basic element 66 | tt2 = sortrows(tt, 1, 'descend'); 67 | for n = 1:Num_class 68 | fe_vec(n,m) = typeClass(tt2(n,2)); 69 | fe_bpa(n,m) = tt2(n,1); 70 | end 71 | % construct the focal element 72 | tmp_evid = [];tt = 0; tmp_fe.basicElement = {}; 73 | for n = 1:Num_class 74 | tmp_fe.basicElement = [tmp_fe.basicElement, fe_vec(n,m)]; 75 | tmp_fe.bpa = fe_bpa(n,m); 76 | tmp_evid = [tmp_evid, tmp_fe]; tt = tt + tmp_fe.bpa; 77 | end 78 | % normalization 79 | for n = 1:Num_class 80 | tmp_evid(n).bpa = tmp_evid(n).bpa/tt; 81 | end 82 | tt_evid = [tt_evid, {tmp_evid}]; 83 | end 84 | evid_set(k) = {tt_evid}; 85 | end 86 | 87 | end 88 | 89 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/pignistic_prop_trans.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-A New Structure of the Focal Element in Object/pignistic_prop_trans.m -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/wine.names: -------------------------------------------------------------------------------- 1 | 1. Title of Database: Wine recognition data 2 | Updated Sept 21, 1998 by C.Blake : Added attribute information 3 | 4 | 2. Sources: 5 | (a) Forina, M. et al, PARVUS - An Extendible Package for Data 6 | Exploration, Classification and Correlation. Institute of Pharmaceutical 7 | and Food Analysis and Technologies, Via Brigata Salerno, 8 | 16147 Genoa, Italy. 9 | 10 | (b) Stefan Aeberhard, email: stefan@coral.cs.jcu.edu.au 11 | (c) July 1991 12 | 3. Past Usage: 13 | 14 | (1) 15 | S. Aeberhard, D. Coomans and O. de Vel, 16 | Comparison of Classifiers in High Dimensional Settings, 17 | Tech. Rep. no. 92-02, (1992), Dept. of Computer Science and Dept. of 18 | Mathematics and Statistics, James Cook University of North Queensland. 19 | (Also submitted to Technometrics). 20 | 21 | The data was used with many others for comparing various 22 | classifiers. The classes are separable, though only RDA 23 | has achieved 100% correct classification. 24 | (RDA : 100%, QDA 99.4%, LDA 98.9%, 1NN 96.1% (z-transformed data)) 25 | (All results using the leave-one-out technique) 26 | 27 | In a classification context, this is a well posed problem 28 | with "well behaved" class structures. A good data set 29 | for first testing of a new classifier, but not very 30 | challenging. 31 | 32 | (2) 33 | S. Aeberhard, D. Coomans and O. de Vel, 34 | "THE CLASSIFICATION PERFORMANCE OF RDA" 35 | Tech. Rep. no. 92-01, (1992), Dept. of Computer Science and Dept. of 36 | Mathematics and Statistics, James Cook University of North Queensland. 37 | (Also submitted to Journal of Chemometrics). 38 | 39 | Here, the data was used to illustrate the superior performance of 40 | the use of a new appreciation function with RDA. 41 | 42 | 4. Relevant Information: 43 | 44 | -- These data are the results of a chemical analysis of 45 | wines grown in the same region in Italy but derived from three 46 | different cultivars. 47 | The analysis determined the quantities of 13 constituents 48 | found in each of the three types of wines. 49 | 50 | -- I think that the initial data set had around 30 variables, but 51 | for some reason I only have the 13 dimensional version. 52 | I had a list of what the 30 or so variables were, but a.) 53 | I lost it, and b.), I would not know which 13 variables 54 | are included in the set. 55 | 56 | -- The attributes are (dontated by Riccardo Leardi, 57 | riclea@anchem.unige.it ) 58 | 1) Alcohol 59 | 2) Malic acid 60 | 3) Ash 61 | 4) Alcalinity of ash 62 | 5) Magnesium 63 | 6) Total phenols 64 | 7) Flavanoids 65 | 8) Nonflavanoid phenols 66 | 9) Proanthocyanins 67 | 10)Color intensity 68 | 11)Hue 69 | 12)OD280/OD315 of diluted wines 70 | 13)Proline 71 | 72 | 5. Number of Instances 73 | 74 | class 1 59 75 | class 2 71 76 | class 3 48 77 | 78 | 6. Number of Attributes 79 | 80 | 13 81 | 82 | 7. For Each Attribute: 83 | 84 | All attributes are continuous 85 | 86 | No statistics available, but suggest to standardise 87 | variables for certain uses (e.g. for us with classifiers 88 | which are NOT scale invariant) 89 | 90 | NOTE: 1st attribute is class identifier (1-3) 91 | 92 | 8. Missing Attribute Values: 93 | 94 | None 95 | 96 | 9. Class Distribution: number of instances per class 97 | 98 | class 1 59 99 | class 2 71 100 | class 3 48 101 | -------------------------------------------------------------------------------- /Code-A New Structure of the Focal Element in Object/属性值-正态分布.vsdx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-A New Structure of the Focal Element in Object/属性值-正态分布.vsdx -------------------------------------------------------------------------------- /Code-Accuracy Enhancement for Noninvasive Glucose Estimation/KernelCalibration_predict.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Accuracy Enhancement for Noninvasive Glucose Estimation/KernelCalibration_predict.m -------------------------------------------------------------------------------- /Code-Accuracy Enhancement for Noninvasive Glucose Estimation/KernelCalibration_train.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Accuracy Enhancement for Noninvasive Glucose Estimation/KernelCalibration_train.m -------------------------------------------------------------------------------- /Code-Accuracy Enhancement for Noninvasive Glucose Estimation/demo.m: -------------------------------------------------------------------------------- 1 | %% Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 2 | % This script is designed to model the signal model of Blood glucose signal 3 | % Author: MarkLHF 4 | % Date: 2021-9-1 5 | % Reference: 6 | 7 | close all; 8 | clear; format long; 9 | 10 | [x,t] = simplefit_dataset; 11 | % train 12 | d = 3; sita = 100; 13 | max_t = max(t);min_t = min(t); 14 | t = (t - mean(t))./max_t; 15 | [ alpha ] = KernelCalibration_train( x', t, 'poly', d ); 16 | % test 17 | y = KernelCalibration_predict(x', x', 'poly', d, alpha); 18 | y = (y - mean(y))./max(y); 19 | 20 | figure; 21 | plot(x,t,'ro');hold on; 22 | plot(x,y,'b-*');hold on; 23 | legend('test-data', 'fitting'); -------------------------------------------------------------------------------- /Code-Adaptive local contrast measure based on local steering kernel/2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Adaptive local contrast measure based on local steering kernel/2.bmp -------------------------------------------------------------------------------- /Code-Adaptive local contrast measure based on local steering kernel/4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Adaptive local contrast measure based on local steering kernel/4.bmp -------------------------------------------------------------------------------- /Code-Adaptive local contrast measure based on local steering kernel/LSK.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Adaptive local contrast measure based on local steering kernel/LSK.m -------------------------------------------------------------------------------- /Code-Adaptive local contrast measure based on local steering kernel/demo.m: -------------------------------------------------------------------------------- 1 | %% This script is designed to implement the measure from the reference article. 2 | % reference: Robust infrared small target detection using local steering kernel reconstruction 3 | % Copyright:2018-9-4 MarkLHF, UESTC.(e-mail:2751867750@qq.com) 4 | clc;close all;clear; 5 | 6 | % [Tips]: the path is data path, you need to CHANGE the path by yourself 7 | addpath('D:\Matlab_program\self-code\test-data'); 8 | % step 1: prepare the test data 9 | Img = imread('0002.bmp'); 10 | figure;imshow(Img);title('test image'); 11 | % step 2: get the patch image 12 | s = 5; % must be odd number 13 | [row, col, channel] = size(Img); 14 | showImg = imresize(Img,[row,col]); 15 | if channel > 1 16 | Img = rgb2gray(Img); 17 | end 18 | padding = (s-1)/2+s; 19 | % 2.1: prepare the deta_coordinate matrix 20 | [ coordinate, ~, len ] = pointVector(-(s-1)/2,(s-1)/2,-(s-1)/2,(s-1)/2); 21 | % 2.2: padding 22 | Img_ex = double(padarray(Img, [padding, padding], 'replicate')); 23 | % 2.3: extract the patch image from the original image 24 | LSK_patch = zeros(s,s,9); 25 | lacm = zeros(row,col); % Local adaptive contrast measure based on regularized LSK 26 | for nrow = 1:row 27 | for ncol = 1:col 28 | % patch image 29 | patch = Img_ex(nrow:nrow+3*s-1,ncol:ncol+3*s-1); 30 | % divide patch Image into 9 parts(3*3=9) 31 | % Tips: I calculate the gradient matrix before segmenting it 32 | [gx, gy] = derivative7(patch, 'x', 'y'); 33 | gx = gx/(max(gx(:))+eps); 34 | gy = gy/(max(gy(:))+eps); 35 | for t = 1:9 36 | % Tips: The reason to set the tt and tp temporal parameter is at 37 | % the bottom 38 | tt = floor((t-1)/3); 39 | tp = mod(t-1,3); 40 | temp_gradient_x = gx(1+tt*s:(tt+1)*s, 1+tp*s:(tp+1)*s); 41 | temp_gradient_y = gy(1+tt*s:(tt+1)*s, 1+tp*s:(tp+1)*s); 42 | % Attention: I DONNOT UNDERSTAND WHY I NEED TO USE THE K 43 | % win = (s-1)/2; 44 | % K = fspecial('disk', win); 45 | % K = K ./ K(win+1, win+1); 46 | % temp_gradient_x = temp_gradient_x .* K; 47 | % temp_gradient_y = temp_gradient_y .* K; 48 | % calculate the LSK of the patch 49 | % Tips: LSK must be greater than 0 50 | temp_lsk = LSK(coordinate, s, s, temp_gradient_x, temp_gradient_y); 51 | var = std(temp_lsk(:)); mean_v = mean(temp_lsk(:)); 52 | if var > eps 53 | temp_lsk_norm = normalise(temp_lsk, mean_v, var); 54 | else 55 | temp_lsk_norm = mean_v*ones(size(temp_lsk)); 56 | end 57 | LSK_patch(:,:,t) = temp_lsk_norm; 58 | end 59 | % step 3: construct the fc and fN vector 60 | fc = reshape(LSK_patch(:,:,5), 1, []); % the central patch is 5th 61 | fN = zeros(8, length(fc)); tmp = 1; 62 | for t = 1:9 63 | if t ~= 5 64 | fN(tmp,:) = reshape(LSK_patch(:,:,t), 1, []); 65 | tmp = tmp + 1; 66 | end 67 | end 68 | % step 4: calculate the coefficient vector w of fN 69 | % --- model: Linear weighted model 70 | lamda = 1.0; 71 | w = pinv(fN*fN'+1.0*eye(8))*(fN*fc'); % pinv() == MP-inverse matrix(N*1) 72 | fT = w'*fN; 73 | lacm(nrow,ncol) = norm(fc-fT,2); 74 | end 75 | end 76 | figure;imshow(lacm,[]);title('LACM-LSK result'); 77 | figure;pcolor(lacm);title('LACM-LSK');colorbar; 78 | figure;mesh(lacm);title('LACM-LSK');xlim([0,col]);ylim([0,row]); 79 | %% Detection part 80 | % binaryzation 81 | mean_confidence = mean(lacm(:)); 82 | std_confidence = std(lacm(:)); 83 | level = mean_confidence + 10*std_confidence; 84 | bw = zeros(row,col); 85 | bw(lacm>level) = 1; 86 | bw = logical(bw); 87 | % calculate the position 88 | bw_img = bwlabel(bw); 89 | stats = regionprops(bw_img); 90 | Ar = cat(1, stats.Area); 91 | target = stats(find(Ar ==max(Ar))); 92 | % show 93 | pp = s; 94 | figure;imshow(showImg);title('detect result');%,'border','tight' 95 | for n = 1:length(target) 96 | pos = [(target(n).Centroid - pp/2) [pp pp]]; 97 | rectangle('Position',1*pos,'EdgeColor','r'); 98 | end 99 | %% the explaination for why set temporal parameter: tt and tp 100 | % an analysis of 3 orders 101 | % t = 1,2,3,4,5,6,7,8,9 102 | % tt = 0,0,0,1,1,1,2,2,2 103 | % tp = 0,1,2,0,1,2,0,1,2 104 | % So: tt = floor((t-1)/3); tp = mod((t-1),3); -------------------------------------------------------------------------------- /Code-Adaptive local contrast measure based on local steering kernel/derivative7.m: -------------------------------------------------------------------------------- 1 | % DERIVATIVE7 - 7-Tap 1st and 2nd discrete derivatives 2 | % 3 | % This function computes 1st and 2nd derivatives of an image using the 7-tap 4 | % coefficients given by Farid and Simoncelli. The results are significantly 5 | % more accurate than MATLAB's GRADIENT function on edges that are at angles 6 | % other than vertical or horizontal. This in turn improves gradient orientation 7 | % estimation enormously. 8 | % 9 | % Usage: [gx, gy, gxx, gyy, gxy] = derivative7(im, derivative specifiers) 10 | % 11 | % Arguments: 12 | % im - Image to compute derivatives from. 13 | % derivative specifiers - A comma separated list of character strings 14 | % that can be any of 'x', 'y', 'xx', 'yy' or 'xy' 15 | % These can be in any order, the order of the 16 | % computed output arguments will match the order 17 | % of the derivative specifier strings. 18 | % Returns: 19 | % Function returns requested derivatives which can be: 20 | % gx, gy - 1st derivative in x and y 21 | % gxx, gyy - 2nd derivative in x and y 22 | % gxy - 1st derivative in y of 1st derivative in x 23 | % 24 | % Examples: 25 | % Just compute 1st derivatives in x and y 26 | % [gx, gy] = derivative7(im, 'x', 'y'); 27 | % 28 | % Compute 2nd derivative in x, 1st derivative in y and 2nd derivative in y 29 | % [gxx, gy, gyy] = derivative7(im, 'xx', 'y', 'yy') 30 | % 31 | % See also: DERIVATIVE5 32 | 33 | % Reference: Hany Farid and Eero Simoncelli "Differentiation of Discrete 34 | % Multi-Dimensional Signals" IEEE Trans. Image Processing. 13(4): 496-508 (2004) 35 | 36 | % Copyright (c) 2010 Peter Kovesi 37 | % Centre for Exploration Targeting 38 | % The University of Western Australia 39 | % http://www.csse.uwa.edu.au/~pk/research/matlabfns/ 40 | % 41 | % Permission is hereby granted, free of charge, to any person obtaining a copy 42 | % of this software and associated documentation files (the "Software"), to deal 43 | % in the Software without restriction, subject to the following conditions: 44 | % 45 | % The above copyright notice and this permission notice shall be included in 46 | % all copies or substantial portions of the Software. 47 | % 48 | % The Software is provided "as is", without warranty of any kind. 49 | % 50 | % April 2010 51 | 52 | function varargout = derivative7(im, varargin) 53 | 54 | varargin = varargin(:); 55 | varargout = cell(size(varargin)); 56 | 57 | % 7-tap interpolant and 1st and 2nd derivative coefficients 58 | p = [ 0.004711 0.069321 0.245410 0.361117 0.245410 0.069321 0.004711]; 59 | d1 = [ 0.018708 0.125376 0.193091 0.000000 -0.193091 -0.125376 -0.018708]; 60 | d2 = [ 0.055336 0.137778 -0.056554 -0.273118 -0.056554 0.137778 0.055336]; 61 | 62 | % Compute derivatives. Note that in the 1st call below MATLAB's conv2 63 | % function performs a 1D convolution down the columns using p then a 1D 64 | % convolution along the rows using d1. etc etc. 65 | gx = false; 66 | for n = 1:length(varargin) 67 | if strcmpi('x', varargin{n}) 68 | varargout{n} = conv2(p, d1, im, 'same'); 69 | gx = true; % Record that gx is available for gxy if needed 70 | gxn = n; 71 | elseif strcmpi('y', varargin{n}) 72 | varargout{n} = conv2(d1, p, im, 'same'); 73 | elseif strcmpi('xx', varargin{n}) 74 | varargout{n} = conv2(p, d2, im, 'same'); 75 | elseif strcmpi('yy', varargin{n}) 76 | varargout{n} = conv2(d2, p, im, 'same'); 77 | elseif strcmpi('xy', varargin{n}) | strcmpi('yx', varargin{n}) 78 | if gx 79 | varargout{n} = conv2(d1, p, varargout{gxn}, 'same'); 80 | else 81 | gx = conv2(p, d1, im, 'same'); 82 | varargout{n} = conv2(d1, p, gx, 'same'); 83 | end 84 | else 85 | error(sprintf('''%s'' is an unrecognized derivative option',varargin{n})); 86 | end 87 | end 88 | 89 | -------------------------------------------------------------------------------- /Code-Adaptive local contrast measure based on local steering kernel/normalise.m: -------------------------------------------------------------------------------- 1 | % NORMALISE - Normalises image values to 0-1, or to desired mean and variance 2 | % 3 | % Usage: 4 | % n = normalise(im) 5 | % 6 | % Offsets and rescales image so that the minimum value is 0 7 | % and the maximum value is 1. Result is returned in n. If the image is 8 | % colour the image is converted to HSV and the value/intensity component 9 | % is normalised to 0-1 before being converted back to RGB. 10 | % 11 | % 12 | % n = normalise(im, reqmean, reqvar) 13 | % 14 | % Arguments: im - A grey-level input image. 15 | % reqmean - The required mean value of the image. 16 | % reqvar - The required variance of the image. 17 | % 18 | % Offsets and rescales image so that it has mean reqmean and variance 19 | % reqvar. Colour images cannot be normalised in this manner. 20 | 21 | % Copyright (c) 1996-2005 Peter Kovesi 22 | % School of Computer Science & Software Engineering 23 | % The University of Western Australia 24 | % http://www.csse.uwa.edu.au/ 25 | % 26 | % Permission is hereby granted, free of charge, to any person obtaining a copy 27 | % of this software and associated documentation files (the "Software"), to deal 28 | % in the Software without restriction, subject to the following conditions: 29 | % 30 | % The above copyright notice and this permission notice shall be included in 31 | % all copies or substantial portions of the Software. 32 | % 33 | % The Software is provided "as is", without warranty of any kind. 34 | 35 | % January 2005 - modified to allow desired mean and variance 36 | 37 | 38 | function n = normalise(im, reqmean, reqvar) 39 | 40 | if ~(nargin == 1 | nargin == 3) 41 | error('No of arguments must be 1 or 3'); 42 | end 43 | 44 | if nargin == 1 % Normalise 0 - 1 45 | if ndims(im) == 3 % Assume colour image 46 | hsv = rgb2hsv(im); 47 | v = hsv(:,:,3); 48 | v = v - min(v(:)); % Just normalise value component 49 | v = v/max(v(:)); 50 | hsv(:,:,3) = v; 51 | n = hsv2rgb(hsv); 52 | else % Assume greyscale 53 | if ~isa(im,'double'), im = double(im); end 54 | n = im - min(im(:)); 55 | n = n/max(n(:)); 56 | end 57 | 58 | else % Normalise to desired mean and variance 59 | 60 | if ndims(im) == 3 % colour image? 61 | error('cannot normalise colour image to desired mean and variance'); 62 | end 63 | 64 | if ~isa(im,'double'), im = double(im); end 65 | im = im - mean(im(:)); 66 | im = im/std(im(:)); % Zero mean, unit std dev 67 | 68 | n = reqmean + im*sqrt(reqvar); 69 | end 70 | -------------------------------------------------------------------------------- /Code-Adaptive local contrast measure based on local steering kernel/pointVector.m: -------------------------------------------------------------------------------- 1 | function [ output_args, center_point, length ] = pointVector( x_start, x_end, y_start, y_end ) 2 | % Summary: this function construct a vector of point with the first col is 3 | % x coordinates and the second col is y coordinates 4 | % Copyright:2018-9-6 MarkLHF, UESTC.(e-mail:2751867750@qq.com) 5 | %{ 6 | detail 7 | Input: x_start --> the start point of x 8 | x_end --> the end point of x 9 | y_start --> the start point of y 10 | y_end --> the end point of y 11 | Output: output_args --> the vector of point 12 | center_point --> the vector of central point 13 | length --> the length of output_args 14 | Tips: the input of number must be non-negetive integer 15 | %} 16 | 17 | % step 1: calculate the total number of the point in the vector 18 | num_x = abs(x_end - x_start) + 1; % x is 19 | num_y = abs(y_end - y_start) + 1; 20 | num_total = num_x * num_y; 21 | length = num_total; 22 | output_args = zeros(num_total, 2); 23 | % step 2: fill the matrix -> output_args 24 | % -- output_args: like [x,y]; the first col is x coordinates and the second 25 | % is y 26 | vector_y = y_start : y_end; 27 | vector_x = x_start : x_end; 28 | vector_t = ones(num_y, 1); 29 | for n = 1:num_x 30 | output_args(1+(n-1)*num_y:n*num_y, 1) = vector_t * vector_x(n); 31 | output_args(1+(n-1)*num_y:n*num_y, 2) = vector_y; 32 | end 33 | center_point = [round((x_start+x_end)/2), round((y_start+y_end)/2)]; 34 | end 35 | 36 | -------------------------------------------------------------------------------- /Code-Adaptive local contrast measure based on local steering kernel/pp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Adaptive local contrast measure based on local steering kernel/pp.jpg -------------------------------------------------------------------------------- /Code-Adaptive local contrast measure based on local steering kernel/pp2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Adaptive local contrast measure based on local steering kernel/pp2.jpg -------------------------------------------------------------------------------- /Code-Bayesian inference for adaptive low rank/arllr.m: -------------------------------------------------------------------------------- 1 | function [ X, E ] = arllr( input_args, sita ) 2 | %% ARLLR 3 | % reference: Unsupervised ridge detection using second order anisotropic Gaussian kernels 4 | % Copyright:2019-2-27 MarkLHF, UESTC.(e-mail:2751867750@qq.com) 5 | %{ 6 | detail 7 | Input: input_args --> the input image(2D, and double type,range[0,1]); 8 | sita --> a parameter(10*-4) 9 | Output: X --> the reconstruction(2D, double) 10 | E --> the residual 11 | %} 12 | %% get the basic information and allocate the store space 13 | % sita = 10^-4; 14 | [row, col] = size(input_args); 15 | X = zeros(row, col); 16 | E = zeros(row, col); 17 | 18 | sigma = 1/(5*std(input_args(:))); 19 | tao = 1.2*sqrt(2)*sigma^2; 20 | total_itera = 1; 21 | 22 | % get the singular value matrix of Y and X 23 | 24 | [U, t_sig_Y, V] = svd(input_args, 'econ'); 25 | sig_Y = diag(t_sig_Y); 26 | 27 | %% main loop 28 | for k = 1:total_itera 29 | %% calculate the every singular 30 | sig_X = proximal_log(sig_Y, tao, sita, 1); 31 | % reconstruct 32 | S_x = diag(sig_X); 33 | X = U * S_x * V'; 34 | %% update 35 | E = input_args - X; 36 | end 37 | 38 | 39 | end 40 | 41 | -------------------------------------------------------------------------------- /Code-Bayesian inference for adaptive low rank/arllre.m: -------------------------------------------------------------------------------- 1 | function [ output_X, output_E, list_e_norm ] = arllre( input_args, itera, show_debug) 2 | %% ARLLRE 3 | % reference: Unsupervised ridge detection using second order anisotropic Gaussian kernels 4 | % Copyright:2019-2-27 MarkLHF, UESTC.(e-mail:2751867750@qq.com) 5 | %{ 6 | detail 7 | Input: input_args --> the input image(2D, and double type); 8 | itera --> the number of iteration; 9 | show_debug --> the switch to show the debug information 10 | Output: output_X --> the reconstruction(2D, double) 11 | output_E --> the residual 12 | list_e_norm --> the list of the norm of E matrix 13 | %} 14 | %% get the basic information and allocate the store space 15 | [row, col] = size(input_args); 16 | 17 | sita = 10^-4; 18 | % sigma = 1/(5*std(input_args(:))); 19 | % tao = 1.2*sqrt(2)*sigma^2; 20 | mu = 1 / (5*std(input_args(:))); 21 | 22 | X = zeros(row, col); 23 | W = zeros(row, col); 24 | E = zeros(row, col); 25 | 26 | list_e_norm = zeros(itera, 1); 27 | %% main loop 28 | for k = 1:itera 29 | tic; 30 | %% update the X_k+1 matrix 31 | % get matrix of Z_X 32 | Z_X = input_args - E + W./mu; 33 | % get the singular value matrix of Z_k+1 34 | [U, t_sig_Y, V] = svd(Z_X); 35 | sig_Y = diag(t_sig_Y); 36 | 37 | % sigma = 1/(5*std(Z_X(:))); 38 | tao = 1/mu; 39 | % calculate the every singular by proximal operator algorithm 40 | sig_X = proximal_log(sig_Y, tao, sita, 1); 41 | 42 | % reconstruct 43 | S_x = diag(sig_X); 44 | if row >= col 45 | d = row - col; 46 | S_x = [S_x; zeros(d, col)]; 47 | else 48 | d = col - row; 49 | S_x = [S_x, zeors(row, d)]; 50 | end 51 | newX = U * S_x * V'; 52 | % newX = singularValueShrinkage(Z_X, tao); 53 | %% update the E matrix 54 | % get matrix of Z_E 55 | Z_E = input_args - newX + W./mu; 56 | % calculate the every singular by proximal operator algorithm 57 | tt = 0.9*max(Z_E(:)); 58 | coeff_t = 0.5*tt^2/(log(abs(tt)/sita+1)); 59 | % [ATTENTION] if you have some question about the 'coeff_t' parameter, 60 | % please contract me to get more detail by the e-mail on the top. 61 | 62 | % [Tips]:the coeff before the matrix E is very important 63 | t_ze = reshape(Z_E, [row*col, 1]); 64 | t_E = proximal_log(t_ze, coeff_t, sita, 1); % tips: sig_E 65 | newE = reshape(t_E, [row, col]); 66 | % newE = softThreshold(Z_E .* (Z_E>0), lamda/mu); 67 | 68 | % the function can show the figure of objective function 69 | % [Tips] the part is just show the objective function, without other 70 | % meaning. 71 | % figure; 72 | % if max(t_ze) > 0 73 | % xmax = max(t_ze); 74 | % xmin = 0; 75 | % else 76 | % xmax = 0; 77 | % xmin = max(t_ze); 78 | % end 79 | % padding = (xmax - xmin)/10; 80 | % xmin = xmin - padding; 81 | % xmax = xmax + padding; 82 | % ezplot(sprintf('%f*log(abs(x)+%f)+0.5*(%f-x)^2', tao/lamda, sita, max(t_ze)),[xmin, xmax]);hold on; 83 | % title('the max(t_ze) of objective funtion'); 84 | % figure; 85 | % if min(t_ze) > 0 86 | % xmax = min(t_ze); 87 | % xmin = 0; 88 | % else 89 | % xmax = 0; 90 | % xmin = min(t_ze); 91 | % end 92 | % padding = (xmax - xmin)/10; 93 | % xmin = xmin - padding; 94 | % xmax = xmax + padding; 95 | % ezplot(sprintf('%f*log(abs(x)+%f)+0.5*(%f-x)^2', tao_e, sita, min(t_ze)),[xmin, xmax]);hold on; 96 | % title('the min(t_ze) of objective funtion'); 97 | %% update the W matrix and mu 98 | newW = W + mu*(input_args - newX - newE); 99 | new_mu = 1.5*mu; 100 | 101 | elapsedTime = toc; 102 | %% record and stop criterion 103 | stopCriterion = norm(input_args - newX - newE, 'fro') / norm(input_args, 'fro'); 104 | list_e_norm(k) = stopCriterion; 105 | if show_debug 106 | disp(sprintf("[#Iter %2d] time is %f, ||E||_f: %f", k, elapsedTime, list_e_norm(k))); 107 | pause(0.01); 108 | end 109 | if stopCriterion < 1e-5 110 | break; 111 | end 112 | %% Assignment to continue 113 | X = newX; E = newE; 114 | W = newW; mu = new_mu; 115 | end 116 | %% output 117 | output_X = X; 118 | output_E = E; 119 | end 120 | 121 | -------------------------------------------------------------------------------- /Code-Bayesian inference for adaptive low rank/gen_patch_img.m: -------------------------------------------------------------------------------- 1 | function patchImg = gen_patch_img(img, patchSize, slideStep) 2 | %% GEN_PATCH_IMG 3 | % This matlab code generates the patch-image for infrared 4 | % patch-image model. 5 | % Copyright:2019-3-12 MarkLHF, UESTC.(e-mail:2751867750@qq.com) 6 | % Tianfang Zhang, UESTC.(e-mail:sparkcarleton@gmail.com) 7 | %{ 8 | detail 9 | Input: img --> the input image(2D, and uint8 type); 10 | patchSize --> the size of patch(size = patchSize*patchSize) 11 | slideStep --> the step of slide window 12 | Output: patchImg --> the patch image(2D, double) 13 | %} 14 | if ~exist('patchSize', 'var') 15 | patchSize = 50; 16 | end 17 | if ~exist('slideStep', 'var') 18 | slideStep = 10; 19 | end 20 | 21 | % img = reshape(1:9, [3 3]) 22 | % img = reshape(1:12, [3 4]) 23 | 24 | [row, col] = size(img); 25 | D = zeros(patchSize*patchSize, (length(1:slideStep:row-patchSize)*length(1:slideStep:col-patchSize))); 26 | counter = 1; 27 | 28 | %% arrayfun version, identical to the following for-loop version 29 | for i = 1:slideStep:row-patchSize 30 | for j = 1:slideStep:col-patchSize 31 | tmp_patch = img(i:i+patchSize-1, j:j+patchSize-1); 32 | D(:, counter) = reshape(tmp_patch, patchSize*patchSize, 1); 33 | counter = counter + 1; 34 | end 35 | end 36 | %% output 37 | patchImg = D; 38 | %% for-loop version 39 | % patchImg = zeros(patchSize * patchSize, rowPatchNum * colPatchNum); 40 | % k = 0; 41 | % for col = colPosArr 42 | % for row = rowPosArr 43 | % k = k + 1; 44 | % tmp_patch = img(row : row + patchSize - 1, col : col + patchSize - 1); 45 | % patchImg(:, k) = tmp_patch(:); 46 | % end 47 | % end 48 | 49 | -------------------------------------------------------------------------------- /Code-Bayesian inference for adaptive low rank/main.m: -------------------------------------------------------------------------------- 1 | %% This script is designed to implement the method from the reference article. 2 | % reference: Bayesian inference for adaptive low rank and sparse matrix estimation 3 | % Author: MarkLHF (2751867750@qq.com) 4 | % Date: 2019/3/6 5 | close all;clear; 6 | detection = 0; 7 | addpath(genpath('D:\Matlab_program\reference\TFOCS')); 8 | %% IPI model 9 | % input test image 10 | ii = 1; 11 | I = imread(strcat(num2str((ii)),'.bmp')); 12 | figure;imshow(I); 13 | [p, q, z]=size(I); 14 | 15 | % rgb2gray 16 | if z==3 17 | I=rgb2gray(I); 18 | end 19 | 20 | % set patch size (adjustable) 21 | patchSize = 50; 22 | slideStep = 10; 23 | 24 | % patch model 25 | % I = im2double(I); 26 | I_double = im2double(I); 27 | D = gen_patch_img(I_double, patchSize, slideStep); 28 | 29 | 30 | [mm, nn]=size(D); 31 | % parameters setting 32 | % lambda =1/(sqrt(min(mm,nn)))*2; 33 | % mu=sqrt(2*max(mm,nn))*4; % this value is related to the degree of noise 34 | % 35 | % SparseRatio = 0.05; 36 | % E_true = zeros(size(D)); 37 | % Eomega = randsample(mm*nn, round(mm*nn*SparseRatio)); 38 | % E_true(Eomega) = rand(length(Eomega),1); % sparse component 39 | 40 | %% Run ARLLR 41 | tic 42 | % [X_hat_t, ~, ~, E_hat_t] = VBRPCA(D,options); 43 | % [X_hat, E_hat] = arllr(D, 10^-4); 44 | [X_hat, E_hat, list_e_norm] = arllre(D, 100, 1); 45 | toc 46 | %% Reconstruct background and target image 47 | [rstT, rstB] = res_patch_img_mean(E_hat, X_hat, I_double, patchSize, slideStep); 48 | % Show the result 49 | figure; 50 | % Tips: the negative value is ignored 51 | subplot(121),imshow(rstT .* (rstT>0), []),title('Target'); 52 | subplot(122),imshow(rstB .* (rstB>0), []),title('Background'); 53 | figure;mesh(rstT.* (rstT>0));title('residual'); 54 | % figure;plot(list_e_norm,'r.-');hold on;title('the norm of residual'); 55 | %% Run toolbox TFOCS 56 | % Ref:http://cvxr.com/tfocs/ 57 | sigma = 1/(5*std(D(:))); 58 | tao = 1.2*sqrt(2)*sigma^2; 59 | lamda = 1; 60 | tol = 5e-3; 61 | 62 | % x_recon = tfocs(smooth_quad, {eye(mm), -D}, proj_l1(tao)); 63 | 64 | %% Detection part 65 | if detection 66 | % binaryzation 67 | mean_confidence = mean(corrupted(:)); 68 | std_confidence = std(corrupted(:)); 69 | level = mean_confidence + 5*std_confidence; 70 | bw = zeros(p,q); 71 | bw(corrupted>level) = 1; 72 | bw = logical(bw); 73 | % calculate the position 74 | bw_img = bwlabel(bw); 75 | stats = regionprops(bw_img, 'Area'); %#ok 76 | Ar = cat(1, stats.Area); 77 | target = stats(find(Ar ==max(Ar))); %#ok 78 | % show 79 | pp = 10; 80 | figure;imshow(I)%,'border','tight');%title('detect result');%,'border','tight' 81 | for n = 1:length(target) 82 | pos = [(target(n).Centroid - pp/2) [pp pp]]; 83 | rectangle('Position',1*pos,'EdgeColor','r'); 84 | end 85 | %% save the result to BMP image 86 | % save target result 87 | save_result = corrupted - min(corrupted(:)); 88 | save_result = save_result/max(save_result(:)); 89 | save_result_tmp = uint8(save_result*255); 90 | % imwrite(save_result_tmp, strcat('target_',num2str((ii)),'.bmp')); 91 | % save background result 92 | save_result = background - min(background(:)); 93 | save_result = save_result/max(save_result(:)); 94 | save_result_tmp = uint8(save_result*255); 95 | % imwrite(save_result_tmp, strcat('background_',num2str((ii)),'.bmp')); 96 | end 97 | % clear the addpath 98 | rmpath(genpath('D:\Matlab_program\reference\TFOCS')); -------------------------------------------------------------------------------- /Code-Bayesian inference for adaptive low rank/proximal_log.m: -------------------------------------------------------------------------------- 1 | function [ output_args ] = proximal_log( input_args, tao, sita, lamda ) 2 | %% PROXIMAL_LOG 3 | % reference: Unsupervised ridge detection using second order anisotropic Gaussian kernels 4 | % Copyright:2019-2-27 MarkLHF, UESTC.(e-mail:2751867750@qq.com) 5 | % this is a auxiliary function to implement the proximal operator algorithm 6 | %{ 7 | detail 8 | Input: input_args --> the input image(2D/1D, and double type); 9 | tao --> the normalization paratmer 10 | sita --> the parameter in the log(|sigma|+sita) 11 | lamda --> the scale factor of log function(default 1) 12 | Output: output_args --> the optimal(2D/1D, double) 13 | %} 14 | %% get the basic information 15 | N_sig = length(input_args); 16 | sig_X = zeros(size(input_args)); 17 | sig_Y = input_args; 18 | 19 | %% calcualte some parameter; 20 | new_sig_Y = sig_Y - sita; 21 | new_tao = lamda*tao - sig_Y*sita; 22 | 23 | %% main loop 24 | for n = 1:N_sig 25 | % judge 26 | t_judge = new_sig_Y(n)^2 - 4*new_tao(n); 27 | 28 | if t_judge >= 0 29 | % part 2 30 | t_sig = new_sig_Y(n) - 2*new_tao(n)/(new_sig_Y(n)+sqrt(t_judge)); 31 | sig_X(n) = max(t_sig, 0); 32 | else 33 | % part 1 34 | sig_X(n) = 0; 35 | end 36 | end 37 | %% output 38 | output_args = sig_X; 39 | end 40 | 41 | -------------------------------------------------------------------------------- /Code-Bayesian inference for adaptive low rank/res_patch_img_mean.m: -------------------------------------------------------------------------------- 1 | function [recImg_T, recImg_B] = res_patch_img_mean(patchImg_T, patchImg_B, img, patchSize, slideStep) 2 | %% RES_PATCH_IMG_MEAN 3 | % This matlab code recovers the image from patch-image using 4 | % mean filter for the sake of speed. 5 | % Copyright:2019-3-12 MarkLHF, UESTC.(e-mail:2751867750@qq.com) 6 | % Tianfang Zhang, UESTC.(e-mail:sparkcarleton@gmail.com) 7 | %{ 8 | detail 9 | Input: patchImg_T --> the patch sparse image(2D, and double type); 10 | patchImg_B --> the patch low-rank image(2D, and double type); 11 | img --> the input image (2D, and uint8 type); 12 | patchSize --> the size of patch(size = patchSize*patchSize) 13 | slideStep --> the step of slide window 14 | Output: recImg_T --> the reconstruction sparse image(2D, double) 15 | recImg_B --> the reconstruction low-rank image(2D, double) 16 | %} 17 | %% get the basic information and allocate the store space 18 | [row, col] = size(img); 19 | 20 | reconsT = zeros(row, col, 100); 21 | reconsB = zeros(row, col, 100); 22 | countMatrix = zeros(row, col); 23 | index = 1; 24 | %% reconstruct the original image 25 | for i = 1:slideStep:row-patchSize 26 | for j = 1:slideStep:col-patchSize 27 | % Count the time each pixel used and record the value 28 | repatch_T = reshape(patchImg_T(:,index), patchSize, patchSize); 29 | repatch_B = reshape(patchImg_B(:,index), patchSize, patchSize); 30 | countMatrix(i:i+patchSize-1, j:j+patchSize-1) = countMatrix(i:i+patchSize-1, j:j+patchSize-1) + 1; 31 | 32 | % Record the value of each pixel 33 | for ii = i:i+patchSize-1 34 | for jj = j:j+patchSize-1 35 | reconsT(ii, jj, countMatrix(ii,jj)) = repatch_T(ii-i+1, jj-j+1); 36 | reconsB(ii, jj, countMatrix(ii,jj)) = repatch_B(ii-i+1, jj-j+1); 37 | end 38 | end 39 | 40 | index = index + 1; 41 | end 42 | end 43 | %% deal with the overlapping region 44 | rstT = zeros(row, col); 45 | rstB = double(img); 46 | 47 | for i = 1:row 48 | for j = 1:col 49 | % Median 50 | if countMatrix(i ,j) > 0 51 | vectorT = reconsT(i, j, 1:countMatrix(i,j)); 52 | vectorB = reconsB(i, j, 1:countMatrix(i,j)); 53 | 54 | rstT(i, j) = mean(vectorT); 55 | rstB(i, j) = mean(vectorB); 56 | end 57 | end 58 | end 59 | %% output 60 | recImg_T = rstT; 61 | recImg_B = rstB; -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/FAG_curve.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/FAG_curve.png -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/IBW_curve.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/IBW_curve.png -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/RMSF_curve.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/RMSF_curve.png -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/TKME_curve.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/TKME_curve.png -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/acoustic_skin.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/acoustic_skin.mat -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/compare_demo.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/compare_demo.m -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Bland-Altman-Analysis-master/.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 | -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Bland-Altman-Analysis-master/.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 | # MATLAB autosaves 21 | *.asv 22 | 23 | # ========================= 24 | # Operating System Files 25 | # ========================= 26 | 27 | # OSX 28 | # ========================= 29 | 30 | .DS_Store 31 | .AppleDouble 32 | .LSOverride 33 | 34 | # Thumbnails 35 | ._* 36 | 37 | # Files that might appear in the root of a volume 38 | .DocumentRevisions-V100 39 | .fseventsd 40 | .Spotlight-V100 41 | .TemporaryItems 42 | .Trashes 43 | .VolumeIcon.icns 44 | 45 | # Directories potentially created on remote AFP share 46 | .AppleDB 47 | .AppleDesktop 48 | Network Trash Folder 49 | Temporary Items 50 | .apdisk 51 | -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Bland-Altman-Analysis-master/Bland JM, Altman DG 1999 - Measuring agreement in method comparison studies.url: -------------------------------------------------------------------------------- 1 | [{000214A0-0000-0000-C000-000000000046}] 2 | Prop3=19,2 3 | [InternetShortcut] 4 | IDList= 5 | URL=http://smm.sagepub.com/content/8/2/135.abstract 6 | HotKey=0 7 | -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Bland-Altman-Analysis-master/ba1999demo.m: -------------------------------------------------------------------------------- 1 | %BA1999DEMO Demonstration of: 2 | % Bland and Altman 1999 3 | % Measuring agreement methods in comparison studies 4 | % http://smm.sagepub.com/content/8/2/135.abstract 5 | 6 | % Copyright (C) 2016 Erik Huizinga, huizinga.erik@gmail.com 7 | % 8 | % This program is free software: you can redistribute it and/or modify 9 | % it under the terms of the GNU General Public License as published by 10 | % the Free Software Foundation, either version 3 of the License, or 11 | % any later version. 12 | % 13 | % This program is distributed in the hope that it will be useful, 14 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | % GNU General Public License for more details. 17 | % 18 | % You should have received a copy of the GNU General Public License 19 | % along with this program. If not, see . 20 | 21 | %% display demo text 22 | disp 'Demonstration of Bland-Altman analysis' 23 | close all; clear; clc; 24 | %% load data 25 | addpath('./lib'); 26 | % Table 1 from the article 27 | load bpdata 28 | 29 | n = BPData(:,1); % subject number 30 | J = BPData(:,2:4); % three successive measurements by expert J 31 | R = BPData(:,5:7); % three successive measurements by expert R 32 | S = BPData(:,8:10); % three successive measurements by machine S 33 | JName = 'Systolic BP, Observer J (mmHg)'; 34 | SName = 'Systolic BP, Machine S (mmHg)'; 35 | 36 | %% 2 Limits of agreement (article page 136) 37 | % This section only considers the first observations by J and S. 38 | J1 = J(:,1); 39 | S1 = S(:,1); 40 | 41 | s = ba(J1,S1); 42 | muD = s.muD; % mean difference (bias) 43 | sD = s.sD; % standard deviation of difference 44 | loa = s.loa; % limits of agreement 45 | display(muD) % article: -16.29 mmHg 46 | display(sD) % article: 19.61 mmHg 47 | display(loa) % article: [-54.7, 22.1] mmHg 48 | 49 | % exclude subjects 78 and 80 (article page number 139) 50 | fprintf '\nExcluding subjects 78 and 80 (outliers):\n' 51 | iEx = [78,80]; 52 | lEx = (n==78) | (n==80); % alternative: logical indices 53 | s = ba(J1,S1, 'Exclude',iEx); 54 | muD = s.muD; 55 | loa = s.loa; 56 | display(muD) % article: -14.9 mmHg 57 | % Erratum: a small error, probably a typo, exist in the original article. 58 | % Note the difference between the muD and the article's mean difference. 59 | % However, because the limits of agreement are the same and, of course, the 60 | % mean difference equals the mean of the limits of agreement, thus the 61 | % calculation here appears to be correct. 62 | display(loa) % article: [-43.6, 15.0] mmHg 63 | 64 | %% 2.1 Graphical presentation of agreement (article page 140) 65 | % If any other figures exist, the numbers below might not be correct. This 66 | % script was written with all other figures closed. 67 | % Figure 1 corresponds to article figure 1, figure 2 corresponds to article 68 | % figure 2. 69 | s = ba(figure, J1,S1, 'XName',JName, 'YName',SName, 'PlotAll',true); 70 | rSMuD = s.rSMuD; 71 | % Article: 0.07 (p. 140), here -0.03, so an error exists either here or in 72 | % the article. 73 | display(rSMuD); % Spearman rank correlation between mean and difference 74 | 75 | % Figure 3 is equal to figure 2, but has added limits of agreement. It 76 | % corresponds to article figure 3. 77 | ba(figure, J1,S1, 'XName',JName, 'YName',SName, ... 78 | 'PlotMeanDifference',true, 'PlotStatistics','basic') 79 | 80 | %% 2.2 Precision of the estimated limits of agreement (article page 141) 81 | clf % Clear figure 3 and recreate it with additional confidence intervals 82 | % (not shown in article). 83 | s = ba(gcf, J1,S1, 'XName',JName, 'YName',SName, ... 84 | 'PlotMeanDifference',true, 'PlotStatistics','extended'); 85 | muDCI = s.muDCI; 86 | loaCI = s.loaCI; % confidence interval of the loa 87 | % article loaCI (p. 142): 88 | % [-61.9, 14.9 89 | % -47.5, 29.3] 90 | display(loaCI) 91 | % article muDCI (p. 142): [-20.5 -12.1] 92 | display(muDCI) -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Bland-Altman-Analysis-master/bpdata.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Bland-Altman-Analysis-master/bpdata.mat -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Bland-Altman-Analysis-master/demo.m: -------------------------------------------------------------------------------- 1 | %BA1999DEMO Demonstration of: 2 | % Bland and Altman 1999 3 | % Measuring agreement methods in comparison studies 4 | % http://smm.sagepub.com/content/8/2/135.abstract 5 | 6 | % Copyright (C) 2016 Erik Huizinga, huizinga.erik@gmail.com 7 | % 8 | % This program is free software: you can redistribute it and/or modify 9 | % it under the terms of the GNU General Public License as published by 10 | % the Free Software Foundation, either version 3 of the License, or 11 | % any later version. 12 | % 13 | % This program is distributed in the hope that it will be useful, 14 | % but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | % GNU General Public License for more details. 17 | % 18 | % You should have received a copy of the GNU General Public License 19 | % along with this program. If not, see . 20 | 21 | %% display demo text 22 | disp 'Demonstration of Bland-Altman analysis' 23 | close all; clear; clc; 24 | %% load data 25 | addpath('./lib'); 26 | % Table 1 from the article 27 | load fitting_data 28 | 29 | JName = 'Real concentration of blood glucose'; 30 | SName = 'Predicted concentration of blood glucose'; 31 | 32 | %% 2 Limits of agreement (article page 136) 33 | % This section only considers the first observations by J and S. 34 | J1 = concentration_list'; 35 | S1 = pred_vec; 36 | 37 | s = ba(J1,S1); 38 | muD = s.muD; % mean difference (bias) 39 | sD = s.sD; % standard deviation of difference 40 | loa = s.loa; % limits of agreement 41 | display(muD) % article: -16.29 mmHg 42 | display(sD) % article: 19.61 mmHg 43 | display(loa) % article: [-54.7, 22.1] mmHg 44 | 45 | % exclude subjects 78 and 80 (article page number 139) 46 | fprintf '\nExcluding subjects 78 and 80 (outliers):\n' 47 | % iEx = [78,80]; 48 | % lEx = (n==78) | (n==80); % alternative: logical indices 49 | % s = ba(J1,S1, 'Exclude',iEx); 50 | % muD = s.muD; 51 | % loa = s.loa; 52 | % display(muD) % article: -14.9 mmHg 53 | % Erratum: a small error, probably a typo, exist in the original article. 54 | % Note the difference between the muD and the article's mean difference. 55 | % However, because the limits of agreement are the same and, of course, the 56 | % mean difference equals the mean of the limits of agreement, thus the 57 | % calculation here appears to be correct. 58 | display(loa) % article: [-43.6, 15.0] mmHg 59 | 60 | %% 2.1 Graphical presentation of agreement (article page 140) 61 | % If any other figures exist, the numbers below might not be correct. This 62 | % script was written with all other figures closed. 63 | % Figure 1 corresponds to article figure 1, figure 2 corresponds to article 64 | % figure 2. 65 | s = ba(figure, J1,S1, 'XName',JName, 'YName',SName, 'PlotAll',true); 66 | rSMuD = s.rSMuD; 67 | % Article: 0.07 (p. 140), here -0.03, so an error exists either here or in 68 | % the article. 69 | display(rSMuD); % Spearman rank correlation between mean and difference 70 | 71 | % Figure 3 is equal to figure 2, but has added limits of agreement. It 72 | % corresponds to article figure 3. 73 | ba(figure, J1,S1, 'XName',JName, 'YName',SName, ... 74 | 'PlotMeanDifference',true, 'PlotStatistics','basic') 75 | 76 | %% 2.2 Precision of the estimated limits of agreement (article page 141) 77 | clf % Clear figure 3 and recreate it with additional confidence intervals 78 | % (not shown in article). 79 | s = ba(gcf, J1,S1, 'XName',JName, 'YName',SName, ... 80 | 'PlotMeanDifference',true, 'PlotStatistics','extended'); 81 | muDCI = s.muDCI; 82 | loaCI = s.loaCI; % confidence interval of the loa 83 | % article loaCI (p. 142): 84 | % [-61.9, 14.9 85 | % -47.5, 29.3] 86 | display(loaCI) 87 | % article muDCI (p. 142): [-20.5 -12.1] 88 | display(muDCI) -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Bland-Altman-Analysis-master/fitting_data.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Bland-Altman-Analysis-master/fitting_data.mat -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Bland-Altman-Analysis-master/lib/Ninv.m: -------------------------------------------------------------------------------- 1 | function x = Ninv(p) 2 | % inverse normal 3 | x = -sqrt(2).*erfcinv(2*p); 4 | end -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Bland-Altman-Analysis-master/lib/Tinv.m: -------------------------------------------------------------------------------- 1 | function x = Tinv(p,n) 2 | % inverse t 3 | assert(p>=.75 & p<=1,'p must satisfy 0.75<=p<=1.') 4 | if n<=1 5 | error 'Not implemented for n<=1.' 6 | elseif n<1000 7 | bii = betaincinv(2*abs(p-1/2), n/2, 1/2, 'upper'); 8 | x = sqrt(n*(1-bii)/bii); 9 | else % n>=1000 10 | % Reference: 11 | % Abramowitz & Stegun, 10th ed. 1972, formula 26.7.5 12 | xp = Ninv(p); 13 | g1 = @(x) (x^3+x)/4; 14 | g2 = @(x) (5*x^5+16*x^3+3*x)/96; 15 | g3 = @(x) (3*x^7+19*x^5+17*x^3-15*x)/384; 16 | g4 = @(x) (79*x^9+776*x^7+1482*x^5-1920*x^3-945*x)/92160; 17 | x = xp + g1(xp)/n + g2(xp)/n^2 + g3(xp)/n^3 + g4(xp)/n^4; 18 | end 19 | end -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Bland-Altman-Analysis-master/lib/dcStruct.m: -------------------------------------------------------------------------------- 1 | function s = dcStruct(prefix,xName,yName,suffix,dcFun) 2 | s.prefix = prefix; 3 | s.xName = xName; 4 | s.yName = yName; 5 | s.suffix = suffix; 6 | s.dcFun = dcFun; 7 | end -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Bland-Altman-Analysis-master/lib/dcUpdateFcn.m: -------------------------------------------------------------------------------- 1 | function str = dcUpdateFcn(~,e) 2 | x = e.Position(1); 3 | y = e.Position(2); 4 | data = e.Target.UserData; 5 | str = data.dcFun(data,x,y); 6 | if ~isempty(data.prefix), str = [data.prefix, str]; end 7 | if ~isempty(data.suffix), str = [str, data.suffix]; end 8 | end -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Bland-Altman-Analysis-master/lib/dcXY.m: -------------------------------------------------------------------------------- 1 | function str = dcXY(data,x,y) 2 | str = {}; 3 | if ~isempty(data.xName), str = [str, [data.xName ': ' num2str(x)]]; end 4 | if ~isempty(data.yName), str = [str, [data.yName ': ' num2str(y)]]; end 5 | end -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Bland-Altman-Analysis-master/lib/isaxes.m: -------------------------------------------------------------------------------- 1 | function tf = isaxes(ax) 2 | tf = strcmp({ax.Type},'axes'); 3 | end -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Bland-Altman-Analysis-master/lib/isfigure.m: -------------------------------------------------------------------------------- 1 | function tf = isfigure(f) 2 | tf = strcmp({f.Type},'figure'); 3 | end -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Bland-Altman-Analysis-master/lib/s2v.m: -------------------------------------------------------------------------------- 1 | function s2v(s) 2 | %#ok<*NODEF> 3 | fn = fieldnames(s); 4 | for f = fn(:).' 5 | assignin('caller',f{:},s.(f{:})) 6 | end 7 | end -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Bland-Altman-Analysis-master/lib/validatePlotArgs.m: -------------------------------------------------------------------------------- 1 | function [doPlotMD,axMD,doPlotC,axC] = validatePlotArgs( ... 2 | PlotAll, PlotMeanDifference, PlotCorrelation, h ... 3 | ) 4 | % default axes variables 5 | axMD = []; 6 | axC = []; 7 | 8 | % doAllPlots 9 | doPlotAll = logical(PlotAll); 10 | if doPlotAll 11 | doPlotMD = true; % do mean-difference plot 12 | doPlotC = true; % do correlation plot 13 | else 14 | doPlotMD = logical(PlotMeanDifference); 15 | doPlotC = logical(PlotCorrelation); 16 | end 17 | 18 | % validate number and type of handles in h for the requested plots 19 | doPlot = [doPlotMD doPlotC]; 20 | if any(doPlot) 21 | nPlot = nnz(doPlot); 22 | if isempty(h) 23 | figure 24 | ax = gobjects(0); 25 | else 26 | nh = numel(h); 27 | if isaxes(h) 28 | if nh==nPlot 29 | ax = h; 30 | else 31 | error(['The number of requested plots (' num2str(nPlot) ... 32 | ') is not equal to the number of axes (' ... 33 | num2str(nh) ') in the first input argument.']) 34 | end 35 | else % h must be a figure or contain nplot figures 36 | if nh==1 37 | figure(h) % error if h is not a figure 38 | ax = gobjects(0); 39 | elseif nh==nPlot 40 | for n = nh:-1:1 41 | figure(h(n)) 42 | ax(n) = axes; 43 | end 44 | elseif all(isfigure(h)) 45 | error(['The number of requested plots (' num2str(nPlot) ... 46 | ') is not equal to the number of figures (' ... 47 | num2str(nh) ') in the first input argument.']) 48 | else 49 | error(['The first optional input argument must be an ' ... 50 | '(array of) axes or figure handle(s).']) 51 | end 52 | end 53 | end 54 | 55 | % create axes if not yet existent 56 | if isempty(ax) 57 | if nPlot>1 58 | for n = nPlot:-1:1 59 | ax(n) = subplot(1,nPlot,n); 60 | end 61 | else 62 | ax = axes; 63 | end 64 | end 65 | 66 | % store axes in plot order 67 | if doPlotMD, axMD = ax(1); ax(1) = []; end 68 | if doPlotC, axC = ax(1); end % ax(1) = []; end 69 | end 70 | end -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Bland-Altman-Analysis-master/lib/validatelogical.m: -------------------------------------------------------------------------------- 1 | function tf = validatelogical(L) 2 | %VALIDATELOGICAL True for arrays that can be converted to logical. 3 | % VALIDATELOGICAL(L) returns logical 1 (true) if L is a logical or 4 | % numeric array and logical 0 (false) otherwise. 5 | % 6 | % See also LOGICAL. 7 | 8 | try tf = islogical(logical(L)); catch, tf = false; end 9 | end -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/BlandAltman.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/BlandAltman.zip -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/BlandAltman/BlandAltmanDemo.m: -------------------------------------------------------------------------------- 1 | % BlandAltmanDemo - demonstrate calling BlandAltman.m 2 | % 3 | % By Ran Klein 4 | % 2016-08-10 RK Major overhull of Bland-Altman.m and new functionality is 5 | % demonstrated. 6 | % 2018-12-12 RK Added support for correlation plot only 7 | % (CorrelationPlot.m). 8 | % Examples added for multiple analyses on a single figure. 9 | 10 | 11 | 12 | %% Generate paramteres for data generation 13 | clear; 14 | noise = 10/100; % percent 15 | npatients = 30; % number of patients 16 | bias = 1; % slope bias 17 | 18 | % Heart muscle territories per patient 19 | territories = {'LAD'}; 20 | nterritories = length(territories); 21 | 22 | % Patient states during measurement 23 | states = {'Rest','Stress'}; 24 | nstates = length(states); 25 | 26 | % Real flow values 27 | restFlow = 0.7*(1+0.2*randn(npatients,nterritories)); 28 | stressFlow = 2*(1+0.2*randn(npatients,nterritories)); 29 | 30 | % Test support for nan values in the data 31 | if 0 32 | restFlow(3,1) = nan; 33 | end 34 | 35 | %% Example 1 36 | % Baseline data with noise 37 | data1 = cat(3, restFlow.*(1), stressFlow.*(1)); 38 | % Follow-up data with noise and a bias 39 | data2 = bias * cat(3, restFlow.*(1), stressFlow.*(1)); 40 | 41 | % BA plot paramters 42 | tit = 'Flow Repeatability'; % figure title 43 | gnames = {territories, states}; % names of groups in data {dimension 1 and 2} 44 | label = {'Baseline Flow','Follow-up Flow','mL/min'}; % Names of data sets 45 | corrinfo = {'n','SSE','r2','eq'}; % stats to display of correlation scatter plot 46 | BAinfo = {'RPC(%)','ks'}; % stats to display on Bland-ALtman plot 47 | limits = 'auto'; % how to set the axes limits 48 | if 1 % colors for the data sets may be set as: 49 | colors = 'br'; % character codes 50 | else 51 | colors = [0 0 1;... % or RGB triplets 52 | 1 0 0]; 53 | end 54 | 55 | % Generate figure with symbols 56 | [cr, fig, statsStruct] = BlandAltman(data1, data2,label,tit,gnames,'corrInfo',corrinfo,'baInfo',BAinfo,'axesLimits',limits,'colors',colors, 'showFitCI',' on'); 57 | 58 | % Generate figure with numbers of the data points (patients) and fixed 59 | % Bland-Altman difference data axes limits 60 | BlandAltman(data1, data2,label,[tit ' (numbers, forced 0 intercept, and fixed BA y-axis limits)'],gnames,'corrInfo',corrinfo,'axesLimits',limits,'colors',colors,'symbols','Num','baYLimMode','square','forceZeroIntercept','on') 61 | 62 | 63 | % Generate figure with differences presented as percentages and confidence 64 | % intervals on the correlation plot 65 | BAinfo = {'RPC'}; 66 | BlandAltman(data1, data2,label,[tit ' (show fit confidence intervals and differences as percentages)'],gnames,'diffValueMode','percent', 'showFitCI','on','baInfo',BAinfo) 67 | 68 | 69 | % Display statistical results that were returned from analyses 70 | disp('Statistical results:'); 71 | disp(statsStruct); 72 | % * Note that non-Gaussian warning may result for the first two analysis as 73 | % the two data sets (rest and stress) make the difference data marginally 74 | % Gaussian (two overlapping Gaussians). This should not be the case with 75 | % the third analysis as it is in percent difference of the means. 76 | 77 | %% Example 2 - using non-Gaussian data and one figure with 2 analyses 78 | disp('Analysis with non-Gaussian distribution data') 79 | % Baseline data with non-Gaussian noise 80 | data1 = cat(3, restFlow.*(1+noise*rand(npatients,nterritories)), stressFlow.*(1+noise*rand(npatients,nterritories))); 81 | % Follow-up data with non-Gaussian noise and a bias 82 | data2 = bias * cat(3, restFlow.*(1+noise*rand(npatients,nterritories)), stressFlow.*(1+noise*rand(npatients,nterritories))); 83 | 84 | figure('Color','w','Units','centimeters', 'Position',[2 2 20 20]) 85 | ah1 = subplot(211); 86 | ah2 = subplot(212); 87 | 88 | BAinfo = {'RPC(%)','ks'}; 89 | 90 | [cr, fig, statsStruct] = BlandAltman(ah1, data1, data2,label,[tit ' (inappropriate Gaussian stats)'],gnames,'corrInfo',corrinfo,'baInfo',BAinfo,'axesLimits',limits,'colors',colors); 91 | % A warning should appear indicating detection of non-Gaussian 92 | % distribution. 93 | 94 | % Repeat analysis using non-parametric analysis, no warning should appear. 95 | BAinfo = {'RPCnp','ks'}; 96 | [cr, fig, statsStruct] = BlandAltman(ah2, data1, data2,label,[tit ' (using non-parametric stats)'],gnames,'corrInfo',corrinfo,'baInfo',BAinfo,'axesLimits',limits,'colors',colors,'baStatsMode','non-parametric'); 97 | % Keep in mind that alpha is set to 0.05 so there is a 1/20 chace of false 98 | % warnings. 99 | 100 | 101 | %% Example 3 - Repeat last analysis, but only with correlation 102 | [cr, fig, statsStruct] = correlationPlot(data1, data2,label,[tit ' (using non-parametric stats)'],gnames,'corrInfo',corrinfo,'colors',colors); -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/BlandAltman/correlationPlot.m: -------------------------------------------------------------------------------- 1 | % correlationPlot Wrapper function for Balnd-Altman to generate only the 2 | % correlation plot. For more infomation please refer to the help on 3 | % BlandAltman. 4 | % 5 | % See also BlandAltman 6 | 7 | % By Ran Klein, The Ottawa Hospital, Department of Nuclear Medicine 8 | 9 | function [r, fig, stats] = correlationPlot(varargin) 10 | varargin = [varargin, 'ProcessCorrelationOnly','On']; 11 | [~, fig, stats] = BlandAltman(varargin{:}); 12 | r = stats.r; 13 | -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/BlandAltman/mynum2str.m: -------------------------------------------------------------------------------- 1 | % str = mynum2str(data, sigfig, maxdec) - converts a number to a string 2 | % 3 | % mynum2str examples (sigfig=3 and maxdec=2) 4 | % 123456.0 --> 123000 5 | % 123.4560 --> 123 6 | % 12.34560 --> 12.3 7 | % 1.234560 --> 1.23 8 | % 0.1234560 --> 0.12 9 | 10 | % By Ran Klein 2012??? 11 | % Modified: 12 | % 2013-12-31 RK Added NA result for empty data. 13 | 14 | function str = mynum2str(data, sigfig, maxdec) 15 | if isempty(data) || ~isfinite(data) 16 | str = 'NA'; 17 | return 18 | end 19 | 20 | if nargin<2 21 | sigfig = 3; % number of significant figures to display (before and after .) 22 | end 23 | if nargin<3 24 | maxdec = 2; % maximum of decimals (after the .) 25 | end 26 | 27 | if isempty(sigfig) 28 | sigfig = floor(log10(abs(data)))+ 1 + maxdec; 29 | end 30 | e = max(-sigfig+1,floor(log10(abs(data)))); 31 | prec = max(-maxdec,e-sigfig+1); % precision 32 | p = round(data/10^(prec))*10^(prec); 33 | str = num2str(p); 34 | i = find(str=='.'); 35 | % number of figures after the decimal 36 | if isempty(i) 37 | i = length(str)+1; 38 | na = 0; 39 | else 40 | na = length(str)-i; 41 | end 42 | % number of figures befor the decimal 43 | t = str(1:i-1); 44 | if strcmpi(t,'0') 45 | nb = 0; % a preceding zero doesn't count 46 | else 47 | nb = sum(t>='0' & t<='9'); 48 | end 49 | 50 | % number of trailing zeros to add 51 | n = min(sigfig-(na+nb),... 52 | maxdec - na); 53 | if n>0 54 | if i>length(str) 55 | str = [str '.']; 56 | end 57 | str = [str '0'*ones(1,n)]; 58 | end -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/BlandAltman/polyfitZero.m: -------------------------------------------------------------------------------- 1 | function [p,S,mu] = polyfitZero(x,y,degree) 2 | % POLYFITZERO Fit polynomial to data, forcing y-intercept to zero. 3 | % P = POLYFITZERO(X,Y,N) is similar POLYFIT(X,Y,N) except that the 4 | % y-intercept is forced to zero, i.e. P(N) = 0. In the same way as 5 | % POLYFIT, the coefficients, P(1:N-1), fit the data Y best in the least- 6 | % squares sense. You can also use Y = POLYVAL(PZERO,X) to evaluate the 7 | % polynomial because the output is the same as POLYFIT. 8 | % 9 | % [P,S,MU] = POLYFITZERO() Return structure, S, similar to POLYFIT for use 10 | % with POLYVAL to calculate error estimates of predictions with P. 11 | % 12 | % [P,S,MU] = POLYFITZERO() Scale X by std(X), returns MU = [0,std(X)]. 13 | % 14 | % See also POLYVAL, POLYFIT 15 | % 16 | % Also see POLYFITN by John D'Errico 17 | % 18 | 19 | % Copyright (c) 2013 Mark Mikofski 20 | % Version 1-1, 2013-10-15 21 | % add delta output 22 | % center and scale 23 | % Version 1-0, 2011-06-29 24 | 25 | %% check args 26 | % X & Y should be numbers 27 | assert(isnumeric(x) && isnumeric(y),'polyfitZero:notNumeric', ... 28 | 'X and Y must be numeric.') 29 | dim = numel(x); % number of elements in X 30 | % DEGREE should be scalar positive number between 1 & 10 inclusive 31 | assert(isnumeric(degree) && isscalar(degree) && degree>0 && degree<=10, ... 32 | 'polyfitZero:degreeOutOfRange', ... 33 | 'DEGREE must be an integer between 1 and 10.') 34 | % DEGREE must be less than number of elements in X & Y 35 | assert(degree 2 46 | mu = [0; std(x)]; 47 | x = (x - mu(1))/mu(2); 48 | end 49 | % using pow() is actually as fast or faster than looping, same # of flops! 50 | z = zeros(dim,degree); 51 | for n = 1:degree 52 | z(:,n) = x.^(degree-n+1); 53 | end 54 | p = z\y; % solve 55 | p = [p;0]; % set y-intercept to zero 56 | %% error estimates 57 | % attribution: this is based on code from POLYFIT by The MathWorks Inc. 58 | if nargout > 1 59 | V = [z,ones(dim,1)]; % append constant term for Vandermonde matrix 60 | % Return upper-triangular factor of QR-decomposition for error estimates 61 | R = triu(qr(V,0)); 62 | r = y - V*p; 63 | S.R = R(1:size(R,2),:); 64 | S.df = max(0,length(y) - (degree+1)); 65 | S.normr = norm(r); 66 | end 67 | p = p'; % polynomial output is row vector by convention 68 | end 69 | -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Clarke_EGA.emf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Clarke_EGA.emf -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Clarke_EGA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/Clarke_EGA.png -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/clarke.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/clarke.m -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/clarke.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/clarke.zip -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/example_data.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/example_data.mat -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/evaluation/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017, Ran Klein 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution 13 | * Neither the name of The Ottawa Hospital nor the names of its 14 | contributors may be used to endorse or promote products derived from this 15 | software without specific prior written permission. 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/fitting_data.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/fitting_data.mat -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/lib/centerFreq.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/lib/centerFreq.m -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/lib/divideDataset.m: -------------------------------------------------------------------------------- 1 | function [ trainset, testset ] = divideDataset( dataset, proprety_list, size_train_set) 2 | %DIVIDEDATASET 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: dataset --> the dataset(struct) 7 | proprety_list --> the list of proprety_list(dim:1D) 8 | size_train_set --> the size of train set 9 | Output: trainset --> the dataset of train (struct) 10 | testset --> the dataset of test (struct) 11 | Tips: 12 | dataset.original: the original data of signal 13 | dataset.cf : the center frequence proprety 14 | dataset.rmsf : the root mean of frequence proprety 15 | dataset.ibw : the instantaneous bandwidth proprety 16 | dataset.tk : the TK energy proprety 17 | %} 18 | order = [1:2:length(proprety_list), 2:2:length(proprety_list)]; 19 | % order = randperm(length(proprety_list)); 20 | min_c = min(proprety_list); max_c = max(proprety_list); 21 | norm_proprety_list = (proprety_list - min(proprety_list))/(max_c - min_c); 22 | % norm_proprety_list = (proprety_list - mean(proprety_list))/(max_c - min_c)*2; 23 | 24 | % size_train_set = 10; 25 | size_test_set = length(proprety_list) - size_train_set; 26 | train_order = sort(order(1:size_train_set)); 27 | test_order = sort(order(size_test_set+1:length(proprety_list))); 28 | % train_order = 1:2:length(concentration_list); 29 | % test_order = 2:2:length(concentration_list); 30 | 31 | if isfield(dataset, 'original') 32 | trainset.original = dataset.original(train_order, :); 33 | testset.original = dataset.original(test_order, :); 34 | else 35 | disp('[warning]: dataset not have original section! ') 36 | end 37 | if isfield(dataset, 'cf') 38 | trainset.cf = dataset.cf(train_order,:); 39 | testset.cf = dataset.cf(test_order,:); 40 | else 41 | disp('[warning]: dataset not have center frequence section! ') 42 | end 43 | if isfield(dataset, 'rmsf') 44 | trainset.rmsf = dataset.rmsf(train_order,:); 45 | testset.rmsf = dataset.rmsf(test_order,:); 46 | else 47 | disp('[warning]: dataset not have root mean square frequence section! ') 48 | end 49 | if isfield(dataset, 'ibw') 50 | trainset.ibw = dataset.ibw(train_order,:); 51 | testset.ibw = dataset.ibw(test_order,:); 52 | else 53 | disp('[warning]: dataset not have instantaneous bandwidth section! ') 54 | end 55 | if isfield(dataset, 'tk') 56 | trainset.tk = dataset.tk(test_order,:); 57 | testset.tk = dataset.tk(test_order,:); 58 | else 59 | disp('[warning]: dataset not have tk energy section! ') 60 | end 61 | if isfield(dataset, 'fag') 62 | trainset.fag = dataset.fag(test_order,:); 63 | testset.fag = dataset.fag(test_order,:); 64 | else 65 | disp('[warning]: dataset not have frequency attenuation gradient section! ') 66 | end 67 | 68 | trainset.concentraion = norm_proprety_list(train_order);% the list of concentration 69 | testset.concentraion = norm_proprety_list(test_order);% the list of concentration 70 | end 71 | 72 | -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/lib/energyop.m: -------------------------------------------------------------------------------- 1 | function [ey,ex]=energyop(sig,gr) 2 | %% %calculates the energy operator of a signal 3 | %% %input 4 | %1. Raw signal (Vector) 5 | %2. gr (Plot or not plot) 6 | %% %Output 7 | %Energy operator signal (ey) 8 | %Teager operator (ex) 9 | %% %Method 10 | %The Teager Energy Operator is determined as 11 | %(x(t)) = (dx/dt)^2+ x(t)(d^2x/dt^2) (1.1) 12 | %in the continuous case (where x_ means the rst derivative of x, and x? means the second 13 | %derivative), and as 14 | %[x[n]] = x^2[n] + x[n - 1]x[n + 1] (1.2) 15 | %in the discrete case. 16 | %% Method 17 | %Note that the function is vectorized for optimum processing speed(Keep calm and vectorize) 18 | %Author : Hooman Sedghamiz 19 | %% hoose792@student.liu.se 20 | %% 21 | if nargin<2 22 | gr=0; 23 | end 24 | sig=sig(:); 25 | %% (x(t)) = (dx/dt)^2+ x(t)(d^2x/dt^2) 26 | %Operator 1 27 | y=diff(sig); 28 | y=[0;y]; 29 | squ=y(2:length(y)-1).^2; 30 | oddi=y(1:length(y)-2); 31 | eveni=y(3:length(y)); 32 | ey=squ - (oddi.*eveni); 33 | %% [x[n]] = x^2[n] - x[n - 1]x[n + 1] 34 | %operator ex 35 | squ1=sig(2:length(sig)-1).^2; 36 | oddi1=sig(1:length(sig)-2); 37 | eveni1=sig(3:length(sig)); 38 | ex=squ1 - (oddi1.*eveni1); 39 | ex = [ex(1); ex; ex(length(sig)-2)]; %make it the same length 40 | %% plots 41 | if gr 42 | figure,ax(1)=subplot(211);plot((sig/max(sig))-mean(sig/max(sig)),'b'), 43 | hold on, 44 | plot((ey/max(ey))-mean(ey/max(ey)),'Linewidth',2,'LineStyle','--','color','r'), 45 | axis tight; 46 | hleg1=legend('Original Signal','Energy Operator'); 47 | set(hleg1,'Location','NorthWest') 48 | ax(2)=subplot(212);plot((sig/max(sig))-mean(sig/max(sig)),'b'), 49 | hold on, 50 | plot((ex/max(ex))-mean(ex/max(ex)),'Linewidth',2,'LineStyle','--','color','g'), 51 | hleg2=legend('Original Signal','Teager Energy'); 52 | set(hleg2,'Location','NorthWest') 53 | axis tight, 54 | zoom on; 55 | linkaxes(ax,'x'); 56 | end 57 | -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/lib/freqAttenGrad.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/lib/freqAttenGrad.m -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/lib/lrm.m: -------------------------------------------------------------------------------- 1 | function [ fitTrain, fitTest, isConverged ] = lrm( train_data, test_data, range ) 2 | %% LRM:support vector machine regression model 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: train_data --> train data 7 | test_data --> test data 8 | range --> the select range (dim: 1D) 9 | Output: fitTrain --> the fitting result of train data 10 | fitTest --> the fitting result of test data 11 | isConverged --> a flag 12 | 13 | Tips: train_data.data (dim:2D) the train vectors are row vector 14 | train_data.value(dim:1D) the responding value of train vectors 15 | the form of test_data is same as train_data 16 | %} 17 | [~, col] = size(train_data.data); 18 | norm_cf = train_data.data./repmat(max(train_data.data,[],2), [1, col]); 19 | Mdl = fitlm(norm_cf(:,range), train_data.value, 'linear'); 20 | 21 | isConverged = 1; 22 | %% test data 23 | norm_test_cf = test_data.data./repmat(max(test_data.data,[],2), [1, col]); 24 | fitTest = predict(Mdl, norm_test_cf(:,range)); 25 | 26 | %% train data 27 | norm_train_cf = train_data.data./repmat(max(train_data.data,[],2), [1, col]); 28 | fitTrain = predict(Mdl, norm_train_cf(:,range)); 29 | 30 | 31 | end 32 | 33 | -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/lib/normalization.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/lib/normalization.m -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/lib/st.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/lib/st.m -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/lib/svr.m: -------------------------------------------------------------------------------- 1 | function [ fitTrain, fitTest, isConverged ] = svr( train_data, test_data, range ) 2 | %% SVR: support vector machine regression model 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: train_data --> train data 7 | test_data --> test data 8 | range --> the select range (dim: 1D) 9 | Output: fitTrain --> the fitting result of train data 10 | fitTest --> the fitting result of test data 11 | isConverged --> a flag 12 | 13 | Tips: train_data.data (dim:2D) the train vectors are row vector 14 | train_data.value(dim:1D) the responding value of train vectors 15 | the form of test_data is same as train_data 16 | %} 17 | [~, col] = size(train_data.data); 18 | norm_cf = train_data.data./repmat(max(train_data.data,[],2), [1, col]); 19 | Mdl = fitrsvm(norm_cf(:,range), train_data.value); 20 | if Mdl.ConvergenceInfo.Converged 21 | % disp(sprintf('Suceess Converged')); 22 | isConverged = 1; 23 | %% test data 24 | norm_test_cf = test_data.data./repmat(max(test_data.data,[],2), [1, col]); 25 | fitTest = predict(Mdl, norm_test_cf(:,range)); 26 | 27 | %% train data 28 | norm_train_cf = train_data.data./repmat(max(train_data.data,[],2), [1, col]); 29 | fitTrain = predict(Mdl, norm_train_cf(:,range)); 30 | else 31 | isConverged = 0; 32 | fitTrain = []; 33 | fitTest = []; 34 | % disp(sprintf('Failed Converged')); 35 | end 36 | 37 | end 38 | 39 | -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/lib/teagerEnergy.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/lib/teagerEnergy.m -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/lib/teagerEnergyImproved.m: -------------------------------------------------------------------------------- 1 | function [ tk ] = teagerEnergyImproved( tfs ) 2 | %% TEAGERENERGY: TK energy calculation function 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: tfs --> the time-frequence spectrum (dim: 2D) 7 | Output: tk --> the teager energy 8 | %} 9 | % Tips: the row represent every frequency point 10 | % the col represent every time point 11 | %% body 12 | rp_tfs = real(tfs); % the real part 13 | ip_tfs = imag(tfs); % the image part 14 | 15 | [row, col] = size(tfs); 16 | tk = zeros(row, col); 17 | for ncol = 2:col-1 18 | tk_r = rp_tfs(:, ncol).^2 - rp_tfs(:, ncol-1).*rp_tfs(:, ncol+1); 19 | tk_i = ip_tfs(:, ncol).^2 - ip_tfs(:, ncol-1).*ip_tfs(:, ncol+1); 20 | 21 | tk(:, ncol) = sqrt(tk_r.^2 + tk_i.^2); 22 | end 23 | tk = max(tk,[],1); % sum(tk, 1); 24 | 25 | end 26 | 27 | -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/lib/test_regression.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/lib/test_regression.m -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/lib/timedepthConvert.m: -------------------------------------------------------------------------------- 1 | function [ depth_vec, signal_valid ] = timedepthConvert( signal_vec, medium_speed, medium_thick, dt) 2 | %% TIMEDEPTHCONVERT: time depth conversion 3 | %{ 4 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 5 | detail 6 | Input: signal_vec --> the time series of signal 7 | medium_speed --> the sound speed in the medium (unit: m/s) 8 | medium_thick --> the thickness of the medium (unit: um) 9 | dt --> the time interval 10 | Output: depth_vec --> the depth series (unit: um) 11 | signal_valid --> the clipped signal (remove the invalid part) 12 | %} 13 | time_used = medium_thick ./ (medium_speed*1e6); 14 | step_used = round(time_used / dt); 15 | 16 | depth_vec = zeros(1, sum(step_used)); 17 | t_left = 1; t_right = 0; tt = 0; 18 | for n = 1:length(step_used) 19 | t_left = 1 + t_right; 20 | t_right = step_used(n) + t_right; 21 | 22 | depth_vec(t_left:t_right) = (1:step_used(n))*dt*medium_speed(n)*1e6 + tt; 23 | tt = depth_vec(t_right); 24 | end 25 | signal_valid = signal_vec(1:sum(step_used)); 26 | end 27 | 28 | -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/real-data.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/real-data.mat -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/signal_model_demo.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/signal_model_demo.m -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/simulate_code/blood_model.m: -------------------------------------------------------------------------------- 1 | function [ output_args ] = blood_model( c ) 2 | %% BLOOD_MODEL calculate the absorption coefficient for different 3 | % concentration glucose solution 4 | %{ 5 | Copyright(C),UESTC, School of Information and Communication Engineering, IDIP 6 | detail 7 | Input: c_glucose --> the concentration (unit: g/L) 8 | Output: output_args --> the absorption coefficient(unit: mm-1) 9 | %} 10 | 11 | %% assume the four main component in the blood 12 | % blood = water + HGb(hemoglobin) + glucose + lipid 13 | % the Combination Rule is ua = ln(10)(ci*si) 14 | % ci : the molar concentration (unit: mol/L) 15 | % si : the molar extinction coefficient (unit: L*mol-1*cm-1) 16 | 17 | %% the molar concentration (unit: mol/L) 18 | c_HGb = 2.32e-5; 19 | c_glucose = 5.55e-5*c; 20 | c_water = 35.555; %35.555 21 | c_lipid = 5.2e-5; 22 | 23 | %% the extinction coefficient (unit: L*mol-1*cm-1) 24 | sita_HGb = 1024; 25 | sita_glucose = 1.48e4; 26 | sita_water = 1.2e-3; 27 | sita_lipid = 4.509; 28 | 29 | output_args = log(10)*(c_HGb*sita_HGb + c_glucose*sita_glucose ... 30 | + c_water*sita_water + c_lipid*sita_lipid); 31 | %% transform the unit to mm-1 32 | output_args = output_args/10; 33 | end 34 | 35 | -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/simulate_code/simulate_result/ReadME.txt: -------------------------------------------------------------------------------- 1 | optical文件夹和acoustic文件夹分别放置了光学仿真结果和声学仿真结果 2 | 3 | 【注】optical_skin_X.mat 中X表示血液模型中血糖的浓度,单位为mg/L(毫克每升) 4 | 5 | optical_skin_X.mat表示光学仿真结果,内部变量说明如下: 6 | (1) kgrid: 仿真用介质网格(正方形网格)--> 光学和声学的网格是共用的 7 | (2) source: 初始压强分布 8 | (3) absorb_energy: 吸收光子密度分布 9 | (4) vmcmedium: 介质光学参数设置 10 | 4.1 absorption_coefficient: 吸收系数; 11 | 4.2 scattering_coefficient: 散射系数; 12 | 4.3 scattering_anisotropy: 各向异性因子; 13 | 4.4 refractive_index: 折射率; 14 | (5) solution:光子密度分布 15 | 16 | acoustic_skin_X.mat表示声学仿真结果,内部变量说明如下: 17 | (1) source: 初始压强分布 18 | (2) absorb_energy: 吸收光子密度分布 19 | (3) sensor_data: 超声仿真结果(共21个探头,取最中间的列数据) 20 | (4) vmcmedium: 介质光学参数设置 21 | 4.1 absorption_coefficient: 吸收系数; 22 | 4.2 scattering_coefficient: 散射系数; 23 | 4.3 scattering_anisotropy: 各向异性因子; 24 | 4.4 refractive_index: 折射率; 25 | (5) solution:光子密度分布 26 | (6) kgrid: 仿真用介质网格(正方形网格)--> 光学和声学的网格是共用的 (可能暂时还没有加进去) -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/simulate_code/simulate_result/acoustic/acoustic_skin.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/simulate_code/simulate_result/acoustic/acoustic_skin.mat -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/simulate_code/simulate_result/optical/optical_skin.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/simulate_code/simulate_result/optical/optical_skin.mat -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/simulate_code/simulate_result/show_model.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/simulate_code/simulate_result/show_model.m -------------------------------------------------------------------------------- /Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/simulate_code/simulate_result/show_result.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Blood glucose detection based on Teager-Kaiser main energy of photoacoustic signal/simulate_code/simulate_result/show_result.m -------------------------------------------------------------------------------- /Code-Dual-Threshold Computation Method/4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Dual-Threshold Computation Method/4.bmp -------------------------------------------------------------------------------- /Code-Dual-Threshold Computation Method/demo.m: -------------------------------------------------------------------------------- 1 | %% This script is designed to implement the method from the reference article. 2 | % reference: Bowstring-Based Dual-Threshold Computation Method for Adaptive Canny Edge Detector 3 | % Copyright:2019-3-1 MarkLHF, UESTC.(e-mail:2751867750@qq.com) 4 | clc;close all;clear; 5 | 6 | Img = imread('4.bmp'); 7 | figure;imshow(Img);title('test image'); 8 | % Check: is color image, or not. 9 | [row, col, dim] = size(Img); 10 | if dim == 3 11 | Img = rgb2gray(Img); 12 | end 13 | Img = im2double(Img); 14 | %% calculate the two threshold 15 | [ upper_thres, lower_thres ] = dualThreshold( Img, 1 ); 16 | 17 | %% show the result(but I don't know how to use two threshold) 18 | fprintf("the high-threshold is %f\n", upper_thres); 19 | fprintf("the low-threshold is %f\n", lower_thres); 20 | 21 | -------------------------------------------------------------------------------- /Code-Dual-Threshold Computation Method/dualThreshold.m: -------------------------------------------------------------------------------- 1 | function [ upper_thres, lower_thres ] = dualThreshold( input_args, scale ) 2 | %% DUALTHRESHOLD 3 | % reference: Bowstring-Based Dual-Threshold Computation Method for Adaptive Canny Edge Detector 4 | % Copyright:2019-2-28 MarkLHF, UESTC.(e-mail:2751867750@qq.com) 5 | %{ 6 | detail 7 | Input: input_args --> the gradient magnitude image(2D image) 8 | scale --> the scale of data type 9 | (Example: double = [0,1] and scale = 1) 10 | Output: upper_thres --> the upper threshold of image(for binary) 11 | lower_thres --> the lower threshold of image 12 | %} 13 | %% <1> calculate the gradient magnitude(GMI) 14 | gmi = input_args; % due to this gradient I had calculated before 15 | 16 | %% <2> normalize the GMI 17 | % [Tips]: GMI(x,y) >= 0 18 | norm_coeff_gmi = max(gmi(:));% the coefficient of normalization (GMI) 19 | gmi_norm = (gmi./norm_coeff_gmi).*scale; 20 | 21 | %% <3> build and normalize the GMH 22 | gmh = imhist(gmi_norm); 23 | 24 | norm_coeff_gmh = max(gmh(:)); % the coefficient of normalization (GMH) 25 | gmh = (gmh./norm_coeff_gmh).*scale; 26 | 27 | %% <4.1> determine the slope of the long-/short-bowstring. 28 | % search the single peak point 29 | peakValue = max(gmh); 30 | peakPoint = find(gmh == peakValue); 31 | 32 | % determine almost zero point(AZP) 33 | gamma = 0.005 * 0.01; 34 | azpValue = gamma * peakValue; 35 | azp = find(gmh <= azpValue); 36 | azp = azp(length(azp)); % set the rightmost point as AZP 37 | % determine kH parameter 38 | kH = (gmh(peakPoint) - gmh(azp))/(peakPoint - azp); 39 | %% <4.2> obtain the temporary upper-threshold 40 | i_range = peakPoint:length(gmh); 41 | lH = gmh(i_range)' - kH.*i_range; 42 | 43 | iH = find(lH == max(lH)); 44 | iH = peakPoint + iH - 1; 45 | %% <4.3> obtain the temporary lower-threshold 46 | % determine kL parameter 47 | kL = (gmh(peakPoint) - gmh(iH))/(peakPoint - iH); 48 | 49 | i_range = peakPoint:2:iH; 50 | lL = gmh(i_range)' - kL.*i_range; 51 | 52 | iL= find(lL == max(lL)); 53 | iL = peakPoint + iL - 1; 54 | %% <5> refine the dual-threshold 55 | % I have some problem in this part, 56 | K = length(gmh); 57 | % output the result 58 | upper_thres = iH/K*scale; 59 | lower_thres = iL/K*scale; 60 | end 61 | 62 | -------------------------------------------------------------------------------- /Code-Kernel Regression for Image Processing and Reconstruction/demo.m: -------------------------------------------------------------------------------- 1 | %% This script is designed to implement the measure from the reference article. 2 | % reference: Kernel Regression for Image Processing and Reconstruction 3 | % Copyright:2018-10-26 MarkLHF, UESTC.(e-mail:2751867750@qq.com) 4 | clc;close all;clear; 5 | 6 | % [Tips]: the path is data path, you need to CHANGE the path by yourself 7 | addpath('D:\Matlab_program\self-code\test-data'); 8 | % step 1: prepare the test data 9 | Img = imread('0001.bmp'); 10 | figure;imshow(Img);title('test image'); 11 | -------------------------------------------------------------------------------- /Code-Kernel Regression for Image Processing and Reconstruction/experiment_1.m: -------------------------------------------------------------------------------- 1 | %% This script is designed to show the shape of LSK 2 | % and test this algorithm's performance when processing a big image 3 | % Copyright:2018-10-28 MarkLHF, UESTC.(e-mail:2751867750@qq.com) 4 | clc;close all;clear; 5 | 6 | % [Tips]: This script is just used as a test platform to comfire my ideas. 7 | % and I won't write enough comment to explain these operation 8 | addpath('D:\Matlab_program\self-code\test-data'); 9 | addpath('.\support\') 10 | Img = imread('0001.bmp'); 11 | figure;imshow(Img);title('test image'); 12 | % transform rgb to gray 13 | [row, col, channel] = size(Img); 14 | if channel > 1 15 | Img = rgb2gray(Img); 16 | end 17 | Img = im2double(Img); 18 | 19 | % iteartive steering kernel regression (second order) 20 | IT = 15; % the total number of iterations 21 | wsize = 11; % the size of the local orientation analysis window 22 | lambda = 1; % the regularization for the elongation parameter 23 | alpha = 0.5; % the structure sensitive parameter 24 | h = 2.4; % the global smoothing parameter 25 | ksize = 5; % the kernel size 26 | r = 1; % the upscaling factor 27 | z = zeros(row, col, IT+1); 28 | zx1 = zeros(row, col, IT+1); 29 | zx2 = zeros(row, col, IT+1); 30 | rmse = zeros(IT+1, 1); 31 | z(:,:,1) = Img; 32 | [zx1c, zx2c] = derivative7(Img, 'x', 'y'); 33 | zx1(:,:,1) = zx1c; 34 | zx2(:,:,1) = zx2c; 35 | C = zeros(2, 2, row, col); 36 | 37 | for i = 2 : IT+1 38 | % compute steering matrix 39 | C = steering(zx1(:,:,i-1), zx2(:,:,i-1), ones(size(Img)), wsize, lambda, alpha); 40 | % steering kernel regression 41 | [zs, zx1s, zx2s] = skr2_regular(z(:,:,i-1), h, C, r, ksize); 42 | z(:,:,i) = zs; 43 | zx1(:,:,i) = zx1s; 44 | zx2(:,:,i) = zx2s; 45 | % display the No.iteration 46 | fprintf('[%d]Iteration\n',i); 47 | %figure(99); imagesc(zs); colormap(gray); axis image; pause(1); 48 | end 49 | % 50 | H11 = zeros(row, col); 51 | H12 = zeros(row, col); 52 | H22 = zeros(row, col); 53 | for nrow = 1:row 54 | for ncol = 1:col 55 | H11(nrow, ncol) = C(1,1,nrow,ncol); 56 | H12(nrow, ncol) = C(1,2,nrow,ncol); 57 | H22(nrow, ncol) = C(2,2,nrow,ncol); 58 | end 59 | end 60 | 61 | % show 62 | figure; imagesc(Img); colormap(gray); axis image;title('The noisy image, STD=25'); 63 | figure; imagesc(H11); colormap(gray); axis image; 64 | figure; mesh(H11); title('H(1,1)'); 65 | figure; imagesc(H12); colormap(gray); axis image; 66 | figure; mesh(H12); title('H(1,2)'); -------------------------------------------------------------------------------- /Code-Kernel Regression for Image Processing and Reconstruction/support/EdgeMirror.m: -------------------------------------------------------------------------------- 1 | function y = EdgeMirror(x, width) 2 | % Edge mirroring function attach the mirror edge to the input image x. 3 | % [usage] 4 | % y = EdgeMirror(x, width) 5 | % 6 | % [parameter] 7 | % x : input image 8 | % width : mirroring width [x y] 9 | % 10 | % [history] 11 | % Jan 20, 2005 : created by hiro 12 | 13 | y = cat(2, x(:, width(2)+1:-1:2), x, x(: ,end-1:-1:end-width(2))); 14 | y = cat(1, y(width(1)+1:-1:2, :), y, y(end-1:-1:end-width(1), :)); -------------------------------------------------------------------------------- /Code-Kernel Regression for Image Processing and Reconstruction/support/derivative7.m: -------------------------------------------------------------------------------- 1 | % DERIVATIVE7 - 7-Tap 1st and 2nd discrete derivatives 2 | % 3 | % This function computes 1st and 2nd derivatives of an image using the 7-tap 4 | % coefficients given by Farid and Simoncelli. The results are significantly 5 | % more accurate than MATLAB's GRADIENT function on edges that are at angles 6 | % other than vertical or horizontal. This in turn improves gradient orientation 7 | % estimation enormously. 8 | % 9 | % Usage: [gx, gy, gxx, gyy, gxy] = derivative7(im, derivative specifiers) 10 | % 11 | % Arguments: 12 | % im - Image to compute derivatives from. 13 | % derivative specifiers - A comma separated list of character strings 14 | % that can be any of 'x', 'y', 'xx', 'yy' or 'xy' 15 | % These can be in any order, the order of the 16 | % computed output arguments will match the order 17 | % of the derivative specifier strings. 18 | % Returns: 19 | % Function returns requested derivatives which can be: 20 | % gx, gy - 1st derivative in x and y 21 | % gxx, gyy - 2nd derivative in x and y 22 | % gxy - 1st derivative in y of 1st derivative in x 23 | % 24 | % Examples: 25 | % Just compute 1st derivatives in x and y 26 | % [gx, gy] = derivative7(im, 'x', 'y'); 27 | % 28 | % Compute 2nd derivative in x, 1st derivative in y and 2nd derivative in y 29 | % [gxx, gy, gyy] = derivative7(im, 'xx', 'y', 'yy') 30 | % 31 | % See also: DERIVATIVE5 32 | 33 | % Reference: Hany Farid and Eero Simoncelli "Differentiation of Discrete 34 | % Multi-Dimensional Signals" IEEE Trans. Image Processing. 13(4): 496-508 (2004) 35 | 36 | % Copyright (c) 2010 Peter Kovesi 37 | % Centre for Exploration Targeting 38 | % The University of Western Australia 39 | % http://www.csse.uwa.edu.au/~pk/research/matlabfns/ 40 | % 41 | % Permission is hereby granted, free of charge, to any person obtaining a copy 42 | % of this software and associated documentation files (the "Software"), to deal 43 | % in the Software without restriction, subject to the following conditions: 44 | % 45 | % The above copyright notice and this permission notice shall be included in 46 | % all copies or substantial portions of the Software. 47 | % 48 | % The Software is provided "as is", without warranty of any kind. 49 | % 50 | % April 2010 51 | 52 | function varargout = derivative7(im, varargin) 53 | 54 | varargin = varargin(:); 55 | varargout = cell(size(varargin)); 56 | 57 | % 7-tap interpolant and 1st and 2nd derivative coefficients 58 | p = [ 0.004711 0.069321 0.245410 0.361117 0.245410 0.069321 0.004711]; 59 | d1 = [ 0.018708 0.125376 0.193091 0.000000 -0.193091 -0.125376 -0.018708]; 60 | d2 = [ 0.055336 0.137778 -0.056554 -0.273118 -0.056554 0.137778 0.055336]; 61 | 62 | % Compute derivatives. Note that in the 1st call below MATLAB's conv2 63 | % function performs a 1D convolution down the columns using p then a 1D 64 | % convolution along the rows using d1. etc etc. 65 | gx = false; 66 | for n = 1:length(varargin) 67 | if strcmpi('x', varargin{n}) 68 | varargout{n} = conv2(p, d1, im, 'same'); 69 | gx = true; % Record that gx is available for gxy if needed 70 | gxn = n; 71 | elseif strcmpi('y', varargin{n}) 72 | varargout{n} = conv2(d1, p, im, 'same'); 73 | elseif strcmpi('xx', varargin{n}) 74 | varargout{n} = conv2(p, d2, im, 'same'); 75 | elseif strcmpi('yy', varargin{n}) 76 | varargout{n} = conv2(d2, p, im, 'same'); 77 | elseif strcmpi('xy', varargin{n}) | strcmpi('yx', varargin{n}) 78 | if gx 79 | varargout{n} = conv2(d1, p, varargout{gxn}, 'same'); 80 | else 81 | gx = conv2(p, d1, im, 'same'); 82 | varargout{n} = conv2(d1, p, gx, 'same'); 83 | end 84 | else 85 | error(sprintf('''%s'' is an unrecognized derivative option',varargin{n})); 86 | end 87 | end 88 | 89 | -------------------------------------------------------------------------------- /Code-Kernel Regression for Image Processing and Reconstruction/support/downsample2.m: -------------------------------------------------------------------------------- 1 | function y = downsample2(x, d) 2 | % DOWMSAMPLE2 [y = downsample2(x, d)] 3 | % 2 dimensional downsampling function 4 | % x : input to be downsampled 5 | % d : downsampling factor 6 | % 7 | % coded by hiro on Nov 21, 2004 8 | 9 | y = downsample(downsample(x.', d).', d); -------------------------------------------------------------------------------- /Code-Kernel Regression for Image Processing and Reconstruction/support/mymse.m: -------------------------------------------------------------------------------- 1 | function y = mymse(x) 2 | 3 | y = sum(x(:).^2) / length(x(:)); -------------------------------------------------------------------------------- /Code-Kernel Regression for Image Processing and Reconstruction/support/round0_255.m: -------------------------------------------------------------------------------- 1 | function y = round0_255(x) 2 | 3 | y = x; 4 | below0 = y < 0; 5 | above255 = y > 255; 6 | 7 | y = y .* abs(below0 - 1); 8 | y = y .* abs(above255 - 1) + above255 * 255; -------------------------------------------------------------------------------- /Code-Kernel Regression for Image Processing and Reconstruction/support/skr2_regular.m: -------------------------------------------------------------------------------- 1 | function [z, zx1, zx2] = skr2_regular(y, h, C, r, ksize) 2 | % [SKR2_REGULAR] 3 | % The second order steering kernel regression function for regularly sampled 4 | % data. 5 | % 6 | % [USAGE] 7 | % [z, zx1, zx2] = skr2_regular(y, h, C, r, ksize) 8 | % 9 | % [RETURNS] 10 | % z : the estimated image 11 | % zx1 : the estimated gradient image along the x1 direction (vertical 12 | % direction) 13 | % zx2 : the estimated gradient image along the x2 direction (horizontal 14 | % direction) 15 | % 16 | % [PARAMETERS] 17 | % y : the input image 18 | % h : the global smoothing parameter 19 | % C : the covariance matrices containing local orientation information 20 | % r : the upscaling factor ("r" must be an integer number) 21 | % ksize : the size of the kernel (ksize x ksize, and "ksize" must be 22 | % an odd number) 23 | % 24 | % [HISTORY] 25 | % June 16, 2007 : created by Hiro 26 | % Apr 14, 2008 : the transpose operator is fixed by Hiro 27 | 28 | % Get the oritinal image size 29 | [N, M] = size(y); 30 | 31 | % Initialize the return parameters 32 | z = zeros(N*r, M*r); 33 | zx1 = zeros(N*r, M*r); 34 | zx2 = zeros(N*r, M*r); 35 | 36 | % Pixel sampling positions 37 | radius = (ksize - 1) / 2; 38 | [x2, x1] = meshgrid(-radius-(r-1)/r : 1/r : radius, -radius-(r-1)/r : 1/r : radius); 39 | 40 | % pre-culculation for covariance matrices 41 | C11 = zeros(N, M); 42 | C12 = zeros(N, M); 43 | C22 = zeros(N, M); 44 | sq_detC = zeros(N, M); 45 | for n = 1 : N 46 | for m = 1 : M 47 | C11(n,m) = C(1,1,n,m); 48 | C12(n,m) = C(1,2,n,m); 49 | C22(n,m) = C(2,2,n,m); 50 | sq_detC(n,m) = sqrt(det(C(:,:,n,m))); 51 | end 52 | end 53 | 54 | % Mirroring 55 | y = EdgeMirror(y, [radius, radius]); 56 | C11 = EdgeMirror(C11, [radius, radius]); 57 | C12 = EdgeMirror(C12, [radius, radius]); 58 | C22 = EdgeMirror(C22, [radius, radius]); 59 | sq_detC = EdgeMirror(sq_detC, [radius, radius]); 60 | 61 | % Estimate an image and its first gradients with pixel-by-pixel 62 | for i = 1 : r 63 | for j = 1 : r 64 | xx1 = downsample2(x1(r-i+1:end, r-j+1:end), r); 65 | xx2 = downsample2(x2(r-i+1:end, r-j+1:end), r); 66 | 67 | % The feture matrix 68 | Xx = [ones(ksize^2,1), xx1(:), xx2(:), xx1(:).^2, xx1(:).*xx2(:), xx2(:).^2]; 69 | 70 | for n = 1 : N 71 | nn = (n - 1) * r + i; 72 | for m = 1 : M 73 | mm = (m - 1) * r + j; 74 | 75 | % Neighboring samples to be taken account into the estimation 76 | yp = y(n:n+ksize-1, m:m+ksize-1); 77 | 78 | % compute the weight matrix 79 | tt = xx1 .* (C11(n:n+ksize-1, m:m+ksize-1) .* xx1... 80 | + C12(n:n+ksize-1, m:m+ksize-1) .* xx2)... 81 | + xx2 .* (C12(n:n+ksize-1, m:m+ksize-1) .* xx1... 82 | + C22(n:n+ksize-1, m:m+ksize-1) .* xx2); 83 | W = exp(-(0.5/h^2) * tt) .* sq_detC(n:n+ksize-1, m:m+ksize-1); 84 | 85 | % Equivalent kernel 86 | Xw = [Xx(:,1).*W(:), Xx(:,2).*W(:), Xx(:,3).*W(:),... 87 | Xx(:,4).*W(:), Xx(:,5).*W(:), Xx(:,6).*W(:)]; 88 | A = inv(Xx' * Xw + eye(6)*0.0000001) * (Xw'); 89 | 90 | % Estimate the pixel values at (nn,mm) 91 | z(nn,mm) = A(1,:) * yp(:); 92 | zx1(nn,mm) = A(2,:) * yp(:); 93 | zx2(nn,mm) = A(3,:) * yp(:); 94 | end 95 | end 96 | end 97 | end 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /Code-Kernel Regression for Image Processing and Reconstruction/support/steering.m: -------------------------------------------------------------------------------- 1 | function C = steering(zx, zy, I, wsize, lambda, alpha) 2 | % Compute steering matrices 3 | % 4 | % [USAGE] 5 | % C = steering(zx, zy, I, wsize, lambda, alpha) 6 | % 7 | % [RETURNS] 8 | % C : steering matrices 9 | % 10 | % [PARAMETERS] 11 | % zx, zy : image gradients along x and y directions 12 | % I : sampling positions 13 | % wsize : size of an analysis window 14 | % lambda : regularization parameter 15 | % alpha : structure sensitive parameter 16 | % 17 | % [HISTORY] 18 | % Nov 19, 2005 : created by hiro 19 | % June 16, 2005 : modified by hiro 20 | % Apr 14, 2008 : economical SVD, by hiro 21 | 22 | [N, M] = size(zx); 23 | C = zeros(2, 2, N, M); 24 | 25 | if mod(wsize, 2) == 0 26 | wsize = wsize + 1; 27 | end 28 | win = floor(wsize / 2); 29 | 30 | K = fspecial('disk', win); 31 | K = K ./ K(win+1, win+1); 32 | % K = ones(wsize,wsize); 33 | 34 | % mirroring 35 | zx = EdgeMirror(zx, [win, win]); 36 | zy = EdgeMirror(zy, [win, win]); 37 | 38 | for i = 1 : N 39 | for j = 1 : M 40 | 41 | if I(i,j) == 0 42 | continue; 43 | end 44 | 45 | gx = zx(i:i+wsize-1, j:j+wsize-1) .* K; 46 | gy = zy(i:i+wsize-1, j:j+wsize-1) .* K; 47 | 48 | G = [gx(:), gy(:)]; 49 | len = sum(K(:)); 50 | [u s v] = svd(G, 0); 51 | S(1) = (s(1,1) + lambda) / (s(2,2) + lambda); 52 | S(2) = (s(2,2) + lambda) / (s(1,1) + lambda); 53 | tmp = (S(1) * v(:,1) * v(:,1)' + S(2) * v(:,2) * v(:,2)') * ((s(1,1) * s(2,2) + 0.0000001) / len)^alpha; 54 | C(1:2, 1:2, i, j) = tmp; 55 | end 56 | end -------------------------------------------------------------------------------- /Code-Multiscale local homogeneity measure/2.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Multiscale local homogeneity measure/2.bmp -------------------------------------------------------------------------------- /Code-Multiscale local homogeneity measure/4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Multiscale local homogeneity measure/4.bmp -------------------------------------------------------------------------------- /Code-Multiscale local homogeneity measure/LHM.m: -------------------------------------------------------------------------------- 1 | function [ output ] = LHM( Input_Img, s ) 2 | % LHM: local homogeneity measure algorithm 3 | % reference: An infrared small target detection method based on multiscale local homogeneity measure 4 | % operation 5 | % Copyright:2018-9-3 MarkLHF, UESTC.(e-mail:2751867750@qq.com) 6 | %{ 7 | detail 8 | model: please refer the orginal article. 9 | Input: Input_Img --> the matrix of Image(must be 2D) 10 | s --> the size of central patch(must be odd number) 11 | Output: output --> the feature map of local homogeneity measure 12 | 13 | Tips: the input matrix must be 2D matrix 14 | %} 15 | 16 | % step 1: get the patch image 17 | [row, col] = size(Input_Img); 18 | boundary = (s-1)/2+s; 19 | matrix_sita = zeros(row, col); 20 | matrix_w = zeros(row, col); 21 | for nrow = 1:row-3*s 22 | for ncol = 1:col-3*s 23 | % patch image 24 | patch = double(Input_Img(nrow:nrow+3*s-1,ncol:ncol+3*s-1)); 25 | % calculate the standard deviation of central patch 26 | central_patch = patch(1+s:2*s,1+s:2*s); 27 | sita_row = boundary + nrow; 28 | sita_col = boundary + ncol; 29 | sita = std(central_patch(:)); 30 | matrix_sita(sita_row, sita_col) = sita; 31 | % calculate the Inter-patch heterogeneity measure 32 | meanVector = zeros(1,9); 33 | % calculate the D vectore and use the block matrix 34 | for t = 1:9 35 | % Tips: The reason to set the tt and tp temporal parameter is at 36 | % the bottom 37 | tt = floor((t-1)/3); 38 | tp = mod(t-1,3); 39 | temp_block = patch(1+tt*s:(tt+1)*s, 1+tp*s:(tp+1)*s); 40 | meanVector(t) = mean(temp_block(:)); 41 | end 42 | D_temp = [meanVector(1:4), meanVector(6:9)]; 43 | % calculate the mean of the central patch (the calculate order can be changed) 44 | mT = meanVector(5); 45 | % 46 | D = -(D_temp - mT); 47 | % calculate the value C 48 | di = zeros(1,4); 49 | for t = 1:4 50 | di(t) = D(t)*D(t+4); 51 | if di(t) < 0 52 | di(t) = 0; 53 | end 54 | end 55 | C = min(di); 56 | % calculate the value w 57 | matrix_w(sita_row, sita_col) = C*(sita+0.01)^-1; 58 | end 59 | end 60 | 61 | % step 2: output the result 62 | output = matrix_w(boundary:boundary+row-3*s, boundary:boundary+col-3*s); 63 | end 64 | %% the explaination for why set temporal parameter: tt and tp 65 | % an analysis of 3 orders 66 | % t = 1,2,3,4,5,6,7,8,9 67 | % tt = 0,0,0,1,1,1,2,2,2 68 | % tp = 0,1,2,0,1,2,0,1,2 69 | % So: tt = floor((t-1)/3); tp = mod((t-1),3); 70 | -------------------------------------------------------------------------------- /Code-Multiscale local homogeneity measure/demo.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Multiscale local homogeneity measure/demo.m -------------------------------------------------------------------------------- /Code-Multiscale local homogeneity measure/impad.m: -------------------------------------------------------------------------------- 1 | % IMPAD - adds zeros to the boundary of an image 2 | % 3 | % Usage: paddedim = impad(im, b, v) 4 | % 5 | % Arguments: im - Image to be padded (greyscale or colour) 6 | % b - Width of padding boundary to be added 7 | % v - This may be: 8 | % 1) A numeric value to be assigned to the padded area. 9 | % 2) 'replicate' which results in the edges of the image 10 | % being replicated outwards to form the padding. 11 | % 4) 'taper' which results in the edges of the image 12 | % being tapered towards the cyclically opposite edge. 13 | % 5) If v is omitted it defaults to 0. 14 | % 15 | % Returns: paddedim - Padded image of size rows+2*b x cols+2*b 16 | % 17 | % Tapering is perhaps the best for frequency domain filtering. 18 | % 19 | % See also: IMTRIM, IMSETBORDER 20 | 21 | % Peter Kovesi 22 | % Centre for Exploration Targeting 23 | % The University of Western Australia 24 | % http://peterkovesi.com/matlabfns/ 25 | % June 2010 26 | % January 2011 Added optional padding value. 27 | % October 2017 Added replicate and taper options. 28 | 29 | function pim = impad(im, b, v) 30 | 31 | if b == 0 32 | pim = im; 33 | return; 34 | end 35 | 36 | if ~exist('v', 'var'), v = 0; end 37 | 38 | [rows, cols, channels] = size(im); 39 | 40 | if isnumeric(im) && isnumeric(v); % numeric padding 41 | pim = v*ones(rows+2*b, cols+2*b, channels, class(im)); 42 | 43 | elseif isnumeric(im) && strcmp(v, 'replicate') 44 | pim = zeros(rows+2*b, cols+2*b, channels, class(im)); 45 | 46 | elseif isnumeric(im) && strcmp(v, 'taper') 47 | pim = zeros(rows+2*b, cols+2*b, channels, 'double'); 48 | 49 | elseif islogical(im) % Logical image 50 | if v == true 51 | pim = true(rows+2*b, cols+2*b, channels); 52 | else 53 | pim = false(rows+2*b, cols+2*b, channels); 54 | end 55 | end 56 | 57 | pim(1+b:rows+b, 1+b:cols+b, :) = im; 58 | 59 | if strcmp(v, 'replicate') 60 | % Replicate image edge values outwards 61 | for r = 1:b 62 | pim(r, 1+b:cols+b, :) = im(1,:,:); % top 63 | pim(rows+b+r, 1+b:cols+b,:) = im(end,:,:); % bottom 64 | 65 | pim(1+b:rows+b, r, :) = im(:,1,:); % left 66 | pim(1+b:rows+b, cols+b+r, :) = im(:,end,:); % right 67 | end 68 | 69 | % Replicate corners 70 | for ch = 1:channels 71 | pim(1:b, 1:b, ch) = im(1,1,ch); % top left 72 | pim(1:b, cols+b+1:end, ch) = im(1,cols,ch); % top right 73 | 74 | pim(rows+b+1:end, 1:b, ch) = im(rows,1,ch); % bottom left 75 | pim(rows+b+1:end, cols+b+1:end, ch) = im(rows,cols,ch); % bottom right 76 | end 77 | 78 | elseif strcmp(v, 'taper') 79 | delta = 1/(2*b+1); % Fractional change that forms the tapered steps 80 | bot_top = pim(rows+b,:) - pim(1+b,:); 81 | for n = 1:b 82 | pim(n,:) = pim(1+b,:) + (b-n+1)*delta*bot_top; % top 83 | pim(rows+b+n,:) = pim(rows+b,:) - n*delta*bot_top; % bottom 84 | end 85 | 86 | right_left = pim(:,cols+b) - pim(:,1+b); 87 | for n = 1:b 88 | pim(:,n) = pim(:,1+b) + (b-n+1)*delta*right_left; % left 89 | pim(:,cols+b+n) = pim(:,cols+b) - n*delta*right_left; % right 90 | end 91 | end -------------------------------------------------------------------------------- /Code-Multiscale local homogeneity measure/pp.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Multiscale local homogeneity measure/pp.jpg -------------------------------------------------------------------------------- /Code-Multiscale local homogeneity measure/pp2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Multiscale local homogeneity measure/pp2.jpg -------------------------------------------------------------------------------- /Code-Unsupervised ridge detection/4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Unsupervised ridge detection/4.bmp -------------------------------------------------------------------------------- /Code-Unsupervised ridge detection/7.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Unsupervised ridge detection/7.bmp -------------------------------------------------------------------------------- /Code-Unsupervised ridge detection/checkattributes.m: -------------------------------------------------------------------------------- 1 | function ok = checkattributes(a, classes, attributes) 2 | %CHECKATTRIBUTES is like VALIDATEATTRIBUTES but returns true or false 3 | % OK = CHECKATTRIBUTES(A,CLASSES,ATTRIBUTES) takes the same arguments as 4 | % VALIDATEATTRIBUTES, excluding the three optional arguments. However 5 | % CHECKATTRIBUTES returns true or false when VALIDATEATTRIBUTES would 6 | % return or throw an exception respectively. 7 | % 8 | % See also VALIDATEATTRIBUTES. 9 | try 10 | validateattributes(a, classes, attributes, 'checkattributes'); 11 | ok = true; 12 | catch ME 13 | if ~isempty(strfind(ME.identifier, ':checkattributes:')) 14 | ok = false; % first argument failed the specified tests 15 | else 16 | rethrow(ME); % there was some other error 17 | end 18 | end 19 | end -------------------------------------------------------------------------------- /Code-Unsupervised ridge detection/demo.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-Unsupervised ridge detection/demo.m -------------------------------------------------------------------------------- /Code-Unsupervised ridge detection/getAnisotropyKernel.m: -------------------------------------------------------------------------------- 1 | function [ output_args ] = getAnisotropyKernel( para_mat, window_size ) 2 | %% GETANISOTROPYKERNEL 3 | % reference: Unsupervised ridge detection using second order anisotropic Gaussian kernels 4 | % Copyright:2019-2-27 MarkLHF, UESTC.(e-mail:2751867750@qq.com) 5 | %{ 6 | detail 7 | Input: para_mat --> the parameter matrix(3*N); N = the number of kernel 8 | window_size --> the size of window(ws) 9 | Output: output_args --> the kernel coefficient set((ws*ws)*N); N = the number of kernel 10 | %} 11 | %% get the basic information 12 | [~, N] = size(para_mat); 13 | [wx,wy] = meshgrid(1:window_size, 1:window_size); 14 | output_args = zeros(window_size*window_size, N); 15 | %% generate the kernel 16 | for n = 1:N 17 | % extract parameter 18 | % d = direction; s = scale; a = anisotropy; 19 | temp_para = para_mat(:,n); 20 | di = temp_para(1); si = temp_para(2); ai = temp_para(3); 21 | % calcualte rotation matrix 22 | rotMat_p = getRotationMatrix(di); % positive 23 | rotMat_n = getRotationMatrix(-di); % negative 24 | aiMat = [ai.^2 0;0 ai.^2]; 25 | 26 | wx_row = reshape(wx, 1, window_size*window_size); 27 | wy_row = reshape(wy, 1, window_size*window_size); 28 | 29 | wxy = [wx_row; wy_row]; 30 | 31 | faiMat = diag(wxy' * rotMat_n * aiMat * rotMat_p * wxy); 32 | fai = reshape(faiMat, window_size, window_size); 33 | % calculate the kernel(size: window_size*window_size) 34 | temp_kernel = 1/(2*pi*si.^2)*exp(-fai./(2*si.^2)); 35 | % store the kernel 36 | output_args(:, n) = reshape(temp_kernel, window_size*window_size, 1); 37 | end 38 | end 39 | 40 | function rotMat = getRotationMatrix(sita) 41 | % this function is designed to generate the 2D rotation matrix 42 | % [Tips]: sita's unit is radian(not degreee) 43 | t_cos = cos(sita); 44 | t_sin = sin(sita); 45 | 46 | rotMat = [ t_cos t_sin; 47 | -t_sin t_cos;]; 48 | end 49 | 50 | -------------------------------------------------------------------------------- /Code-Unsupervised ridge detection/getKernelParameter.m: -------------------------------------------------------------------------------- 1 | function [ output_args ] = getKernelParameter( D, S, A) 2 | %% GETKERNELPARAMETER 3 | % reference: Unsupervised ridge detection using second order anisotropic Gaussian kernels 4 | % Copyright:2019-2-27 MarkLHF, UESTC.(e-mail:2751867750@qq.com) 5 | %{ 6 | detail 7 | Input: D = (d1, d2, ... , dk) and di in [0 pi](direction) (1-D) 8 | S = (s1, s2, ... , sm) and si > 0 (scale) (1-D) 9 | A = (a1, a2, ... , an) and ai > 1 (anisotropy) (1-D) 10 | Output: output_args --> the parameter matrix(3*N); N = the number of kernel 11 | %} 12 | %% allocate space to store the parameter 13 | len_D = length(D); 14 | len_S = length(S); 15 | len_A = length(A); 16 | 17 | N = len_A * len_D * len_S; 18 | 19 | output_args = zeros(3, N); 20 | %% generate the parameter matrix 21 | % output_args(1,:) = D 22 | % output_args(2,:) = S 23 | % output_args(3,:) = A 24 | % <1> set the D parameter 25 | temp = repmat(D, len_S*len_A, 1); 26 | output_args(1, :) = reshape(temp, [1, N]); 27 | % <2> set the S parameter 28 | temp = repmat(S, len_D*len_A, 1); 29 | output_args(2, :) = reshape(temp, [1, N]); 30 | % <3> set the A parameter 31 | temp = repmat(A, len_S*len_D, 1); 32 | output_args(3, :) = reshape(temp, [1, N]); 33 | end 34 | 35 | -------------------------------------------------------------------------------- /Code-Unsupervised ridge detection/hystThresh.m: -------------------------------------------------------------------------------- 1 | function e = hystThresh(e, g, thresh, conn) 2 | %HYSTTHRESH carries out hysteresis thresholding, as for Canny 3 | % E = HYSTTHRESH(E, G, THRESH) takes a raw edge map, a gradient magnitude 4 | % array and a threshold or pair of thresholds, and returns a new edge map 5 | % wherever the gradient magnitude exceeds or equals the lower threshold 6 | % and is connected to a position where the gradient exceeds or equals the 7 | % higher threshold. 8 | % 9 | % E - a logical N-D array, giving the raw edge map 10 | % 11 | % G - the underlying array of gradients (or other values); should not 12 | % contain negative values; same size as E 13 | % 14 | % THRESH - a vector of the form [LOW HIGH] giving the lower and 15 | % higher thresholding values. If thresh is a scalar, simple 16 | % thresholding is carried out. Should contain positive values, with 17 | % HIGH > LOW. 18 | % 19 | % E = HYSTTHRESH(E, G, THRESH, CONN) allows the connectivity to be set. 20 | % 21 | % CONN - an integer giving the neighbourhood size to establish 22 | % connected regions. The default (if empty or omitted) is as for 23 | % IMRECONSTRUCT. 24 | % 25 | % See also: canny, imreconstruct 26 | ge = g .* e; 27 | e = ge > thresh(1); % simple thresholding, or lower bound 28 | if ~isscalar(thresh) 29 | e2 = ge > thresh(2); 30 | if nargin < 4 || isempty(conn) 31 | e = imreconstruct(e2, e); 32 | else 33 | e = imreconstruct(e2, e, conn); 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/RegressionTest.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-WaveFeature and evidential regression for blood glucose detection/RegressionTest.m -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/RegressionTest_kcross.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-WaveFeature and evidential regression for blood glucose detection/RegressionTest_kcross.m -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/demo.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-WaveFeature and evidential regression for blood glucose detection/demo.m -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/demo_kcross.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-WaveFeature and evidential regression for blood glucose detection/demo_kcross.m -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/extractWaveFeature.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-WaveFeature and evidential regression for blood glucose detection/extractWaveFeature.m -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/lib/centerFreq.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-WaveFeature and evidential regression for blood glucose detection/lib/centerFreq.m -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/lib/computeFoldSizes.m: -------------------------------------------------------------------------------- 1 | function [foldSizes] = computeFoldSizes(vecsPerCat, numFolds) 2 | %COMPUTEFOLDSIZES Compute the fold sizes for the provided data set. 3 | % [foldSizes] = computeFoldSizes(vecsPerCat, numFolds); 4 | % 5 | % Part of performing n-fold cross-validation. See 'getFoldVectors'. 6 | % 7 | % Parameters: 8 | % vecsPerCat - Column vector with the number of vectors in the data set for 9 | % each category. 10 | % numFolds - The number of folds you'll be using for cross validation. 11 | % 12 | % Returns: 13 | % A matrix (with size numCategories x numFolds) containing the number of 14 | % vectors to include in each of the 'numFolds' folds for each category. 15 | 16 | % $Author: ChrisMcCormick $ $Date: 2013/07/31 22:00:00 $ $Revision: 1.0 $ 17 | 18 | % Get the number of categories present. 19 | numCats = numel(vecsPerCat); 20 | 21 | % For each category... 22 | for (i = 1 : numCats) 23 | 24 | % Get the number of vectors for this category; 25 | numVecs = vecsPerCat(i, 1); 26 | 27 | % Verify that there are at least 'numFolds' samples. 28 | if (numVecs < numFolds) 29 | disp("ERROR! Each category must have at least 'numFolds' samples."); 30 | return; 31 | end 32 | end 33 | 34 | % foldSizes will be a matrix holding the number of vectors to place in each fold 35 | % for each category. The number of folds may not divide evenly into the number 36 | % of vectors, so we need to distribute the remainder. 37 | foldSizes = zeros(numCats, numFolds); 38 | 39 | % For each category... 40 | for (i = 1 : numCats) 41 | 42 | % Get the the number of vectors for this category. 43 | numVecs = vecsPerCat(i, 1); 44 | 45 | % For each of the ten folds... 46 | for (fold = 1 : numFolds) 47 | 48 | % Divide the remaining number of vectors by the remaining number of folds. 49 | foldSize = ceil(numVecs / (numFolds - fold + 1)); 50 | 51 | % Store the fold size. 52 | foldSizes(i, fold) = foldSize; 53 | 54 | % Update the number of remaining vectors for this category. 55 | numVecs = numVecs - foldSize; 56 | end 57 | end 58 | 59 | % Verify the fold sizes sum up correctly. 60 | if (any(sum(foldSizes, 2) ~= vecsPerCat)) 61 | disp("ERROR! The sum of fold sizes did not equal the number of category vectors."); 62 | return; 63 | end 64 | 65 | end 66 | -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/lib/error_reg.m: -------------------------------------------------------------------------------- 1 | function [err,G]=error_reg(g,x,y,m,z,is,K,alpha) 2 | % Error function used by tbmreg_fit 3 | % [err,G]=error_fun(g,x,y,m,z,is,K,alpha) 4 | % 5 | % Inputs: 6 | % g: gamma parameter, to be optimized 7 | % x: matrix of input vectors, size (n,d), n=nb pf examples, d=nb of features 8 | % m: matrix of bbas, size (n,c+1); focal element c+1 is output frame 9 | % is: indices of the K nearest neighbors 10 | % is(i,k) = index of the K-th NN of example i 11 | % K: nb of neighbors 12 | % alpha: parameter used to compute the bba's (usually >= 0.9) 13 | % 14 | % Outputs 15 | % err= value of objective function 16 | % G: derivative of error function with respect to g (empty in the current version; the derivative is evaluated 17 | % numerically by the optimization procedure harris.m 18 | 19 | [n,d]=size(x); 20 | c=size(m,2)-1; 21 | 22 | 23 | % Error calculation 24 | 25 | mk = [zeros(n,c) ones(n,1)]; 26 | mm = mk; 27 | phi = zeros(n,K); 28 | 29 | for k = 1:K 30 | I = is(:,k); 31 | phi(:,k) = alpha*exp(-g^2*sum((x(I,:)-x).^2,2)); 32 | mk = [(m(I,1:c).*repmat(phi(:,k),1,c)) (1- (1-m(I,c+1)) .* phi(:,k))]; 33 | mm = [(mm(:,1:c).*(mk(:,1:c)+repmat(mk(:,c+1),1,c))+... 34 | mk(:,1:c).*repmat(mm(:,c+1),1,c)) (mm(:,c+1).*mk(:,c+1))]; 35 | end 36 | Kn = sum(mm,2); 37 | mmn = mm./(Kn*ones(1,c+1)); 38 | 39 | yprev=mmn*z; 40 | err=mean((y-yprev).^2); 41 | G=[]; 42 | -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/lib/freqAttenGrad.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-WaveFeature and evidential regression for blood glucose detection/lib/freqAttenGrad.m -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/lib/getFoldVectors.m: -------------------------------------------------------------------------------- 1 | function [X_train, y_train, X_val, y_val] = getFoldVectors(X_sorted, y_sorted, ... 2 | categories, vecsPerCat, ... 3 | foldSizes, roundNumber) 4 | %GETFOLDVECTORS Selects the vectors to use for training and validation for the 5 | % specified round number. 6 | % [X_train, y_train, X_val, y_val] = getFoldVectors(X_sorted, y_sorted, ... 7 | % categories, vecsPerCat, ... 8 | % foldSizes, roundNumber) 9 | % 10 | % With n-fold cross-validation, the data set is divided into n folds, and then 11 | % training and validation are performed in 'n' separate rounds. In each round, 12 | % 1 fold is used for validation while the remaining n - 1 folds are used for 13 | % training. 14 | % 15 | % Parameters: 16 | % X_sorted - The matrix of input vectors, one per row, grouped by 17 | % category. 18 | % y_sorted - The category or class label of the associated input vector. 19 | % categories - A column vector listing the category values in use by this 20 | % data set. 21 | % vecsPerCat - Column vector listing the number of vectors in the dataset 22 | % for each category. 23 | % foldSizes - The precomputed fold sizes for each category. 24 | % roundNumber - The current round of validation (a value between 1 and the 25 | % number of folds). 26 | % 27 | % Returns: 28 | % Vectors to use for training in this round (with their associated 29 | % categories) and vectors to use for validation in this round (also with 30 | % their associated categories). 31 | 32 | % $Author: ChrisMcCormick $ $Date: 2013/07/31 22:00:00 $ $Revision: 1.0 $ 33 | 34 | X_train = []; 35 | y_train = []; 36 | X_val = []; 37 | y_val = []; 38 | 39 | % ================================ 40 | % Verify Sorting 41 | % ================================ 42 | 43 | % Verify the vectors are properly sorted. 44 | catStart = 1; 45 | 46 | % For each category... 47 | for (i = 1 : numel(categories)) 48 | 49 | % Compute the index of the last vector of this category. 50 | catEnd = catStart + vecsPerCat(i) - 1; 51 | 52 | % Verify that all of the vectors in the range catStart : catEnd have 53 | % the expected category. 54 | if (any(y_sorted(catStart : catEnd) ~= categories(i))) 55 | disp("Input vectors are not properly sorted!"); 56 | return; 57 | end 58 | 59 | % Set the starting index of the next category. 60 | catStart = catEnd + 1; 61 | end 62 | 63 | % ================================== 64 | % Select Vectors 65 | % ================================== 66 | 67 | % Get the number of folds from the foldSizes matrix. 68 | [~,numFolds] = size(foldSizes); 69 | 70 | catStart = 1; 71 | 72 | % For each category... 73 | for (catIndex = 1 : numel(categories)) 74 | 75 | % Get the list of fold sizes for this category as a column vector. 76 | catFoldSizes = foldSizes(catIndex, :)'; 77 | 78 | % Set the starting index of the first fold for this category. 79 | foldStart = catStart; 80 | 81 | % For each fold... 82 | for (foldIndex = 1 : numFolds) 83 | 84 | % Compute the index of the last vector in this fold. 85 | foldEnd = foldStart + catFoldSizes(foldIndex) - 1; 86 | 87 | % Select all of the vectors in this fold. 88 | foldVectors = X_sorted(foldStart : foldEnd, :); 89 | foldCats = y_sorted(foldStart : foldEnd, :); 90 | 91 | % If this fold is to be used for validation in this round... 92 | if (foldIndex == roundNumber) 93 | % Append the vectors to the validation set. 94 | X_val = [X_val; foldVectors]; 95 | y_val = [y_val; foldCats]; 96 | % Otherwise, use the fold for training. 97 | else 98 | % Append the vectors to the training set. 99 | X_train = [X_train; foldVectors]; 100 | y_train = [y_train; foldCats]; 101 | end 102 | 103 | % Update the starting index of the next fold. 104 | foldStart = foldEnd + 1; 105 | end 106 | 107 | % Set the starting index of the next category. 108 | catStart = catStart + vecsPerCat(catIndex); 109 | end 110 | 111 | end 112 | -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/lib/lssvr_predict.m: -------------------------------------------------------------------------------- 1 | function [ y_pred ] = lssvr_predict( x_input, x_train, alfa, bias, g ) 2 | %LSSVR_PREDICT -- instruction 3 | % details: 4 | %[Input] 5 | % x_input: the input range x; like x in the f(x) 6 | % x_train: the train x 7 | % alfa: Lagrange multipliers, N*1 vector, N is the number of sample 8 | % bias: a bias of the linear model, a number 9 | % g: Radial Basis Functon learning parameter, is equal to 1/2sigma^2(gaussian function) 10 | %[Output] 11 | % y_pred: the prediected value 12 | %[Reference] 13 | % https://www.mathworks.com/matlabcentral/fileexchange/73706-support-vector-regression-ls-svr-for-non-linear-functions 14 | % [1] L. T. Qin, S. S. Liu, H. L. Liu, and Y. H. Zhang, "Support vector regression and least squares support vector regression for hormetic dose-response curves fitting," (in English), Chemosphere, vol. 78, no. 3, pp. 327-334, Jan 2010, doi: 10.1016/j.chemosphere.2009.10.029. 15 | % Ludovico Cuoghi (2022). Support Vector Regression ( LS-SVR) for Non Linear functions (https://www.mathworks.com/matlabcentral/fileexchange/73706-support-vector-regression-ls-svr-for-non-linear-functions), MATLAB Central File Exchange. Retrieved April 22, 2022. 16 | if nargin < 4 17 | g = 0.01; 18 | end 19 | [~,x_length] = size(x_input); 20 | xs_length=length(x_train); 21 | 22 | A = x_input'*x_train; 23 | M = diag(diag(x_input'*x_input))*ones(x_length,xs_length); 24 | M2 = ones(x_length,xs_length)*diag(diag(x_train'*x_train)); 25 | A=M+M2-2*A; 26 | A = exp(-g*A); 27 | 28 | y_pred = A*alfa+bias; 29 | end 30 | 31 | -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/lib/lssvr_train.m: -------------------------------------------------------------------------------- 1 | function [ alfa, bias ] = lssvr_train( x_train, y_train, C, g ) 2 | %LSSVR_TRAIN -- instruction 3 | % details: 4 | %[Input] 5 | % x_train: the input range x; like x in the f(x); each x should be a col vector 6 | % y_train: the input data 7 | % C: Parameter defined to avoid overfitting 8 | % g: Radial Basis Functon learning parameter, is equal to 1/2sigma^2(gaussian function) 9 | %[Output] 10 | % alfa: Lagrange multipliers, N*1 vector, N is the number of sample 11 | % bias: a bias of the linear model, a number 12 | %[Reference] 13 | % https://www.mathworks.com/matlabcentral/fileexchange/73706-support-vector-regression-ls-svr-for-non-linear-functions 14 | % [1] L. T. Qin, S. S. Liu, H. L. Liu, and Y. H. Zhang, "Support vector regression and least squares support vector regression for hormetic dose-response curves fitting," (in English), Chemosphere, vol. 78, no. 3, pp. 327-334, Jan 2010, doi: 10.1016/j.chemosphere.2009.10.029. 15 | % Ludovico Cuoghi (2022). Support Vector Regression ( LS-SVR) for Non Linear functions (https://www.mathworks.com/matlabcentral/fileexchange/73706-support-vector-regression-ls-svr-for-non-linear-functions), MATLAB Central File Exchange. Retrieved April 22, 2022. 16 | %% parameter check 17 | if nargin < 2 18 | C = 100; 19 | elseif nargin < 3 20 | g = 0.01; 21 | end 22 | %% main body 23 | xs_length=length(x_train); 24 | A = x_train'*x_train; 25 | M=diag(diag(A))*ones(xs_length,xs_length); % -> N = repmat(diag(A2),[1,N]) 26 | A=M+M'-2*A; 27 | % R=diag(Inf*ones(xs_lenght,1)); % remove the self 28 | % A2=max(A2,R); % A2 means the distrances of these x (||x-xi||^2) 29 | A = exp(-g*A); 30 | A = A + 1/C*diag(ones(xs_length,1)); 31 | 32 | O=[0, ones(1,xs_length); 33 | ones(xs_length,1), A]; 34 | 35 | b=zeros(xs_length+1,1); 36 | c=zeros(xs_length+1,1); 37 | 38 | c(2:xs_length+1) = y_train'; 39 | 40 | b=inv(O)*c; %it contains LaGrange multipliers and bias 41 | 42 | % For convenience, we separate the LaGrange Multipliers and the Bias term 43 | 44 | %Bias term 45 | bias=b(1,1); 46 | 47 | %Define LaGrange Multipliers alfa 48 | alfa=b(2:xs_length+1); 49 | 50 | end 51 | 52 | -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/lib/randSortAndGroup.m: -------------------------------------------------------------------------------- 1 | function [X_sorted, y_sorted] = randSortAndGroup(X, y, categories) 2 | %RANDSORTANDGROUP Randomly sort the vectors in X, then group them by category. 3 | % [X_sorted, y_sorted] = randSortAndGroup(X, y, categories); 4 | % 5 | % Parameters: 6 | % X - The matrix of input vectors, one per row. 7 | % y - The category or class label of the associated input vector. 8 | % categories - A column vector listing the category values in use by this data set. 9 | % 10 | % Returns: 11 | % The inputs X and y but with the vectors grouped by category and in a random 12 | % order within their category. 13 | 14 | % $Author: ChrisMcCormick $ $Date: 2013/07/31 22:00:00 $ $Revision: 1.0 $ 15 | 16 | % ====================================== 17 | % Randomly Sort The Vectors 18 | % ====================================== 19 | 20 | % Get the total number of input vectors. 21 | [totalVecs,~] = size(X); 22 | 23 | % Get a random order of the indeces. 24 | randOrder = randperm(totalVecs)'; 25 | 26 | % Sort the vectors and categories with the random order. 27 | randVecs = X(randOrder, :); 28 | randCats = y(randOrder, :); 29 | 30 | X_sorted = []; 31 | y_sorted = []; 32 | 33 | % ======================================= 34 | % Group The Vectors By Category 35 | % ======================================= 36 | 37 | % Re-group the vectors according to category. 38 | Num_categories = numel(categories); 39 | for (i = 1 : Num_categories) 40 | 41 | % Get the next category value. 42 | cat = categories(i); 43 | 44 | % Select all of the vectors for this category. 45 | catVecs = randVecs((randCats == cat), :); 46 | catCats = randCats((randCats == cat), :); 47 | 48 | % Append the vectors for this category. 49 | X_sorted = [X_sorted; catVecs]; 50 | y_sorted = [y_sorted; catCats]; 51 | end 52 | 53 | end 54 | -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/lib/st.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-WaveFeature and evidential regression for blood glucose detection/lib/st.m -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/lib/tbmreg_fit.m: -------------------------------------------------------------------------------- 1 | function [g,err,z] = tbmreg_fit(x,y,w,K,alpha,g0,ymin,ymax); 2 | 3 | % Learning algorithm for TBM regression method 4 | % [g,err,z] = tbmreg_fit(x,y,w,K,alpha,g0,ymin,ymax); 5 | 6 | % Inputs: 7 | 8 | % x: matrix of input vectors, size (n,d), n=nb pf examples, d=nb of features 9 | % y: vector (n,1) of target outputs 10 | % w: vector (n,1) or reliabilities of target output values (1: the value is fully reliable; 0: the value is actually 11 | % totally unknown) 12 | % K: number of neighbors 13 | % alpha: parameter used to compute the bba's (usually >= 0.9) 14 | % g0: initial guess for gamma parameter (a scalar) 15 | % ymin, ymax: lower and upper bounds for the domain of the output variable 16 | 17 | % Outputs: 18 | 19 | % g: optimized scalar gamma parameter 20 | % err: training error 21 | % z: vector of the c distinct values of y in the training sets (the focal elements of the output bba's) 22 | 23 | % USES: 24 | % err_reg.m : error function, returns the error and the gradient 25 | % MATLAB optimization toolbox (function fminbnd) 26 | 27 | % Reference : 28 | % S. Petit-Renaud and T. Denoeux. Nonparametric regression analysis of uncertain and imprecise data using 29 | % belief Functions. International Journal of Approximate Reasoning, Vol. 35, No. 1, 1-28, 2004. 30 | 31 | [n,d]=size(x); 32 | [z,ii,jj]=unique(y); 33 | c=length(z); 34 | m=zeros(n,c+1); 35 | for i=1:n 36 | m(i,jj(i))=w(i); 37 | m(i,c+1)=1-w(i); 38 | end 39 | z(c+1)=(ymax+ymin)/2; 40 | 41 | % Search for K nearest neighbors in training set 42 | 43 | D=x*x'; 44 | N=diag(diag(D))*ones(n,n); % -> N = repmat(diag(D),[1,N]) 45 | D=N+N'-2*D; 46 | R=diag(Inf*ones(n,1)); % remove the self 47 | D=max(D,R); % D means the distrances of these x (||x-xi||^2) 48 | 49 | is=zeros(n,K); % the minimum in the first col. 50 | for i=1:K 51 | [tmp,I]=min(D,[],2); % the minimum of each row. 52 | is(:,i)=I; 53 | D=max(D,R(I,:)); 54 | end 55 | % Optimization 56 | 57 | 58 | options=optimset('fminbnd'); 59 | g=fminbnd('error_reg',eps,20,options,x,y,m,z,is,K,alpha); 60 | err=error_reg(g,x,y,m,z,is,K,alpha); 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/lib/tbmreg_val.m: -------------------------------------------------------------------------------- 1 | function [mt,mtn,yprev,z] = tbmreg_val(x,y,w,xt,K,alpha,g,ymin,ymax); 2 | 3 | % Propagation algorithm for TBM regression method 4 | % [mt,mtn,yprev,z] = tbmreg_val(x,y,w,xt,K,alpha,g,ymin,ymax); 5 | 6 | % Inputs: 7 | 8 | % x: matrix of input vectors, size (n,d), n=nb pf examples, d=nb of features 9 | % y: vector (n,1) of target outputs 10 | % w: vector (n,1) or reliabilities of target output values (1: the value is fully reliable; 0: the value is actually 11 | % totally unknown) 12 | % xt: matrix (nt,d) of test input vectors 13 | % K: number of neighbors 14 | % alpha: parameter used to compute the bba's (usually >= 0.9) 15 | % g: gamma parameter (a scalar) 16 | % ymin, ymax: lower and upper bounds for the domain of the output variable 17 | 18 | % Outputs: 19 | 20 | % mt: matrix (nt,c+1) of unnormalized output bba's for teh test examples 21 | % mtn: matrix (nt,c+1) of normalized output bba's for teh test examples 22 | % yprev: vector (nt,1) of point predictions for the test examples 23 | % z: vector of the c distinct values of y in the training sets (the focal elements of the output bba's) 24 | 25 | % USES: 26 | % err_reg.m : error function, returns the error and the gradient 27 | % harris.m : optimization procedure 28 | 29 | % Reference : 30 | % S. Petit-Renaud and T. Denoeux. Nonparametric regression analysis of uncertain and imprecise data using 31 | % belief Functions. International Journal of Approximate Reasoning, Vol. 35, No. 1, 1-28, 2004. 32 | 33 | [n,d]=size(x); 34 | nt=size(xt,1); 35 | 36 | [z,ii,jj]=unique(y); 37 | c=length(z); 38 | m=zeros(n,c+1); 39 | for i=1:n, 40 | m(i,jj(i))=w(i); 41 | m(i,c+1)=1-w(i); 42 | end; 43 | z(c+1)=(ymax+ymin)/2; 44 | 45 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 46 | % Computation of the K-nearest neighbors in the training set 47 | 48 | D=xt*x'; 49 | D=repmat(sum(xt.^2,2),1,n)+repmat(sum(x.^2,2)',nt,1)-2*D; 50 | R=diag(Inf*ones(n,1)); 51 | 52 | ist=zeros(nt,K); 53 | for i=1:K 54 | [tmp,I]=min(D,[],2); 55 | ist(:,i)=I; 56 | D=max(D,R(I,:)); 57 | end 58 | 59 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 60 | % Computation of the bba's 61 | 62 | mk = [zeros(nt,c) ones(nt,1)]; 63 | mt = mk; 64 | phi = zeros(nt,K); 65 | 66 | for k = 1:K 67 | I = ist(:,k); 68 | phi = alpha*exp(-g^2*sum((x(I,:)-xt).^2,2)); 69 | mk = [(m(I,1:c).*repmat(phi,1,c)) (1-(1-m(I,c+1)) .* phi)]; 70 | mt = [(mt(:,1:c).*(mk(:,1:c)+repmat(mk(:,c+1),1,c))+... 71 | mk(:,1:c).*repmat(mt(:,c+1),1,c)) (mt(:,c+1).*mk(:,c+1))]; 72 | end 73 | 74 | % normalization 75 | 76 | Kn = sum(mt,2); 77 | mtn = mt./(Kn*ones(1,c+1)); 78 | yprev=mtn*z; 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/lib/teagerEnergy.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-WaveFeature and evidential regression for blood glucose detection/lib/teagerEnergy.m -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/real-data.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-WaveFeature and evidential regression for blood glucose detection/real-data.mat -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/real-data2.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-WaveFeature and evidential regression for blood glucose detection/real-data2.mat -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/real-data_total.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-WaveFeature and evidential regression for blood glucose detection/real-data_total.mat -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/result_data_Long.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-WaveFeature and evidential regression for blood glucose detection/result_data_Long.mat -------------------------------------------------------------------------------- /Code-WaveFeature and evidential regression for blood glucose detection/result_data_chen.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcs7846/code-paper-recurrent/0278c487d1295e8feeb49d758ec7f1c8a988453e/Code-WaveFeature and evidential regression for blood glucose detection/result_data_chen.mat --------------------------------------------------------------------------------