diff --git a/Default Models/DefaultMassModels.txt b/Default Models/DefaultMassModels.txt new file mode 100644 index 0000000..8b18b6e --- /dev/null +++ b/Default Models/DefaultMassModels.txt @@ -0,0 +1,4 @@ +Mass_IDH_Mutant +Mass_IDH_Only +Mass_TERTp_Only +Mass_Double_Mutant \ No newline at end of file diff --git a/Default Models/DefaultModelsLog.txt b/Default Models/DefaultModelsLog.txt new file mode 100644 index 0000000..d850a72 --- /dev/null +++ b/Default Models/DefaultModelsLog.txt @@ -0,0 +1,5 @@ +IDH_Mutant +IDH_Only +TERT_Mutant +TERT_Only +Double_Mutant \ No newline at end of file diff --git a/Default Models/MassDefaults/Mass_Double_Mutant.mat b/Default Models/MassDefaults/Mass_Double_Mutant.mat new file mode 100644 index 0000000..b8a4430 Binary files /dev/null and b/Default Models/MassDefaults/Mass_Double_Mutant.mat differ diff --git a/Default Models/MassDefaults/Mass_IDH_Mutant.mat b/Default Models/MassDefaults/Mass_IDH_Mutant.mat new file mode 100644 index 0000000..e46f784 Binary files /dev/null and b/Default Models/MassDefaults/Mass_IDH_Mutant.mat differ diff --git a/Default Models/MassDefaults/Mass_IDH_Only.mat b/Default Models/MassDefaults/Mass_IDH_Only.mat new file mode 100644 index 0000000..b982558 Binary files /dev/null and b/Default Models/MassDefaults/Mass_IDH_Only.mat differ diff --git a/Default Models/MassDefaults/Mass_TERTp_Only.mat b/Default Models/MassDefaults/Mass_TERTp_Only.mat new file mode 100644 index 0000000..3de10b2 Binary files /dev/null and b/Default Models/MassDefaults/Mass_TERTp_Only.mat differ diff --git a/Default Models/ModelsV2/Double_Mutant.mat b/Default Models/ModelsV2/Double_Mutant.mat new file mode 100644 index 0000000..f7309f1 Binary files /dev/null and b/Default Models/ModelsV2/Double_Mutant.mat differ diff --git a/Default Models/ModelsV2/IDH_Mutant.mat b/Default Models/ModelsV2/IDH_Mutant.mat new file mode 100644 index 0000000..a3300bd Binary files /dev/null and b/Default Models/ModelsV2/IDH_Mutant.mat differ diff --git a/Default Models/ModelsV2/IDH_Only.mat b/Default Models/ModelsV2/IDH_Only.mat new file mode 100644 index 0000000..5a68d46 Binary files /dev/null and b/Default Models/ModelsV2/IDH_Only.mat differ diff --git a/Default Models/ModelsV2/TERT_Mutant.mat b/Default Models/ModelsV2/TERT_Mutant.mat new file mode 100644 index 0000000..798820b Binary files /dev/null and b/Default Models/ModelsV2/TERT_Mutant.mat differ diff --git a/Default Models/ModelsV2/TERT_Only.mat b/Default Models/ModelsV2/TERT_Only.mat new file mode 100644 index 0000000..1c962ca Binary files /dev/null and b/Default Models/ModelsV2/TERT_Only.mat differ diff --git a/IRIS.mlapp b/IRIS.mlapp new file mode 100644 index 0000000..ef041a4 Binary files /dev/null and b/IRIS.mlapp differ diff --git a/Scripts/ADASYN.m b/Scripts/ADASYN.m new file mode 100644 index 0000000..7136ba3 --- /dev/null +++ b/Scripts/ADASYN.m @@ -0,0 +1,359 @@ +function [out_featuresSyn, out_labelsSyn] = ADASYN(in_features, in_labels, in_beta, in_kDensity, in_kSMOTE, in_featuresAreNormalized) +%this function implements the ADASYN method as proposed in the following +%paper: +% +%[1]: H. He, Y. Bai, E.A. Garcia, and S. Li, "ADASYN: Adaptive Synthetic +%Sampling Approach for Imbalanced Learning", Proc. Int'l. J. Conf. Neural +%Networks, pp. 1322--1328, (2008). +% +%the implementation follows the notation and equation numbers given in +%section 3.1.4 of another paper: +% +%[2]: H. He and E.A. Garcia, "Learning from imbalanced data", +%Knowledge and Data Engineering, IEEE Transactions on 21, no. 9, +%pp. 1263--1284, (2009). +% +% +%the purpose of the ADASYN method is to improve class balance towards +%equally-sized classes for a given input dataset. this is achieved by +%synthetically creating new examples from the minority class via linear +%interpolation between existing minority class samples. this approach is +%known as the SMOTE method, cf. section 3.1.3 in [2]. ADASYN is an +%extension of SMOTE, creating more examples in the vicinity of the boundary +%between the two classes, than in the interior of the minority class. +%cf. the supplied script demo_ADASYN for an example of this. +% +% +% INPUTS: +%---------- +%in_features: +%(N \times P) matrix of numerical features. each row is one example, each +%column is one feature, hence there are N examples with P features each. +% +%in_labels: +%boolean N-vector of labels, defining the classes to which the examples in +%in_features belong. +% +%in_beta [default: 1]: +%desired level of balance, where 0 means that the size of the minority +%class will not be changed, and 1 means that the minority class will be +%ADASYNed to have (approximately, due to rounding) the same size as the +%majority class. any value of in_beta between 0 and 1 provides a compromise +%between these two extremes. +%note that in_beta IS NOT the resulting class ratio, but a percentage of +%how much class balance is improved in comparison to the given class +%balance! 0 means nothing is improved in comparison to the given class +%balance and 1 means class sizes are perfectly equalized (except for small +%rounding-related deviations). +% +%in_kDensity [default: 5]: +%k for kNN used in ADASYN density estimation, i.e. in calculation of the +%\Gamma_i values in eq. (4) of reference [2]. this is the kNN call that +%regards examples from both classes. +% +%in_kSMOTE [default: 5]: +%k for kNN used in subsequent SMOTE-style synthesis of new examples. +%this is the kNN call that regards only examples from the minority class. +%cf. eq. (1) in reference [2]. +% +%in_featuresAreNormalized [default: true]: +%boolean indicating whether the features (i.e. the different columns) in +%in_features are already normalized to the same scale or not. +%by default normalized features are assumed as the input, i.e. the user is +%expected to apply a normalization method of choice before passing the data +%to the ADASYN function. +%the practical difference in the two values of in_featuresAreNormalized is +%the following: +%true: Euclidean distance is used in all kNN calls. for reasonable +% results, in_features should already be normalized when calling +% ADASYN(). +%false: standardized Euclidean distance (type "doc knnsearch" into MATLAB +% console and look for 'seuclidean' for an explanation) is used in +% all kNN calls. any normalization already present in in_features is +% ignored, and instead unit variance normalization is used. +% however, this does NOT modify the data. the normalization is only +% applied within knnsearch. +% +% +% OUTPUTS: +%---------- +%out_featuresSyn, out_labelsSyn: +%features and labels of ONLY the synthetically created examples. +%note that each entry of out_labelsSyn is the label of the minority class +%since only examples of the minority class are created. +%concatenating [in_features out_featuresSyn] and [in_labels out_labelsSyn] +%gives a new example set with the desired class balance. +% +% +% +% +%------------------------------------------------------------------------- +% Version: 1.0 +% Date: 2015-04-17 +% Author: Dominic Siedhoff +%------------------------------------------------------------------------- +% +% +%------------------------------------------------------------------------- +% Copyright (c) 2015 Dominic Siedhoff +%------------------------------------------------------------------------- +% +% License: This software may be freely used, shared and modified. It must +% not be sold. It is provided without any explicit or implicit +% warranty of any kind. This license text must be included with +% every copy made. +% +%------------------------------------------------------------------------- + + + + +if nargin < 3 || isempty(in_beta) + in_beta = 1; +end + +if nargin < 4 || isempty(in_kDensity) + in_kDensity = 5; +end + +if nargin < 5 || isempty(in_kSMOTE) + in_kSMOTE = 5; +end + +if nargin < 6 || isempty(in_featuresAreNormalized) + in_featuresAreNormalized = true; +end + + +if in_beta == 0 + %nothing needs to be done because beta==0 is defined to mean that + %current class ratio is kept: + out_featuresSyn = []; + out_labelsSyn = []; + return; +end + + +if ~all(in_labels==0 | in_labels==1) + error('ADASYN: in_labels may contain only the values 0 and 1.'); +end + + +numZeros = sum(in_labels==0); +numOnes = sum(in_labels==1); + +if numOnes == numZeros + %nothing needs to be done because if classes are already balanced, then + %for any in_beta, this is already the desired result. + out_featuresSyn = []; + out_labelsSyn = []; + return; +else + if numZeros > numOnes + majLabel = logical(0); + minLabel = logical(1); + else + majLabel = logical(1); + minLabel = logical(0); + end +end + +%rename: +S = in_features; +clear in_features; + +%feature sets by class: +Smin = S(in_labels==minLabel,:); +Smaj = S(in_labels==majLabel,:); + +%eq (3): +G = (size(Smaj,1) - size(Smin,1)) * in_beta; +G = round(G); + +%handle boundary cases: +if size(Smin,1)==0 + warning('ADASYN: there were no examples of the minority class in the data. hence balancing is not possible. Returning empty matrices.'); + out_featuresSyn = []; + out_labelsSyn = []; + return; +end + +if size(Smin,1)==1 + warning('ADASYN: there was only one example of the minority class in the data. Hence returning G copies of that single example for balancing.'); + out_featuresSyn = repmat(Smin, [G 1]); + out_labelsSyn = logical(minLabel * ones([G 1])); + return; +end + + +if in_featuresAreNormalized + knnDistance = 'euclidean'; +else + %IMPORTANT: using 'seuclidean' as the distance measure means that + %standardized Euclidean distance is used, i.e. the standard deviation + %of the coordinates is automatically divided away. hence, using + %'seuclidean' instead of 'euclidean' saves the effort of normalizing + %the feature values by a Z-transformation (0mean,1var). + %cf. documentation of input parameter in_featuresAreNormalized for more + %information. + knnDistance = 'seuclidean'; +end + +%kNN for density estimation: +idcs = knnsearch_nonflat(S,Smin, 'K',in_kDensity+1, 'Distance',knnDistance); +%note: why in_kDensity+1? because Smin is a subset of S and hence all +%points in Smin have a trivial nearest neighbor in S with distance 0. +%but that neighbor is not interesting because it's the point from Smin +%itself. hence remove it: +idcs = idcs(:,2:end); + + +%compute the \Gamma values (eq. (4) in reference [2]): +Gamma = zeros([size(Smin,1) 1]); +for cmi=1:size(Smin,1) %cmi: current minority example index + cNNs = idcs(cmi,:); %current NearestNeighbors + cNNsLabels = in_labels(cNNs); %labels of cNNs: + cNNsLabelsMaj = (cNNsLabels == majLabel); + cDelta = nnz(cNNsLabelsMaj); %the Delta_i of eq. (4) in reference [2] + + %write Gamma, not yet normalized: + Gamma(cmi) = cDelta / in_kDensity; + +end + +%normalize Gamma to give a distribution function: +if sum(Gamma)==0 + %if there is no class overlap w.r.t. these knn settings, create a + %uniform distribution: + Gamma = 1/length(Gamma) * ones(size(Gamma)); +else + %create nonuniform distribution: + Gamma = Gamma / sum(Gamma); %this makes it exactly eq. (4) in reference [2] +end + +%compute g_i (eq. (5) in reference [2]): +%these g_i are the numbers of synthetic examples to be generated from each +%example in Smin +g = round(Gamma * G); + +if sum(g)==0 + warning('ADASYN: Classes are already well-balanced (i.e. sum(g)==0). Returning empty matrices.'); + out_featuresSyn = []; + out_labelsSyn = []; + return; +end + +%with this g known, call the ADASYN_SMOTE subroutine...: +out_featuresSyn = ADASYN_SMOTE(Smin,g,in_kSMOTE,knnDistance); + +%...and generate the labels: +out_labelsSyn = logical(minLabel * ones([size(out_featuresSyn,1) 1])); +out_featuresSyn=[S; out_featuresSyn] + +out_labelsSyn=[in_labels ; out_labelsSyn] + +function Ssyn = ADASYN_SMOTE(Smin,g,k,knnDistance) +%subroutine implementing SMOTE algorithm as it is to be used by function +%ADASYN(). cf. section 3.1.3 in the following paper for details: +% +%[2]: H. He and E.A. Garcia, "Learning from imbalanced data", +%Knowledge and Data Engineering, IEEE Transactions on 21, no. 9, +%pp. 1263--1284, (2009). +% +% +% INPUTS: +%---------- +% +%Smin: +%minority set from ADASYN() +% +%g: +%minority example synthesis counts as computed by ADASYN() +% +%k: +%number of neighbors to be regarded in kNN for SMOTE algorithm +% +%knnDistance: +%distance function used in kNN for SMOTE algorithm. depends on ADASYN's +%parameter in_featuresAreNormalized. please type "help ADASYN" into +%MATLAB's console for more information +% +% +% OUTPUTS: +%---------- +%Ssyn: set of synthetic examples created from input set Smin by applying +%the SMOTE algorithm + + +%determine nearest neighbors: +idcs = knnsearch_nonflat(Smin,Smin, 'K',k+1, 'Distance',knnDistance); +%note: why k+1? because we search kNNs of Smin in Smin itself and hence all +%points in Smin have a trivial nearest neighbor in Smin with distance 0. +%but that neighbor is not interesting because it's the point from Smin +%itself. hence remove it: +idcs = idcs(:,2:end); + +%initialize output and writing target as an empty matrix +Ssyn = zeros([0 size(Smin,2)]); + +%for every minority example xi... +for cei=1:size(Smin,1) %cei: current example index + + %current minority example: + xi = Smin(cei,:); + + %number of synthetic examples to be created from xi: + gi = g(cei); + + %allocate space for gi examples to be created from xi: + xiSyn = zeros(gi, size(Smin,2)); + + %...iterate over synthetic examples to be created from xi and + %random partner from set of nearest neighbors: + for csi=1:gi %csi: current synthetic example index + + %get random partner example from nearest neighbors of xi: + %neighbor index: + nIdx = idcs(cei, randi(size(idcs,2))); + %neighbor: + xiHat = Smin(nIdx,:); + + %create synthetic example as according to eq. (1) in reference [2]: + delta = rand(1); + xSyn = xi + delta * (xiHat - xi); + + %write it to xiSyn: + xiSyn(csi,:) = xSyn; + + end + + %append examples synthesized from xi to overall synthetic example set: + Ssyn = [Ssyn; xiSyn]; + +end + + + + + +function [IDX,D] = knnsearch_nonflat(X,Y, varargin) +%wraps knnsearch from MATLAB's statistics toolbox. +%knnsearch_nonflat executes knnsearch only on the dimensions with nonzero +%standard deviation, i.e. the flat dimensions are not passed on to +%knnsearch. this prevents pdist2 from producing the following warning in +%the context of standardized Euclidean distance ('seuclidean') in the +%presence of flat dimensions: +%"Warning: Some columns of S are zeros." +%if this warning occurs, pdist2 (and as a consequence knnsearch) gives only +%bad dummy results because the standardized Euclidean distance can not be +%computed properly in the presence of flat dimensions. +%using knnsearch_nonflat prevents this by filtering out flat dimensions. + +nonflatX = std(X) ~= 0; +nonflatY = std(Y) ~= 0; + +nonflat = nonflatX & nonflatY; + +[IDX,D] = knnsearch(X(:,nonflat), Y(:,nonflat), varargin{:}); + + diff --git a/Scripts/assignVals.m b/Scripts/assignVals.m new file mode 100644 index 0000000..2f1eb33 --- /dev/null +++ b/Scripts/assignVals.m @@ -0,0 +1,58 @@ +function [cx,f]=assignVals(app,metabolites,columns,varargin) + + poss=get(0,'ScreenSize'); + f=uifigure('Position',[poss(3)/4 poss(3)/4 300 300],'Color','White','DeleteFcn',@assign); + f.Position(3); + lbl=uilabel(f,'Text','Assign Metabolites','Position',[100 f.Position(3)-25 122 20]); + + lbl=uilabel(f,'Text','Required Variables','Position',[15 f.Position(3)-75 125 20]); + lbl=uilabel(f,'Text','Excel Variables','Position',[160 f.Position(3)-75 125 20]); + + drop=uidropdown(f,'Position',[15 f.Position(3)-100 125 20],'BackgroundColor','White' ,'Items',metabolites); + drop2=uidropdown(f,'Position',[160 f.Position(3)-100 125 20],'BackgroundColor','White' ,'Items',columns); + + + btn = uibutton(f,'push',... + 'Position',[100 f.Position(3)-200 122 20],... + 'ButtonPushedFcn', @btnPushed); + btn.Text='Assign Metabolites'; + + btn2 = uibutton(f,'push',... + 'Position',[100 f.Position(3)-225 122 20],... + 'ButtonPushedFcn', @save); + btn2.Text='Save'; + + lbl=uilabel(f,'Text','Metabolites assigned','Position'... + ,[10 f.Position(3)-280 300 20]); + lbl.Visible='off'; + global assignedList + global reqVars; + reqVars=zeros(1,length(drop.Items)); + function btnPushed(varargin) + + + [~,ind2]=ismember(drop2.Value,drop2.Items); + [~,ind]=ismember(drop.Value,drop.Items); + reqVars(ind)=ind2; + + str = strjoin(drop.Items(find(reqVars>0)),', '); + lbl.Text=['Metabolite(s) ' str ' has been assigned']; + lbl.Visible='on'; + lbl.Tooltip=lbl.Text; + + end + global cx; + function save(varargin) + app.reqVars=reqVars; + cx=reqVars; + delete(f); + end + function cx=assign(varargin) + + cx=reqVars + try + app.reqVars=reqVars + catch + end + end +end \ No newline at end of file diff --git a/Scripts/assignVals2.m b/Scripts/assignVals2.m new file mode 100644 index 0000000..1c6edeb --- /dev/null +++ b/Scripts/assignVals2.m @@ -0,0 +1,68 @@ +function [cx,f]=assignVals2(app,metabolites,columns,varargin) + + poss=get(0,'ScreenSize'); + f=uifigure('Position',[poss(3)/4 poss(3)/4 300 300],'Color','White','DeleteFcn',@assign); + f.Position(3); + lbl=uilabel(f,'Text','Assign Metabolites','Position',[100 f.Position(3)-25 122 20]); + + lbl=uilabel(f,'Text','Required Variables','Position',[15 f.Position(3)-75 125 20]); + lbl=uilabel(f,'Text','Excel Variables','Position',[195 f.Position(3)-75 125 20]); + lbl=uilabel(f,'Text','','Position',[100 f.Position(3)-75 125 20]); + + drop=uidropdown(f,'Position',[15 f.Position(3)-100 80 20],'BackgroundColor','White' ,'Items',metabolites); + drop2=uidropdown(f,'Position',[100 f.Position(3)-100 80 20],'BackgroundColor','White' ,'Items',columns); + drop3=uidropdown(f,'Position',[195 f.Position(3)-100 80 20],'BackgroundColor','White' ,'Items',columns); + + + btn = uibutton(f,'push',... + 'Position',[85 f.Position(3)-200 152 20],... + 'ButtonPushedFcn', @btnPushed); + btn.Text='Assign Standard Deviations'; + + btn2 = uibutton(f,'push',... + 'Position',[100 f.Position(3)-225 122 20],... + 'ButtonPushedFcn', @save); + btn2.Text='Save'; + + lbl=uilabel(f,'Text','Metabolites assigned','Position'... + ,[10 f.Position(3)-280 300 20]); + lbl.Visible='off'; + global assignedList + global reqVars; + global reqVars2 + reqVars=zeros(1,length(drop.Items)); + reqVars2=zeros(1,length(drop.Items)); + + function btnPushed(varargin) + + + [~,ind2]=ismember(drop2.Value,drop2.Items); + [~,ind]=ismember(drop.Value,drop.Items); + [~,ind3]=ismember(drop3.Value,drop3.Items); + + reqVars(ind)=ind3 + reqVars2(ind)=ind2 + + str = strjoin(drop.Items(find(reqVars>0)),', '); + lbl.Text=['Metabolite(s) ' str ' has been assigned']; + lbl.Visible='on'; + lbl.Tooltip=lbl.Text; + + end + global cx; + function save(varargin) + + cx=reqVars; + delete(f); + end + function cx=assign(varargin) + + cx=reqVars + try + app.reqVars=reqVars + app.reqVars2=reqVars2; + catch + end + end + %app.reqVars=reqVars; +end \ No newline at end of file diff --git a/Scripts/assignVals3.m b/Scripts/assignVals3.m new file mode 100644 index 0000000..502c292 --- /dev/null +++ b/Scripts/assignVals3.m @@ -0,0 +1,126 @@ +function [cx,f]=assignVals3(app,metabolites,columns,varargin) + + poss=get(0,'ScreenSize'); + f=uifigure('Position',[poss(3)/4 poss(3)/4 300 300],'Color','White','DeleteFcn',@assign); + f.Position(3); + %% + %Labels + lbl=uilabel(f,'Text','Assign Standard Deviations','Position',[100 f.Position(3)-25 122 20]); + lbl=uilabel(f,'Text','Standard Deviations','Position',[15 f.Position(3)-75 125 20]); + lbl=uilabel(f,'Text','All Variables','Position',[160 f.Position(3)-75 125 20]); + lbl=uilabel(f,'Text','Metabolites assigned','Position'... + ,[10 f.Position(3)-280 300 20]); + lbl.Visible='off'; + + %% + %dropDowns + drop=uidropdown(f,'Position',[15 f.Position(3)-100 125 20],'BackgroundColor','White' ,'Items',metabolites); + drop2=uidropdown(f,'Position',[160 f.Position(3)-100 125 20],'BackgroundColor','White' ,'Items',columns); + +%% +%Buttons + btn = uibutton(f,'push',... + 'Position',[80 f.Position(3)-200 162 20],... + 'ButtonPushedFcn', @btnPushed); + btn.Text='Assign Standard Deviations'; + + btn2 = uibutton(f,'push',... + 'Position',[100 f.Position(3)-225 122 20],... + 'ButtonPushedFcn', @save); + btn2.Text='Save'; + + asRule = uibutton(f,'push',... + 'Position',[100 f.Position(3)-250 122 20],... + 'ButtonPushedFcn', @asRuleFcn); + asRule.Text='Define a Rule'; + +%% + + global assignedList + global reqVars; + reqVars=zeros(1,length(drop.Items)); +%% + % Functions + + + function asRuleFcn(varargin) + + prompt = {'Enter the rule. (e.g +1 ,-1,+5):'}; + dlg_title = 'Assign STDs and corresponding Conc/Ratio'; + num_lines= 1; + def = {'0'}; + answer = inputdlg(prompt,dlg_title,num_lines,def); + + ff=uifigure('Position',[100,100,600,400],'Color','White','DeleteFcn',@assign); + + stdList=uilistbox(ff,'Position',[50,100,150,250]); + metList=uilistbox(ff,'Position',[200,100,150,250]); + metDrop=uidropdown(ff,'Position',[370,215,150,30],'BackgroundColor','White' ,'Items',drop2.Items); + change = uibutton(ff,'push',... + 'Position',[370,150,150,30],... + 'ButtonPushedFcn', @changeFcn); + change.Text='Change'; + ok = uibutton(ff,'push',... + 'Position',[370,115,150,30],... + 'ButtonPushedFcn', @okFcn); + ok.Text='OK'; + + + function okFcn(varargin) + + str=strjoin(metList.Items,','); + lbl.Text=[str ' are assigned']; + lbl.Visible="on"; + reqVars=find(ismember(drop2.Items,metList.Items)==1); + delete(ff); + + end + + function changeFcn(varargin) + items=metList.Items + ind=find(ismember(metList.Items,metList.Value)==1) + items{ind}=metDrop.Value; + metList.Items=items; + + end + + stdList.Items=drop.Items; + inds=find(ismember(drop2.Items,drop.Items)==1); + inds2=str2num(string(answer))+inds; + metList.Items={drop2.Items{inds2}}; + + end + + + + + + function btnPushed(varargin) + + + [~,ind2]=ismember(drop2.Value,drop2.Items); + [~,ind]=ismember(drop.Value,drop.Items); + reqVars(ind)=ind2; + + str = strjoin(drop.Items(find(reqVars>0)),', '); + lbl.Text=['Metabolite(s) ' str ' has been assigned']; + lbl.Visible='on'; + lbl.Tooltip=lbl.Text; + + end + global cx; + function save(varargin) + app.reqVars2=reqVars; + + cx=reqVars; + delete(f); + end + function cx=assign(varargin) + + cx=reqVars + try + app.reqVars2=reqVars + catch + end + end +end \ No newline at end of file diff --git a/Scripts/barplotM.m b/Scripts/barplotM.m new file mode 100644 index 0000000..71c80d9 --- /dev/null +++ b/Scripts/barplotM.m @@ -0,0 +1,37 @@ +function barplotM(ax,data,groups) + +classes=data(:,groups); +inds=ones(1,size(data,2)); +inds(groups)=0; +groups2=table2array(data(:,groups)); +data2=data(:,find(inds==1)); + +classes=table2array(unique(classes)); +try +classes=classes(~(isnan(classes))); +catch +classes=string(classes(~(classes==""))); +end +classes + +k=1; +means=zeros(1,size(data2,2)); +for i=classes' + dats=data2(groups2==i,:); + + means=[means;mean(table2array(dats),1)]; + + +end + b=bar3(ax, means(2:end,:)); + + set(ax,'yticklabel',classes); + set(ax,'xticklabel',dats.Properties.VariableNames); + %ax.Grid="off"; + rotate3d (ax,'on'); + + + + +end + \ No newline at end of file diff --git a/Scripts/centerFigure.m b/Scripts/centerFigure.m new file mode 100644 index 0000000..e8e3ffc --- /dev/null +++ b/Scripts/centerFigure.m @@ -0,0 +1,49 @@ +function lo_table=centerFigure(figure,rpt) +import mlreportgen.dom.* +import mlreportgen.report.* +import mlreportgen.utils.* +pageLayout = getReportLayout(rpt); +pageSize = pageLayout.PageSize; +pageMargins = pageLayout.PageMargins; + +bodyWidth = units.toInches(pageSize.Width) - ... + units.toInches(pageMargins.Left) - ... + units.toInches(pageMargins.Right); + +if strcmpi(rpt.Type,"docx") + bodyWidth = bodyWidth - ... + units.toInches(pageMargins.Gutter); +end +bodyWidth = sprintf("%0.2fin",bodyWidth); + + +bodyHeight = units.toInches(pageSize.Height) - ... + units.toInches(pageMargins.Top) - ... + units.toInches(pageMargins.Bottom); + +if strcmpi(rpt.Type,"pdf") + bodyHeight = bodyHeight - ... + units.toInches(pageMargins.Header) - ... + units.toInches(pageMargins.Footer); +end +bodyHeight = sprintf("%0.2fin",bodyHeight); + +fig = (figure); +figImg = figure; +figImg.Style = [figImg.Style {ScaleToFit}]; + +para = Paragraph(figImg); +para.Style = [para.Style {OuterMargin("0in","0in","0in","0in")}]; + +lo_table = Table({para}); +lo_table.Width = bodyWidth; + +lo_table.TableEntriesStyle = [lo_table.TableEntriesStyle ... + { ... + Height(bodyHeight), ... + HAlign("center"), ... + VAlign("middle") ... + }]; + +add(rpt,lo_table); +end \ No newline at end of file diff --git a/Scripts/cnca.m b/Scripts/cnca.m new file mode 100644 index 0000000..0684f6f --- /dev/null +++ b/Scripts/cnca.m @@ -0,0 +1,27 @@ +function [features,L]=cnca(tablev,predictors,response,verbose) + + +obs=table2array(tablev(:,predictors)); +grp=table2array(tablev(:,response)); + +rng(2); % For reproducibility +cvp = cvpartition(grp,'holdout',0.2) + +Xtrain = obs(cvp.training,:); +ytrain = grp(cvp.training,:); +Xtest = obs(cvp.test,:); +ytest = grp(cvp.test,:); + + +nca = fscnca(Xtrain,ytrain,'FitMethod','exact','Lambda',0,... + 'Solver','sgd','Standardize',true,'Verbose',verbose); + +[cx,features]=sort(nca.FeatureWeights); + + + + +L = loss(nca,Xtest,ytest); + + +end \ No newline at end of file diff --git a/Scripts/confusionMatPlot.m b/Scripts/confusionMatPlot.m new file mode 100644 index 0000000..6e66668 --- /dev/null +++ b/Scripts/confusionMatPlot.m @@ -0,0 +1,54 @@ +function confusionMatPlot(ax,ygt,ypr,varargin) +f=ax +class=length(unique(ygt)); +boxes=class*class+class*2+1 +cla(ax); + +TextColor=[0 0 0] +RectColor=[1 1 1] + + + +for i=0:class + for j=0:class + + rectangle(f,'Position',[i/boxes j/boxes 1/boxes 1/boxes ],'FaceColor',RectColor) + if (i==0 | j==0)-(i==0 & j==0) + ind= max(i,j); + text(f,(i+0.5)/boxes,(j+0.5)/boxes,['Class ' num2str(ind-1)],'HorizontalAlignment','Center','Color',TextColor) + + elseif i==0 & j==0 + text(f,(i+0.5)/boxes,(j+0.5)/boxes,'All 100%','HorizontalAlignment','Center','Color',TextColor) + else + val=sum((ygt==i-1).*(ypr==j-1)) + percent=round(val/length(ygt),4)*100; + text(f,(i+0.5)/boxes,(j+0.5)/boxes,[num2str(val) ' ' num2str(percent) '%'],'HorizontalAlignment','Center','Color',TextColor) + end + end + +end +set(f, 'YDir','reverse'); +ax=f; +ax.Title.String="Ground Truth"; +ax.Title.Color=[0 0 0]; +ax.Title.ButtonDownFcn=@txtHandler; +ax.YLabel.String="Predicted"; +ax.YLabel.Color=[ 0 0 0]; +pos=get(ax.YLabel,'Position'); +t=text(f,pos(1),pos(2),'Prediction','Rotation',90,'Color',[0 0 0]); + + + +axis(ax,'off') + + + + + + + + + + + +end \ No newline at end of file diff --git a/Scripts/confusionMatPlotSideVal1.m b/Scripts/confusionMatPlotSideVal1.m new file mode 100644 index 0000000..c55081a --- /dev/null +++ b/Scripts/confusionMatPlotSideVal1.m @@ -0,0 +1,94 @@ + + +%Creates model plots for trained models + +% ax is the axis that you want to plot. Default is 'gca'. +% ygt is the ground truth. +% ypr is the predicted. +% +% 17.08.2020 +% Abdullah BAÅž +% Ph.D BME Bogazici University +% Turkish Republic Of Northern Cyprus + + + +function confusionMatPlotSideVal1(ax,ygt,ypr,varargin) +f=ax; +cla(ax); +class=length(unique(ygt)); +boxes=7*class; + +TextColor=[0 0 0] +RectColor=[1 1 1] +properties={'Sensitivity','FNR','FPR','Specificity','Prevalance','PPV','FOR'}; + +for i=0:class-1 + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens=(TP)/(TP+FN); + FNR= (FN)/(TP+FN); + FPR= (FP)/(FP+TN); + Specifity=(TN)/(FP+TN); + Prevalance=(TP+FN)/(sum(cmVals{i+1})); + PPV=(TP)/(TP+FP); + FOR=(FN)/(FN+TN); + + variableVals{i+1}=[Sens FNR FPR Specifity Prevalance PPV FOR] + +end + + + +for i=0:class + if i~=0 + valss=variableVals{i}; + end + for j=0:7 + + rectangle(f,'Position',[i/boxes j/boxes 1/boxes 1/boxes ],'FaceColor',RectColor) + if (j==0)-(i==0 & j==0) + ind= max(i,j); + text(f,(i+0.5)/boxes,(j+0.5)/boxes,['Class ' num2str(ind-1)],'HorizontalAlignment','Center','Color',TextColor) + elseif (i==0)-(i==0 & j==0) + + text(f,(i+0.5)/boxes,(j+0.5)/boxes,[properties{j}],'HorizontalAlignment','Center','Color',TextColor) + elseif i==0 & j==0 + text(f,(i+0.5)/boxes,(j+0.5)/boxes,'All 100%','HorizontalAlignment','Center','Color',TextColor) + else + + percent=round(valss(j),4)*100; + text(f,(i+0.5)/boxes,(j+0.5)/boxes,[' ' num2str(percent) '%'],'HorizontalAlignment','Center','Color',TextColor) + end + end + +end +set(f, 'YDir','reverse') +ax=f; +ax.Title.String="Classes"; +ax.Title.Color=[0,0,0]; +ax.Title.ButtonDownFcn=@txtHandler; +ax.YLabel.String="Metrics"; +ax.YLabel.Color=[0,0,0]; +pos=get(ax.YLabel,'Position'); +t=text(f,pos(1),pos(2),'Metrics','Rotation',90,'Color',[0,0,0]); + + +axis(ax,'off') + + + + + + + + + + + + +end \ No newline at end of file diff --git a/Scripts/confusionMatPlotSideVal2.m b/Scripts/confusionMatPlotSideVal2.m new file mode 100644 index 0000000..a7d33d6 --- /dev/null +++ b/Scripts/confusionMatPlotSideVal2.m @@ -0,0 +1,85 @@ +function confusionMatPlotSideVal2(ax,ygt,ypr,varargin) +f=ax; +class=length(unique(ygt)); +boxes=7*class; +cla(ax); +TextColor=[0 0 0] +RectColor=[1 1 1] +properties={'LR+','LR-','Accuracy','FDR','NPV','DOR','F1 Score'}; + +for i=0:class-1 + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens=(TP)/(TP+FN); + FNR= (FN)/(TP+FN); + FPR= (FP)/(FP+TN); + Specifity=(TN)/(FP+TN); + Prevalance=(TP+FN)/(sum(cmVals{i+1})); + PPV=(TP)/(TP+FP); + FOR=(FN)/(FN+TN); + + LR=((TP)/(TP+FN))/((FP)/(FP+TN)); + LR_=((FN)/(TP+FN))/((TN)/(FP+TN)); + Accuracy=(TP+TN)/((sum(cmVals{i+1}))); + FDR=(FP)/(FP+TP); + NPV=(TN)/(FN+TN); + DOR=(LR)/(LR_); + F1Score=2*((PPV*Sens)/(PPV+Sens)); + variableVals{i+1}=[LR,LR_,Accuracy,FDR,NPV,DOR,F1Score]; + +end + + + +for i=0:class + if i~=0 + valss=variableVals{i}; + end + for j=0:7 + + rectangle(f,'Position',[i/boxes j/boxes 1/boxes 1/boxes ],'FaceColor',RectColor) + if (j==0)-(i==0 & j==0) + ind= max(i,j); + text(f,(i+0.5)/boxes,(j+0.5)/boxes,['Class ' num2str(ind-1)],'HorizontalAlignment','Center','Color',[0 0 0 ],'LineWidth',2) + elseif (i==0)-(i==0 & j==0) + + text(f,(i+0.5)/boxes,(j+0.5)/boxes,[properties{j}],'HorizontalAlignment','Center','Color',[0 0 0 ],'LineWidth',2) + elseif i==0 & j==0 + text(f,(i+0.5)/boxes,(j+0.5)/boxes,'All 100%','HorizontalAlignment','Center','Color',[0 0 0 ],'LineWidth',2) + else + + percent=round(valss(j),4)*100; + text(f,(i+0.5)/boxes,(j+0.5)/boxes,[' ' num2str(percent) '%'],'HorizontalAlignment','Center','Color',[0 0 0 ],'LineWidth',2) + end + end + +end +set(f, 'YDir','reverse') + +ax=f; +ax.Title.String="Classes"; +ax.Title.Color=[0 0 0]; +ax.Title.ButtonDownFcn=@txtHandler; +ax.YLabel.String="Metrics"; +ax.YLabel.Color=[0 0 0 ]; +pos=get(ax.YLabel,'Position'); +t=text(f,pos(1),pos(2),'Metrics','Rotation',90,'Color',[0 0 0 ],'LineWidth',3); + +axis(f,'off') + + + + + + + + + + + + +end \ No newline at end of file diff --git a/Scripts/crlbThe.m b/Scripts/crlbThe.m new file mode 100644 index 0000000..c7953ed --- /dev/null +++ b/Scripts/crlbThe.m @@ -0,0 +1,225 @@ +function [data2,f,data,crlb]=crlbThe(app,data) +crlb=-1; +VThe=50; +LThe=.5; +data2=data; +f=uifigure('Position',[200 200 1050 500],'Color',[1 1 1]); +btnReset = uibutton(f,'push',... + 'Text', 'Reset Table',... + 'Position',[40,400,150,30],'FontWeight','Bold'); +edtL = uieditfield(f,'numeric',... + 'Limits', [0 100],... + 'LowerLimitInclusive','off',... + 'UpperLimitInclusive','on',... + 'Value', 30,'Position',[180 240 100 25]); +edtV = uieditfield(f,'numeric',... + 'Limits', [0 Inf],... + 'LowerLimitInclusive','off',... + 'UpperLimitInclusive','on',... + 'Value', 30,'Position',[180 300 100 25]); + +VThe=(edtV.Value); +LThe=(edtL.Value)/100; +lbl=uilabel(f,'Text',"CRLB Threshold",'Position',[180,335,100,15]); +lbl=uilabel(f,'Text',"Column Percent",'Position',[180,275,100,15]); + +tab=uitable(f,'Position',[300 50 750 400]); +btn = uibutton(f,'push',... + 'Text', 'Assign STD Columns',... + 'Position',[40,150,150,30],'FontWeight','Bold'); +btnFilt = uibutton(f,'push',... + 'Text', 'Imputer',... + 'Position',[40,100,150,40],"BackgroundColor",[0.00,0.45,0.74],"FontColor","white",'FontWeight','Bold'); +btnFiltConf = uibutton(f,'push',... + 'Text', 'Confirm Table',... + 'Position',[40,10,150,40],"BackgroundColor",[0.47,0.67,0.19],"FontColor","white",'FontWeight','Bold'); +btnRow = uibutton(f,'push',... + 'Text', 'Apply Row Threshold %30',... + 'Position',[30,55,170,40],"BackgroundColor",[0.47,0.67,0.19],"FontColor","white",'FontWeight','Bold'); + + +btnFilt.ButtonPushedFcn=@fltOut; +btnFiltConf.ButtonPushedFcn=@confirm; +btn.ButtonPushedFcn=@ata; +btnReset.ButtonPushedFcn=@reset; +btnRow.ButtonPushedFcn=@rowFcn; + +list=uilistbox(f,'Position',[20,190,160,170]); +list.Multiselect="on"; +tab.Data=data; +global row; +global col; +global ind; +global r; +global c; +global rows; +global c2; + +list.Items=tab.Data.Properties.VariableNames; + function rowFcn(varargin) + d = uiprogressdlg(f,'Message','Processing',... + 'Title','CRLB Menu'); + d.Value=0.5 + s = uistyle("BackgroundColor",'black',"FontColor",'white'); + [~,ind]=(ismember(list.Value,list.Items)) + d.Value=0.75; + datam=table2array(tab.Data(:,col)) + datam=datam>(edtV.Value) + rows=sum(datam,2)<=size(datam,2)*0.3 + rows2=sum(datam,2)>size(datam,2)*0.3 + addStyle(tab,s,'row',find(rows2==1)) + d.Value=1; + delete(d); + end + + + function reset(varargin) + removeStyle(tab) + tab.Data=data; + list.Items=data.Properties.VariableNames; + end + + + + function confirm(varargin) + s = uistyle("BackgroundColor",'green',"FontColor",'black'); +disp('adasd') +rows + data2=tab.Data(find(rows==1),:); + election = uiconfirm(f,"Would you like to export resulted table?","Save",... + 'Options',{'Yes','No'},... + 'DefaultOption',1,'CancelOption',2); + switch election + case 'Yes' + [file,path]=uiputfile({'*.txt';'*.xlsx'}) + writetable(data2(:,unique(c2)),[path,file]); + + case 'No' + end + unique(c2) + app.UITable2.Data=data2; + removeStyle(app.UITable2); + + app.PREDICTORSListBox.Value={app.PREDICTORSListBox.Items{unique(c2)}}; + addStyle(app.UITable2,s,'column',unique(c2)); + + app.crlb=VThe; + delete(f); + end + function fltOut(varargin) + + selection = uiconfirm(f,"Improper Concentration Fill","Select the fill method",... + 'Options',{'Zero Fill','Mean Imputer','Median Imputer',... + },... + 'DefaultOption',1,'CancelOption',2); + dat=tab.Data; +d = uiprogressdlg(f,'Message','This process will take few minutes',... + 'Title','CRLB Menu'); + d.Value=0.5 + switch selection + case 'Zero Fill' + + for i=(unique(c))' + dat2= dat.(dat.Properties.VariableNames{i}); + dat2(r(c==i))=0; + dat.(dat.Properties.VariableNames{i})=dat2; + + end + tab.Data=dat; + set(tab, 'ColumnName',dat.Properties.VariableNames); + + case 'Mean Imputer' + + for i=(unique(c))' + dat2= dat.(dat.Properties.VariableNames{i}); + dat2(r(c==i))=mean(dat2); + dat.(dat.Properties.VariableNames{i})=dat2; + + end + tab.Data=dat; + set(tab, 'ColumnName',dat.Properties.VariableNames); + + case 'Median Imputer' + for i=(unique(c))' + dat2= dat.(dat.Properties.VariableNames{i}); + i + c + dat2 + dat2(r(c==i))=median(dat2); + dat.(dat.Properties.VariableNames{i})=dat2; + + end + tab.Data=dat; + set(tab, 'ColumnName',dat.Properties.VariableNames); + case 'KNN Imputer' + for i=(unique(c))' + dat2= dat.(dat.Properties.VariableNames{i}); + i + c + dat2 + dat2(r(c==i))=missing; + dat.(dat.Properties.VariableNames{i})=dat2; + + end + tab.Data=dat; + set(tab, 'ColumnName',dat.Properties.VariableNames); + + end + d.Value=1; + delete(d); + end + + function ata(varargin) + d = uiprogressdlg(f,'Message','This process will take few minutes',... + 'Title','CRLB Menu'); + d.Value=0.5 + [xa,fa]=assignVals3(app,list.Value,list.Items); + + waitfor(fa); + app.reqVars2 + + removeStyle(tab); + VThe=(edtV.Value); + LThe=(edtL.Value)/100; + s = uistyle("BackgroundColor",'green',"FontColor",'black'); + s2 = uistyle("BackgroundColor",'red',"FontColor",'white'); + s3=uistyle("BackgroundColor",'yellow',"FontColor",'black'); + [~,ind]=(ismember(list.Value,list.Items)); + addStyle(tab,s,'column',ind); + addStyle(tab,s,'column',app.reqVars2); + + arr=table2array(tab.Data(:,ind))(length(arr)*LThe))); + addStyle(tab,s2,'column',ind(the>(length(arr)*LThe))); + + + catch + end + d.Value=0.8; + colVals=(the<(length(arr)*LThe)); + colVals=find(colVals==1) + arr=arr(:,(the<(length(arr)*LThe))); + ind2=sum(arr,2)==size(arr,2); + [ind3,~]=find(ind2==0); + + %tab.Data=tab.Data(ind2,:); + col=ind(the<(length(arr)*LThe)); + [row,~]=find(ind2==0); + [rows]=ones(1,size(tab.Data,1)); + + [r,c]=find(arr==0); + [r2,c2]=find(arr==1); + d.Value=1; + + c=app.reqVars2(colVals(c))'; + c2=app.reqVars2(colVals(c2))'; + + col2=app.reqVars2(colVals); + addStyle(tab,s3,'cell',[r,c]); + delete(d); + end + + +end \ No newline at end of file diff --git a/Scripts/datagenerators/ASUWO.m b/Scripts/datagenerators/ASUWO.m new file mode 100644 index 0000000..08a02f0 --- /dev/null +++ b/Scripts/datagenerators/ASUWO.m @@ -0,0 +1,88 @@ +function [final_features, final_mark] = ASUWO(original_features, original_mark, CThresh , K, NN, NS) + +%Inputs: + % original_features: The features of original dataset needed to be oversampled. + % original_mark: The label of original dataset needed to be oversampled. + % CThresh: Coefficient to tune the threshold for clustering. + % NN: Number of nearest neighbors to be found for each minority instance to determine the weights. + % NS: Number of nearest neighbors used to identify noisy instances. + % K: Number of folds in the K-fold Cross Validation. + +%Outputs: + % final_features: The features of dataset after being oversampled. + % final_mark: The label of dataset after being oversampled. +% Copyright 2015 Iman Nekooeimehr. This code may be freely used and +% distributed, so long as it maintains this copyright line. + +%Removing noisy instances for both minority and majority class: +[Clean_orig_inst, Clean_orig_mark] = Noise_Remover(original_features, original_mark, NS); + +NNC = 5; +Out_Th = 2; + +% Separating Minority and Majority instances +MinorityIndex = find(Clean_orig_mark == -1); +MajorityIndex = find(Clean_orig_mark == 1); +Majority_features = Clean_orig_inst(MajorityIndex,:); +Minority_features = Clean_orig_inst(MinorityIndex,:); +Maj_size = size(Majority_features,1); + +%% Clustering the minority instances by considering majority instances: +[IDX_min] = Mod_AggCluster(Majority_features, Minority_features ,CThresh); +Kmin = size(unique(IDX_min),1); +m_each_min = histc(IDX_min,1:Kmin); + +%% Finding cluster sizes for minority class using K fold cross validation +[Kmin2, rand_matrix, num_cluster_min] = Num_OV_Finder(IDX_min, Majority_features, Minority_features, m_each_min, Kmin, K, Out_Th); + +final_features = Minority_features; + +%% find selection probability and oversample within minority clusters +[p,q]=size(Majority_features); + +for i=1:Kmin2 + minority_clustered = rand_matrix(~isnan(rand_matrix(:,i)),i); + Minority_clustered_features = Minority_features(minority_clustered,:); + [m,n]=size(Minority_clustered_features); + dist_vec = []; + for i2=1:m + %find nearest K1 borderline majority sets + dist = zeros(p,1); + for j=1:p + x = sum((Majority_features(j,:) - Minority_clustered_features(i2,:)).^2); + dist(j,1) = x; + end + distm = sort (dist); + dist_vec = [dist_vec distm(1:NN)]; + end + thresh = quantile(dist_vec(1,:),0.5); + dist_vec(dist_vec > thresh) = thresh; + dist_vec = dist_vec./n; + dist_rec = (1./dist_vec).^1; + mean_dis = mean(dist_rec,1); + totw = sum(mean_dis); + P = mean_dis ./ totw; + %end of our selection probability algorithm + + j2 = 1; + while j2 <= (num_cluster_min(1,i)) + %find nearest K samples from S2(i,:) + S2=sample(Minority_clustered_features,P',1); + Condidates = nearestneighbour(S2', Minority_clustered_features', 'NumberOfNeighbours', min(NNC,m)); + Condidates(:,1) = [] ; + rn=ceil(rand(1)*(size(Condidates,2))); + Sel_index = Condidates(:,rn); + g = Minority_clustered_features(Sel_index,:); + alpha=rand(1) ; + snew = S2(1,:) + alpha.*(g-S2(1,:)); + final_features = [final_features;snew]; + j2=j2+1; + end +end + +r = size(final_features,1); +MinMark = -1 * ones(r,1); +MaxMark = ones(Maj_size,1); +final_mark = [MinMark; MaxMark]; +final_features = [final_features; Majority_features]; + diff --git a/Scripts/datagenerators/ASUWO_Main.m b/Scripts/datagenerators/ASUWO_Main.m new file mode 100644 index 0000000..6349f4d --- /dev/null +++ b/Scripts/datagenerators/ASUWO_Main.m @@ -0,0 +1,54 @@ +clear +clc +close all + +% Loading the example dataset +load fisheriris +X = meas; +%Y = [ones(100,1); -1 * ones(50,1)]; +Y = [ones(50,1); -1 * ones(50,1);ones(50,1)]; + +[N D] = size(X); +% Standardize the feature sapce +for i = 1:D + X_scaled(:,i) = 2*((X(:,i) - min(X(:,i))) / ( max(X(:,i)) - min(X(:,i)) ))-1; +end +X_scaled = X_scaled + normrnd(0,0.01,size(X_scaled)); + +NumberFolds = 3; +NumIteration = 2; + +SR_RG = 1; +stepSize = 1; + +division = round(N/NumberFolds); + +%% Buiding the models +for ite = 1:NumIteration + C = cvpartition(Y,'k',NumberFolds); + for num = 1:NumberFolds; + trainData = X_scaled(training(C,num),:); + trainLabel = Y(training(C,num),:); + testData = X_scaled(test(C,num),:); + testLabel = Y(test(C,num),:); + %% Oversampling using SMOTE + display ('SMOTE:') + [trainDataSMOTE, trainLabelSMOTE] = SMOTE(trainData,trainLabel); + %% Oversampling using Borderline SMOTE + display ('Borderline SMOTE:') + NNC = 5; + [borderMin_BorSMOTE, trainDatanewBorSMOTE, trainLabelnewBorSMOTE] = BorSMOTE(trainData,trainLabel,NNC); + %% Oversampling using Safe-level SMOTE + display ('Safe-level SMOTE:') + NNC = 5; + [trainDatanewSafeSMOTE, trainLabelnewSafeSMOTE] = Safe_Level_SMOTE(trainData,trainLabel,NNC); + %% Oversampling using ASUWO + display ('ASUWO:') + CThresh = 1; + K = 3; + NN = 5; + NS = 5; + [trainDatanewASUWO, trainLabelnewASUWO] = ASUWO(trainData,trainLabel, CThresh , K, NN, NS); + end + perm = []; +end \ No newline at end of file diff --git a/Scripts/datagenerators/BorSMOTE.m b/Scripts/datagenerators/BorSMOTE.m new file mode 100644 index 0000000..c52d165 --- /dev/null +++ b/Scripts/datagenerators/BorSMOTE.m @@ -0,0 +1,54 @@ +function [border_min, final_features, final_mark] = BorSMOTE(original_features, original_mark, NNC) + +%NNC = NNC + 1; + +Minority_index = find(original_mark == -1); +Minority_features = original_features(Minority_index,:); + +% Finding the 5 positive nearest neighbours of all the positive blobs +Minority_neighbors = nearestneighbour(Minority_features', original_features', 'NumberOfNeighbours', NNC); + +num_min_neighbor = zeros(1,length(Minority_index)); +for i=1:length(Minority_index) + for j = 2:NNC + if(original_mark(Minority_neighbors(j,i),1)== 1) + num_min_neighbor(1,i) = num_min_neighbor(1,i)+1; + end + end +end + +border_min = Minority_index(find(num_min_neighbor > (NNC-1)/2),1); +while size( border_min,1) < 4 + NNC = NNC - 1; + border_min = Minority_index(find(num_min_neighbor > (NNC-1)/2),1); +end +Border_min_features = original_features(border_min,:); +NNC = 5; +Num_Ov = ceil(max(size(find(original_mark == -1),1) - size(find(original_mark == 1),1),size(find(original_mark == 1),1) - size(find(original_mark == -1),1))); +j2 = 1; +Limit = size(Border_min_features,1); + +if Limit > 3 + final_features = original_features; + while j2 <= Num_Ov + %find nearest K samples from S2(i,:) + S2 = datasample(Border_min_features,1); + Condidates = nearestneighbour(S2', Minority_features', 'NumberOfNeighbours', min(NNC-1,Limit)); + Condidates(:,1) = [] ; + rn = ceil(rand(1)*(size(Condidates,2))); + Sel_index = Condidates(:,rn); + g = Minority_features(Sel_index,:); + alpha = rand(1); + snew = S2(1,:) + alpha.*(g-S2(1,:)); + final_features = [final_features;snew]; + j2=j2+1; + end +mark = -1 * ones(Num_Ov,1); +final_mark = [original_mark; mark]; +else + [final_features ,final_mark] = SMOTE(original_features, original_mark); +end + + + + diff --git a/Scripts/datagenerators/ClusterSMOTE.m b/Scripts/datagenerators/ClusterSMOTE.m new file mode 100644 index 0000000..6d0befa --- /dev/null +++ b/Scripts/datagenerators/ClusterSMOTE.m @@ -0,0 +1,34 @@ +function [final_features ,final_mark] = ClusterSMOTE(original_features, original_mark, Ncluster) + +ind = find(original_mark == -1); +Min_instances = original_features(ind,:); +min_clusters = kmeans(Min_instances,Ncluster); + +KNN = 6; +final_features = original_features; + +Num_Ov = ceil(max(size(find(original_mark == -1),1) - size(find(original_mark == 1),1),size(find(original_mark == 1),1) - size(find(original_mark == -1),1))); +j2 = 1; + + +while j2 <= Num_Ov + %find nearest K samples from S2(i,:) + [S2 idx]= datasample(Min_instances,1); + Min_Cluster = find(min_clusters == min_clusters(idx)); + Min_cand = Min_instances(Min_Cluster,:); + Limit = size(Min_cand,1); + Condidates = nearestneighbour(S2', Min_cand', 'NumberOfNeighbours', min(KNN,Limit)); + Condidates(:,1) = [] ; + if size(Condidates,2)>= 1 + rn=ceil(rand(1)*(size(Condidates,2))); + Sel_index = Condidates(:,rn); + g = Min_instances(Sel_index,:); + alpha = rand(1); + snew = S2(1,:) + alpha.*(g-S2(1,:)); + final_features = [final_features;snew]; + j2=j2+1; + end +end + +mark = -1 * ones(Num_Ov,1); +final_mark = [original_mark; mark]; \ No newline at end of file diff --git a/Scripts/datagenerators/Mod_AggCluster.m b/Scripts/datagenerators/Mod_AggCluster.m new file mode 100644 index 0000000..5587ce2 --- /dev/null +++ b/Scripts/datagenerators/Mod_AggCluster.m @@ -0,0 +1,153 @@ +function [min_clusters] = Mod_AggCluster(Majority_features, Minority_features ,CThresh) + +% This code is a modification of the source code for Hierachical Clustering +% implemented by David Ross +% The source code for the original Hierachical Clustering can be found in: +% http://www.cs.toronto.edu/~dross/code/ + +SizeMin = size(Minority_features,1); +min_clusters = (1:SizeMin)'; + +%% Clustering the majority class using Hierachical Clustering +maj_clusters = Orig_agg_cluster(Majority_features, CThresh); + +% Kmaj = size(unique(maj_clusters),1); +% m_each_maj = histc(maj_clusters,1:Kmaj); + +Whole_data_min = [Minority_features; Majority_features]; +D = pdist(Whole_data_min,'euclidean'); +point_dist_min = squareform(D); + +%% Clustering the Minority instances using majority clusters +min_clusters = inside_AggCluster(Minority_features', min_clusters, maj_clusters, point_dist_min, CThresh); + +function labels = inside_AggCluster(data, same_clusters, other_clusters, point_dist_whole, CThresh) +Num_Reject = 0; +N = size(data,2); +Exist_Clus = unique(same_clusters); +M = size(Exist_Clus ,1); + +% the distance between each pair of points +point_dist = point_dist_whole(1:N,1:N); +point_dist2 = point_dist; +for i=1:N + point_dist2(i,i) = 100; +end + +% Measuring the threshold +thresh = mean(median(point_dist2)).* CThresh; + +% Clusters is a cell array of vectors. Each vector contains the +% indicies of the points belonging to that cluster. +% Initially, each point is in it's own cluster. +clusters = cell(M,1); +for cc = 1:M + clusters{cc} = find(same_clusters == Exist_Clus(cc))'; +end + +% until the termination condition is met +mm = 0; +while mm < thresh + + % compute the distances between all pairs of clusters + cluster_dist = inf*ones(length(clusters)); + for c1 = 1:length(clusters) + for c2 = (c1+1):length(clusters) + cluster_dist(c1,c2) = cluster_distance(clusters{c1}, clusters{c2}, point_dist, 3); + end + end + + % merge the two nearest clusters + [mm ii] = min(cluster_dist(:)); + [ii(1) ii(2)] = ind2sub(size(cluster_dist), ii(1)); + + if mm > thresh || length(clusters) < 3, + break + end + % find the distance of nearest clusters to other class clusters: + Unique_Other = unique(other_clusters); + num_clus = size(Unique_Other,1); + + for k = 1:num_clus + MN2other(k) = cluster_distance_maj(clusters{ii(1)}, N + find(other_clusters == Unique_Other(k)), point_dist_whole, 3); + end + flag = 1; + Distr = histc(other_clusters,1:max(other_clusters)); + Distr(Distr == 0) = [] ; + near_other_ind = find(MN2other < mm & Distr' > 3); + for t = 1:length(near_other_ind) + check_dis = cluster_distance_maj(clusters{ii(2)}, N + find(other_clusters == Unique_Other(near_other_ind(t))) , point_dist_whole, 3); + if check_dis =1 + for fk = 1:size(LessFoldsIn,1) + temp1 = rand_matrix(~isnan(rand_matrix(1:end,LessFoldsIn(fk))),LessFoldsIn(fk)); + Added = randsample(temp1,folds-size(temp1,1),true); + rand_matrix ((size(temp1,1)+1):folds,LessFoldsIn(fk)) = Added; + end +end + +% Split each Minority cluster and put some portion of each in the fold matrix +buffer = [] ; +folds_matrix = []; +for i = 1:folds-1 + for j=1:Kmin2 + temp = rand_matrix(~isnan(rand_matrix(1:end,j)),j); + division = floor(size(temp,1)/folds); + buffer = [buffer; temp(((i-1)*division+1):i*division,1)]; + end + padadd(folds_matrix,buffer) + buffer = []; +end + +for j=1:Kmin2 + temp = rand_matrix(~isnan(rand_matrix(1:end,j)),j); + division = floor(size(temp,1)/folds); + buffer = [buffer; temp(((folds-1)*division+1):end,1)]; +end +padadd(folds_matrix,buffer) + +% Finding the number of misclassified instances +errorCluster_min = zeros(1,Kmin2); +C = nchoosek(1:folds,folds-1); +% for ite = 1:folds +ite = 1; + A_min = folds_matrix(:,C(ite,:)); + Min_Feat_Train = Minority_features(A_min(~isnan(A_min)),:); + B_min = folds_matrix(:,~ismember(1:folds,C(ite,:))); + Min_Feat_Valid = Minority_features(B_min(~isnan(B_min)),:); + % Train the SVM + Feat_Train_whole = [Min_Feat_Train; Majority_features]; + trainLabel_whole = [-1*ones(size(Min_Feat_Train,1),1);ones(Maj_size,1)]; + [trainDatanew, trainLabelnew] = SMOTE(Feat_Train_whole, trainLabel_whole); + %model = svmtrain(trainLabelnew, trainDatanew, Options); + model = fitcdiscr(trainDatanew, trainLabelnew); + + % Use the LDA/SVM model to classify the data + predict_label_SMOTE = predict(model, Min_Feat_Valid); + % predict_label_SMOTE = svmpredict(testLabel, Min_Feat_Valid, model, '-q'); % run the SVM model on the test data + misclassified = B_min(predict_label_SMOTE == 1); + errorCluster_min = sum(ismember(rand_matrix,misclassified)) + errorCluster_min; +%end + +NeedOv = Maj_size - Min_size; +% Kmin_real = size(m_each_min_real,1); +Pow_m_each = m_each_min .^ pow; +Ratio_Size = (1./Pow_m_each)/sum(1./Pow_m_each,1); + +ratio_min = errorCluster_min./sum(~isnan(rand_matrix)); +ratio_min(ratio_min <= 0.1)= 0.1; +ratio_min2 = ratio_min/sum(ratio_min); + +% ratio_min2(ratio_min2 <= 0.1)= 0.1; +New_Ratio = ratio_min2 .* Ratio_Size'; +ratio_min_scaled = New_Ratio/sum(New_Ratio) +Final_Ov = floor(NeedOv * ratio_min_scaled) + +end \ No newline at end of file diff --git a/Scripts/datagenerators/Orig_agg_cluster.m b/Scripts/datagenerators/Orig_agg_cluster.m new file mode 100644 index 0000000..7ef9c65 --- /dev/null +++ b/Scripts/datagenerators/Orig_agg_cluster.m @@ -0,0 +1,65 @@ +function labels = Orig_agg_cluster(data, CThresh) + +N = size(data,2); + +% Clusters is a cell array of vectors. Each vector contains the +% indicies of the points belonging to that cluster. +% Initially, each point is in it's own cluster. +clusters = cell(N,1); +for cc = 1:length(clusters) + clusters{cc} = [cc]; +end + +% the distance between each pair of points +% point_dist = point_distance(data); +D = pdist(data,'euclidean'); +point_dist = squareform(D); +point_dist2 = point_dist; +for i=1:N + point_dist2(i,i) = 100; +end +thresh = mean(median(point_dist2)).* CThresh; + +Z = linkage(D,'complete'); +labels = cluster(Z,'cutoff',thresh, 'criterion', 'distance'); + +function d = point_distance(X) +N = size(X,2); +d = sum(X.^2,1); +d = ones(N,1)*d + d'*ones(1,N) - 2*X'*X; + + + +%////////////////////////////////////////////////////////// +% d = cluster_distance(c1,c2,point_dist,linkage) +% Computes the pairwise distances between clusters c1 +% and c2, using the point distance info in point_dist. +%---------------------------------------------------------- + +function d = cluster_distance(c1,c2,point_dist,version) + +M1 = length(c1); +M2 = length(c2); +MaxM = max([M1,M2]); + +d = point_dist(c1,c2); +if version == 1 + d = min(d(:))*MaxM^0; +else if version == 2 + d = mean(d(:))*MaxM^0; + else + d = max(d(:))*MaxM^0; + end +end + +%////////////////////////////////////////////////////////// +% clusters = merge_clusters(clusters, indicies) +% Merge the clusters indicated by the entries indicies(1) +% and indicies(2) of cell array 'clusters'. +%---------------------------------------------------------- +function clusters = merge_clusters(clusters, indicies) +clusters{indicies(1)} = [clusters{indicies(1)} clusters{indicies(2)}]; +clusters(indicies(2)) = []; + + + diff --git a/Scripts/datagenerators/SMOTE.m b/Scripts/datagenerators/SMOTE.m new file mode 100644 index 0000000..a06db4d --- /dev/null +++ b/Scripts/datagenerators/SMOTE.m @@ -0,0 +1,29 @@ +function [final_features ,final_mark] = SMOTE(original_features, original_mark) + +ind = find(original_mark == -1); +P = original_features(ind,:); +KNN = 5; +final_features = original_features; +Limit = size(original_features,2); + +Num_Ov = ceil(max(size(find(original_mark == -1),1) - size(find(original_mark == 1),1),size(find(original_mark == 1),1) - size(find(original_mark == -1),1))); +j2 = 1; +while j2 <= Num_Ov + %find nearest K samples from S2(i,:) + S2= datasample(P,1); + Condidates = nearestneighbour(S2', P', 'NumberOfNeighbours', min(KNN,Limit)); + Condidates(:,1) = [] ; + rn=ceil(rand(1)*(size(Condidates,2))); + Sel_index = Condidates(:,rn); + g = P(Sel_index,:); + alpha = rand(1); + snew = S2(1,:) + alpha.*(g-S2(1,:)); + final_features = [final_features;snew]; + j2=j2+1; +end + +mark = -1 * ones(Num_Ov,1); +final_mark = [original_mark; mark]; + + + diff --git a/Scripts/datagenerators/Safe_Level_SMOTE.m b/Scripts/datagenerators/Safe_Level_SMOTE.m new file mode 100644 index 0000000..f6e6b63 --- /dev/null +++ b/Scripts/datagenerators/Safe_Level_SMOTE.m @@ -0,0 +1,68 @@ +function [final_features ,final_mark] = Safe_Level_SMOTE(original_features, original_mark, KNN) + +ind = find(original_mark == -1); +Min_ins = original_features(ind,:); +KNN = KNN + 1; +final_features = original_features; +Limit = size(Min_ins,1); + +Num_Ov = ceil(max(size(find(original_mark == -1),1) - size(find(original_mark == 1),1),size(find(original_mark == 1),1) - size(find(original_mark == -1),1))); +j2 = 1; + +Safe_Level = safe_level_Finder(Min_ins, original_features, original_mark, KNN); + +while j2 <= Num_Ov + %find nearest K samples from S2(i,:) + [FirstCand idx] = datasample(Min_ins,1); + Safe_Level_cand1 = Safe_Level(idx); + Condidates = nearestneighbour(FirstCand', Min_ins', 'NumberOfNeighbours', min(KNN,Limit)); + Condidates(:,1) = [] ; + rn=ceil(rand(1)*(size(Condidates,2))); + Sel_index = Condidates(:,rn); + SecondCand = Min_ins(Sel_index,:); + Safe_Level_cand2 = Safe_Level(Sel_index); + + if Safe_Level_cand2 ~= 0 + Safe_level_ratio = Safe_Level_cand1/Safe_Level_cand2; + else + Safe_level_ratio = inf; + end + + if (Safe_level_ratio == inf && Safe_Level_cand1 == 0) + else + if (Safe_level_ratio == inf && Safe_Level_cand1 ~= 0) + gap = 0; + else if Safe_level_ratio == 1 + gap = rand(1); + else if Safe_level_ratio > 1 + gap = rand(1)*(1/Safe_level_ratio); + else if Safe_level_ratio < 1 + gap = rand(1) * Safe_level_ratio + 1 - Safe_level_ratio; + end + end + end + end + snew = FirstCand(1,:) + gap.*(SecondCand - FirstCand(1,:)); + final_features = [final_features;snew]; + j2=j2+1; + end +end + +mark = -1 * ones(Num_Ov,1); +final_mark = [original_mark; mark]; +end + +function Safe_Level = safe_level_Finder(Minority_features, WholeDataInst, WholeDataLable, KNN) + +Ins_neighbors = nearestneighbour(Minority_features', WholeDataInst', 'NumberOfNeighbours', KNN); +Safe_Level = zeros(1,size(Minority_features,1)); + +for i = 1:size(Minority_features,1) + for j = 2:KNN + if(WholeDataLable(Ins_neighbors(j,i),1)== -1) + Safe_Level(1,i) = Safe_Level(1,i) + 1; + end + end +end + +end \ No newline at end of file diff --git a/Scripts/datagenerators/nearestneighbour.m b/Scripts/datagenerators/nearestneighbour.m new file mode 100644 index 0000000..64805f7 --- /dev/null +++ b/Scripts/datagenerators/nearestneighbour.m @@ -0,0 +1,380 @@ +function [idx, tri] = nearestneighbour(varargin) +%NEARESTNEIGHBOUR find nearest neighbours +% IDX = NEARESTNEIGHBOUR(X) finds the nearest neighbour by Euclidean +% distance to each point (column) in X from X. X is a matrix with points +% as columns. IDX is a vector of indices into X, such that X(:, IDX) are +% the nearest neighbours to X. e.g. the nearest neighbour to X(:, 2) is +% X(:, IDX(2)) +% +% IDX = NEARESTNEIGHBOUR(P, X) finds the nearest neighbour by Euclidean +% distance to each point in P from X. P and X are both matrices with the +% same number of rows, and points are the columns of the matrices. Output +% is a vector of indices into X such that X(:, IDX) are the nearest +% neighbours to P +% +% IDX = NEARESTNEIGHBOUR(I, X) where I is a logical vector or vector of +% indices, and X has at least two rows, finds the nearest neighbour in X +% to each of the points X(:, I). +% I must be a row vector to distinguish it from a single point. +% If X has only one row, the first input is treated as a set of 1D points +% rather than a vector of indices +% +% IDX = NEARESTNEIGHBOUR(..., Property, Value) +% Calls NEARESTNEIGHBOUR with the indicated parameters set. Property +% names can be supplied as just the first letters of the property name if +% this is unambiguous, e.g. NEARESTNEIGHBOUR(..., 'num', 5) is equivalent +% to NEARESTNEIGHBOUR(..., 'NumberOfNeighbours', 5). Properties are case +% insensitive, and are as follows: +% Property: Value: +% --------- ------ +% NumberOfNeighbours natural number, default 1 +% NEARESTNEIGHBOUR(..., 'NumberOfNeighbours', K) finds the closest +% K points in ascending order to each point, rather than the +% closest point. If Radius is specified and there are not +% sufficient numbers, fewer than K neighbours may be returned +% +% Radius positive, default +inf +% NEARESTNEIGHBOUR(..., 'Radius', R) finds neighbours within +% radius R. If NumberOfNeighbours is not set, it will find all +% neighbours within R, otherwise it will find at most +% NumberOfNeighbours. The IDX matrix is padded with zeros if not +% all points have the same number of neighbours returned. Note +% that specifying a radius means that the Delaunay method will +% not be used. +% +% DelaunayMode {'on', 'off', |'auto'|} +% DelaunayMode being set to 'on' means NEARESTNEIGHBOUR uses the +% a Delaunay triangulation with dsearchn to find the points, if +% possible. Setting it to 'auto' means NEARESTNEIGHBOUR decides +% whether to use the triangulation, based on efficiency. Note +% that the Delaunay triangulation will not be used if a radius +% is specified. +% +% Triangulation Valid triangulation produced by +% delaunay or delaunayn +% If a triangulation is supplied, NEARESTNEIGHBOUR will attempt +% to use it (in conjunction with dsearchn) to find the +% neighbours. +% +% [IDX, TRI] = NEARESTNEIGHBOUR( ... ) +% If the Delaunay Triangulation is used, TRI is the triangulation of X'. +% Otherwise, TRI is an empty matrix +% +% Example: +% +% % Find the nearest neighbour in X to each column of X +% x = rand(2, 10); +% idx = nearestneighbour(x); +% +% % Find the nearest neighbours to each point in p +% p = rand(2, 5); +% x = rand(2, 20); +% idx = nearestneighbour(p, x) +% +% % Find the five nearest neighbours to points x(:, [1 6 20]) in x +% x = rand(4, 1000) +% idx = nearestneighbour([1 6 20], x, 'NumberOfNeighbours', 5) +% +% % Find all neighbours within radius of 0.1 of the points in p +% p = rand(2, 10); +% x = rand(2, 100); +% idx = nearestneighbour(p, x, 'r', 0.1) +% +% % Find at most 10 nearest neighbours to point p from x within a +% % radius of 0.2 +% p = rand(1, 2); +% x = rand(2, 30); +% idx = nearestneighbour(p, x, 'n', 10, 'r', 0.2) +% +% +% See also DELAUNAYN, DSEARCHN, TSEARCH + +%TODO Allow other metrics than Euclidean distance +%TODO Implement the Delaunay mode for multiple neighbours + +% Copyright 2006 Richard Brown. This code may be freely used and +% distributed, so long as it maintains this copyright line +error(nargchk(1, Inf, nargin, 'struct')); + +% Default parameters +userParams.NumberOfNeighbours = [] ; % Finds one +userParams.DelaunayMode = 'auto'; % {'on', 'off', |'auto'|} +userParams.Triangulation = [] ; +userParams.Radius = inf ; + +% Parse inputs +[P, X, fIndexed, userParams] = parseinputs(userParams, varargin{:}); + +% Special case uses Delaunay triangulation for speed. + +% Determine whether to use Delaunay - set fDelaunay true or false +nX = size(X, 2); +nP = size(P, 2); +dim = size(X, 1); + +switch lower(userParams.DelaunayMode) + case 'on' + %TODO Delaunay can't currently be used for finding more than one + %neighbour + fDelaunay = userParams.NumberOfNeighbours == 1 && ... + size(X, 2) > size(X, 1) && ... + ~fIndexed && ... + userParams.Radius == inf; + case 'off' + fDelaunay = false; + case 'auto' + fDelaunay = userParams.NumberOfNeighbours == 1 && ... + ~fIndexed && ... + size(X, 2) > size(X, 1) && ... + userParams.Radius == inf && ... + ( ~isempty(userParams.Triangulation) || delaunaytest(nX, nP, dim) ); +end + +% Try doing Delaunay, if fDelaunay. +fDone = false; +if fDelaunay + tri = userParams.Triangulation; + if isempty(tri) + try + tri = delaunayn(X'); + catch + msgId = 'NearestNeighbour:DelaunayFail'; + msg = ['Unable to compute delaunay triangulation, not using it. ',... + 'Set the DelaunayMode parameter to ''off''']; + warning(msgId, msg); + end + end + if ~isempty(tri) + try + idx = dsearchn(X', tri, P')'; + fDone = true; + catch + warning('NearestNeighbour:DSearchFail', ... + 'dsearchn failed on triangulation, not using Delaunay'); + end + end +else % if fDelaunay + tri = []; +end + +% If it didn't use Delaunay triangulation, find the neighbours directly by +% finding minimum distances +if ~fDone + idx = zeros(userParams.NumberOfNeighbours, size(P, 2)); + + % Loop through the set of points P, finding the neighbours + Y = zeros(size(X)); + for iPoint = 1:size(P, 2) + x = P(:, iPoint); + + % This is the faster than using repmat based techniques such as + % Y = X - repmat(x, 1, size(X, 2)) + for i = 1:size(Y, 1) + Y(i, :) = X(i, :) - x(i); + end + + % Find the closest points, and remove matches beneath a radius + dSq = sum(abs(Y).^2, 1); + iRad = find(dSq < userParams.Radius^2); + if ~fIndexed + iSorted = iRad(minn(dSq(iRad), userParams.NumberOfNeighbours)); + else + iSorted = iRad(minn(dSq(iRad), userParams.NumberOfNeighbours + 1)); + iSorted = iSorted(2:end); + end + + % Remove any bad ones + idx(1:length(iSorted), iPoint) = iSorted'; + end + %while ~isempty(idx) && isequal(idx(end, :), zeros(1, size(idx, 2))) + % idx(end, :) = []; + %end + idx( all(idx == 0, 2), :) = []; +end % if ~fDone +if isvector(idx) + idx = idx(:)'; +end +end % nearestneighbour + + + + +%DELAUNAYTEST Work out whether the combination of dimensions makes +%fastest to use a Delaunay triangulation in conjunction with dsearchn. +%These parameters have been determined empirically on a Pentium M 1.6G / +%WinXP / 512MB / Matlab R14SP3 platform. Their precision is not +%particularly important +function tf = delaunaytest(nx, np, dim) +switch dim + case 2 + tf = np > min(1.5 * nx, 400); + case 3 + tf = np > min(4 * nx , 1200); + case 4 + tf = np > min(40 * nx , 5000); + + % if the dimension is higher than 4, it is almost invariably better not + % to try to use the Delaunay triangulation + otherwise + tf = false; +end % switch +end % delaunaytest + + + + +%MINN find the n most negative elements in x, and return their indices +% in ascending order +function I = minn(x, n) + +% Make sure n is no larger than length(x) +n = min(n, length(x)); + +% Sort the first n +[xsn, I] = sort(x(1:n)); + +% Go through the rest of the entries, and insert them into the sorted block +% if they are negative enough +for i = (n+1):length(x) + j = n; + while j > 0 && x(i) < xsn(j) + j = j - 1; + end + + if j < n + % x(i) should go into the (j+1) position + xsn = [xsn(1:j), x(i), xsn((j+1):(n-1))]; + I = [I(1:j), i, I((j+1):(n-1))]; + end +end + +end %minn + + +%PARSEINPUTS Support function for nearestneighbour +function [P, X, fIndexed, userParams] = parseinputs(userParams, varargin) +if length(varargin) == 1 || ~isnumeric(varargin{2}) + P = varargin{1}; + X = varargin{1}; + fIndexed = true; + varargin(1) = []; +else + P = varargin{1}; + X = varargin{2}; + varargin(1:2) = []; + + % Check the dimensions of X and P + if size(X, 1) ~= 1 + % Check to see whether P is in fact a vector of indices + if size(P, 1) == 1 + try + P = X(:, P); + catch + error('NearestNeighbour:InvalidIndexVector', ... + 'Unable to index matrix using index vector'); + end + fIndexed = true; + else + fIndexed = false; + end % if size(P, 1) == 1 + else % if size(X, 1) ~= 1 + fIndexed = false; + end + + if ~fIndexed && size(P, 1) ~= size(X, 1) + error('NearestNeighbour:DimensionMismatch', ... + 'No. of rows of input arrays doesn''t match'); + end +end +% Parse the Property/Value pairs +if rem(length(varargin), 2) ~= 0 + error('NearestNeighbour:propertyValueNotPair', ... + 'Additional arguments must take the form of Property/Value pairs'); +end + +propertyNames = {'numberofneighbours', 'delaunaymode', 'triangulation', ... + 'radius'}; +while length(varargin) ~= 0 + property = varargin{1}; + value = varargin{2}; + + % If the property has been supplied in a shortened form, lengthen it + iProperty = find(strncmpi(property, propertyNames, length(property))); + if isempty(iProperty) + error('NearestNeighbour:InvalidProperty', 'Invalid Property'); + elseif length(iProperty) > 1 + error('NearestNeighbour:AmbiguousProperty', ... + 'Supplied shortened property name is ambiguous'); + end + property = propertyNames{iProperty}; + + switch property + case 'numberofneighbours' + if rem(value, 1) ~= 0 || ... + value > length(X) - double(fIndexed) || ... + value < 1 + error('NearestNeighbour:InvalidNumberOfNeighbours', ... + 'Number of Neighbours must be an integer, and smaller than the no. of points in X'); + end + userParams.NumberOfNeighbours = value; + + case 'delaunaymode' + fOn = strcmpi(value, 'on'); + if strcmpi(value, 'off') + userParams.DelaunayMode = 'off'; + elseif fOn || strcmpi(value, 'auto') + if userParams.NumberOfNeighbours ~= 1 + if fOn + warning('NearestNeighbour:TooMuchForDelaunay', ... + 'Delaunay Triangulation method works only for one neighbour'); + end + userParams.DelaunayMode = 'off'; + elseif size(X, 2) < size(X, 1) + 1 + if fOn + warning('NearestNeighbour:TooFewDelaunayPoints', ... + 'Insufficient points to compute Delaunay triangulation'); + end + userParams.DelaunayMode = 'off'; + + elseif size(X, 1) == 1 + if fOn + warning('NearestNeighbour:DelaunayDimensionOne', ... + 'Cannot compute Delaunay triangulation for 1D input'); + end + userParams.DelaunayMode = 'off'; + else + userParams.DelaunayMode = value; + end + else + warning('NearestNeighbour:InvalidOption', ... + 'Invalid Option'); + end % if strcmpi(value, 'off') + + case 'radius' + if isscalar(value) && isnumeric(value) && isreal(value) && value > 0 + userParams.Radius = value; + if isempty(userParams.NumberOfNeighbours) + userParams.NumberOfNeighbours = size(X, 2) - double(fIndexed); + end + else + error('NearestNeighbour:InvalidRadius', ... + 'Radius must be a positive real number'); + end + + + case 'triangulation' + if isnumeric(value) && size(value, 2) == size(X, 1) + 1 && ... + all(ismember(1:size(X, 2), value)) + userParams.Triangulation = value; + else + error('NearestNeighbour:InvalidTriangulation', ... + 'Triangulation not a valid Delaunay Triangulation'); + end + end % switch property + + varargin(1:2) = []; +end % while +if isempty(userParams.NumberOfNeighbours) + userParams.NumberOfNeighbours = 1; +end +end %parseinputs \ No newline at end of file diff --git a/Scripts/datagenerators/padadd.m b/Scripts/datagenerators/padadd.m new file mode 100644 index 0000000..0fad28b --- /dev/null +++ b/Scripts/datagenerators/padadd.m @@ -0,0 +1,92 @@ +function [output] = padadd(A, x, index) +% PADADD Adds data columns to an array even column lengths don't match. +% Missmatched areas of data array are padded with NaNs. +% +% answer = padadd(A, x) +% appends "x" column vector as the last column of "A" +% +% answer = padadd(A, x, index) +% assigns "x" to the column specified by "index" in "A" +% by overwriting any existing data. +% +% If "x" is a matrix, "index" specifies the leftmost column written to. +% +% The result is saved recursively to "A" if the output argument is omitted +% and "A" is a defined variable +% +%Example: +% padadd( eye(2,2), 2*ones(4,1) ) +% +% ans = +% +% 1 0 2 +% 0 1 2 +% NaN NaN 2 +% NaN NaN 2 +% +%Author: HDJ + +%check input argument number +if (nargin < 2) + error('not enough input arguments') +end + +%transpose 'x' if it is a row vector +if (size(x,1) == 1) | (size(x,2) == 1) & (size(x,2) > size(x,1)) + x = x'; +end + +%get sizes of 'A' and 'x' +dAr = size(A,1); +dAc = size(A,2); +dxr = size(x,1); +dxc = size(x,2); + + +if nargin == 2 + %if index is not specified + %index = dAc + 1; %default to adding a column to the end + index = dAc + (1:dxc); %default to adding all columns to the end +else + %create index array from index argument + index = index(1)+ (0:dxc-1); +end + +%%%%%%BEGIN PADDING SECTION%%%%%% +%if index is outside current size of 'A' then pad whole columns of 'A' +if dAc < index(end) + answer = [A,NaN*ones(dAr,index(end)-dAc)]; +else + answer = A; +end + +%if 'x' is shorter or the same height as 'A' then pad 'x' as necessary +if dAr >= dxr, + %answer(:,index) = [ x(:,1); NaN*ones(dAr-dxr,1)]; + answer(:,index) = [ x; NaN*ones(dAr-dxr,dxc)]; +end + +%if 'x' is taller than 'A' then pad 'A' +if dAr < dxr, + answer = [answer; NaN*ones(dxr-dAr,size(answer,2))]; + %answer(:,index) = x(:,1); + answer(:,index) = x; +end +%%%%%%END PADDING SECTION%%%%%% + +%%%%%%DECIDE OUTPUT METHOD%%%%%% +%get input arguments name +ARGIN = inputname(1); +%if no output argument, ouput to A is available +if (nargout == 0) + %if ARG is a variable + if ~(isempty(ARGIN)) + assignin('caller', ARGIN, answer); + return + end +end + +%default action if either there is an ouput argument +%or if input is not a variable +output = answer; +%%%%%%END DECIDE OUTPUT METHOD%%%%%% \ No newline at end of file diff --git a/Scripts/datagenerators/sample.m b/Scripts/datagenerators/sample.m new file mode 100644 index 0000000..1996d2b --- /dev/null +++ b/Scripts/datagenerators/sample.m @@ -0,0 +1,29 @@ +function d=sample(I,P,N) +% This code is from the authors of the paper MWMOTE. The paper can be found +% in the following link: +% http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=6361394&tag=1 + + +%samples N data from the input vectors according to probability +%distribution P; + +[m,n]=size(P); +C=zeros(m,1); +prev=0; +for i=1:m + C(i)=P(i)+prev; + prev=C(i); +end +d=[]; + +for i=1:N + rn=rand(1); + + for j=1:m + if(rn<=C(j)) + d=[d;I(j,:)]; + break; + end; + end +end + diff --git a/Scripts/deleter.m b/Scripts/deleter.m new file mode 100644 index 0000000..2cf60c9 --- /dev/null +++ b/Scripts/deleter.m @@ -0,0 +1,16 @@ +function deleter(txt,model) + +fid = fopen(txt,'rt') ; +S = textscan(fid,'%s','delimiter','\n') ; +S = S{1} ; +fclose(fid) ; +% Get the indices of REV and remove them +idx = strcmp(S,model) ; +S(idx) = [] ; +% Get the indices of ! and remove them + +% write to file +fid = fopen('modelsLog.txt','wt') ; +fprintf(fid,'%s\n',S{:}); +fclose(fid) ; +end \ No newline at end of file diff --git a/Scripts/example1.m b/Scripts/example1.m new file mode 100644 index 0000000..a9f3725 --- /dev/null +++ b/Scripts/example1.m @@ -0,0 +1,313 @@ +function example1(varargin) +% Create the figure and define the "MouseMove" Callback +% Define where to place your UIPANEL + + +varargin{1}.Position; +ff=uifigure('Position',[varargin{1}.Position(1:2) 900 665]); +global ax; +global b; + +ax=varargin{1}; +pos=[10 550 150 50]; +posInc=[0 50 0 0]; +background=uibutton(ff,'push'); +background.Position=pos+posInc; +background.ButtonPushedFcn=@backPushed; +background.Text='Change Background Color'; + + +nFig=uibutton(ff,'push'); +nFig.Position=pos; +nFig.ButtonPushedFcn=@newFigLine; +nFig.Text='Show Line on New Figure'; + + +panel=uipanel(ff); +panel.Position=[200 50 650 600]; +panel.BackgroundColor=[0.4 0.4 0.4]; +%% +line=uibutton(ff,'push'); +line.Position=pos-posInc-[0 0 55 0]; +line.ButtonPushedFcn=@LineColorSet; +line.Text='Set Line/Text Color'; + + + +global lines; +global ax2; +global xx2; +global xx2Color; +ax2=linePushed; + +lines=findobj(ax2, 'type', 'line'); + +texts=findobj(ax2, 'type', 'text'); + +txts={}; +for i=1:length(texts) + try + txts{end+1}=texts(i).String{end}; + catch + txts{end+1}=texts(i).String; + end +end + + +lineDropDown=uidropdown(ff,'Items',... + txts,'Position',pos-posInc+[100 0 -75 0],... + 'ValueChangedFcn',@lineselection,'BackgroundColor',[1,1,1]); + + + + + + + + + + +%% +export=uibutton(ff,'push'); +export.Position=pos-posInc*6; +export.ButtonPushedFcn=@exportPushed; +export.Text='Export Graphics'; + +ChangeFont=uibutton(ff,'push'); +ChangeFont.Position=pos-posInc*5; +ChangeFont.ButtonPushedFcn=@ChangeFontPushed; +ChangeFont.Text='Font Options'; + +xcol=uilabel(ff,'Text','X Axis Color','Position',pos-posInc*3) + +xcoled=uieditfield(ff,'Text','Position',pos-posInc*3-[-70 -10 45 20],'Value'... + ,num2str(ax2.XColor),'FontColor',[0 0 0],'ValueChangedFcn',@colorChange); + + +ycol=uilabel(ff,'Text','Y Axis Color','Position',pos-posInc*4) + +ycoled=uieditfield(ff,'Text','Position',pos-posInc*4-[-70 -10 45 20],'Value'... + ,num2str(ax2.YColor),'FontColor',[0 0 0],'ValueChangedFcn',@colorChange); +checkAll=uicheckbox(ff,'Text','Change All Lines Color','Position',pos-[0 0 25 10]-posInc*1.75); +checkAllTexts=uicheckbox(ff,'Text','Change All Texts Color','Position',pos-[0 0 25 10]-posInc*2.25); +panel.AutoResizeChildren="off"; +xx2=[]; + function newFigLine(varargin) + fc= figure; + fx=subplot(1,1,1,'Parent',fc); + xlim(fx,get(ax2,'xlim')); + xa=copyobj(lines(xx2),fx); + xt=copyobj(texts(xx2),fx); + try + xa.YData=lines(xx2).YData-min(lines(xx2).YData); + xt.Position(2)=xt.Position(2)-min(lines(xx2).YData); + fx.XTick=(ax2.XTick); + fx.XTickLabel=(ax2.XTickLabel); + ylim(fx,[min((xa.YData))-(max(xa.YData)*0.1),max((xa.YData))*1.10]) + catch + + + end + + + + + + end + function ChangeFontPushed(varargin) + + + + exportFig=uifigure('Position',[400 400 300 220]); + + lbl = uilabel(exportFig); + lbl.Text = 'Font Size-(must be numeric )'; + lbl.Position = [20 177 300 50]; + + lbl2 = uilabel(exportFig); + lbl2.Text = 'Font Type'; + lbl2.Position = [20 125 300 50]; + + lbl2 = uilabel(exportFig); + lbl2.Text = 'Font Interpreter'; + lbl2.Position = [20 57 300 50]; + + + dropDown=uidropdown(exportFig,'Items',... + listfonts,'Value',get(ax2.XLabel,'FontName'),'Position',[20 115 270 25],... + 'BackgroundColor',[1,1,1]); + + dropDown2=uidropdown(exportFig,'Items',... + {'TeX','LaTeX','none'},'Value','TeX',... + 'Position',[20 50 270 25],... + 'BackgroundColor',[1,1,1]); + + + export2=uibutton(exportFig,'push'); + export2.Position=[125 15 50 20]; + export2.ButtonPushedFcn=@changeFont; + export2.Text='Change Fonts'; + txtBox=uieditfield(exportFig,'numeric','Position',[20 170 190 25]... + ,'Value',get(ax2.XLabel,'FontSize'),'FontColor',[0.66 0.66 0.66]); + + function changeFont(varargin) + txt_obj = findall(ax2,'Type','text') + set(txt_obj,'FontName',dropDown.Value,'FontSize',txtBox.Value,'Interpreter',dropDown2.Value); + end + + end + function colorChange(varargin) + + try + ax2.XColor=(xcoled.Value) + + catch + + msgbox('Please insert proper RGB Triplet to X Axis Color') + end + + try + ax2.YColor=(ycoled.Value) + + catch + + msgbox('Please insert proper RGB Triplet to Y Axis Color') + end + + + + end + function lineselection(varargin) + if ~isempty(xx2) & ~isempty(xx2Color) + xx2Color + xx2 + lines(xx2).Color=(xx2Color); + lines(xx2).LineWidth=lines(xx2).LineWidth-1; + texts(xx2).Color=(xx2Color); + + end + + + [~,xx2]=(ismember((varargin{1}.Value),varargin{1}.Items)) ; + xx2Color=lines(xx2).Color; + lines(xx2).Color=[0 0 1] ; + texts(xx2).Color=[0 0 1] ; + + lines(xx2).LineWidth=lines(xx2).LineWidth+1; + end + function LineColorSet(varargin) + c=uisetcolor() + + + if checkAll.Value + for i=1:length(lines) + + lines(i).Color=c; + + end + end + if checkAllTexts.Value + for i=1:length(lines) + + texts(i).Color=c; + + end + end + + if ~(checkAllTexts.Value | checkAll.Value) + lines(xx2).Color=c; + texts(xx2).Color=c; + + xx2Color=c; + end + end + function exportPushed(varargin) + + + + + exportFig=uifigure('Position',[400 400 300 220]); + + lbl = uilabel(exportFig); + lbl.Text = 'Filename-(pdf,png,jpg,jpeg is supported)'; + lbl.Position = [20 177 270 50]; + + dropDown1=uidropdown(exportFig,'Items',... + {'.pdf','.png','.jpeg','.jpg','.tif','.tiff','.emf','.eps'},'Position',[213 170 80 25],... + 'BackgroundColor',[1,1,1]); + + + txtBox=uieditfield(exportFig,'Text','Position',[20 170 190 25],'Value'... + ,'example','FontColor',[0.66 0.66 0.66],'ValueChangingFcn',@colorBlack); + function colorBlack(varargin) + varargin{:} + varargin{1}.FontColor=[0 0 0]; + + end + + function exportPushed2(varargin) + ax2=get(panel,'Children'); + + xx=[char(txtBox.Value),char(dropDown1.Value)] + if ~isempty(xx) + f=waitbar(0.2,"Exporting"); + exportgraphics(panel,xx,'ContentType','Vector','BackgroundColor',ax2.Color, 'Resolution',str2num(dropDown.Value)); + waitbar(1,f,"Finished!"); + close(f); + end + + + end + + export2=uibutton(exportFig,'push'); + export2.Position=[125 65 50 20]; + export2.ButtonPushedFcn=@exportPushed2; + export2.Text='Save'; + + + lbl2 = uilabel(exportFig); + lbl2.Text = 'DPI Values'; + lbl2.Position = [20 115 270 50]; + + dropDown=uidropdown(exportFig,'Items',... + {'150','300','600','900'},'Position',[20 105 270 25],... + 'BackgroundColor',[1,1,1]); + + + + + + + + + + + end + function ax2=linePushed(varargin) + %set(ax,'Parent',panel) + + delete(findobj(panel, 'type', 'axes')); + + ax2=copyobj(ax,panel,'legacy'); + ax2.Position=[0.15 0.15 0.8 0.8 ]; + panel.BackgroundColor=ax.Color; + set(ax2,'ycolor',ax.Color); + ax2.Title.ButtonDownFcn=@textHandler; + ax2.XLabel.ButtonDownFcn=@textHandler; + ax2.YLabel.ButtonDownFcn=@textHandler; + end + function backPushed(varargin) + c = uisetcolor([1 1 0],'Select a color'); + %ax.Color=c; + + panel.BackgroundColor=c; + ax2=get(panel,'Children'); + ax2.Color=c; + set(ax2,'ycolor',ax2.Color); + end + + + +end + + diff --git a/Scripts/exporter.m b/Scripts/exporter.m new file mode 100644 index 0000000..cbf0c09 --- /dev/null +++ b/Scripts/exporter.m @@ -0,0 +1,19 @@ +function exporter(tabdata,indices,trueclass) +%%This script is for exporting predicted indices and add results to the end +%%of the table +%Abdullah BAÅž + +format={'*.txt';'*.xlsx'} + table=tabdata; + format={'*.txt';'*.xlsx'} + [file,path]=uiputfile(format) + table=table(indices(:,1),:); + + + table.predicted=trueclass; + writetable(table,[path,file]); + + + + +end \ No newline at end of file diff --git a/Scripts/getWebWindowOfUiFigure2.m b/Scripts/getWebWindowOfUiFigure2.m new file mode 100644 index 0000000..58667ef --- /dev/null +++ b/Scripts/getWebWindowOfUiFigure2.m @@ -0,0 +1,39 @@ +function webWindow = getWebWindowOfUiFigure2(fig) + % returns the underlaying webwindow of the given figure handle in case of an uifigure, otherwise it returns an empty + % webwindow array + % + %%Example + %{ + % standard Java based Matlab figure -> no webwindow is returned + fig = figure + ww = getWebWindowOfUiFigure(fig); + assert(isempty(ww)) + + % Web based Matlab figure (uifigure) -> webwindow is returned + figWeb = uifigure + ww = getWebWindowOfUiFigure(figWeb); + assert(numel(ww) == 1) + + % change the figures icon + ww.Icon % returns the current path of the icon + % set a new icon; on Windows systems it must be an .ico file + ww.Icon = fullfile(matlabroot, '\toolbox\matlab\icons\file_open.png') + ww.Icon = fullfile(matlabroot, '\toolbox\matlab\icons\webicon.gif') + % "C:\MATLAB\R2019b\toolbox\compiler\Resources\default_icon.ico" + ww.Icon = fullfile(matlabroot, '\toolbox\matlab\toolstrip\web\image\uicontainer.ico') + + %} + figNameOrig = fig.Name; % original figure name + figNameTemp = [fig.Name, tempname('$')]; % creaet a unique temporary figure name (in case of multiple figures with the same name exists + fig.Name = figNameTemp; % rename the figure in case of multiple figures with the same name exists + drawnow + ww = matlab.internal.webwindowmanager.instance.findAllWebwindows(); + webWindow = matlab.internal.webwindow.empty(); + for ii = 1:numel(ww) + if strcmp(ww(ii).Title, figNameTemp) + webWindow = ww(ii); + break; + end + end + fig.Name = figNameOrig; % restore orignal figure name +end \ No newline at end of file diff --git a/Scripts/htmls/AI.gif b/Scripts/htmls/AI.gif new file mode 100644 index 0000000..e42ff28 Binary files /dev/null and b/Scripts/htmls/AI.gif differ diff --git a/Scripts/htmls/background.png b/Scripts/htmls/background.png new file mode 100644 index 0000000..09b47c4 Binary files /dev/null and b/Scripts/htmls/background.png differ diff --git a/Scripts/htmls/deneme2123.png b/Scripts/htmls/deneme2123.png new file mode 100644 index 0000000..ab34869 Binary files /dev/null and b/Scripts/htmls/deneme2123.png differ diff --git a/Scripts/htmls/example.png b/Scripts/htmls/example.png new file mode 100644 index 0000000..b7e5237 Binary files /dev/null and b/Scripts/htmls/example.png differ diff --git a/Scripts/htmls/load.html b/Scripts/htmls/load.html new file mode 100644 index 0000000..890f143 --- /dev/null +++ b/Scripts/htmls/load.html @@ -0,0 +1,53 @@ + + + + + + + + + +Load File + + + diff --git a/Scripts/htmls/load_class.html b/Scripts/htmls/load_class.html new file mode 100644 index 0000000..594a4a1 --- /dev/null +++ b/Scripts/htmls/load_class.html @@ -0,0 +1,49 @@ + + + + + + + + + +Load File + + + diff --git a/Scripts/htmls/load_class_single.html b/Scripts/htmls/load_class_single.html new file mode 100644 index 0000000..d0d6485 --- /dev/null +++ b/Scripts/htmls/load_class_single.html @@ -0,0 +1,49 @@ + + + + + + + + + +Load File + + + diff --git a/Scripts/htmls/manual.html b/Scripts/htmls/manual.html new file mode 100644 index 0000000..7909866 --- /dev/null +++ b/Scripts/htmls/manual.html @@ -0,0 +1,58 @@ + + + + + + + + + +
+ Avatar +
+
Hello World
+
+
+ + + diff --git a/Scripts/htmls/manual.png b/Scripts/htmls/manual.png new file mode 100644 index 0000000..91c4f90 Binary files /dev/null and b/Scripts/htmls/manual.png differ diff --git a/Scripts/htmls/sidebar.html b/Scripts/htmls/sidebar.html new file mode 100644 index 0000000..7c1d0ab --- /dev/null +++ b/Scripts/htmls/sidebar.html @@ -0,0 +1 @@ + diff --git a/Scripts/htmls/single.png b/Scripts/htmls/single.png new file mode 100644 index 0000000..38f246a Binary files /dev/null and b/Scripts/htmls/single.png differ diff --git a/Scripts/htmls/upload.png b/Scripts/htmls/upload.png new file mode 100644 index 0000000..b5a298b Binary files /dev/null and b/Scripts/htmls/upload.png differ diff --git a/Scripts/htmls/usermanual.html b/Scripts/htmls/usermanual.html new file mode 100644 index 0000000..2f7926b --- /dev/null +++ b/Scripts/htmls/usermanual.html @@ -0,0 +1,11 @@ + + + + + diff --git a/Scripts/lassoFeature.m b/Scripts/lassoFeature.m new file mode 100644 index 0000000..6ff8d1e --- /dev/null +++ b/Scripts/lassoFeature.m @@ -0,0 +1,15 @@ +function [features,FitInfo,features2]=lassoFeature(tableV,predictors,response) + +rng default % For reproducibility + +x=table2array(tableV(:,predictors)); +y=table2array(tableV(:,response)); + +[features2,FitInfo] = lasso(x,y,'CV',10); + +idxLambdaMinMSE = FitInfo.IndexMinMSE; +features = (features2(:,idxLambdaMinMSE)~=0); + +features=find(features==1); + +end \ No newline at end of file diff --git a/Scripts/manual.png b/Scripts/manual.png new file mode 100644 index 0000000..91c4f90 Binary files /dev/null and b/Scripts/manual.png differ diff --git a/Scripts/modelPlotter.m b/Scripts/modelPlotter.m new file mode 100644 index 0000000..c85bdce --- /dev/null +++ b/Scripts/modelPlotter.m @@ -0,0 +1,93 @@ +function modelPlotter(app,model,panel,whichPlot,color) + +%% This script is for plotting model details. +% Model is the model struct which is created by GLIOMA_DIAGNOSIS TOOL +% panel is the app component name +% whichPlot is the plot selection variable. It has 'confusionMatrix' or +% 'cm' , 'ROC','AUC','CUSTOM' +% with CUSTOM you will pop-uped to a dialog to choose the custom script. +% This function passes x,y,accuracy,specificity,sensitivity and cm +% respectively to the custom script. You should organize your script with +% taking account of this data transfer protocol. +% +% 25.08.2020 +% Abdullah BAÅž +% Ph.D BoÄŸaziçi University BME +% Kaplıca/CYPRUS +%% + +switch whichPlot + + case 'cm' + sz=size(model.plots.cm) + + x=1:sz(1)*sz(2) + + t=repmat(model.plots.cm,1,sz(1)^2); + b=imagesc(ax,model.plots.cm) + %b.ButtonDownFcn=@ + %text(ax,x(:), x(:),t, 'HorizontalAlignment', 'Center') + + colormap (ax,winter) + set(ax,'XColor',color) + set(ax,'YColor',color) + + case 'ROC' + + plot(ax,model.plots.X,model.plots.Ypr,model.plots.OPTROCPT(1),model.plots.OPTROCPT(2),'r*')%w,'Color',1-panel.BackgroundColor); + set(ax,'XColor',color) + set(ax,'YColor',color) + + case 'AUC' + + + + case 'CUSTOM' + + + case 'all' + + + + + + ax=subplot(2,2,4,'Parent',panel) + cla(ax); + ax.Color=panel.BackgroundColor; + ax.YLabel.String='True Positive Rate'; + ax.YColor=[1,1,1]; + ax.XLabel.String='False Positive Rate'; + ax.XColor=[1,1,1]; + + ax.Title.String='\color{white}ROC Curve'; + + + + + + model.plots.X + model.plots.Y + plot(ax,model.plots.X,model.plots.Y,model.plots.OPTROCPT(1),model.plots.OPTROCPT(2),'r*')%w,'Color',1-panel.BackgroundColor); + model.plots.AUC + text(ax,model.plots.OPTROCPT(1),model.plots.OPTROCPT(2),['AUC=' num2str(round(model.plots.AUC,3))],'Color',[0,0,0],'VerticalAlignment','bottom'); + hold(ax,'on') + x2=[1:3]; + y2=[0 0 0]; + patch(ax,[model.plots.X' [1 0 ]],[model.plots.Y' [0 0] ],'black','FaceAlpha',0.2); + set(ax,'XColor',color) + set(ax,'YColor',color) + box(ax,'off'); + set(ax,'TickLength',[0 0]) + + ax.XLabel.String='False Positive Rate'; + ax.YLabel.String='True Positive Rate'; + + + + +ax.ButtonDownFcn=@app.axClick; + + + + +end \ No newline at end of file diff --git a/Scripts/modelResPlot.m b/Scripts/modelResPlot.m new file mode 100644 index 0000000..0845c57 --- /dev/null +++ b/Scripts/modelResPlot.m @@ -0,0 +1,50 @@ +% MODEL PLOT +% In this script users can plot skeleton of model plotting +% ax (Axis): is the axis that you want to plot +% res (cell) : is the value of models +% Labels : is the text value +% Author Abdullah BAÅž +% BoÄŸaziçi BME CIL +% Cyprus/ Dhavlos 14.06.2020 +% + + + + +function modelResPlot(ax,res,Labels) + +cla(ax); +f=ax; + +if nargin<3 + + Labels=1:length(res{1}) + +end +boxes=length(res)*length(res{1}) +for i=0:length(res) + if i~=0 + resc=res{i}; + end + iter=1; + + for j=1:2:length(res{1})*2 + + rect=rectangle(f,'Position',[i/boxes j/boxes 1/boxes 1/boxes ],'FaceColor',[0.5 0.5 0.5]); + if (i==0 | j==0)-(i==0 & j==0) + ind= max(i,j); + rect.FaceColor=[0,0,1]; + text(f,(i+0.5)/boxes,(j+0.5)/boxes,[' ' (Labels{iter}) ],'HorizontalAlignment','Center','Color',[1,1,1],'Rotation',90) + iter=iter+1; + else + + text(f,(i+0.5)/boxes,(j+0.5)/boxes,[ num2str(resc(iter))],'HorizontalAlignment','Center','Color',[1,1,1]) + iter=iter+1; + end + end + +end +%camroll(ax,90) +axis(ax,'off') +set(ax,'OuterPosition',[0 0 1 1 ]) +end \ No newline at end of file diff --git a/Scripts/models/BaggedTrees.m b/Scripts/models/BaggedTrees.m new file mode 100644 index 0000000..20c90d4 --- /dev/null +++ b/Scripts/models/BaggedTrees.m @@ -0,0 +1,212 @@ + +function [trainedClassifier, validationAccuracy] = CoarseKNNS(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +response2 +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor = categoricalVal; +classes=unique(response(~isnan(response))); +% This code specifies all the classifier options and trains the classifier. + + + + +template = templateTree(... + 'MaxNumSplits', 64); +classificationKNN = fitcensemble(... + predictors, ... + response, ... + 'Method', 'Bag', ... + 'NumLearningCycles', 30, ... + 'Learners', template, ... + 'ClassNames', classes); + + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +% Perform cross-validation + + + + +if HoldOut>0 +disp("Holdout method is using with the value of '"+num2str(HoldOut)+"'") +cvp = cvpartition(response, 'Holdout', HoldOut); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + + + + +template = templateTree(... + 'MaxNumSplits', 64); +classificationKNN = fitcensemble(... + trainingPredictors, ... + trainingResponse, ... + 'Method', 'Bag', ... + 'NumLearningCycles', 30, ... + 'Learners', template, ... + 'ClassNames', classes); + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +% Perform cross-validation + +predictors = predictors(cvp.test, :); +response = response(cvp.test, :); +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictors); +correctPredictions = (validationPredictions == response); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else +disp("K-Fold method is using with '"+num2str(Folds)+"' folds") + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=response; +ypr=validationPredictions; +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; + +end + diff --git a/Scripts/models/BoostedTrees.m b/Scripts/models/BoostedTrees.m new file mode 100644 index 0000000..571a7b2 --- /dev/null +++ b/Scripts/models/BoostedTrees.m @@ -0,0 +1,211 @@ +function [trainedClassifier, validationAccuracy] = CoarseKNNS(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +response2 +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor =categoricalVal; +% Train a classifier +classes=unique(response(~isnan(response))); +% This code specifies all the classifier options and trains the classifier. +try +template = templateTree(... + 'MaxNumSplits', 20); +classificationKNN = fitcensemble(... + predictors, ... + response, ... + 'Method', 'AdaBoostM1', ... + 'NumLearningCycles', 30, ... + 'Learners', template, ... + 'LearnRate', 0.1, ... + 'ClassNames', classes); +catch + template = templateTree(... + 'MaxNumSplits', 20); +classificationKNN = fitcensemble(... + predictors, ... + response, ... + 'Method', 'AdaBoostM2', ... + 'NumLearningCycles', 30, ... + 'Learners', template, ... + 'LearnRate', 0.1, ... + 'ClassNames', classes); + +end +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +isCategoricalPredictor = [false, false, false, false, false, false, false, false, false]; +% Perform cross-validation + + + + +if HoldOut>0 + +cvp = cvpartition(response, 'Holdout', HoldOut); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + + + + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +isCategoricalPredictor = [false, false, false, false, false, false, false, false, false]; +% Perform cross-validation + +predictors = predictors(cvp.test, :); +response = response(cvp.test, :); +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictors); +correctPredictions = (validationPredictions == response); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=response; +ypr=validationPredictions; +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; + +end + + diff --git a/Scripts/models/CoarseGaussianSVM.m b/Scripts/models/CoarseGaussianSVM.m new file mode 100644 index 0000000..059972c --- /dev/null +++ b/Scripts/models/CoarseGaussianSVM.m @@ -0,0 +1,213 @@ +function [trainedClassifier, validationAccuracy] = CoarseKNNS(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +response2 +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor = [false, false, false, false, false, false, false, false, false]; +% Train a classifier +classes=unique(response(~isnan(response))); +% This code specifies all the classifier options and trains the classifier. + +classificationKNN = fitcsvm(... + predictors, ... + response, ... + 'KernelFunction', 'gaussian', ... + 'PolynomialOrder', [], ... + 'KernelScale', 6.9, ... + 'BoxConstraint', 1, ... + 'Standardize', true, ... + 'ClassNames', classes); + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); +trainedClassifier.plots.cm='1'; +trainedClassifier.plots.X='1'; +trainedClassifier.plots.Ygt='1'; +trainedClassifier.plots.Ypr='1'; +trainedClassifier.plots.sensitivity='1'; +trainedClassifier.plots.specifity='1'; + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +isCategoricalPredictor = [false, false, false, false, false, false, false, false, false]; +% Perform cross-validation + + + + +if HoldOut>0 + +cvp = cvpartition(response, 'Holdout', HoldOut); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + +classificationSVM = fitcsvm(... + trainingPredictors, ... + trainingResponse, ... + 'KernelFunction', 'gaussian', ... + 'PolynomialOrder', [], ... + 'KernelScale', 6.9, ... + 'BoxConstraint', 1, ... + 'Standardize', true, ... + 'ClassNames', classes); + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +isCategoricalPredictor = [false, false, false, false, false, false, false, false, false]; +% Perform cross-validation + +predictors = predictors(cvp.test, :); +response = response(cvp.test, :); +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictors); +correctPredictions = (validationPredictions == response); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=response; +ypr=validationPredictions; +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; + +end + + diff --git a/Scripts/models/CoarseKNNS.m b/Scripts/models/CoarseKNNS.m new file mode 100644 index 0000000..367aafc --- /dev/null +++ b/Scripts/models/CoarseKNNS.m @@ -0,0 +1,207 @@ +function [trainedClassifier, validationAccuracy] = CoarseKNNS(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +response2 +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor = categoricalVal; +classes=unique(response(~isnan(response))); +% This code specifies all the classifier options and trains the classifier. + + +classificationKNN = fitcknn(... + predictors, ... + response, ... + 'Distance', 'Euclidean', ... + 'Exponent', [], ... + 'NumNeighbors', 100, ... + 'DistanceWeight', 'Equal', ... + 'Standardize', true, ... + 'ClassNames', classes); + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +% Perform cross-validation + + + + +if HoldOut>0 +disp("Holdout method is using with the value of '"+num2str(HoldOut)+"'") + +cvp = cvpartition(response, 'Holdout', HoldOut); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + + + +classificationKNN = fitcknn(... + trainingPredictors, ... + trainingResponse, ... + 'Distance', 'Euclidean', ... + 'Exponent', [], ... + 'NumNeighbors', 100, ... + 'DistanceWeight', 'Equal', ... + 'Standardize', true, ... + 'ClassNames', classes); + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +% Perform cross-validation + +predictors = predictors(cvp.test, :); +response = response(cvp.test, :); +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictors); +correctPredictions = (validationPredictions == response); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else +disp("K-Fold method is using with '"+num2str(Folds)+"' folds") + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=response; +ypr=validationPredictions; +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; +end + + diff --git a/Scripts/models/CoarseTreee.m b/Scripts/models/CoarseTreee.m new file mode 100644 index 0000000..3d26b2e --- /dev/null +++ b/Scripts/models/CoarseTreee.m @@ -0,0 +1,213 @@ +function [trainedClassifier, validationAccuracy] = CoarseKNNS(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +response2 +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor = categoricalVal +% Train a classifier +classes=unique(response(~isnan(response))); +% This code specifies all the classifier options and trains the classifier. + + + + +classificationKNN= fitctree(... + predictors, ... + response, ... + 'SplitCriterion', 'gdi', ... + 'MaxNumSplits', 4, ... + 'Surrogate', 'off', ... + 'ClassNames', classes); + + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); +trainedClassifier.plots.cm='1'; +trainedClassifier.plots.X='1'; +trainedClassifier.plots.Ygt='1'; +trainedClassifier.plots.Ypr='1'; +trainedClassifier.plots.sensitivity='1'; +trainedClassifier.plots.specifity='1'; + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +isCategoricalPredictor = [false, false, false, false, false, false, false, false, false]; +% Perform cross-validation + + + + +if HoldOut>0 + +cvp = cvpartition(response, 'Holdout', HoldOut); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + + + +classificationKNN= fitctree(... + trainingPredictors, ... + trainingResponse, ... + 'SplitCriterion', 'gdi', ... + 'MaxNumSplits', 4, ... + 'Surrogate', 'off', ... + 'ClassNames', classes); + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +isCategoricalPredictor = [false, false, false, false, false, false, false, false, false]; +% Perform cross-validation + +predictors = predictors(cvp.test, :); +response = response(cvp.test, :); +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictors); +correctPredictions = (validationPredictions == response); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=response; +ypr=validationPredictions; +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; + +end + + diff --git a/Scripts/models/CosineKNNS.m b/Scripts/models/CosineKNNS.m new file mode 100644 index 0000000..6af0bd6 --- /dev/null +++ b/Scripts/models/CosineKNNS.m @@ -0,0 +1,212 @@ +function [trainedClassifier, validationAccuracy] = CoarseKNNS(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +response2 +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor =categoricalVal; +% Train a classifier +classes=unique(response(~isnan(response))); + +% This code specifies all the classifier options and trains the classifier. + + + +classificationKNN = fitcknn(... + predictors, ... + response, ... + 'Distance', 'Cosine', ... + 'Exponent', [], ... + 'NumNeighbors', 10, ... + 'DistanceWeight', 'Equal', ... + 'Standardize', true, ... + 'ClassNames', classes); + + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +isCategoricalPredictor = [false, false, false, false, false, false, false, false, false]; +% Perform cross-validation + + + + +if HoldOut>0 + +cvp = cvpartition(response, 'Holdout', HoldOut); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + + + + +classificationKNN = fitcknn(... + trainingPredictors, ... + trainingResponse, ... + 'Distance', 'Cosine', ... + 'Exponent', [], ... + 'NumNeighbors', 10, ... + 'DistanceWeight', 'Equal', ... + 'Standardize', true, ... + 'ClassNames', classes); + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +isCategoricalPredictor = [false, false, false, false, false, false, false, false, false]; +% Perform cross-validation + +predictors = predictors(cvp.test, :); +response = response(cvp.test, :); +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictors); +correctPredictions = (validationPredictions == response); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=response; +ypr=validationPredictions; +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; + +end + diff --git a/Scripts/models/CubicKNNS.m b/Scripts/models/CubicKNNS.m new file mode 100644 index 0000000..561ca37 --- /dev/null +++ b/Scripts/models/CubicKNNS.m @@ -0,0 +1,214 @@ + +function [trainedClassifier, validationAccuracy] = CoarseKNNS(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +response2 +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor =categoricalVal; +% Train a classifier +classes=unique(response(~isnan(response))); + +% This code specifies all the classifier options and trains the classifier. + + + + +classificationKNN = fitcknn(... + predictors, ... + response, ... + 'Distance', 'Minkowski', ... + 'Exponent', 3, ... + 'NumNeighbors', 10, ... + 'DistanceWeight', 'Equal', ... + 'Standardize', true, ... + 'ClassNames', classes); + + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +% Perform cross-validation + + + + +if HoldOut>0 + +cvp = cvpartition(response, 'Holdout', HoldOut); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + + + + +classificationKNN = fitcknn(... + trainingPredictors, ... + trainingResponse, ... + 'Distance', 'Minkowski', ... + 'Exponent', 3, ... + 'NumNeighbors', 10, ... + 'DistanceWeight', 'Equal', ... + 'Standardize', true, ... + 'ClassNames', classes); + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +isCategoricalPredictor = [false, false, false, false, false, false, false, false, false]; +% Perform cross-validation + +predictors = predictors(cvp.test, :); +response = response(cvp.test, :); +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictors); +correctPredictions = (validationPredictions == response); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=response; +ypr=validationPredictions; +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; + +end + diff --git a/Scripts/models/CubicSVM.asv b/Scripts/models/CubicSVM.asv new file mode 100644 index 0000000..e517e34 --- /dev/null +++ b/Scripts/models/CubicSVM.asv @@ -0,0 +1,185 @@ +function [trainedClassifier, validationAccuracy] = CoarseKNNS(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +response2 +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor = categoricalVal; +classes=unique(response(~isnan(response))); +% This code specifies all the classifier options and trains the classifier. + + + + + + +if HoldOut>0 + +cvp = cvpartition(response, 'Holdout', HoldOut); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + +try +classificationKNN = fitcsvm(... + trainingPredictors, ... + trainingResponse, ... + 'KernelFunction', 'polynomial', ... + 'PolynomialOrder', 3, ... + 'KernelScale', 'auto', ... + 'BoxConstraint', 1, ... + 'Standardize', true, ... + 'ClassNames', classes); +catch + template = templateSVM(... + 'KernelFunction', 'polynomial', ... + 'PolynomialOrder', 3, ... + 'KernelScale', 'auto', ... + 'BoxConstraint', 1, ... + 'Standardize', true); + classificationKNN = fitcecoc(... + trainingPredictors, ... + trainingResponse, ... + 'Learners', template, ... + 'Coding', 'onevsone', ... + 'ClassNames', classes); +end + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table + + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Perform cross-validation + +predictorstest = predictors(cvp.test, :); +responsetest = response(cvp.test, :) + +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictorstest); +correctPredictions = (validationPredictions == responsetest); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=responsetest; +ypr=validationPredictions; +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(responsetest,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; + +end + + diff --git a/Scripts/models/CubicSVM.m b/Scripts/models/CubicSVM.m new file mode 100644 index 0000000..5babd51 --- /dev/null +++ b/Scripts/models/CubicSVM.m @@ -0,0 +1,225 @@ +function [trainedClassifier, validationAccuracy] = CoarseKNNS(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +response2 +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor = categoricalVal; +classes=unique(response(~isnan(response))); +% This code specifies all the classifier options and trains the classifier. + + + + + + +if HoldOut>0 + +cvp = cvpartition(response, 'Holdout', HoldOut,'Stratify',true); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + +try +classificationKNN = fitcsvm(... + trainingPredictors, ... + trainingResponse, ... + 'KernelFunction', 'polynomial', ... + 'PolynomialOrder', 3, ... + 'KernelScale', 'auto', ... + 'BoxConstraint', 1, ... + 'Standardize', true, ... + 'ClassNames', classes); +catch + template = templateSVM(... + 'KernelFunction', 'polynomial', ... + 'PolynomialOrder', 3, ... + 'KernelScale', 'auto', ... + 'BoxConstraint', 1, ... + 'Standardize', true); + classificationKNN = fitcecoc(... + trainingPredictors, ... + trainingResponse, ... + 'Learners', template, ... + 'Coding', 'onevsone', ... + 'ClassNames', classes); +end + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table + + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Perform cross-validation + +predictorstest = predictors(cvp.test, :); +response = response(cvp.test, :) + +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictorstest); +correctPredictions = (validationPredictions == response); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else + + +try + + +classificationKNN = fitcsvm(... + predictors, ... + response, ... + 'KernelFunction', 'polynomial', ... + 'PolynomialOrder', 3, ... + 'KernelScale', 'auto', ... + 'BoxConstraint', 1, ... + 'Standardize', true, ... + 'ClassNames', classes); +catch + template = templateSVM(... + 'KernelFunction', 'polynomial', ... + 'PolynomialOrder', 3, ... + 'KernelScale', 'auto', ... + 'BoxConstraint', 1, ... + 'Standardize', true); + classificationKNN = fitcecoc(... + predictors, ... + response, ... + 'Learners', template, ... + 'Coding', 'onevsone', ... + 'ClassNames'); +end + +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=response; +ypr=validationPredictions; +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; + +end + + diff --git a/Scripts/models/DefaultModelIDHMut.m b/Scripts/models/DefaultModelIDHMut.m new file mode 100644 index 0000000..2cd084b --- /dev/null +++ b/Scripts/models/DefaultModelIDHMut.m @@ -0,0 +1,130 @@ +function [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 06-Oct-2020 12:06:52 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable = array2table(trainingData, 'VariableNames', {'column_1', 'column_2', 'column_3', 'column_4', 'column_5', 'column_6', 'column_7', 'column_8'}); + +predictorNames = {'column_1', 'column_2', 'column_3', 'column_4', 'column_5', 'column_6', 'column_7'}; +predictors = inputTable(:, predictorNames); +response = inputTable.column_8; +isCategoricalPredictor = [false, false, false, false, false, false, false]; + +% Train a classifier +% This code specifies all the classifier options and trains the classifier. +classificationSVM = fitcsvm(... + predictors, ... + response, ... + 'KernelFunction', 'linear', ... + 'PolynomialOrder', [], ... + 'KernelScale', 'auto', ... + 'BoxConstraint', 1, ... + 'Standardize', true, ... + 'ClassNames', [0; 1]); + +% Create the result struct with predict function +predictorExtractionFcn = @(x) array2table(x, 'VariableNames', predictorNames); +svmPredictFcn = @(x) predict(classificationSVM, x); +trainedClassifier.predictFcn = @(x) svmPredictFcn(predictorExtractionFcn(x)); + +% Add additional fields to the result struct +trainedClassifier.ClassificationSVM = classificationSVM; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 7 columns because this model was trained using 7 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable = array2table(trainingData, 'VariableNames', {'column_1', 'column_2', 'column_3', 'column_4', 'column_5', 'column_6', 'column_7', 'column_8'}); + +predictorNames = {'column_1', 'column_2', 'column_3', 'column_4', 'column_5', 'column_6', 'column_7'}; +predictors = inputTable(:, predictorNames); +response = inputTable.column_8; +isCategoricalPredictor = [false, false, false, false, false, false, false]; + +% Perform cross-validation +partitionedModel = crossval(trainedClassifier.ClassificationSVM, 'KFold', 5); + +% Compute validation predictions +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); + +% Compute validation accuracy +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); + + + + +ygt=response; +ypr=validationPredictions; +for i=0:length(2)-1 + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.Accuracy=validationAccuracy; +trainedClassifier.Req=predictorNames; + + diff --git a/Scripts/models/DefaultModelIDHMut2.m b/Scripts/models/DefaultModelIDHMut2.m new file mode 100644 index 0000000..3dc2d27 --- /dev/null +++ b/Scripts/models/DefaultModelIDHMut2.m @@ -0,0 +1,156 @@ +function [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 06-Oct-2020 12:11:57 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable = array2table(trainingData, 'VariableNames', {'column_1', 'column_2', 'column_3', 'column_4', 'column_5', 'column_6', 'column_7', 'column_8'}); + +predictorNames = {'column_1', 'column_2', 'column_3', 'column_4', 'column_5', 'column_6', 'column_7'}; +predictors = inputTable(:, predictorNames); +response = inputTable.column_8; +isCategoricalPredictor = [false, false, false, false, false, false, false]; + +% Train a classifier +% This code specifies all the classifier options and trains the classifier. +template = templateTree(... + 'MaxNumSplits', 107); +classificationEnsemble = fitcensemble(... + predictors, ... + response, ... + 'Method', 'Bag', ... + 'NumLearningCycles', 30, ... + 'Learners', template, ... + 'ClassNames', [0; 1]); + +% Create the result struct with predict function +predictorExtractionFcn = @(x) array2table(x, 'VariableNames', predictorNames); +ensemblePredictFcn = @(x) predict(classificationEnsemble, x); +trainedClassifier.predictFcn = @(x) ensemblePredictFcn(predictorExtractionFcn(x)); + +% Add additional fields to the result struct +trainedClassifier.ClassificationEnsemble = classificationEnsemble; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 7 columns because this model was trained using 7 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable = array2table(trainingData, 'VariableNames', {'column_1', 'column_2', 'column_3', 'column_4', 'column_5', 'column_6', 'column_7', 'column_8'}); + +predictorNames = {'column_1', 'column_2', 'column_3', 'column_4', 'column_5', 'column_6', 'column_7'}; +predictors = inputTable(:, predictorNames); +response = inputTable.column_8; +isCategoricalPredictor = [false, false, false, false, false, false, false]; + +% Set up holdout validation +cvp = cvpartition(response, 'Holdout', 0.25); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + +% Train a classifier +% This code specifies all the classifier options and trains the classifier. +template = templateTree(... + 'MaxNumSplits', 107); +classificationEnsemble = fitcensemble(... + trainingPredictors, ... + trainingResponse, ... + 'Method', 'Bag', ... + 'NumLearningCycles', 30, ... + 'Learners', template, ... + 'ClassNames', [0; 1]); + +% Create the result struct with predict function +ensemblePredictFcn = @(x) predict(classificationEnsemble, x); +validationPredictFcn = @(x) ensemblePredictFcn(x); + +% Add additional fields to the result struct + + +% Compute validation predictions +validationPredictors = predictors(cvp.test, :); +validationResponse = response(cvp.test, :); +[validationPredictions, validationScores] = validationPredictFcn(validationPredictors); + +% Compute validation accuracy +correctPredictions = (validationPredictions == validationResponse); +isMissing = isnan(validationResponse); +correctPredictions = correctPredictions(~isMissing); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +ygt=validationResponse; +ypr=validationPredictions; +for i=0:length(2)-1 + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(validationResponse,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.Accuracy=validationAccuracy; +trainedClassifier.Req=predictorNames; + + + diff --git a/Scripts/models/Discriminant.m b/Scripts/models/Discriminant.m new file mode 100644 index 0000000..4f9ae04 --- /dev/null +++ b/Scripts/models/Discriminant.m @@ -0,0 +1,210 @@ +function [trainedClassifier, validationAccuracy] = CoarseKNNS(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +response2 +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor = categoricalVal; +% Train a classifier +classes=unique(response(~isnan(response))); + +% This code specifies all the classifier options and trains the classifier. + + +subspaceDimension = max(1, min(7, width(predictors) - 1)); +classificationKNN = fitcensemble(... + predictors, ... + response, ... + 'Method', 'Subspace', ... + 'NumLearningCycles', 30, ... + 'Learners', 'discriminant', ... + 'NPredToSample', subspaceDimension, ... + 'ClassNames', classes); + + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); + + + + +if HoldOut>0 + +cvp = cvpartition(response, 'Holdout', HoldOut); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + + + + +subspaceDimension = max(1, min(7, width(trainingPredictors) - 1)); +classificationKNN = fitcensemble(... + trainingPredictors, ... + trainingResponse, ... + 'Method', 'Subspace', ... + 'NumLearningCycles', 30, ... + 'Learners', 'discriminant', ... + 'NPredToSample', subspaceDimension, ... + 'ClassNames', classes); + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +isCategoricalPredictor = [false, false, false, false, false, false, false, false, false]; +% Perform cross-validation + +predictors = predictors(cvp.test, :); +response = response(cvp.test, :); +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictors); +correctPredictions = (validationPredictions == response); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=response; +ypr=validationPredictions; +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; + +end + + diff --git a/Scripts/models/FGSVM.m b/Scripts/models/FGSVM.m new file mode 100644 index 0000000..4dbca92 --- /dev/null +++ b/Scripts/models/FGSVM.m @@ -0,0 +1,221 @@ +function [trainedClassifier, validationAccuracy] = CoarseKNNS(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +response2 +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor = categoricalVal; +% Train a classifier +classes=unique(response(~isnan(response))); + +% This code specifies all the classifier options and trains the classifier. + + + + + +try +classificationKNN = fitcsvm(... + predictors, ... + response, ... + 'KernelFunction', 'gaussian', ... + 'PolynomialOrder', [], ... + 'KernelScale', 0.9, ... + 'BoxConstraint', 1, ... + 'Standardize', true, ... + 'ClassNames', classes); + +catch +template = templateSVM(... + 'KernelFunction', 'gaussian', ... + 'PolynomialOrder', [], ... + 'KernelScale', 2.3, ... + 'BoxConstraint', 1, ... + 'Standardize', true); +classificationKNN = fitcecoc(... + predictors, ... + response, ... + 'Learners', template, ... + 'Coding', 'onevsone', ... + 'ClassNames', classes); +end +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +isCategoricalPredictor = [false, false, false, false, false, false, false, false, false]; +% Perform cross-validation + + + + +if HoldOut>0 + +cvp = cvpartition(response, 'Holdout', HoldOut); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + + + + + + + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +% Perform cross-validation + +predictors = predictors(cvp.test, :); +response = response(cvp.test, :); +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictors); +correctPredictions = (validationPredictions == response); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=response; +ypr=validationPredictions; +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; + +end + + diff --git a/Scripts/models/FineKNNS.m b/Scripts/models/FineKNNS.m new file mode 100644 index 0000000..4d4de84 --- /dev/null +++ b/Scripts/models/FineKNNS.m @@ -0,0 +1,212 @@ +function [trainedClassifier, validationAccuracy] = CoarseKNNS(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +response2 +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor = categoricalVal; +% Train a classifier +classes=unique(response(~isnan(response))); + +% This code specifies all the classifier options and trains the classifier. + + + +classificationKNN = fitcknn(... + predictors, ... + response, ... + 'Distance', 'Euclidean', ... + 'Exponent', [], ... + 'NumNeighbors', 1, ... + 'DistanceWeight', 'Equal', ... + 'Standardize', true, ... + 'ClassNames', classes); + + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +% Perform cross-validation + + + + +if HoldOut>0 + +cvp = cvpartition(response, 'Holdout', HoldOut); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + + + + +classificationKNN = fitcknn(... + trainingPredictors, ... + trainingResponse, ... + 'Distance', 'Euclidean', ... + 'Exponent', [], ... + 'NumNeighbors', 1, ... + 'DistanceWeight', 'Equal', ... + 'Standardize', true, ... + 'ClassNames', classes); + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +isCategoricalPredictor = [false, false, false, false, false, false, false, false, false]; +% Perform cross-validation + +predictors = predictors(cvp.test, :); +response = response(cvp.test, :); +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictors); +correctPredictions = (validationPredictions == response); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=response; +ypr=validationPredictions; +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; + +end + diff --git a/Scripts/models/FineTree.m b/Scripts/models/FineTree.m new file mode 100644 index 0000000..99d1015 --- /dev/null +++ b/Scripts/models/FineTree.m @@ -0,0 +1,206 @@ +function [trainedClassifier, validationAccuracy] = CoarseKNNS(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +response2 +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor = categoricalVal; +classes=unique(response(~isnan(response))); + +% This code specifies all the classifier options and trains the classifier. + + + +classificationKNN = fitctree(... + predictors, ... + response, ... + 'SplitCriterion', 'gdi', ... + 'MaxNumSplits', 100, ... + 'Surrogate', 'off', ... + 'ClassNames', classes); + + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +% Perform cross-validation + + + + +if HoldOut>0 + +cvp = cvpartition(response, 'Holdout', HoldOut); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + + + + +classificationKNN = fitctree(... + trainingPredictors, ... + trainingResponse, ... + 'SplitCriterion', 'gdi', ... + 'MaxNumSplits', 100, ... + 'Surrogate', 'off', ... + 'ClassNames', classes); + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); + + +predictors = predictors(cvp.test, :); +response = response(cvp.test, :); +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictors); +correctPredictions = (validationPredictions == response); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=response; +ypr=validationPredictions; +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; + +end + diff --git a/Scripts/models/LinearSVM2.m b/Scripts/models/LinearSVM2.m new file mode 100644 index 0000000..7301947 --- /dev/null +++ b/Scripts/models/LinearSVM2.m @@ -0,0 +1,222 @@ + +function [trainedClassifier, validationAccuracy] = CoarseKNNS(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +response2 +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor = categoricalVal; +classes=unique(response(~isnan(response))); +% This code specifies all the classifier options and trains the classifier. + + +% Train a classifier +% This code specifies all the classifier options and trains the classifier. +template = templateSVM(... + 'KernelFunction', 'linear', ... + 'PolynomialOrder', [], ... + 'KernelScale', 'auto', ... + 'BoxConstraint', 1, ... + 'Standardize', true); +classificationKNN = fitcecoc(... + predictors, ... + response, ... + 'Learners', template, ... + 'Coding', 'onevsone', ... + 'ClassNames', classes); + + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +% Perform cross-validation + + + + +if HoldOut>0 +disp("Holdout method is using with the value of '"+num2str(HoldOut)+"'") + +cvp = cvpartition(response, 'Holdout', HoldOut); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + + + + +% Train a classifier +% This code specifies all the classifier options and trains the classifier. +template = templateSVM(... + 'KernelFunction', 'linear', ... + 'PolynomialOrder', [], ... + 'KernelScale', 'auto', ... + 'BoxConstraint', 1, ... + 'Standardize', true); +classificationKNN = fitcecoc(... + trainingPredictors, ... + trainingResponse, ... + 'Learners', template, ... + 'Coding', 'onevsone', ... + 'ClassNames', classes); + + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +% Perform cross-validation + +predictors = predictors(cvp.test, :); +response = response(cvp.test, :); +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictors); +correctPredictions = (validationPredictions == response); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else +disp("K-Fold method is using with '"+num2str(Folds)+"' folds") + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=response; +ypr=validationPredictions; +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; + +end + + + diff --git a/Scripts/models/MediumGaussianSVM.m b/Scripts/models/MediumGaussianSVM.m new file mode 100644 index 0000000..9053095 --- /dev/null +++ b/Scripts/models/MediumGaussianSVM.m @@ -0,0 +1,217 @@ +function [trainedClassifier, validationAccuracy] = CoarseKNNS(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +response2 +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor =categoricalVal; +classes=unique(response(~isnan(response))); + +% This code specifies all the classifier options and trains the classifier. + + +try + +classificationKNN = fitcsvm(... + predictors, ... + response, ... + 'KernelFunction', 'gaussian', ... + 'PolynomialOrder', [], ... + 'KernelScale', 3.6, ... + 'BoxConstraint', 1, ... + 'Standardize', true, ... + 'ClassNames',classes); + +catch + template = templateSVM(... + 'KernelFunction', 'gaussian', ... + 'PolynomialOrder', [], ... + 'KernelScale', 9.300000000000001, ... + 'BoxConstraint', 1, ... + 'Standardize', true); +classificationKNN = fitcecoc(... + predictors, ... + response, ... + 'Learners', template, ... + 'Coding', 'onevsone', ... + 'ClassNames', classes); + + + +end +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +% Perform cross-validation + + + + +if HoldOut>0 + +cvp = cvpartition(response, 'Holdout', HoldOut); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + + + +; + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +% Perform cross-validation + +predictors = predictors(cvp.test, :); +response = response(cvp.test, :); +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictors); +correctPredictions = (validationPredictions == response); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=response; +ypr=validationPredictions; +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; + +end + diff --git a/Scripts/models/MediumKNNS.m b/Scripts/models/MediumKNNS.m new file mode 100644 index 0000000..91f9bd0 --- /dev/null +++ b/Scripts/models/MediumKNNS.m @@ -0,0 +1,214 @@ +function [trainedClassifier, validationAccuracy] = CoarseKNNS(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +response2 +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor = categoricalVal; +classes=unique(response(~isnan(response))); +% This code specifies all the classifier options and trains the classifier. + + + + +classificationKNN = fitcknn(... + predictors, ... + response, ... + 'Distance', 'Euclidean', ... + 'Exponent', [], ... + 'NumNeighbors', 10, ... + 'DistanceWeight', 'Equal', ... + 'Standardize', true, ... + 'ClassNames', classes); + + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +% Perform cross-validation + + + + +if HoldOut>0 +disp("Holdout method is using with the value of '"+num2str(HoldOut)+"'") + +cvp = cvpartition(response, 'Holdout', HoldOut); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + + + + +classificationKNN = fitcknn(... + trainingPredictors, ... + trainingResponse, ... + 'Distance', 'Euclidean', ... + 'Exponent', [], ... + 'NumNeighbors', 10, ... + 'DistanceWeight', 'Equal', ... + 'Standardize', true, ... + 'ClassNames', classes); + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +% Perform cross-validation + +predictors = predictors(cvp.test, :); +response = response(cvp.test, :); +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictors); +correctPredictions = (validationPredictions == response); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else +disp("K-Fold method is using with '"+num2str(Folds)+"' folds") + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=response; +ypr=validationPredictions; +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; + +end + + + diff --git a/Scripts/models/MediumTree.m b/Scripts/models/MediumTree.m new file mode 100644 index 0000000..97ca832 --- /dev/null +++ b/Scripts/models/MediumTree.m @@ -0,0 +1,206 @@ +function [trainedClassifier, validationAccuracy] = CoarseKNNS(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or tot +% +response2 +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor = categoricalVal; +classes=unique(response(~isnan(response))); +% This code specifies all the classifier options and trains the classifier. + + +classificationKNN = fitctree(... + predictors, ... + response, ... + 'SplitCriterion', 'gdi', ... + 'MaxNumSplits', 20, ... + 'Surrogate', 'off', ... + 'ClassNames', classes); + + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +% Perform cross-validation + + + + +if HoldOut>0 +disp("Holdout method is using with the value of '"+num2str(HoldOut)+"'") + +cvp = cvpartition(response, 'Holdout', HoldOut); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + + + +classificationKNN = fitctree(... + trainingPredictors, ... + trainingResponse, ... + 'SplitCriterion', 'gdi', ... + 'MaxNumSplits', 20, ... + 'Surrogate', 'off', ... + 'ClassNames', classes); + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +% Perform cross-validation + +predictors = predictors(cvp.test, :); +response = response(cvp.test, :); +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictors); +correctPredictions = (validationPredictions == response); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else +disp("K-Fold method is using with '"+num2str(Folds)+"' folds") + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=response; +ypr=validationPredictions; +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; + +end + + + diff --git a/Scripts/models/QuadraticSVM.m b/Scripts/models/QuadraticSVM.m new file mode 100644 index 0000000..3209f99 --- /dev/null +++ b/Scripts/models/QuadraticSVM.m @@ -0,0 +1,220 @@ +function [trainedClassifier, validationAccuracy] = QuadraticSVM(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor = categoricalVal; +classes=unique(response(~isnan(response))); + +% This code specifies all the classifier options and trains the classifier. + + +try +classificationKNN = fitcsvm(... + predictors, ... + response, ... + 'KernelFunction', 'polynomial', ... + 'PolynomialOrder', 2, ... + 'KernelScale', 'auto', ... + 'BoxConstraint', 1, ... + 'Standardize', true, ... + 'ClassNames', classes); +catch + + template = templateSVM(... + 'KernelFunction', 'polynomial', ... + 'PolynomialOrder', 2, ... + 'KernelScale', 'auto', ... + 'BoxConstraint', 1, ... + 'Standardize', true); + classificationKNN = fitcecoc(... + predictors, ... + response, ... + 'Learners', template, ... + 'Coding', 'onevsone', ... + 'ClassNames', classes); + + + + +end + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +% Perform cross-validation + + + + +if HoldOut>0 +disp("Holdout method is using with the value of '"+num2str(HoldOut)+"'") + +cvp = cvpartition(response, 'Holdout', HoldOut); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +% Perform cross-validation + +predictors = predictors(cvp.test, :); +response = response(cvp.test, :); +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictors); +correctPredictions = (validationPredictions == response); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else +disp("K-Fold method is using with '"+num2str(Folds)+"' folds") + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=response; +ypr=validationPredictions; +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; + +end + + + + diff --git a/Scripts/models/RUSBoosted.m b/Scripts/models/RUSBoosted.m new file mode 100644 index 0000000..0fba7ac --- /dev/null +++ b/Scripts/models/RUSBoosted.m @@ -0,0 +1,210 @@ +function [trainedClassifier, validationAccuracy] = CoarseKNNS(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +response2 +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor = categoricalVal; +classes=unique(response(~isnan(response))); +% This code specifies all the classifier options and trains the classifier. + + + +template = templateTree(... + 'MaxNumSplits', 20); +classificationKNN= fitcensemble(... + predictors, ... + response, ... + 'Method', 'RUSBoost', ... + 'NumLearningCycles', 30, ... + 'Learners', template, ... + 'LearnRate', 0.1, ... + 'ClassNames', classes); + + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); + + + + +if HoldOut>0 +disp("Holdout method is using with the value of '"+num2str(HoldOut)+"'") + +cvp = cvpartition(response, 'Holdout', HoldOut); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + + + +template = templateTree(... + 'MaxNumSplits', 20); +classificationKNN= fitcensemble(... + trainingPredictors, ... + trainingResponse, ... + 'Method', 'RUSBoost', ... + 'NumLearningCycles', 30, ... + 'Learners', template, ... + 'LearnRate', 0.1, ... + 'ClassNames', classes); + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); + +predictors = predictors(cvp.test, :); +response = response(cvp.test, :); +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictors); +correctPredictions = (validationPredictions == response); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else +disp("K-Fold method is using with '"+num2str(Folds)+"' folds") + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=response; +ypr=validationPredictions; +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; + +end + + + diff --git a/Scripts/models/WeightedKNNS.m b/Scripts/models/WeightedKNNS.m new file mode 100644 index 0000000..6fd5fc8 --- /dev/null +++ b/Scripts/models/WeightedKNNS.m @@ -0,0 +1,229 @@ + +function [trainedClassifier, validationAccuracy] = CoarseKNNS(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +response2 +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor = categoricalVal; +% Train a classifier +classes=unique(response(~isnan(response))); +% This code specifies all the classifier options and trains the classifier. + + + + +classificationKNN = fitcknn(... + predictors, ... + response, ... + 'Distance', 'Euclidean', ... + 'Exponent', [], ... + 'NumNeighbors', 10, ... + 'DistanceWeight', 'SquaredInverse', ... + 'Standardize', true, ... + 'ClassNames',classes); + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); +trainedClassifier.plots.cm='1'; +trainedClassifier.plots.X='1'; +trainedClassifier.plots.Ygt='1'; +trainedClassifier.plots.Ypr='1'; +trainedClassifier.plots.sensitivity='1'; +trainedClassifier.plots.specifity='1'; + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +isCategoricalPredictor =categoricalVal; +% Perform cross-validation + + + + +if HoldOut>0 + +cvp = cvpartition(response, 'Holdout', HoldOut); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + + + + + + +classificationKNN = fitcknn(... + trainingPredictors, ... + trainingResponse, ... + 'Distance', 'Euclidean', ... + 'Exponent', [], ... + 'NumNeighbors', 10, ... + 'DistanceWeight', 'SquaredInverse', ... + 'Standardize', true, ... + 'ClassNames',classes); + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); +trainedClassifier.plots.cm='1'; +trainedClassifier.plots.X='1'; +trainedClassifier.plots.Ygt='1'; +trainedClassifier.plots.Ypr='1'; +trainedClassifier.plots.sensitivity='1'; +trainedClassifier.plots.specifity='1'; + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +isCategoricalPredictor = [false, false, false, false, false, false, false, false, false]; +% Perform cross-validation + +predictors = predictors(cvp.test, :); +response = response(cvp.test, :); +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictors); +correctPredictions = (validationPredictions == response); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=response; +ypr=validationPredictions; + +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end + +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; + +end + + + diff --git a/Scripts/models/linearDiscriminant.m b/Scripts/models/linearDiscriminant.m new file mode 100644 index 0000000..ca56a05 --- /dev/null +++ b/Scripts/models/linearDiscriminant.m @@ -0,0 +1,209 @@ + +function [trainedClassifier, validationAccuracy] = CoarseKNNS(trainingData,response2,Folds,HoldOut,classt,categoricalVal) +% [trainedClassifier, validationAccuracy] = trainClassifier(trainingData) +% Returns a trained classifier and its accuracy. This code recreates the +% classification model trained in Classification Learner app. Use the +% generated code to automate training the same model with new data, or to +% learn how to programmatically train models. +% +response2 +% Input: +% trainingData: A matrix with the same number of columns and data type +% as the matrix imported into the app. +% +% Output: +% trainedClassifier: A struct containing the trained classifier. The +% struct contains various fields with information about the trained +% classifier. +% +% trainedClassifier.predictFcn: A function to make predictions on new +% data. +% +% validationAccuracy: A double containing the accuracy in percent. In +% the app, the History list displays this overall accuracy score for +% each model. +% +% Use the code to train the model with new data. To retrain your +% classifier, call the function from the command line with your original +% data or new data as the input argument trainingData. +% +% For example, to retrain a classifier trained with the original data set +% T, enter: +% [trainedClassifier, validationAccuracy] = trainClassifier(T) +% +% To make predictions with the returned 'trainedClassifier' on new data T2, +% use +% yfit = trainedClassifier.predictFcn(T2) +% +% T2 must be a matrix containing only the predictor columns used for +% training. For details, enter: +% trainedClassifier.HowToPredict + +% Auto-generated by MATLAB on 31-May-2020 03:30:11 + + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +summary(trainingData) + +inputTable=trainingData; + +predictorsInd=(1:size(trainingData,2)); + + + +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames); +response = inputTable.(inputTable.Properties.VariableNames{response2}); + + + +isCategoricalPredictor = categoricalVal; +classes=unique(response(~isnan(response))); + +% This code specifies all the classifier options and trains the classifier. + + + + +classificationKNN = fitcdiscr(... + predictors, ... + response, ... + 'DiscrimType', 'linear', ... + 'Gamma', 0, ... + 'FillCoeffs', 'off', ... + 'ClassNames',classes); + + + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +% Perform cross-validation + + + + +if HoldOut>0 + +cvp = cvpartition(response, 'Holdout', HoldOut); +trainingPredictors = predictors(cvp.training, :); +trainingResponse = response(cvp.training, :); +trainingIsCategoricalPredictor = isCategoricalPredictor; + + + + + +classificationKNN = fitcdiscr(... + trainingPredictors, ... + trainingResponse, ... + 'DiscrimType', 'linear', ... + 'Gamma', 0, ... + 'FillCoeffs', 'off', ... + 'ClassNames',classes); + +% Create the result struct with predict function +predictorExtractionFcn = @(y) y(:, predictorNames); +knnPredictFcn = @(x) predict(classificationKNN, x); +trainedClassifier.predictFcn = @(x) knnPredictFcn(predictorExtractionFcn(x)); + + + +% Add additional fields to the result struct +trainedClassifier.Classification = classificationKNN; +trainedClassifier.About = 'This struct is a trained model exported from Classification Learner R2020a.'; +trainedClassifier.HowToPredict = sprintf('To make predictions on a new predictor column matrix, X, use: \n yfit = c.predictFcn(X) \nreplacing ''c'' with the name of the variable that is this struct, e.g. ''trainedModel''. \n \nX must contain exactly 13 columns because this model was trained using 13 predictors. \nX must contain only predictor columns in exactly the same order and format as your training \ndata. Do not include the response column or any columns you did not import into the app. \n \nFor more information, see How to predict using an exported model.'); + +% Extract predictors and response +% This code processes the data into the right shape for training the +% model. +% Convert input to table +inputTable=trainingData; +predictorsInd=(1:size(trainingData,2)); +predictorsInd(response2)=[]; +predictorNames = trainingData.Properties.VariableNames(predictorsInd); +predictors = inputTable(:, predictorNames) +response = inputTable.(string(inputTable.Properties.VariableNames{response2})); +response=response(~isnan(response)); +% Perform cross-validation + +predictors = predictors(cvp.test, :); +response = response(cvp.test, :); +[validationPredictions, validationScores] = trainedClassifier.predictFcn(predictors); +correctPredictions = (validationPredictions == response); +validationAccuracy = sum(correctPredictions)/length(correctPredictions); + + +else + +partitionedModel = crossval(trainedClassifier.Classification, 'KFold', Folds); +% Compute validation predictions + +[validationPredictions, validationScores] = kfoldPredict(partitionedModel); +% Compute validation accuracy; +validationAccuracy = 1 - kfoldLoss(partitionedModel, 'LossFun', 'ClassifError'); +disp("resp") + +end + + + + + +ygt=response; +ypr=validationPredictions; +for i=classes' + TP=sum((ygt==i).*(ypr==i)) + FN=sum((ygt==i).*~(ypr==i)) + FP=sum(~(ygt==i).*(ypr==i)) + TN=sum(~(ygt==i).*~(ypr==i)) + cmVals{i+1}=[TP FN FP TN] + + Sens{i+1}=(TP)/(TP+FN); + Specificity{i+1}=(TN)/(FP+TN); + +end +trainedClassifier.RequiredVariables=predictorNames; + +[X,Y,T,AUC,OPTROCPT,SUBY,SUBYNAMES] = perfcurve(response,validationPredictions,1); +trainedClassifier.plots.AUC=AUC; +trainedClassifier.plots.OPTROCPT=OPTROCPT; +trainedClassifier.plots.T=T; +trainedClassifier.plots.SUBY=SUBY; +trainedClassifier.plots.SUBYNAMES=SUBYNAMES; +trainedClassifier.plots.X=X; +trainedClassifier.plots.Y=Y; +trainedClassifier.plots.Ygt=response; +trainedClassifier.plots.Ypr=validationPredictions; +trainedClassifier.plots.sensitivity=Sens; +trainedClassifier.plots.specificity=Specificity; +trainedClassifier.plots.cmVals=cmVals; +trainedClassifier.plots.Accuracy=validationAccuracy; +trainedClassifier.classes=classt; + +end + + diff --git a/Scripts/modelsLog.txt b/Scripts/modelsLog.txt new file mode 100644 index 0000000..e69de29 diff --git a/Scripts/pcaPlot.m b/Scripts/pcaPlot.m new file mode 100644 index 0000000..10a1cd3 --- /dev/null +++ b/Scripts/pcaPlot.m @@ -0,0 +1,57 @@ +%% PCA Plot is the function that creates PCA plot +%% ax is the axis that you want to show the plot +%% data is whole table +% Abdullah BAÅž +% BoÄŸaziçi University CIL BOUN +% TRNC +% abdullah.bas@boun.edu.tr + +function pcaPlot(ax,data,groups,dim,lines,dax) + + +classes=data(:,groups); +inds=ones(1,size(data,2)); +inds(groups)=0; +groups2=table2array(data(:,groups)); +data2=data(:,find(inds==1)); + + +classes=table2array(unique(classes)); +try +classes=classes(~(isnan(classes))); +catch +classes=string(classes(~(classes==""))); +end +k=1; + +for i=classes' + + dats=data2(groups2==i,:); +try + [coeff,score,latent] = pca(table2array(dats)); + + biplot(ax,coeff(:,1:dim),'scores',score(:,1:dim),'varlabels',dats.Properties.VariableNames,... + 'Color',[rand rand rand],'MarkerSize',10,'DisplayName',num2str(i)); + catch + + end + + + +end + +a=findobj(ax,'Type','Line','Tag','varline'); +set(a,'Color','black','LineWidth',2); + +a=findobj(ax,'Type','Text','Tag','varname') +set(a,'Color','black','FontWeight','Bold'); +a=findobj(ax,'Type','Line','Tag','varline') +set(a,'Color','black','LineWidth',2); +if lines + delete(a); + a=findobj(ax,'Type','Text'); + +delete(a); +end +%legend(ax); +end \ No newline at end of file diff --git a/Scripts/radarplot2.m b/Scripts/radarplot2.m new file mode 100644 index 0000000..9b30c13 --- /dev/null +++ b/Scripts/radarplot2.m @@ -0,0 +1,162 @@ +%Creates a radar (spider) plot for multi-data series. +% This function creates radar plots for input matrices. Input matrices must +% be cell. +% ax is the axis that you want to plot. Default is 'gca'. +% R is the input data. +% Labels are the label cell matrix. Must be cell and same length with R{:}. +% varargin is used for 'LineColor','FillColor','LineStyle','WebNum' +% 17.08.2020 +% Abdullah BAÅž +% Ph.D BME Bogazici University +% Turkish Republic Of Northern Cyprus +function maxx=radarplot2(ax,R,Labels,varargin) + + + + + +% This is the function for FillColor callback. +% varargin{1}: is the object that being clicked. +function FillColor(varargin) + +prompt = {'Enter the color as RGB triplet - [r g b]','Enter face alpha - :'}; +dlgtitle = 'Input'; +dims = [1 35]; +definput = {'[1 1 1]','0.3'}; +answer = inputdlg(prompt,dlgtitle,dims,definput) + +if ~isempty(answer) +varargin{1}.FaceColor=str2num(answer{1}); +varargin{1}.FaceAlpha=str2num(answer{2}); + +end + +end +property={'LineColor','FillColor','LineStyle','WebNum','isFirst','max'}; +value={[0 0 1],'None','',6,true,0}; + +le=length(varargin); +le=1:2:le; +%index = ismember(contains(property,varargin{le},'IgnoreCase',true)) + +[tf,inds]= (ismember(property,{varargin{le}})); +inds=find(inds>0); +k=1; + + +for i=inds + value{i}=varargin{le(k)+1}; + k=k+1; +end + + + +n=size(R{1},2); +m=size(R{1},1); +maxx=value{6}; +for i=1:length(R) + + if maxx0 & ~value{5} + + AxisR=linspace(0,maxx*1.1,WebNum) + for i=1:WebNum + text(ax,AxisR(1)*sin((pi/n)*0.95),AxisR(i)*cos((pi/n)*0.95),num2str(AxisR(i),1),'FontSize',10,'Color',[1 1 1]) + end + [M,AxisR]=meshgrid(ones(1,n),AxisR); + AxisR=[AxisR AxisR(:,1)]; + [AxisTheta,M]=meshgrid(2*pi/n*[0:n]+pi/n,ones(1,size(AxisR,1))); + AxisX=AxisR.*sin(AxisTheta); + AxisY=AxisR.*cos(AxisTheta); + hold (ax,"on") + box(ax,"off"); + set(ax,'xtick',[]); + set(ax,'ytick',[]); + set(ax,'ycolor',ax.Color); + plot(ax,AxisX,AxisY,':k','Color',[1,1,1],'LineWidth',1) + plot(ax,AxisX',AxisY',':k','Color',[1,1,1],'LineWidth',1) + set(ax,'xcolor',[0,0,0]); + +end + + + +for ik=1:length(R) +hold (ax,"on") +'GÄ°R' + try + if (size(R{ik},1))~=(size(R{ik+1},1)) + error("Matrices that entered as cell subs ('"+ik+"' , '"+ik+1+"') are not same sized. Terminating!") + return; + end + catch + + end + + + + R1=R{ik}; + try + val=value{2}; + val=val{ik}; + catch + val=value{2}; + + end + + + + n=size(R1,2); + m=size(R1,1); + + R1=[R1 R1(:,1)]; + [Theta,M]=meshgrid(2*pi/n*[0:n]+pi/n); + X=R1.*sin(Theta); + Y=R1.*cos(Theta); + A=plot(ax,X',Y','LineWidth',2); + %A(:).ButtonDownFcn=@PlotColor; + MAXAXIS=maxx*1.2; + %axis(ax,[-MAXAXIS MAXAXIS -MAXAXIS MAXAXIS]); + axis (ax,"equal") + + if ~value{5} + + LableTheta=2*pi/n*[0:n-1]+pi/n; + LableR=MAXAXIS; + LableX=LableR.*sin(LableTheta); + LableY=LableR.*cos(LableTheta); + + for i=1:length(Labels) + + tx=text(ax,LableX(i), LableY(i),Labels{i}, 'FontSize',14,'Color',[1 1 1],'HorizontalAlignment','center','Rotation',0); + tx.ButtonDownFcn=@textHandler; + end + end + + + + for i=1:m + + set(A(i),'Color',val); + + end + + + if num2str(value{2})~="None" + + F=fill(ax,X(i,:),Y(i,:),value{2},'LineStyle','none'); + set(F,'FaceAlpha',0.3); + F.ButtonDownFcn=@FillColor; + end + + +end +hold (ax,"on"); + +end diff --git a/Scripts/radarplotOUT.m b/Scripts/radarplotOUT.m new file mode 100644 index 0000000..9566093 --- /dev/null +++ b/Scripts/radarplotOUT.m @@ -0,0 +1,197 @@ + +% RADAR PLOT % +% ----------------------------------------------------------------------- % +%%Creates a radar (spider) plot for multi-data series. +% This function creates radar plots for input matrices. Input matrices must +% be cell. +% ax is the axis that you want to plot. +% R is the input data. +% Labels are the label cell matrix. Must be cell and same length with R{:}. +% varargin is used for 'LineColor','FillColor','LineStyle','WebNum' +% 17.08.2020 +% Abdullah BAÅž +% Ph.D BME Bogazici University +% Turkish Republic Of Northern Cyprus + +% ----------------------------------------------------------------------- % +% Example of use: % +% % +% class_2 = 0.5+0.5*randn(100,1); % +% roc_curve(class_1, class_2); % +% ----------------------------------------------------------------------- % +% Version log: % +% - 1.0: Original script (17/08/2020). % + +% ----------------------------------------------------------------------- % +% Author: Abdullah BAÅž % +% Date: 17/08/2020 % +% E-mail: abdullah.bas@boun.edu.tr % +% % +% Sources: Fawcett (2006), Powers (2011), and Ting (2011) % +% ----------------------------------------------------------------------- % + + + + +function maxx=radarplotOUT(ax,R,Labels,varargin) + + + +function FillColor(varargin) + +prompt = {'Enter the color as RGB triplet - [r g b]','Enter face alpha - :'}; +dlgtitle = 'Input'; +dims = [1 35]; +definput = {'[1 1 1]','0.3'}; +answer = inputdlg(prompt,dlgtitle,dims,definput) + +if ~isempty(answer) +varargin{1}.FaceColor=str2num(answer{1}); +varargin{1}.FaceAlpha=str2num(answer{2}); + +end + +end +property={'LineColor','FillColor','LineStyle','WebNum','isFirst','max','WebColor'}; +value={[0 0 1],'None','',6,false,0,[1 1 1]}; + +le=length(varargin); +le=1:2:le; +%index = ismember(contains(property,varargin{le},'IgnoreCase',true)) + +[tf,inds]= (ismember(property,{varargin{le}})); + +inds2=find(inds>0); +inds=nonzeros(inds)'; +k=1; + + +vv={varargin{le+1}} + +for i=inds2 + value{i}=vv{inds(k)} + k=k+1; +end + + +n=size(R{1},2); +m=size(R{1},1); +maxx=value{6}; +for i=1:length(R) + + if maxx0 & ~value{5} + + AxisR=linspace(0,maxx*1.1,WebNum) + for i=1:WebNum + text(ax,AxisR(1)*sin((pi/n)*0.95),AxisR(i)*cos((pi/n)*0.95),num2str(AxisR(i),3),'FontSize',10,'Color',value{7}) + end + [M,AxisR]=meshgrid(ones(1,n),AxisR); + AxisR=[AxisR AxisR(:,1)]; + [AxisTheta,M]=meshgrid(2*pi/n*[0:n]+pi/n,ones(1,size(AxisR,1))); + AxisX=AxisR.*sin(AxisTheta); + AxisY=AxisR.*cos(AxisTheta); + hold (ax,"on") + box(ax,"off"); + set(ax,'xtick',[]); + set(ax,'ytick',[]); + set(ax,'ycolor',ax.Color); + plot(ax,AxisX,AxisY,':k','Color',value{7},'LineWidth',1) + plot(ax,AxisX',AxisY',':k','Color',value{7},'LineWidth',1) + set(ax,'xcolor',[0,0,0]); + +end + + + +for ik=1:length(R) +hold (ax,"on") +'GÄ°R' + try + if (size(R{ik},1))~=(size(R{ik+1},1)) + error("Matrices that entered as cell subs ('"+ik+"' , '"+ik+1+"') are not same sized. Terminating!") + return; + end + catch + + end + + + + R1=R{ik}; + try + val=value{2}; + val=val{ik}; + catch + val=value{2}; + + end + + + + n=size(R1,2); + m=size(R1,1); + + R1=[R1 R1(:,1)]; + [Theta,M]=meshgrid(2*pi/n*[0:n]+pi/n); + X=R1.*sin(Theta); + Y=R1.*cos(Theta); + A=plot(ax,X',Y','LineWidth',2,'Color',value{1}); + %A(:).ButtonDownFcn=@PlotColor; + MAXAXIS=maxx*1.2; + %axis(ax,[-MAXAXIS MAXAXIS -MAXAXIS MAXAXIS]); + axis (ax,"equal") + + if ~value{5} + + LableTheta=2*pi/n*[0:n-1]+pi/n; + LableR=MAXAXIS; + LableX=LableR.*sin(LableTheta); + LableY=LableR.*cos(LableTheta); + + for i=1:length(Labels) + + LableX(i) + if LableX(i)>maxx/100 + tx=text(ax,LableX(i), LableY(i),Labels{i}, 'FontSize',14,'Color',value{7},'HorizontalAlignment','left','Rotation',0); + elseif LableX(i)<0 + tx=text(ax,LableX(i), LableY(i),Labels{i}, 'FontSize',14,'Color',value{7},'HorizontalAlignment','right','Rotation',0); + + elseif LableX(i)= thres(id_t))); % True positives + FP = length(find(class_1 >= thres(id_t))); % False positives + FN = length(find(class_2 < thres(id_t))); % False negatives + TN = length(find(class_1 < thres(id_t))); % True negatives + + curve(id_t,1) = TP/(TP + FN); % Sensitivity + curve(id_t,2) = TN/(TN + FP); % Specificity + + % Distance between each point and the optimum point (0,1) + distance(id_t)= sqrt((1-curve(id_t,1))^2+(curve(id_t,2)-1)^2); + end + + % Optimum threshold and parameters + [~, opt] = min(distance); + TP = length(find(class_2 >= thres(opt))); % No. true positives + FP = length(find(class_1 >= thres(opt))); % No. false positives + FN = length(find(class_2 < thres(opt))); % No. false negatives + TN = length(find(class_1 < thres(opt))); % No. true negatives + + % Output parameters + param.Threshold = thres(opt); % Optimum threshold position + param.Sensi = curve(opt,1); % Sensitivity + param.Speci = curve(opt,2); % Specificity + param.AROC = abs(trapz(1-curve(:,2),curve(:,1))); % Area under curve + param.Accuracy = (TP+TN)/(TP+TN+FP+FN); % Aaccuracy + param.PPV = TP/(TP+FP); % Positive predictive value + param.NPV = TN/(TN+FN); % Negative predictive value + param.FNR = FN/(FN+TP); % False negative rate + param.FPR = FP/(FP+TN); % False positive rate + param.FDR = FP/(FP+TP); % False discovery rate + param.FOR = FN/(FN+TN); % False omission rate + param.F1_score = 2*TP/(2*TP+FP+FN); % F1 score + param.MCC = (TP*TN-FP*FN)/sqrt((TP+FP)*(TP+FN)*(TN+FP)*(TN+FN)); % Matthews correlation coefficient + param.BM = param.Sensi+param.Speci-1; % Informedness + param.MK = param.PPV+param.NPV-1; % Markedness + + param.TP = TP; % No. true positives + param.FP = FP; % No. false positives + param.FN = FN; % No. false negatives + param.TN = TN; % No. true negatives + + % Plotting if required + if(dispp == 1) + fill_color = [11/255, 208/255, 217/255]; + fill([1-curve(:,2); 1], [curve(:,1); 0], fill_color,'FaceAlpha',0.5); + hold on; plot(1-curve(:,2), curve(:,1), '-b', 'LineWidth', 2); + hold on; plot(1-curve(opt,2), curve(opt,1), 'or', 'MarkerSize', 10); + hold on; plot(1-curve(opt,2), curve(opt,1), 'xr', 'MarkerSize', 12); + hold off; axis square; grid on; xlabel('1 - specificity'); ylabel('sensibility'); + title(['AROC = ' num2str(param.AROC)]); + end + + % AROC warning + if param.AROC < 0.5 + warning('Since AROC is less than 0.5, you should swap the classes: roc_curve(class_2,class_1).'); + end + + % Log screen parameters if required + if(dispt == 1) + fprintf('\n ROC CURVE PARAMETERS\n'); + fprintf(' ------------------------------\n'); + fprintf(' - Distance: %.4f\n', distance(opt)); + fprintf(' - Threshold: %.4f\n', param.Threshold); + fprintf(' - Sensitivity: %.4f\n', param.Sensi); + fprintf(' - Specificity: %.4f\n', param.Speci); + fprintf(' - AROC: %.4f\n', param.AROC); + fprintf(' - Accuracy: %.4f\n', param.Accuracy); + fprintf(' - PPV: %.4f\n', param.PPV); + fprintf(' - NPV: %.4f\n', param.NPV); + fprintf(' - FNR: %.4f\n', param.FNR); + fprintf(' - FPR: %.4f\n', param.FPR); + fprintf(' - FDR: %.4f\n', param.FDR); + fprintf(' - FOR: %.4f\n', param.FOR); + fprintf(' - F1 score: %.4f\n', param.F1_score); + fprintf(' - MCC: %.4f\n', param.MCC); + fprintf(' - BM: %.4f\n', param.BM); + fprintf(' - MK: %.4f\n', param.MK); + fprintf(' \n'); + end + + % Assinging parameters and curve data + ROC_data.param = param; + ROC_data.curve = curve; +end \ No newline at end of file diff --git a/Scripts/scriptester.m b/Scripts/scriptester.m new file mode 100644 index 0000000..07866b7 --- /dev/null +++ b/Scripts/scriptester.m @@ -0,0 +1,8 @@ +function scriptester(app) +% This script is for adding required variables to app components + +%Abdullah BAÅž +%Bogazici University BME Ph.D +%19.08.2020 +get(app.excelpanel,'Children') +end \ No newline at end of file diff --git a/Scripts/scriptester2.m b/Scripts/scriptester2.m new file mode 100644 index 0000000..5f3c960 --- /dev/null +++ b/Scripts/scriptester2.m @@ -0,0 +1,8 @@ +function scriptester2(app) +% This script is for adding required variables to app components + +%Abdullah BAÅž +%Bogazici University BME Ph.D +%19.08.2020 +get(app.excelpanel,'Children') +end \ No newline at end of file diff --git a/Scripts/scripttester.m b/Scripts/scripttester.m new file mode 100644 index 0000000..4904d3f --- /dev/null +++ b/Scripts/scripttester.m @@ -0,0 +1,51 @@ + +% SCRÄ°PT TESTER % +% ----------------------------------------------------------------------- % +% It is for testing the scripts +% ----------------------------------------------------------------------- % +% Author: Abdullah BAÅž % +% Date: 15/08/2020 % +% E-mail: abdullah.bas@boun.edu.tr % +% BME Bogazici University. Computational Imaging Lab % +% % +% ----------------------------------------------------------------------- % + + + +function [tert2,idh2,double2]=scripttester(app,tabledata,metabs,tert,idh,doble) + +VAL=[9,12,13,14,3]; +values1=tabledata.concentration([9,12,13]); +values2=tabledata.concentration([9,12,13,14,3]); + +SD=tabledata.SDpct(unique([9,12,13,14,3])); +VAL2=VAL(find(SD>=30)); +sdLarger={''}; +for i=1:length(VAL2) + + sdLarger{i}=['Metab=' char(tabledata.name(VAL2(i))) ' Value=' num2str(tabledata.concentration(VAL2(i))) ' SD=' num2str(tabledata.SDpct(VAL2(i)))]; + +end +if ~isempty(VAL2) + app.SDLARGER.Items=sdLarger; + + h=questdlg('There are SD threshold violances','something','YES','NO','NO'); + switch h + case 'YES' + values1 + [tert2,tertPred]=tert.predictFcn(array2table(round(values1) ,'VariableNames',tert.RequiredVariables)) + [idh2,idhPred]=idh.predictFcn(array2table(round(values1),'VariableNames',idh.RequiredVariables)) + [double2,doublePred]=doble.predictFcn(array2table(round(values2),'VariableNames',doble.RequiredVariables)) + + case 'NO' + cond=0;%abort code + otherwise + cond=0; + end +end + + + + + +end \ No newline at end of file diff --git a/Scripts/scripttester2.m b/Scripts/scripttester2.m new file mode 100644 index 0000000..1459fd3 --- /dev/null +++ b/Scripts/scripttester2.m @@ -0,0 +1,16 @@ +function scripttester2(app) +% This script is for adding required variables to app components + +%Abdullah BAÅž +%Bogazici University BME Ph.D +%19.08.2020 +a=findobj(app.excelpanel,'type','Axes'); +b=get(a(1),'Children'); +for i=1:length(a) + + set(a(i).Title,'ButtonDownFcn',@textHandler); + a(i).YLabel.ButtonDownFcn=@textHandler; + a(i).XLabel.ButtonDownFcn=@textHandler; + +end +end \ No newline at end of file diff --git a/Scripts/sequentialFeature61.m b/Scripts/sequentialFeature61.m new file mode 100644 index 0000000..12d8a3c --- /dev/null +++ b/Scripts/sequentialFeature61.m @@ -0,0 +1,18 @@ +function [fs,history]=sequentialFeature61(tableV,predictors,response,verbose) + +rng('default') % For reproducibility +X = table2array(tableV(:,predictors)); + +y = table2array(tableV(:,response)); + +c = cvpartition(y,'k',4) +opts = statset('Display','iter'); + +fun = @(XT,yT,Xt,yt)loss(fitcecoc(XT,yT),Xt,yt); + + +[fs,history] = sequentialfs(fun,X,y,'cv',c,'options',opts) + + + +end \ No newline at end of file diff --git a/Scripts/stepwiseFeature.m b/Scripts/stepwiseFeature.m new file mode 100644 index 0000000..4f5b7a8 --- /dev/null +++ b/Scripts/stepwiseFeature.m @@ -0,0 +1,16 @@ +function [features]=stepwiseFeature(tableV,predictors,response,verbose) + + +rng default % For reproducibility + +x=table2array(tableV(:,predictors)); +y=table2array(tableV(:,response)); + + mdl = stepwiselm(x,y,'PEnter',0.06) +a=mdl +features=find(ismember(a.VariableNames,a.PredictorNames)==1) + + + + +end \ No newline at end of file diff --git a/Scripts/structDisp.m b/Scripts/structDisp.m new file mode 100644 index 0000000..004e3aa --- /dev/null +++ b/Scripts/structDisp.m @@ -0,0 +1,76 @@ + +function structDisp(app,structs,node,listbox) + +% This is the function of visualizing structures on treeNodes +% It needs structure, selected node and a listbox for output. +% app is the figure that handles all the operations +% +% Abdullah BAÅž +% Bogazici University +% BME +% 01.08.2020 + + +cx.models=structs; + + + +txt=''; +x.Text="aa"; +try + x=(node.Parent) + + x.Text; + isstring(x.Text); + while isstring(string(x.Text)) + + + txt=insertBefore([txt],1,[x.Text '.']); + x=(x.Parent); + end + + +catch + + +end + + +if isempty(txt) + f=fieldnames(structs); +else + + try + f=fieldnames(struct(eval(['cx.' txt node.Text]))); + catch + try + %msgbox("Not a struct please use plot or show to see data") + app.(listbox).Items=string(num2cell((eval(['cx.' txt node.Text]))')); + + return; + catch + + ff=app.GliomaIDHMutationDiagnosisToolUIFigure; + + selection = uiconfirm(ff,'Selected Data Type is not supported.','Would you like to save the node as mat file?',... + 'Icon','warning') + switch selection + case 'OK' + + dat=eval(struct(['cx.' txt node.Text])); + [file,path]=uiputfile(); + save([path file],'dat'); + end + return; + end + + end +end +a=node.Children; +a.delete; +for i=1:length(f) + + cat1=uitreenode(node,'Text',f{i},'NodeData',[]); + uitreenode(cat1,'Text',f{i},'NodeData',[]); + +end \ No newline at end of file diff --git a/Scripts/tablecreator.m b/Scripts/tablecreator.m new file mode 100644 index 0000000..8925fed --- /dev/null +++ b/Scripts/tablecreator.m @@ -0,0 +1,12 @@ +function formalTable=tablecreator(headers,data) +formalTable = mlreportgen.dom.FormalTable(headers,data); +formalTable.RowSep = "Solid"; +formalTable.ColSep = "Solid"; +formalTable.Border = "Solid"; +formalTable.Header.TableEntriesStyle = [formalTable.Header.TableEntriesStyle,... + {mlreportgen.dom.Bold(true)}]; +formalTable.TableEntriesStyle = [formalTable.TableEntriesStyle,... + {mlreportgen.dom.InnerMargin("2pt","2pt","2pt","2pt"),... + mlreportgen.dom.WhiteSpace("preserve")}]; + +end \ No newline at end of file diff --git a/Scripts/test.m b/Scripts/test.m new file mode 100644 index 0000000..e5107de --- /dev/null +++ b/Scripts/test.m @@ -0,0 +1,5 @@ +function test(a,b) + +fieldnames(b) +b.WeightedKNN +end \ No newline at end of file diff --git a/Scripts/textHandler.m b/Scripts/textHandler.m new file mode 100644 index 0000000..dd00a0c --- /dev/null +++ b/Scripts/textHandler.m @@ -0,0 +1,84 @@ +% This function is for handling changes -position and string- of text +% objects. +% With this function users can manipulate strings. +% 13.09.2020 +% varargin{1}: axis that has been clicked. +% varargin {2}: Click type (1-2). +% Abdullah BAÅž +% BME Bogazici University +% Turkey +% TRNC. + +function textHandler(varargin) + + + + + +global ax; +global y; +global b; + +ax=get(varargin{1},'Parent') +y=0; +if varargin{2}.Button==1 + + if b==1 + b=0; + return; + end + + + + + prompt = {'Please insert the new text','Enter Font Color as RGB Triplet - :'}; + dlgtitle = 'Input'; + dims = [1 35]; + definput = {varargin{1}.String,num2str(varargin{1}.Color)}; + answer = inputdlg(prompt,dlgtitle,dims,definput) + %varargin{1}.BackgroundColor=[0 0 1] + + varargin{2}.Button + if ~isempty(answer) + varargin{1}.String=(answer{1}); + varargin{1}.Color=str2num(answer{2}); + + end + + +elseif varargin{2}.Button==3 + + y=1; + b=1; + x=1; + varargin{1}.BackgroundColor + if string(varargin{1}.BackgroundColor)=='none' + varargin{1}.BackgroundColor=[0 0 1]; + + else + varargin{1}.BackgroundColor='none' + y=0; + return; + end + + while y + C=mouseMove(ax); + varargin{2}.Source.Position=[C(1,1),C(1,2)] ; + %title(ax, ['\color{white}(X,Y) = (', num2str(C(1,1)), ', ',num2str(C(1,2)), ')']); + drawnow(); + x=x+1; + end + +end + + + + + function C=mouseMove (varargin) + C = get (varargin{1}, 'CurrentPoint'); + end + + + + +end diff --git a/Scripts/trainer.m b/Scripts/trainer.m new file mode 100644 index 0000000..e96ad9f --- /dev/null +++ b/Scripts/trainer.m @@ -0,0 +1,178 @@ +function [ans2,model]=trainer(app,script,Label,trainerResp,trainerPredictors); + +trainerPredictors + +table=app.UITable5.Data +varnames=app.UITable5.Data.Properties.VariableNames +response=varnames(trainerResp); + +if ~isempty(trainerPredictors) + for i=1:length(trainerPredictors) + if iscell(table2array(table(:,trainerPredictors(i)))) + columnName=varnames(trainerPredictors(i)) + table.(columnName{1})=categorical(table2array(table(:,trainerPredictors(i)))) + categoricalVal(i)=1 + else + categoricalVal(i)=0 + end + end + values=app.UITable5.Data(:,trainerPredictors); + +else + values=removevars(app.UITable5.Data,response{1}); +end +categoricalVal(end+1)=0 +if iscell(app.UITable5.Data(:,trainerResp)) + categoricalVal(end)=1 +end + + +values=[values,app.UITable5.Data(:,trainerResp)] + + + +if app.auto==1 + + func=str2func(script); + class=unique(table2array(app.UITable5.Data(:,trainerResp))); + [model,a]=func(values,size(values,2),app.Spinner.Value,app.HoldOutSlider.Value/100,class,categoricalVal) + model.CRLB=app.crlb; + app.(Label).FontColor="White"; + app.(Label).FontWeight='bold'; + num2str(app.(Label).BackgroundColor) + if string((app.(Label).BackgroundColor))~="none" + + ansx=strsplit(app.(Label).Text,' ') + + ansx=[strjoin({ansx{1:end-1}},' ') ' ' num2str(a,2)]; + app.(Label).Text=ansx; + + else + app.(Label).Text=[app.(Label).Text ' ' num2str(a,2)] + end + app.(Label).BackgroundColor=[0.00,0.45,0.74]; + ss=strsplit(Label,'Label') + ans2={ss{1}}; + app.(Label).Tooltip=sprintf(['Specificity=' num2str([model.plots.specificity{:}],3) '\n' ... + 'Sensitivity=' num2str([model.plots.sensitivity{:}],3)]); + return; +end +fig=app.GliomaIDHMutationDiagnosisToolUIFigure; +msg='Please Select the process'; +title='Options'; +answer = uiconfirm(fig,msg,title,... + 'Options',{'New','New & Save','Save','Cancel'}... + ,'CancelOption',4,'Icon','info'); + + +switch answer + + case "New" + prompt = {'Please Enter Model Name:','Please enter class names:'}; + dlgtitle = 'Input'; + dims = [1 35]; + definput = {'DefaultModel','class1 class2 class3 class4'}; + answer = inputdlg(prompt,dlgtitle,dims,definput) + ans2=answer; + class=strsplit(answer{2},' '); + + func=str2func(script); + [model,a]=func(values,size(values,2),app.Spinner.Value,app.HoldOutSlider.Value/100,class,categoricalVal) + model.CRLB=app.crlb; + app.(Label).Tooltip=sprintf(['Specificity=' num2str([model.plots.specificity{:}],3) '\n' ... + 'Sensitivity=' num2str([model.plots.sensitivity{:}],3)]); + app.(Label).FontColor="White"; + app.(Label).FontWeight='bold'; + num2str(app.(Label).BackgroundColor) + if string((app.(Label).BackgroundColor))~="none" + + ansx=strsplit(app.(Label).Text,' ') + + ansx=[strjoin({ansx{1:end-1}},' ') ' ' num2str(a,2)]; + app.(Label).Text=ansx; + + else + app.(Label).Text=[app.(Label).Text ' ' num2str(a,2)] + end + app.(Label).BackgroundColor=[0.00,0.45,0.74]; + + case "New & Save" + prompt = {'Please enter class names:'}; + dlgtitle = 'Input'; + dims = [1 35]; + definput = {'class1 class2 class3 class4'}; + answer = inputdlg(prompt,dlgtitle,dims,definput) + ans2=answer; + class=strsplit(answer{1},' '); + + func=str2func(script); + [model,a]=func(values,size(values,2),app.Spinner.Value,app.HoldOutSlider.Value/100,class,categoricalVal) + model.CRLB=app.crlb; + app.(Label).Tooltip=sprintf(['Specificity=' num2str([model.plots.specificity{:}],3) '\n' ... + 'Sensitivity=' num2str([model.plots.sensitivity{:}],3)]); + app.(Label).FontColor="White"; + app.(Label).FontWeight='bold'; + if string((app.(Label).BackgroundColor))~="none" + + ansx=strsplit(app.(Label).Text,' ') + + ansx=[strjoin({ansx{1:end-1}},' ') ' ' num2str(a,2)]; + app.(Label).Text=ansx; + + else + app.(Label).Text=[app.(Label).Text ' ' num2str(a,2)] + end + app.(Label).BackgroundColor=[0.00,0.45,0.74]; + + [file,path]=uiputfile({'*.mat'}); + txtmodelReader('save','path','modelsLog.txt','modelname',[path file]); + %[fs filesep ans2{1} '.mat' ] + ans2=strsplit(file,'.'); + save([path file],'model'); + case 'Save' + + + try + + s=strsplit(Label,'Label') + + + a=app.automodels.(s{1}); + catch + uiconfirm(app.GliomaIDHMutationDiagnosisToolUIFigure,'There is no model trained with this method','Error','Icon','Error') + ans2='' + model='' + return + end + filter = {'*.mat'}; + [file, path] = uiputfile(filter); + if file==0 + model='' + ans2='' + return; + end + s2=strsplit(file,'.'); + ans2=s2; + prompt = {'Please enter class names:'}; + dlgtitle = 'Input'; + dims = [1 35]; + ba=(a.classes(~isnan(a.classes)))'; + + definput = {num2str(ba)} + answer = inputdlg(prompt,dlgtitle,dims,definput) + class=strsplit(answer{1},' ') + + a.classes=strsplit(num2str(ba),' ') + a.pseudo_classes=class; + model=a; + save([path ,file],'model'); + app.(Label).Tooltip=sprintf(['Specificity=' num2str([model.plots.specificity{:}],3) '\n' ... + 'Sensitivity=' num2str([model.plots.sensitivity{:}],3)]); + txtmodelReader('save','path','modelsLog.txt','modelname',[path ,file]); + ans2=strsplit(file,'.'); + uiconfirm(app.GliomaIDHMutationDiagnosisToolUIFigure,['Saved to : ' path file],'Model is Saved','Icon','success') + case "Cancel" + ans2='' + model='' +end +end \ No newline at end of file diff --git a/Scripts/txtmodelReader.m b/Scripts/txtmodelReader.m new file mode 100644 index 0000000..006d6ff --- /dev/null +++ b/Scripts/txtmodelReader.m @@ -0,0 +1,86 @@ +function [models]=txtmodelReader(version,varargin) + + +% This script is basically txt reader for saved models that created by +% GliomaDiagnosisTool +% Version is setted up for choosing saving and opening txt log file +% filepath is the path for saving/opening +% varargin is used for 4 things. +% 1- For filepath you can use 'path','path/to/dir' +% 2- If you want to choose path with uigetfile then you can use +% 'uiget',true (default false) +% 3- For savepath you can customize it with 'savepath' for default it uses 'path' value. +% 4- For append new model as a line to existing txt log use 'modelname','modelnameValue' + + +% Abdullah BAÅž Ph.D. +% BME +% Bogazici University 15.08.2020 +models=''; + +property={'path','uiget','savepth','modelname'}; +value={'modelsLog.txt',false,1,''}; + + + +le=length(varargin); +le=1:2:le; +%index = ismember(contains(property,varargin{le},'IgnoreCase',true)) + +[tf,inds]= (ismember(property,{varargin{le}})); +inds=find(inds>0); +k=1; +for i=inds + value{i}=varargin{le(k)+1}; + k=k+1; +end + +if value{3}==1 + value{3}=value{1}; +end +filepath=value{1}; + +switch version + case 'open' + + if value{2} + + [file,path] = uigetfile({'*.txt';'*.mat';'*.*'},... + 'File Selector'); + filepath=[file filesep path]; + + end + %% + %File path and parameters + txt=fopen(filepath); + if txt==-1 + error(["File is not founded in the '"+[filepath]+"' directory"]) + return; + end + ch=fgetl(txt); + i=1; + %% While loop and reading txt line by line + while ischar(ch) + + models{i}=ch; + ch=fgetl(txt); + i=i+1; + + end + + + fclose(txt); + + %% + case 'save' + if value{4}=="" + + error('Model name is not entered!') + return; + end + txt=fopen(filepath,'a+') ; + + fprintf(txt,'\n%s' ,(value{4})); + +end + diff --git a/Scripts/variablePlot.m b/Scripts/variablePlot.m new file mode 100644 index 0000000..5001923 --- /dev/null +++ b/Scripts/variablePlot.m @@ -0,0 +1,73 @@ +function variablePlot(ax,data,groups,varargin) +%% +% This script is for visualization. +% data is the input table. +% groups is the index of the response +% 25.10.2020 +% Abdullah BAÅž +% BME BOÄžAZİÇİ +% Ä°stanbul Ãœsküdar +%% + +classes=data(:,groups); +inds=ones(1,size(data,2)); +inds(groups)=0; +groups2=table2array(data(:,groups)); +data2=data(:,find(inds==1)); +val=varargin; + +classes=table2array(unique(classes)); +try +classes=classes(~(isnan(classes))); +catch +classes=string(classes(~(classes==""))); +end +classes + +k=1; +for i =classes'; + + + dats=data2(groups2==i,:); + if val{1} + scatter(ax,i*ones(1,size(dats,1)),(dats.(val{2})),'DisplayName',num2str(i)); + ax.Title.String=val{2} + xticks(ax,[]) + + else + x=table2array(dats); + SEM = std(x)./sqrt(length(x)); % Standard Error + + conf = val{4}; + alpha = 1 - conf; + pLo = alpha/2; + pUp = 1 - alpha/2; + + + ts = tinv([pLo pUp],size(x,1)-1); + means=mean(x,1); + CI = mean(x,1) + ts(1)*SEM + CI2=mean(x,1) + ts(2)*SEM + plot(ax,mean(table2array(dats),1),'-mo','MarkerEdgeColor','k',... + 'LineWidth',2,'Color',rand(1,3),'DisplayName',num2str(i),'MarkerFaceColor',[0.1 0.1 0.6]); + xticks(ax,[1:size(dats,2)]) + xticklabels(ax,dats.Properties.VariableNames); + if val{3} + patch(ax,[[1:size(dats,2)] fliplr([1:size(dats,2)])], ... + [CI fliplr(CI2)],[rand rand rand],'EdgeColor','None', ... + 'DisplayName',[num2str(i) ' Confidence Interval' ],'FaceAlpha',0.3) + end + + end + hold(ax,'on'); + + + + + +end +hold(ax,'off'); +ax.XLim=[min(ax.XLim-2),max(ax.XLim+2)]; +%ax.YLim=[max(ax.YLim*-1.22),max(ax.YLim*1.2)]; +legend(ax) +end \ No newline at end of file diff --git a/Scripts/variablePlot2.m b/Scripts/variablePlot2.m new file mode 100644 index 0000000..e32fa1f --- /dev/null +++ b/Scripts/variablePlot2.m @@ -0,0 +1,76 @@ +%% +% This script is for visualization. +% data is the input table. +% groups is the index of the response +% 25.10.2020 +% Abdullah BAÅž +% BME BOÄžAZİÇİ +% Ä°stanbul Ãœsküdar +%% + + +function variablePlot(ax,data,groups,varargin) + + +classes=data(:,groups); +inds=ones(1,size(data,2)); +inds(groups)=0; +groups2=table2array(data(:,groups)); +data2=data(:,find(inds==1)); +val=varargin; + +classes=table2array(unique(classes)); +try +classes=classes(~(isnan(classes))); +catch +classes=string(classes(~(classes==""))); +end +classes + +k=1; +for i =classes'; + + + dats=data2(groups2==i,:); + if val{1} + scatter(ax,i*ones(1,size(dats,1)),(dats.(val{2})),'DisplayName',num2str(i)); + ax.Title.String=val{2} + xticks(ax,[]) + + else + x=table2array(dats); + SEM = std(x)./sqrt(length(x)); % Standard Error + + conf = val{4}; + alpha = 1 - conf; + pLo = alpha/2; + pUp = 1 - alpha/2; + + + ts = tinv([pLo pUp],size(x,1)-1); + means=mean(x); + CI = mean(x) + ts(1)*SEM + CI2=mean(x) + ts(2)*SEM + plot(ax,mean(table2array(dats)),'-mo','MarkerEdgeColor','k',... + 'LineWidth',2,'Color',rand(1,3),'DisplayName',num2str(i),'MarkerFaceColor',[0.1 0.1 0.6]); + xticks(ax,[1:size(dats,2)]) + xticklabels(ax,dats.Properties.VariableNames); + if val{3} + patch(ax,[[1:size(dats,2)] fliplr([1:size(dats,2)])], ... + [CI fliplr(CI2)],[rand rand rand],'EdgeColor','None', ... + 'DisplayName',[num2str(i) ' Confidence Interval' ],'FaceAlpha',0.3) + end + + end + hold(ax,'on'); + + + + + +end +hold(ax,'off'); +ax.XLim=[min(ax.XLim-2),max(ax.XLim+2)]; +%ax.YLim=[max(ax.YLim*-1.22),max(ax.YLim*1.2)]; +legend(ax) +end \ No newline at end of file diff --git a/icons/1.jpg b/icons/1.jpg new file mode 100644 index 0000000..deba3ae Binary files /dev/null and b/icons/1.jpg differ diff --git a/icons/2.gif b/icons/2.gif new file mode 100644 index 0000000..126beaa Binary files /dev/null and b/icons/2.gif differ diff --git a/icons/3143124.svg b/icons/3143124.svg new file mode 100644 index 0000000..4408f35 --- /dev/null +++ b/icons/3143124.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/icons/ACU.jpg b/icons/ACU.jpg new file mode 100644 index 0000000..a542140 Binary files /dev/null and b/icons/ACU.jpg differ diff --git a/icons/AI.gif b/icons/AI.gif new file mode 100644 index 0000000..886a1a0 Binary files /dev/null and b/icons/AI.gif differ diff --git a/icons/AcibademUniLogoOrjinal.png b/icons/AcibademUniLogoOrjinal.png new file mode 100644 index 0000000..13f33da Binary files /dev/null and b/icons/AcibademUniLogoOrjinal.png differ diff --git a/icons/Anita Black (1).png b/icons/Anita Black (1).png new file mode 100644 index 0000000..007f6a9 Binary files /dev/null and b/icons/Anita Black (1).png differ diff --git a/icons/Anita Black (2).png b/icons/Anita Black (2).png new file mode 100644 index 0000000..410a503 Binary files /dev/null and b/icons/Anita Black (2).png differ diff --git a/icons/Anita Black (3).png b/icons/Anita Black (3).png new file mode 100644 index 0000000..aa3be24 Binary files /dev/null and b/icons/Anita Black (3).png differ diff --git a/icons/Anita Black.png b/icons/Anita Black.png new file mode 100644 index 0000000..e9627ed Binary files /dev/null and b/icons/Anita Black.png differ diff --git "a/icons/Bo\304\237azi\303\247i_\303\234niversitesi_Logo.png" "b/icons/Bo\304\237azi\303\247i_\303\234niversitesi_Logo.png" new file mode 100644 index 0000000..599614b Binary files /dev/null and "b/icons/Bo\304\237azi\303\247i_\303\234niversitesi_Logo.png" differ diff --git "a/icons/Ekran Al\304\261nt\304\261s\304\261.JPG" "b/icons/Ekran Al\304\261nt\304\261s\304\261.JPG" new file mode 100644 index 0000000..43fdbfa Binary files /dev/null and "b/icons/Ekran Al\304\261nt\304\261s\304\261.JPG" differ diff --git a/icons/GL.jpg b/icons/GL.jpg new file mode 100644 index 0000000..e3a02fe Binary files /dev/null and b/icons/GL.jpg differ diff --git a/icons/Load (1).png b/icons/Load (1).png new file mode 100644 index 0000000..1036ad5 Binary files /dev/null and b/icons/Load (1).png differ diff --git a/icons/Load (2).png b/icons/Load (2).png new file mode 100644 index 0000000..48026b7 Binary files /dev/null and b/icons/Load (2).png differ diff --git a/icons/Load (3).png b/icons/Load (3).png new file mode 100644 index 0000000..ed8035e Binary files /dev/null and b/icons/Load (3).png differ diff --git a/icons/Load (4).png b/icons/Load (4).png new file mode 100644 index 0000000..d653ca9 Binary files /dev/null and b/icons/Load (4).png differ diff --git a/icons/Load (5).png b/icons/Load (5).png new file mode 100644 index 0000000..b47f2f2 Binary files /dev/null and b/icons/Load (5).png differ diff --git a/icons/Load (6).png b/icons/Load (6).png new file mode 100644 index 0000000..a3fe625 Binary files /dev/null and b/icons/Load (6).png differ diff --git a/icons/Load (7).png b/icons/Load (7).png new file mode 100644 index 0000000..1122885 Binary files /dev/null and b/icons/Load (7).png differ diff --git a/icons/Load.png b/icons/Load.png new file mode 100644 index 0000000..396ee56 Binary files /dev/null and b/icons/Load.png differ diff --git "a/icons/Prof. Dr. Alp Din\303\247e34r.png" "b/icons/Prof. Dr. Alp Din\303\247e34r.png" new file mode 100644 index 0000000..09f27c8 Binary files /dev/null and "b/icons/Prof. Dr. Alp Din\303\247e34r.png" differ diff --git "a/icons/Prof. Dr. Alp Din\303\247er (1).png" "b/icons/Prof. Dr. Alp Din\303\247er (1).png" new file mode 100644 index 0000000..2a087e8 Binary files /dev/null and "b/icons/Prof. Dr. Alp Din\303\247er (1).png" differ diff --git "a/icons/Prof. Dr. Alp Din\303\247er (2).png" "b/icons/Prof. Dr. Alp Din\303\247er (2).png" new file mode 100644 index 0000000..3130c83 Binary files /dev/null and "b/icons/Prof. Dr. Alp Din\303\247er (2).png" differ diff --git "a/icons/Prof. Dr. Alp Din\303\247er.png" "b/icons/Prof. Dr. Alp Din\303\247er.png" new file mode 100644 index 0000000..6a36fd5 Binary files /dev/null and "b/icons/Prof. Dr. Alp Din\303\247er.png" differ diff --git a/icons/a_0 vs c_0.PNG b/icons/a_0 vs c_0.PNG new file mode 100644 index 0000000..02adc62 Binary files /dev/null and b/icons/a_0 vs c_0.PNG differ diff --git a/icons/a_1 vs c_1.PNG b/icons/a_1 vs c_1.PNG new file mode 100644 index 0000000..e7d3b28 Binary files /dev/null and b/icons/a_1 vs c_1.PNG differ diff --git a/icons/accuracy.png b/icons/accuracy.png new file mode 100644 index 0000000..01acccf Binary files /dev/null and b/icons/accuracy.png differ diff --git a/icons/adv.png b/icons/adv.png new file mode 100644 index 0000000..1a3a1b5 Binary files /dev/null and b/icons/adv.png differ diff --git a/icons/advace.png b/icons/advace.png new file mode 100644 index 0000000..f7cfea9 Binary files /dev/null and b/icons/advace.png differ diff --git a/icons/advacepng.png b/icons/advacepng.png new file mode 100644 index 0000000..1b2f2ae Binary files /dev/null and b/icons/advacepng.png differ diff --git a/icons/advance.png b/icons/advance.png new file mode 100644 index 0000000..13fcdbb Binary files /dev/null and b/icons/advance.png differ diff --git a/icons/advanced2.png b/icons/advanced2.png new file mode 100644 index 0000000..1a3a1b5 Binary files /dev/null and b/icons/advanced2.png differ diff --git a/icons/adve.png b/icons/adve.png new file mode 100644 index 0000000..2c6fb46 Binary files /dev/null and b/icons/adve.png differ diff --git a/icons/ai-digital.gif b/icons/ai-digital.gif new file mode 100644 index 0000000..37b958e Binary files /dev/null and b/icons/ai-digital.gif differ diff --git a/icons/algorithm.png b/icons/algorithm.png new file mode 100644 index 0000000..e0b8eb8 Binary files /dev/null and b/icons/algorithm.png differ diff --git a/icons/algorithm2.png b/icons/algorithm2.png new file mode 100644 index 0000000..6c8d727 Binary files /dev/null and b/icons/algorithm2.png differ diff --git a/icons/all (1).PNG b/icons/all (1).PNG new file mode 100644 index 0000000..222968b Binary files /dev/null and b/icons/all (1).PNG differ diff --git a/icons/all.PNG b/icons/all.PNG new file mode 100644 index 0000000..222968b Binary files /dev/null and b/icons/all.PNG differ diff --git a/icons/analysis.png b/icons/analysis.png new file mode 100644 index 0000000..1c55946 Binary files /dev/null and b/icons/analysis.png differ diff --git a/icons/analytics-1925495_1920.png b/icons/analytics-1925495_1920.png new file mode 100644 index 0000000..f8d2dee Binary files /dev/null and b/icons/analytics-1925495_1920.png differ diff --git a/icons/anatomy-1751201_640.png b/icons/anatomy-1751201_640.png new file mode 100644 index 0000000..a5fb85a Binary files /dev/null and b/icons/anatomy-1751201_640.png differ diff --git a/icons/anita.ico b/icons/anita.ico new file mode 100644 index 0000000..4fc87a6 Binary files /dev/null and b/icons/anita.ico differ diff --git a/icons/background.png b/icons/background.png new file mode 100644 index 0000000..09b47c4 Binary files /dev/null and b/icons/background.png differ diff --git a/icons/border.png b/icons/border.png new file mode 100644 index 0000000..3e11aca Binary files /dev/null and b/icons/border.png differ diff --git a/icons/brain.png b/icons/brain.png new file mode 100644 index 0000000..9f35ac4 Binary files /dev/null and b/icons/brain.png differ diff --git a/icons/call-center.png b/icons/call-center.png new file mode 100644 index 0000000..e0b8eb8 Binary files /dev/null and b/icons/call-center.png differ diff --git a/icons/chart (1).png b/icons/chart (1).png new file mode 100644 index 0000000..7e061be Binary files /dev/null and b/icons/chart (1).png differ diff --git a/icons/chart.png b/icons/chart.png new file mode 100644 index 0000000..f70a689 Binary files /dev/null and b/icons/chart.png differ diff --git a/icons/cil.png b/icons/cil.png new file mode 100644 index 0000000..0d705ce Binary files /dev/null and b/icons/cil.png differ diff --git a/icons/dowload.png b/icons/dowload.png new file mode 100644 index 0000000..bb855e3 Binary files /dev/null and b/icons/dowload.png differ diff --git "a/icons/d\303\274nya ortalama oran\304\261 (1).png" "b/icons/d\303\274nya ortalama oran\304\261 (1).png" new file mode 100644 index 0000000..5a700b4 Binary files /dev/null and "b/icons/d\303\274nya ortalama oran\304\261 (1).png" differ diff --git "a/icons/d\303\274nya ortalama oran\304\261 (2).png" "b/icons/d\303\274nya ortalama oran\304\261 (2).png" new file mode 100644 index 0000000..dbd1763 Binary files /dev/null and "b/icons/d\303\274nya ortalama oran\304\261 (2).png" differ diff --git "a/icons/d\303\274nya ortalama oran\304\261 (3).png" "b/icons/d\303\274nya ortalama oran\304\261 (3).png" new file mode 100644 index 0000000..ebd68ee Binary files /dev/null and "b/icons/d\303\274nya ortalama oran\304\261 (3).png" differ diff --git "a/icons/d\303\274nya ortalama oran\304\261.png" "b/icons/d\303\274nya ortalama oran\304\261.png" new file mode 100644 index 0000000..f926b25 Binary files /dev/null and "b/icons/d\303\274nya ortalama oran\304\261.png" differ diff --git a/icons/excel.png b/icons/excel.png new file mode 100644 index 0000000..0186b2a Binary files /dev/null and b/icons/excel.png differ diff --git a/icons/eye.png b/icons/eye.png new file mode 100644 index 0000000..e50c866 Binary files /dev/null and b/icons/eye.png differ diff --git a/icons/f3c193426f452b967cee44c0e7317c75.jpg b/icons/f3c193426f452b967cee44c0e7317c75.jpg new file mode 100644 index 0000000..3a89678 Binary files /dev/null and b/icons/f3c193426f452b967cee44c0e7317c75.jpg differ diff --git a/icons/file (1).png b/icons/file (1).png new file mode 100644 index 0000000..bda394a Binary files /dev/null and b/icons/file (1).png differ diff --git a/icons/file.png b/icons/file.png new file mode 100644 index 0000000..0725429 Binary files /dev/null and b/icons/file.png differ diff --git a/icons/giphy.gif b/icons/giphy.gif new file mode 100644 index 0000000..d86e0cb Binary files /dev/null and b/icons/giphy.gif differ diff --git a/icons/grain.png b/icons/grain.png new file mode 100644 index 0000000..93dfbc7 Binary files /dev/null and b/icons/grain.png differ diff --git a/icons/icons8-user-manual-16.png b/icons/icons8-user-manual-16.png new file mode 100644 index 0000000..65467a9 Binary files /dev/null and b/icons/icons8-user-manual-16.png differ diff --git a/icons/intersection.png b/icons/intersection.png new file mode 100644 index 0000000..28a540a Binary files /dev/null and b/icons/intersection.png differ diff --git a/icons/left-arrow.png b/icons/left-arrow.png new file mode 100644 index 0000000..d999cdf Binary files /dev/null and b/icons/left-arrow.png differ diff --git a/icons/loader.png b/icons/loader.png new file mode 100644 index 0000000..88a8a4d Binary files /dev/null and b/icons/loader.png differ diff --git a/icons/manual.png b/icons/manual.png new file mode 100644 index 0000000..91c4f90 Binary files /dev/null and b/icons/manual.png differ diff --git a/icons/map-folded-paper (1).png b/icons/map-folded-paper (1).png new file mode 100644 index 0000000..26a1367 Binary files /dev/null and b/icons/map-folded-paper (1).png differ diff --git a/icons/map-folded-paper.png b/icons/map-folded-paper.png new file mode 100644 index 0000000..86d827a Binary files /dev/null and b/icons/map-folded-paper.png differ diff --git a/icons/multiple-variable-lines-graphic.png b/icons/multiple-variable-lines-graphic.png new file mode 100644 index 0000000..f45cdae Binary files /dev/null and b/icons/multiple-variable-lines-graphic.png differ diff --git a/icons/option.png b/icons/option.png new file mode 100644 index 0000000..8c5bb8f Binary files /dev/null and b/icons/option.png differ diff --git a/icons/options.png b/icons/options.png new file mode 100644 index 0000000..71a2a0f Binary files /dev/null and b/icons/options.png differ diff --git a/icons/output-onlinepngtools (1).png b/icons/output-onlinepngtools (1).png new file mode 100644 index 0000000..f560772 Binary files /dev/null and b/icons/output-onlinepngtools (1).png differ diff --git a/icons/output-onlinepngtools (10).png b/icons/output-onlinepngtools (10).png new file mode 100644 index 0000000..903baad Binary files /dev/null and b/icons/output-onlinepngtools (10).png differ diff --git a/icons/output-onlinepngtools (11).png b/icons/output-onlinepngtools (11).png new file mode 100644 index 0000000..4c1d64d Binary files /dev/null and b/icons/output-onlinepngtools (11).png differ diff --git a/icons/output-onlinepngtools (12).png b/icons/output-onlinepngtools (12).png new file mode 100644 index 0000000..dd75985 Binary files /dev/null and b/icons/output-onlinepngtools (12).png differ diff --git a/icons/output-onlinepngtools (13).png b/icons/output-onlinepngtools (13).png new file mode 100644 index 0000000..4167bf6 Binary files /dev/null and b/icons/output-onlinepngtools (13).png differ diff --git a/icons/output-onlinepngtools (14).png b/icons/output-onlinepngtools (14).png new file mode 100644 index 0000000..1240d7f Binary files /dev/null and b/icons/output-onlinepngtools (14).png differ diff --git a/icons/output-onlinepngtools (15).png b/icons/output-onlinepngtools (15).png new file mode 100644 index 0000000..53032ea Binary files /dev/null and b/icons/output-onlinepngtools (15).png differ diff --git a/icons/output-onlinepngtools (16).png b/icons/output-onlinepngtools (16).png new file mode 100644 index 0000000..b2f2da5 Binary files /dev/null and b/icons/output-onlinepngtools (16).png differ diff --git a/icons/output-onlinepngtools (17).png b/icons/output-onlinepngtools (17).png new file mode 100644 index 0000000..34f303a Binary files /dev/null and b/icons/output-onlinepngtools (17).png differ diff --git a/icons/output-onlinepngtools (18).png b/icons/output-onlinepngtools (18).png new file mode 100644 index 0000000..4467f97 Binary files /dev/null and b/icons/output-onlinepngtools (18).png differ diff --git a/icons/output-onlinepngtools (2).png b/icons/output-onlinepngtools (2).png new file mode 100644 index 0000000..1f5e853 Binary files /dev/null and b/icons/output-onlinepngtools (2).png differ diff --git a/icons/output-onlinepngtools (3).png b/icons/output-onlinepngtools (3).png new file mode 100644 index 0000000..10934ed Binary files /dev/null and b/icons/output-onlinepngtools (3).png differ diff --git a/icons/output-onlinepngtools (4).png b/icons/output-onlinepngtools (4).png new file mode 100644 index 0000000..601a0b4 Binary files /dev/null and b/icons/output-onlinepngtools (4).png differ diff --git a/icons/output-onlinepngtools (5).png b/icons/output-onlinepngtools (5).png new file mode 100644 index 0000000..0fa73e5 Binary files /dev/null and b/icons/output-onlinepngtools (5).png differ diff --git a/icons/output-onlinepngtools (6).png b/icons/output-onlinepngtools (6).png new file mode 100644 index 0000000..cf4dd55 Binary files /dev/null and b/icons/output-onlinepngtools (6).png differ diff --git a/icons/output-onlinepngtools (7).png b/icons/output-onlinepngtools (7).png new file mode 100644 index 0000000..b4aa0cb Binary files /dev/null and b/icons/output-onlinepngtools (7).png differ diff --git a/icons/output-onlinepngtools (8).png b/icons/output-onlinepngtools (8).png new file mode 100644 index 0000000..6975d80 Binary files /dev/null and b/icons/output-onlinepngtools (8).png differ diff --git a/icons/output-onlinepngtools (9).png b/icons/output-onlinepngtools (9).png new file mode 100644 index 0000000..163fb29 Binary files /dev/null and b/icons/output-onlinepngtools (9).png differ diff --git a/icons/output-onlinepngtools.png b/icons/output-onlinepngtools.png new file mode 100644 index 0000000..a81cb88 Binary files /dev/null and b/icons/output-onlinepngtools.png differ diff --git a/icons/pennant.png b/icons/pennant.png new file mode 100644 index 0000000..e53e545 Binary files /dev/null and b/icons/pennant.png differ diff --git a/icons/plus.png b/icons/plus.png new file mode 100644 index 0000000..a3069f6 Binary files /dev/null and b/icons/plus.png differ diff --git a/icons/popup_1.png b/icons/popup_1.png new file mode 100644 index 0000000..8bcff0c Binary files /dev/null and b/icons/popup_1.png differ diff --git a/icons/precision.png b/icons/precision.png new file mode 100644 index 0000000..355ec54 Binary files /dev/null and b/icons/precision.png differ diff --git a/icons/pubs.png b/icons/pubs.png new file mode 100644 index 0000000..32e3459 Binary files /dev/null and b/icons/pubs.png differ diff --git a/icons/rec.png b/icons/rec.png new file mode 100644 index 0000000..b468767 Binary files /dev/null and b/icons/rec.png differ diff --git a/icons/single.png b/icons/single.png new file mode 100644 index 0000000..38f246a Binary files /dev/null and b/icons/single.png differ diff --git a/icons/ssd.png b/icons/ssd.png new file mode 100644 index 0000000..a9cc3a3 Binary files /dev/null and b/icons/ssd.png differ diff --git a/icons/table.png b/icons/table.png new file mode 100644 index 0000000..7423389 Binary files /dev/null and b/icons/table.png differ diff --git a/icons/trainerD.png b/icons/trainerD.png new file mode 100644 index 0000000..fef8b86 Binary files /dev/null and b/icons/trainerD.png differ diff --git a/icons/trainerPlots.png b/icons/trainerPlots.png new file mode 100644 index 0000000..a18e8a2 Binary files /dev/null and b/icons/trainerPlots.png differ diff --git a/icons/upload.png b/icons/upload.png new file mode 100644 index 0000000..b5a298b Binary files /dev/null and b/icons/upload.png differ diff --git a/icons/vector.png b/icons/vector.png new file mode 100644 index 0000000..f6408ca Binary files /dev/null and b/icons/vector.png differ diff --git a/icons/versus.png b/icons/versus.png new file mode 100644 index 0000000..1e5d6bd Binary files /dev/null and b/icons/versus.png differ diff --git "a/icons/\304\261nvestigate.png" "b/icons/\304\261nvestigate.png" new file mode 100644 index 0000000..b1f305c Binary files /dev/null and "b/icons/\304\261nvestigate.png" differ diff --git a/iris.m b/iris.m new file mode 100644 index 0000000..55eef5f --- /dev/null +++ b/iris.m @@ -0,0 +1,8142 @@ +classdef iris < matlab.apps.AppBase + + % Properties that correspond to app components + properties (Access = public) + GliomaIDHMutationDiagnosisToolUIFigure matlab.ui.Figure + MR_Spectroscopy matlab.ui.container.TabGroup + ManualEntryTab matlab.ui.container.Tab + ManualEntryPan matlab.ui.container.Panel + Classify matlab.ui.control.Button + EnterButton matlab.ui.control.Button + MetaboliteMenuDropDown matlab.ui.control.DropDown + Image2 matlab.ui.control.Image + EditField matlab.ui.control.EditField + ListBox matlab.ui.control.ListBox + Tree3 matlab.ui.container.Tree + modelsd matlab.ui.container.TreeNode + MetaboliteConcentrationEntryLabel matlab.ui.control.Label + Image9 matlab.ui.control.Image + BacktoMainMenuLabel matlab.ui.control.Label + ModelMetricsPanel matlab.ui.container.Panel + ListBox_2 matlab.ui.control.ListBox + Image8 matlab.ui.control.Image + Image8_2 matlab.ui.control.Image + Image8_3 matlab.ui.control.Image + AccuracyLabel matlab.ui.control.Label + SpecificityLabel matlab.ui.control.Label + SensitivityLabel matlab.ui.control.Label + NaNLabel matlab.ui.control.Label + NaNLabel_2 matlab.ui.control.Label + NaNLabel_3 matlab.ui.control.Label + Image15 matlab.ui.control.Image + ResultLabel matlab.ui.control.Label + NaNLabel_4 matlab.ui.control.Label + MainMenuPanel matlab.ui.container.Panel + ManualEntryButton matlab.ui.control.Button + ExcelEntryButton matlab.ui.control.Button + LCModelEntryButton matlab.ui.control.Button + PlotsButton matlab.ui.control.Button + ExcelEntryPanel matlab.ui.container.Panel + ButtonPanel matlab.ui.container.Panel + progressbar matlab.ui.control.UIAxes + LoadButton matlab.ui.control.Button + ClassifyButton matlab.ui.control.Button + ExportClassesButton matlab.ui.control.Button + Image10 matlab.ui.control.Image + BacktoMainMenuLabel_2 matlab.ui.control.Label + ProcessingLabel matlab.ui.control.Label + ModelsListBox_3Label matlab.ui.control.Label + ModelsListBox_3 matlab.ui.control.ListBox + LoadButton_4 matlab.ui.control.Button + UITableExcelEntry matlab.ui.control.Table + Class1Label matlab.ui.control.Label + Class2Label matlab.ui.control.Label + PlotsPanel matlab.ui.container.Panel + PlotsMenuPanel matlab.ui.container.Panel + ModelPlots matlab.ui.control.Button + LCMODELPLOTS matlab.ui.control.Button + ExcelPlots matlab.ui.control.Button + Image11 matlab.ui.control.Image + BacktoMainMenuLabel_3 matlab.ui.control.Label + plottingpanels1 matlab.ui.container.Panel + plottingpanels2 matlab.ui.container.Panel + ModelPlotsPanel matlab.ui.container.Panel + RefreshButton_2 matlab.ui.control.Button + PlotButton_3 matlab.ui.control.Button + ModelsListBoxLabel matlab.ui.control.Label + ModelsListBox matlab.ui.control.ListBox + Image12 matlab.ui.control.Image + Image12_2 matlab.ui.control.Image + BacktoMainMenuLabel_4 matlab.ui.control.Label + BacktopreviousMenuLabel matlab.ui.control.Label + LCModelPlotsPanel matlab.ui.container.Panel + LoadButton_2 matlab.ui.control.Button + PlotButton_4 matlab.ui.control.Button + Image13 matlab.ui.control.Image + Image13_2 matlab.ui.control.Image + BacktoMainMenuLabel_5 matlab.ui.control.Label + BacktoPreviousMenuLabel matlab.ui.control.Label + MetabolitesListBoxLabel matlab.ui.control.Label + MetabolitesListBox matlab.ui.control.ListBox + ExcelPlotPanel matlab.ui.container.Panel + TabGroup3 matlab.ui.container.TabGroup + DataTab matlab.ui.container.Tab + LoadButton_6 matlab.ui.control.Button + UITable4 matlab.ui.control.Table + AssignButton matlab.ui.control.Button + ListBox_5Label matlab.ui.control.Label + ListBox_5 matlab.ui.control.ListBox + GroupingFeatureLabel matlab.ui.control.Label + DropDown matlab.ui.control.DropDown + Image24 matlab.ui.control.Image + BacktoPlotsMenuLabel matlab.ui.control.Label + greenLabel matlab.ui.control.Label + blueLabel matlab.ui.control.Label + PlotsTab matlab.ui.container.Tab + excelpanel matlab.ui.container.Panel + Plot matlab.ui.control.Button + PlotsButtonGroup matlab.ui.container.ButtonGroup + VariablePlotButton_2 matlab.ui.control.ToggleButton + SpiderPlotButton_2 matlab.ui.control.ToggleButton + PCAPlotButton matlab.ui.control.ToggleButton + BoxPlotButton_2 matlab.ui.control.ToggleButton + BarPlotButton matlab.ui.control.ToggleButton + LinePlotButton matlab.ui.control.ToggleButton + ConfidenceIntervalCheckBox matlab.ui.control.CheckBox + ScatterCheckBox matlab.ui.control.CheckBox + CI matlab.ui.control.NumericEditField + MergeCheckBox_2 matlab.ui.control.CheckBox + CompactCheckBox matlab.ui.control.CheckBox + PCDimensionSpinnerLabel matlab.ui.control.Label + PCDimensionSpinner matlab.ui.control.Spinner + Feature1DropDownLabel matlab.ui.control.Label + Feature1DropDown matlab.ui.control.DropDown + Feature2DropDownLabel matlab.ui.control.Label + Feature2DropDown matlab.ui.control.DropDown + ResultsPanel matlab.ui.container.Panel + LCModelEntryPanel matlab.ui.container.Panel + LoadButton_3 matlab.ui.control.Button + ClassifyButton_2 matlab.ui.control.Button + ModelsListBox_2Label matlab.ui.control.Label + ModelsListBox_2 matlab.ui.control.ListBox + CoordFilesListBoxLabel matlab.ui.control.Label + CoordFilesListBox matlab.ui.control.ListBox + Image14 matlab.ui.control.Image + BacktoMainMenuLabel_6 matlab.ui.control.Label + MR_Diffusion matlab.ui.container.TabGroup + Tab_3 matlab.ui.container.Tab + Tab2_3 matlab.ui.container.Tab + Tree matlab.ui.container.Tree + NormalUserNode matlab.ui.container.TreeNode + MRSpectroscopyNode matlab.ui.container.TreeNode + MassSpectroscopyNode matlab.ui.container.TreeNode + AdvancedUserNode matlab.ui.container.TreeNode + AboutNode matlab.ui.container.TreeNode + AdvancedUser matlab.ui.container.TabGroup + TrainerTab matlab.ui.container.Tab + trainertab matlab.ui.container.TabGroup + VariablePlotsTab matlab.ui.container.Tab + trainerpanel matlab.ui.container.Panel + Variable1DropDownLabel matlab.ui.control.Label + Variable1DropDown matlab.ui.control.DropDown + Variable2DropDownLabel matlab.ui.control.Label + Variable2DropDown matlab.ui.control.DropDown + plots_2 matlab.ui.control.Button + PLOTSButtonGroup matlab.ui.container.ButtonGroup + VariablePlotButton matlab.ui.control.ToggleButton + SpiderPlotButton matlab.ui.control.ToggleButton + BoxPlotButton matlab.ui.control.ToggleButton + LinePlotButton_3 matlab.ui.control.ToggleButton + CompactCheckBox_3 matlab.ui.control.CheckBox + MeanSpiderCheckBox matlab.ui.control.CheckBox + MergeCheckBox matlab.ui.control.CheckBox + BarPlotButton_3 matlab.ui.control.ToggleButton + ScatterCheck matlab.ui.control.CheckBox + CISpinnerLabel matlab.ui.control.Label + CISpinner matlab.ui.control.Spinner + CheckBox matlab.ui.control.CheckBox + PCAPlotButton_3 matlab.ui.control.ToggleButton + DimensionSpinnerLabel matlab.ui.control.Label + DimensionSpinner matlab.ui.control.Spinner + Image16 matlab.ui.control.Image + BacktomainmenuLabel matlab.ui.control.Label + Image16_2 matlab.ui.control.Image + BacktopreviousmenuLabel matlab.ui.control.Label + ModelPlotsTab matlab.ui.container.Tab + Panel_2 matlab.ui.container.Panel + MODELSListBox_3Label matlab.ui.control.Label + MODELSListBox_3 matlab.ui.control.ListBox + RefreshButton matlab.ui.control.Button + PlotButton_2 matlab.ui.control.Button + TrainingPanel matlab.ui.container.Panel + KNN matlab.ui.container.Panel + Image5 matlab.ui.control.Image + WeightedKNNLabel matlab.ui.control.Label + CoarseKNNLabel matlab.ui.control.Label + Image5_5 matlab.ui.control.Image + fineknn matlab.ui.control.Image + FineKNNLabel matlab.ui.control.Label + fineknn_2 matlab.ui.control.Image + CubicKNNLabel matlab.ui.control.Label + fineknn_3 matlab.ui.control.Image + CosineKNNLabel matlab.ui.control.Label + SVM matlab.ui.container.Panel + linearsvm matlab.ui.control.Image + LinearSVMLabel matlab.ui.control.Label + QuadraticSVMLabel matlab.ui.control.Label + quadraticsvm matlab.ui.control.Image + Image5_4 matlab.ui.control.Image + CubicSVMLabel matlab.ui.control.Label + Image5_6 matlab.ui.control.Image + FineGaussianSVMLabel matlab.ui.control.Label + Image5_7 matlab.ui.control.Image + MediumGaussianSVMLabel matlab.ui.control.Label + Forest matlab.ui.container.Panel + CoarseTree matlab.ui.control.Image + MediumTree matlab.ui.control.Image + MediumTreeLabel matlab.ui.control.Label + CoarseTreeLabel matlab.ui.control.Label + CoarseTree_2 matlab.ui.control.Image + FineTreeLabel matlab.ui.control.Label + Ensemble matlab.ui.container.Panel + BoostedTrees matlab.ui.control.Image + BoostedTreesLabel matlab.ui.control.Label + BaggedTree matlab.ui.control.Image + BaggedTreesLabel matlab.ui.control.Label + Discriminant matlab.ui.control.Image + DiscriminantLabel matlab.ui.control.Label + RUSB matlab.ui.control.Image + RUSBoostedLabel matlab.ui.control.Label + KFoldCrossValidationLabel matlab.ui.control.Label + Image18 matlab.ui.control.Image + Spinner matlab.ui.control.Spinner + Image18_2 matlab.ui.control.Image + Image19 matlab.ui.control.Image + BacktoMainMenuLabel_8 matlab.ui.control.Label + Image19_2 matlab.ui.control.Image + BacktoPreviousMenuLabel_2 matlab.ui.control.Label + HoldOutSliderLabel matlab.ui.control.Label + HoldOutSlider matlab.ui.control.Slider + RunAllButton matlab.ui.control.Button + SyntheticDataButton matlab.ui.control.Button + RankFeaturesButton matlab.ui.control.Button + ListBox_6 matlab.ui.control.ListBox + FeaturesRankDescendingOrderLabel matlab.ui.control.Label + SelectasPredictorsButton matlab.ui.control.Button + SelectedFeaturesLabel matlab.ui.control.Label + SequentialFeatureSelectionButton matlab.ui.control.Button + RunsSpinner matlab.ui.control.Spinner + RunsSpinnerLabel matlab.ui.control.Label + ReportTrainer matlab.ui.container.Panel + ReportAll matlab.ui.control.Button + AdvancedMenuPanel matlab.ui.container.Panel + UITable2 matlab.ui.control.Table + Panel_3 matlab.ui.container.Panel + RESPONSEListBoxLabel matlab.ui.control.Label + RESPONSEListBox matlab.ui.control.ListBox + trainer32 matlab.ui.control.Button + PREDICTORSListBoxLabel matlab.ui.control.Label + PREDICTORSListBox matlab.ui.control.ListBox + TrainerLoad matlab.ui.control.Button + predictor matlab.ui.control.Button + plots_3 matlab.ui.control.Button + Image17 matlab.ui.control.Image + BacktoMainMenuLabel_7 matlab.ui.control.Label + ResponseDropDownLabel matlab.ui.control.Label + ResponseDropDown matlab.ui.control.DropDown + ApplyCRLBThresholdMRSpectroscopyButton matlab.ui.control.Button + Selectsubtab matlab.ui.control.Button + statisticaltests matlab.ui.control.Button + PredictorsLabel matlab.ui.control.Label + ResponseLabel matlab.ui.control.Label + UITable5 matlab.ui.control.Table + ModelParametersPanel matlab.ui.container.Panel + Tree2 matlab.ui.container.Tree + models2 matlab.ui.container.TreeNode + Node2 matlab.ui.container.TreeNode + advancedList matlab.ui.control.ListBox + advancedPlot matlab.ui.control.Button + SubplotCheckBox matlab.ui.control.CheckBox + advancedPanel matlab.ui.container.Panel + Image22 matlab.ui.control.Image + BacktoMainMenuLabel_11 matlab.ui.control.Label + advancedPlot_2 matlab.ui.control.Button + ListBox_10 matlab.ui.control.ListBox + MainMenuPanel_2 matlab.ui.container.Panel + TrainNewModelButton matlab.ui.control.Button + TrainedModelsButton matlab.ui.control.Button + PlotsButton_2 matlab.ui.control.Button + Image20 matlab.ui.control.Image + ClicktoLoadDataLabel matlab.ui.control.Label + BacktoMainMenuLabel_9 matlab.ui.control.Label + Image20_2 matlab.ui.control.Image + modelsPlotALLadvanced matlab.ui.container.Panel + modelsplotpaneladvanced matlab.ui.container.Panel + RefreshButton_3 matlab.ui.control.Button + PlotButton_5 matlab.ui.control.Button + Image25 matlab.ui.control.Image + BacktoMainMenuLabel_13 matlab.ui.control.Label + ModelsListBox_4Label matlab.ui.control.Label + ModelsListBox_4 matlab.ui.control.ListBox + Panel_5 matlab.ui.container.Panel + load_html matlab.ui.control.HTML + Classifier matlab.ui.container.Tab + ClassifierMainPanel matlab.ui.container.Panel + Image21 matlab.ui.control.Image + TableEntryLabel matlab.ui.control.Label + Image21_2 matlab.ui.control.Image + SingleDataPointEntryLabel matlab.ui.control.Label + load_table matlab.ui.control.HTML + load_single matlab.ui.control.HTML + ExcelEntry matlab.ui.container.Panel + UITable3 matlab.ui.control.Table + LoadButton_5 matlab.ui.control.Button + MODELSListBox_4Label matlab.ui.control.Label + MODELSListBox_4 matlab.ui.control.ListBox + ClassifyButton_3 matlab.ui.control.Button + ExportClassesButton_2 matlab.ui.control.Button + Image23 matlab.ui.control.Image + BacktoMainMenuLabel_12 matlab.ui.control.Label + Label_13 matlab.ui.control.Label + Class2Label_2 matlab.ui.control.Label + Label_11 matlab.ui.control.Label + ExportClassesButton_4 matlab.ui.control.Button + classes_res matlab.ui.control.HTML + ManualPanel matlab.ui.container.Panel + Classify_2 matlab.ui.control.Button + EnterButton_2 matlab.ui.control.Button + MetaboliteMenuDropDown_2 matlab.ui.control.DropDown + EditField_2 matlab.ui.control.EditField + ListBox_3 matlab.ui.control.ListBox + Tree3_2 matlab.ui.container.Tree + modelsd_2 matlab.ui.container.TreeNode + PredictorsLabel_2 matlab.ui.control.Label + Image9_2 matlab.ui.control.Image + BacktoMainMenuLabel_10 matlab.ui.control.Label + ModelMetricsPanel_2 matlab.ui.container.Panel + ListBox_4 matlab.ui.control.ListBox + Image8_4 matlab.ui.control.Image + Image8_5 matlab.ui.control.Image + Image8_6 matlab.ui.control.Image + AccuracyLabel_2 matlab.ui.control.Label + SpecificityLabel_2 matlab.ui.control.Label + SensitivityLabel_2 matlab.ui.control.Label + NaNLabel_5 matlab.ui.control.Label + NaNLabel_6 matlab.ui.control.Label + NaNLabel_7 matlab.ui.control.Label + Image15_2 matlab.ui.control.Image + ResultLabel_2 matlab.ui.control.Label + NaNLabel_8 matlab.ui.control.Label + About matlab.ui.container.TabGroup + AcknowledgementsTab matlab.ui.container.Tab + Label matlab.ui.control.Label + Image4 matlab.ui.control.Image + Image4_2 matlab.ui.control.Image + ProjectTeamTab matlab.ui.container.Tab + Image3 matlab.ui.control.Image + PublicationsTab matlab.ui.container.Tab + PublicationsLabel matlab.ui.control.Label + Label_2 matlab.ui.control.Label + Label_3 matlab.ui.control.Label + Label_4 matlab.ui.control.Label + Label_5 matlab.ui.control.Label + Label_6 matlab.ui.control.Label + Label_7 matlab.ui.control.Label + Label_8 matlab.ui.control.Label + Label_9 matlab.ui.control.Label + Label_10 matlab.ui.control.Label + MassSpectroscopy matlab.ui.container.TabGroup + MassSpectroscopyTab matlab.ui.container.Tab + ManualEntryPan_2 matlab.ui.container.Panel + Classify_3 matlab.ui.control.Button + EnterButton_3 matlab.ui.control.Button + MetaboliteMenuDropDown_3 matlab.ui.control.DropDown + Image2_2 matlab.ui.control.Image + EditField_3 matlab.ui.control.EditField + ListBox_7 matlab.ui.control.ListBox + Tree3_3 matlab.ui.container.Tree + modelsd_3 matlab.ui.container.TreeNode + MetaboliteConcentrationEntryLabel_2 matlab.ui.control.Label + Image9_3 matlab.ui.control.Image + BacktoMainMenuLabel_14 matlab.ui.control.Label + ModelMetricsPanel_3 matlab.ui.container.Panel + ListBox_8 matlab.ui.control.ListBox + Image8_7 matlab.ui.control.Image + Image8_8 matlab.ui.control.Image + Image8_9 matlab.ui.control.Image + AccuracyLabel_3 matlab.ui.control.Label + SpecificityLabel_3 matlab.ui.control.Label + SensitivityLabel_3 matlab.ui.control.Label + NaNLabel_9 matlab.ui.control.Label + NaNLabel_10 matlab.ui.control.Label + NaNLabel_11 matlab.ui.control.Label + Image15_3 matlab.ui.control.Image + ResultLabel_3 matlab.ui.control.Label + NaNLabel_12 matlab.ui.control.Label + MainMenuPanel_3 matlab.ui.container.Panel + ManualEntryButton_2 matlab.ui.control.Button + ExcelEntryButton_2 matlab.ui.control.Button + PlotsButton_3 matlab.ui.control.Button + ExcelEntryPanel_2 matlab.ui.container.Panel + ButtonPanel_2 matlab.ui.container.Panel + progressbar_2 matlab.ui.control.UIAxes + LoadButton_7 matlab.ui.control.Button + ClassifyButton_4 matlab.ui.control.Button + ExportClassesButton_3 matlab.ui.control.Button + Image10_2 matlab.ui.control.Image + BacktoMainMenuLabel_15 matlab.ui.control.Label + ProcessingLabel_2 matlab.ui.control.Label + ModelsListBox_5Label matlab.ui.control.Label + ModelsListBox_5 matlab.ui.control.ListBox + LoadButton_8 matlab.ui.control.Button + UITableExcelEntry_2 matlab.ui.control.Table + Label_12 matlab.ui.control.Label + Class2Label_3 matlab.ui.control.Label + PlotsPanel_2 matlab.ui.container.Panel + PlotsMenuPanel_2 matlab.ui.container.Panel + ModelPlots_2 matlab.ui.control.Button + LCMODELPLOTS_2 matlab.ui.control.Button + ExcelPlots_2 matlab.ui.control.Button + Image11_2 matlab.ui.control.Image + BacktoMainMenuLabel_16 matlab.ui.control.Label + plottingpanels1_2 matlab.ui.container.Panel + plottingpanels2_2 matlab.ui.container.Panel + ModelPlotsPanel_2 matlab.ui.container.Panel + RefreshButton_4 matlab.ui.control.Button + PlotButton_6 matlab.ui.control.Button + ModelsListBox_6Label matlab.ui.control.Label + ModelsListBox_6 matlab.ui.control.ListBox + Image12_3 matlab.ui.control.Image + Image12_4 matlab.ui.control.Image + BacktoMainMenuLabel_17 matlab.ui.control.Label + BacktopreviousMenuLabel_2 matlab.ui.control.Label + LCModelPlotsPanel_2 matlab.ui.container.Panel + LoadButton_9 matlab.ui.control.Button + PlotButton_7 matlab.ui.control.Button + Image13_3 matlab.ui.control.Image + Image13_4 matlab.ui.control.Image + BacktoMainMenuLabel_18 matlab.ui.control.Label + BacktoPreviousMenuLabel_3 matlab.ui.control.Label + MetabolitesListBox_2Label matlab.ui.control.Label + MetabolitesListBox_2 matlab.ui.control.ListBox + ExcelPlotPanel_2 matlab.ui.container.Panel + TabGroup3_2 matlab.ui.container.TabGroup + DataTab_2 matlab.ui.container.Tab + LoadButton_10 matlab.ui.control.Button + UITable4_2 matlab.ui.control.Table + AssignButton_2 matlab.ui.control.Button + ListBox_5Label_2 matlab.ui.control.Label + ListBox_9 matlab.ui.control.ListBox + GroupingFeatureLabel_2 matlab.ui.control.Label + DropDown_2 matlab.ui.control.DropDown + Image24_2 matlab.ui.control.Image + BacktoPlotsMenuLabel_2 matlab.ui.control.Label + greenLabel_2 matlab.ui.control.Label + blueLabel_2 matlab.ui.control.Label + PlotsTab_2 matlab.ui.container.Tab + excelpanel_2 matlab.ui.container.Panel + Plot_2 matlab.ui.control.Button + PlotsButtonGroup_2 matlab.ui.container.ButtonGroup + VariablePlotButton_3 matlab.ui.control.ToggleButton + SpiderPlotButton_3 matlab.ui.control.ToggleButton + PCAPlotButton_2 matlab.ui.control.ToggleButton + BoxPlotButton_3 matlab.ui.control.ToggleButton + BarPlotButton_2 matlab.ui.control.ToggleButton + LinePlotButton_2 matlab.ui.control.ToggleButton + ConfidenceIntervalCheckBox_2 matlab.ui.control.CheckBox + ScatterCheckBox_2 matlab.ui.control.CheckBox + CI_2 matlab.ui.control.NumericEditField + MergeCheckBox_3 matlab.ui.control.CheckBox + CompactCheckBox_2 matlab.ui.control.CheckBox + PCDimensionSpinner_2Label matlab.ui.control.Label + PCDimensionSpinner_2 matlab.ui.control.Spinner + Feature1DropDown_2Label matlab.ui.control.Label + Feature1DropDown_2 matlab.ui.control.DropDown + Feature2DropDown_2Label matlab.ui.control.Label + Feature2DropDown_2 matlab.ui.control.DropDown + ResultsPanel_2 matlab.ui.container.Panel + Image26 matlab.ui.control.Image + Panel_6 matlab.ui.container.Panel + UserManualLabel matlab.ui.control.Label + sidebar_html matlab.ui.control.HTML + HTML matlab.ui.control.HTML + HTML2 matlab.ui.control.HTML + end + + + properties (Access = private) + tabledata,metabs,corrMatrix,sp,bg,fit,coord_filename; + indices; + net; + net2; + net3; + manualControl; + IDHIndices; + TERTIndices; + DoubleIndices; + VAL=[9,12,13,14,33]; + manualValues; + ax; + ax2; % Description + position; % Description + % Description + pt_axis; % Description + % Description + trainerCount=0; + % Description + trainerResp; + % Description + trainerPredictors; % Description + models=struct; % Description + + Defmodels; % Description + + TrueClass=[]; % Description + + + row; % Description + excelPredictors; % Description + excelResp; % Excel Response + + DefMassmodels; % It is the struct that stores default mass models + plottype=0; % Plot type is the MASS/MR Spectroscopy shifting + + featureselection; % Last applied feature selection + confirmedSelection; % Confirmed Selection + Features; % Description + % Description + outAll={}; %All reports merged together + variablesOut; % Description + iterations={}; %Iteratÿon counter + groups={} %Iteratÿon groups + groupSz={} % Iteratÿon groupsize + % Description + % Description + subindices; % This is for subselection at advanced user + % Description + manual % Description + end + + properties (Access = public) + deen="aasd" % Description + reqVars; + crlb=-1; + reqVars2; + auto=0; + automodels; % Description + out; % reported table which is generated from run all process + currentModel; % Lastly trained model + + end + + methods (Access = public) + + function vargout=radarPlot(app,P,axis2, varargin ) + %%% Get the number of dimensions and points + + [M, N] = size(P); + %%% Plot the axes + % Radial offset per axis + th = (2*pi/M)*(ones(2,1)*(M:-1:1)); + % Axis start and end + r = [0;1]*ones(1,M); + % Conversion to cartesian coordinates to plot using regular plot. + [x,y] = pol2cart(th, r); + % hLine = line(axis2,x, y,... + % 'LineWidth', 1.5,... + % 'Color', [1, 1, 1]*0.5 ); + % for i = 1:numel(hLine) + % set(get(get(hLine(i),'Annotation'),'LegendInformation'),... + % 'IconDisplayStyle','off'); % Exclude line from legend + % end + toggle = ~ishold; + if toggle + hold on + end + %%% Plot axes isocurves + % Radial offset per axis + th = (2*pi/M)*(ones(9,1)*(M:-1:1)); + % Axis start and end + r = (linspace(0.1, 0.9, 9)')*ones(1,M); + % Conversion to cartesian coordinates to plot using regular plot. + [x,y] = pol2cart(th, r); + % hLine = line(axis2,[x, x(:,1)]', [y, y(:,1)]',... + % 'LineWidth', 1,... + % 'Color', [1, 1, 1]*0.5 ); + % for i = 1:numel(hLine) + % set(get(get(hLine(i),'Annotation'),'LegendInformation'),... + % 'IconDisplayStyle','off'); % Exclude line from legend + % end + %%% Insert axis labels + % Compute minimum and maximum per axis + + minV = min(P,[],2); + maxV = max(P,[],2); + for j = 1:M + % Generate the axis label + msg = sprintf('x{%d} = %5.2f ... %5.2f',... + j, minV(j), maxV(j)); + [mx, my] = pol2cart( th(1, j), 1.1); + text(axis2,mx, my, msg); + end + axis([-1,1,-1,1]*1.5) + % Hold on to plot data points + hold on + % Radius + R = 0.8*((P - (minV*ones(1,N)))./((maxV-minV)*ones(1,N))) + 0.1; + R = [R; R(1,:)]; + Th = (2*pi/M) * ((M:-1:0)'*ones(1,N)); + % polar(Th, R) + [X, Y] = pol2cart(Th, R); + h = plot(axis2,X, Y); + axis([-1,1,-1,1]); + axis square; + axis off; + if toggle + hold off + end + if nargout > 0 + varargout{1} = h; + end + + end + + + + function [tabledata,metabs,corrMatrix,sp,bg,fit,coord_filename]= load_lcmodel(app) + + [file,folder] = uigetfile('*.coord','MultiSelect',"on"); + + + file=cellstr(string(file)); + folder=cellstr(string(folder)); + + for i=1:length(file) + %dirs=dir([folder '\*']) + + %irs=dirs((~[dirs(:).isdir])) + splitted=strsplit((file{i}),'.coord'); + %directories=strsplit([dirs(1).folder filesep dirs(1).name],'.coord') + %x=zeros(1,272), x(1:2:end)=1, x2=vec2mat(x,17),x3=x2(1:16,1:16) + mainText=[folder{:} filesep splitted{1}]; + + + + + %dirs=dir([folder,'\1\35ms\sl' int2str(x(1,i)) '_' int2str(x(2,i)) '-' int2str(x(3,i)) '.coord']) + + figurelist=''; % Define patient protocol numbers + + + + + %vox_name=sprintf('sl1_%d-%d',slx,sly); + %vox={vox_name}; + PID=(figurelist); + %voxname=char(vox(m)); + %cd(PID); + % coord_filename=strcat(PID,'.coord'); + % output_filename=strcat(PID,'.print'); + coord_filename{i}=[mainText '.coord']; + output_filename=strcat(mainText,'.print'); + + % Read metabolite details and correlation coefficients table + [metabs{i},corrMatrix{i}]=io_loadlcmdetail(output_filename); + + [bg{i}]=io_readlcmcoord_getBackground(coord_filename{i},'bg'); + ppm=bg{i}.ppm; + ind=1; + + [fit{i}]=io_readlcmcoord_getBackground(coord_filename{i},'fit'); + fit{i}.specs=fit{i}.specs-bg{i}.specs; + [sp{i}]=io_readlcmcoord_getBackground(coord_filename{i},'sp'); + + tabledata{i}=mrs_readLcmodelTABLE(strcat(mainText,'.table')); + %table_res{1,tot_vox}=tabledata; + %% + % Create a line plot of all metabolites minus the background + %figx=figure('units','centimeters','outerposition',[0 0 50 30]); + + + + end + + end + + + + function results = axClick(app,varargin) + + + if varargin{2}.Button==3 + + answer = questdlg('Choose the process', ... + 'Processes', ... + 'Title Changes','Zoom In','More..','Zoom In'); + % Handle response + + switch answer + + case 'Title Changes' + app.titleChange(varargin{1}); + + case 'Zoom In' + + app.zoomInOut(answer,varargin{1}); + + case 'More..' + plotMa(varargin{1},'EditType','Advanced') + %app.export(varargin{1}); + + end + else + + + + + + + end + + + end + + function results = RestoreZoom(app,varargin) + if varargin{2}.Button==3 + answer = questdlg('Choose the process', ... + 'Processes', ... + 'Title Changes','Zoom Out','More..','Zoom Out'); + % Handle response + + switch answer + + case 'Title Changes' + app.titleChange(varargin{1}); + + case 'Zoom Out' + + app.zoomInOut(answer,varargin{1}); + + + case 'More..' + plotMa(varargin{1},'EditType','Advanced') + end + end + end + + + function results = titleChange(app,varargin) + xx = inputdlg({'Axes Title','X Title','Y Title'},... + 'Titles', [1 50; 1 50; 1 50]); + varargin{1}.Title.String=[ xx{1}]; + varargin{1}.XLabel.String=[ xx{2}]; + varargin{1}.YLabel.String=[ xx{3}]; + varargin{1}.Title.ButtonDownFcn=@textHandler; + varargin{1}.XLabel.ButtonDownFcn=@textHandler; + varargin{1}.YLabel.ButtonDownFcn=@textHandler; + end + + + + function results = zoomInOut(app,answer,varargin) + + varargin{1} + switch answer + case "Zoom Out" + + for a=1:length(app.ax) + try + set(app.ax{a},'OuterPosition',app.position{a}); + catch + app.ax + app.position + set(app.ax,'OuterPosition',app.position); + + end + end + + + varargin{1}.ButtonDownFcn=@app.axClick; + case "Zoom In" + for a=1:length(app.ax) + set( app.ax{a},'OuterPosition',[0 0 0 0]); + end + set( varargin{1},'OuterPosition',[0 0 1 1]); + varargin{1}.ButtonDownFcn=@app.RestoreZoom; + end + + end + + function results = export(app,varargin) + + xx = inputdlg({'Export Quality','Filename'},... + 'Titles', [1 50; 1 50]); + f=waitbar(0.2,"Exporting"); + + exportgraphics(varargin{1},xx{2},'ContentType','vector','BackgroundColor','none', 'Resolution',str2num(xx{1})) + waitbar(1,f,"Finished!"); + pause(0.5); + close(f); + end + + function results = plotSpectra(app,modplot,i,ppm,linewidth,ax,color,FontSize,varargin) + + + + app.pt_axis=0; + ind=1; + modplot=sort(modplot); + + + for n=modplot + outArr=[] + if n>3 + % Tekrar okumasÿna gerek yok bunu tersten al + vars=strsplit(app.MetabolitesListBox.Items{n},'+') + for ik=1:length(vars) + [buff]=io_readlcmcoord(app.coord_filename{i},vars{ik}); %Graph of the specific metabolite is taken from coordfile(Ex: Only Glu graph from coord file) + if ~isempty(buff.specs) + + outArr(ik,:)=buff.specs + + end + + + end + out.ppm=buff.ppm + out.specs=sum(outArr,1) + if ~isempty(out.specs) + spectra_all(ind,:)=out.specs'; + legendtext{ind}=[ strcat(strjoin(string(app.MetabolitesListBox.Items{n})),'-','SD:',num2str(app.tabledata{i}.SDpct(n-3)),'%')]; + a=spectra_all(ind,:)-app.bg{i}.specs'; + + + b1(ind)=plot(ax,fliplr(ppm),fliplr(a)+app.pt_axis,'LineWidth',linewidth,"Color",color); + t=text(app.ax{i},ppm(1)*1.01,a(end)+app.pt_axis, legendtext{ind},"Color",color,"FontSize",FontSize,'VerticalAlignment','middle'); + set(t,'FontSize',FontSize) + + ds=t.FontSize; + t.ButtonDownFcn=@textHandler; + app.pt_axis=app.pt_axis-ds*6; + ind=ind+1; + hold (ax,"on") + else + + + legendtext{ind}=[strcat(strjoin(string(app.MetabolitesListBox.Items{n})),'-','SD:',num2str(app.tabledata{i}.SDpct(n-3)),'%')]; + %app.pt_axis=app.pt_axis+min(app.pt_axis*0.1,-5); + b1(ind)=plot(ax,ppm, ones(size(ppm)).*app.pt_axis,'LineWidth',linewidth,"Color",color); + t=text(app.ax{i},ppm(1)*1.01,app.pt_axis, legendtext{ind},"Color",color,"FontSize",FontSize,'VerticalAlignment','middle'); + t.ButtonDownFcn=@textHandler; + set(t,'FontSize',FontSize) + + ds=t.FontSize; + + + app.pt_axis=app.pt_axis-ds*6; + + + ind=ind+1; + hold (ax,"on") + end + elseif n<=3 + + + cs={'sp{i}','bg{i}','fit{i}'}; + legends={'In Vivo','Baseline','Fit'}; + x=eval(['app.' cs{n}]); + + b1(ind)=plot(ax,fliplr(ppm),fliplr(x.specs')+app.pt_axis,'LineWidth',linewidth,"Color",color); + + t=text(app.ax{i},ppm(1)*1.01,x.specs(end)+app.pt_axis, legends{n},"Color",color,"FontSize",FontSize,'VerticalAlignment','middle'); + ds=t.FontSize; + t.ButtonDownFcn=@textHandler; + set(t,'FontSize',FontSize) + + app.pt_axis=app.pt_axis-ds*2; + + legendtext{ind}=string(legends{n}); + ind=ind+1; + hold (ax,"on"); + + + + end + + + + end + set(ax,'Color',[1,1,1]); + finalt=strsplit(string(app.coord_filename{i}),filesep ); + title(ax,['\color{black}' finalt{end}]); + set(ax,'ytick',[]); + set(ax,'yticklabel',[ppm(end):ppm(1)]); + set(ax,'xtick',ppm(1)-fliplr([0.5,1,1.5,2,2.5,3,3.5])+ppm(end)); + set(ax,'XColor',color); + xtickangle(ax,45) + %set(ax,'XTickRotate') + dsc=[0.5,1,1.5,2,2.5,3,3.5]%round(linspace(ppm(end),ppm(1),7)-0.01,2); + cx=strsplit(sprintf("%.2f ",fliplr(dsc))," "); + + set(ax,'xticklabel',cx); + set(ax,'box','off'); + %set(ax,'ticklength',[0,0]) + + + xlim(ax,[ppm(end),ppm(1)*1.25]); + ylim(ax,'auto'); + + ax.XLabel.String="Chemical Shift (ppm)"; + ax.XLabel.Color=[0,0,0]; + ax.Title.ButtonDownFcn=@textHandler; + ax.XLabel.ButtonDownFcn=@textHandler; + pos=get(ax,'Position'); + + set(ax,'Position',[pos([1,2]) pos(3)/1.5 pos(4)]) + xc=get(ax,'xlim'); + yc=get(ax,'ylim'); + %ax.XLabel.Position=[pos(1)+(xc(2))/2,pos(2)-yc(2)]; + ax.XLabel.ButtonDownFcn=@textHandler; + set(ax.Title,'ButtonDownFcn',@textHandler); + ax.ButtonDownFcn=@app.axClick; + app.position{i}=ax.OuterPosition; + hold (ax,'off'); + results=get(ax,'ylim') + end + end + + % Callbacks that handle component events + methods (Access = private) + + % Code that executes after component creation + function startupFcn(app) + %app.GliomaIDHMutationDiagnosisToolUIFigure.WindowStyle = 'docked'; + %set(app.GliomaIDHMutationDiagnosisToolUIFigure,'Icon','anita.ico') + app.HTML.HTMLSource='usermanual.html' + app.load_html.HTMLSource='load.html' + app.load_table.HTMLSource='load_class.html' + app.sidebar_html.HTMLSource='sidebar.html' + app.load_single.HTMLSource='load_class_single.html' + models=txtmodelReader('open','modelsLog.txt'); + for i=models + + try + bufm=load ([i{1}]); + + ky=strsplit(i{1},{'/','\','.'}); + ky=ky{end-1}; + + app.models.(ky)=bufm.model; + disp([i{1} '.mat file is founded in the directory and added to models']) + catch + disp([i{1} '.mat file is NOT founded in the directory!' ]) + end + end + + Defmodels=txtmodelReader('open','path','DefaultModelsLog.txt'); + + for i=Defmodels + + try + Pre_CRC=i{1}; + + + bufm=load ([i{1} '.mat']); + app.Defmodels.(Pre_CRC)=bufm.model; + disp([i{1} '.mat file is founded in the directory and added to models']) + catch + disp([i{1} '.mat file is NOT founded in the directory!' ]) + end + end + DefMassmodels=txtmodelReader('open','path','DefaultMassModels.txt'); + + + for i=DefMassmodels + + try + Pre_CRC=i{1}; + + + bufm=load ([i{1} '.mat']); + app.DefMassmodels.(Pre_CRC)=bufm.model; + disp([i{1} '.mat file is founded in the directory and added to models']) + catch + disp([i{1} '.mat file is NOT founded in the directory!' ]) + end + end + + end + + % Callback function + function ShowButtPushed(app, event) + app.indices; + if app.UITable.Visible=="on"; + app.UITable.Visible=false; + app.Button_5.Visible=true; + app.ReportPanel.Visible="off"; + else + app.UITable.Visible=true; + app.Button_5.Visible=false; + app.ReportPanel.Visible="off"; + end + + end + + % Callback function + function LoadButtPushed2(app, event) + [a,b]=uigetfile({'*.xlsx;*.xls;*.csv','Excel files (*.xlsx,*.csv)'}); + if a==0 + return ; + end + removeStyle(app.UITable) + a=readtable([b filesep a],'ReadVariableNames',true); + app.UITable.Data=a; + set(app.UITable, 'ColumnName',a.Properties.VariableNames); + app.indices; + if app.UITable.Visible=="on" + app.UITable.Visible=false; + app.Button_5.Visible=true; + app.ReportPanel.Visible="off"; + else + app.UITable.Visible=true; + app.Button_5.Visible=false; + app.ReportPanel.Visible="off"; + end + app.UITable.BackgroundColor = [1 1 .9; .9 .95 1]; + app.UITable.ColumnSortable = true; + msgbox("Excel File Loaded",'Load Complete','none','replace'); + end + + % Callback function + function UITableCellSelection(app, event) + indices = event.Indices; + indices + app.indices=indices; + + + + end + + % Callback function + function ClassifyButtButtonPushed(app, event) + app.TERTIndices=0; + app.IDHIndices=0; + app.DoubleIndices=0; + app.progressbar_3.Visible="on"; + app.ProcessingLabel_1.Visible="on"; + step=floor(700/size(app.indices,1)); + for i=1:size(app.indices,1) + % yellow + gCH=[ones(60,step*i) zeros(60,step*(size(app.indices,1)-i))]; + imshow(cat(3,zeros(size(gCH)),gCH,zeros(size(gCH))),'Parent',app.progressbar_3); + drawnow(); + app.indices(i,1); + table=app.UITable.Data; + values=table(app.indices(i,1),:); + values2=table2array(values); + values1=(values2([1,2,3])); + values3=values2([1,2,3]); + values4=values2([1,2,3,4,8]); + + [tert tertP]=app.net.predictFcn(array2table(values1 ,'VariableNames',app.net.RequiredVariables)) + [double doubleP]=app.net3.predictFcn(array2table(values4,'VariableNames',app.net3.RequiredVariables)) + [idh idhP]=app.net2.predictFcn(array2table(values3,'VariableNames',app.net2.RequiredVariables)) + % app.TERT_OnlyLabel.Text=num2str(x) + % app.IDH_OnlyLabel.Text=num2str(x2) + % app.DoubleMutantLabel.Text=num2str(x1) + + if double==1 + app.DoubleIndices=[app.DoubleIndices,app.indices(i,1)]; + app.DoubleMutantLabel.Visible="on"; + %app.IDH_OnlyLabel.Visible="off"; + %app.TERT_OnlyLabel.Visible="off"; + s = uistyle('BackgroundColor','green','FontColor','black','FontWeight','Bold'); + addStyle(app.UITable,s,'row',app.indices(i,1)); + elseif idh==1 + app.IDHIndices=[app.IDHIndices app.indices(i,1)]; + %app.DoubleMutantLabel.Visible="off"; + app.IDH_OnlyLabel.Visible="on"; + %app.TERT_OnlyLabel.Visible="off"; + s = uistyle('BackgroundColor','blue','FontColor','white','FontWeight','Bold'); + addStyle(app.UITable,s,'row',app.indices(i,1)); + elseif tert==1 + app.TERTIndices=[app.TERTIndices app.indices(i,1)]; + %app.DoubleMutantLabel.Visible="off"; + %app.IDH_OnlyLabel.Visible="off"; + app.TERT_OnlyLabel.Visible="on"; + s = uistyle('BackgroundColor','red'); + addStyle(app.UITable,s,'row',app.indices(i,1)); + else + + end + end + app.progressbar_3.Visible="off"; + app.ProcessingLabel_1.Visible="off"; + end + + % Callback function + function ReportButtButtonPushed(app, event) + app.TERTLabel_2.Visible="off"; + app.aLabel.Visible="off"; + app.DOUBLELabel.Visible="off"; + app.ReportPanel.Visible="on"; + app.UITable.Visible="off"; + app.Button_5.Visible="off"; + x=[length(app.IDHIndices)-1 length(app.TERTIndices)-1 length(app.DoubleIndices)-1]; + t=pie(app.pie,x,[1 1 1]); + for i=1:length(find(x>0)) + t(i*2).BackgroundColor=[0.9 0.9 0.9]; + + end + app.TERT.BackgroundColor=[0.15 0.15 0.15]; + table=app.UITable.Data; + p=table(app.IDHIndices(2:end),1:9); + p1=table(app.TERTIndices(2:end),1:9); + p2=table(app.DoubleIndices(2:end),1:9); + mean(table2array(p,1)); + mean(table2array(p1,1)); + mean(table2array(p2,1)); + means=([mean(table2array(p),1) ; mean(table2array(p1),1); mean(table2array(p2),1)]); + isnan(means); + means(isnan(means))=-1; + b=bar3(app.TERT, means); + variables={"IDH Only","TERT Only","Double"}; + set(app.TERT,'yticklabel',variables); + set(app.TERT,'xticklabel',p.Properties.VariableNames); + app.TERT.Title.String="\color{magenta}Metabolite Mean Values"; + + rotate3d (app.TERT,'on'); + b(1).XData; + + for i=1:length(b) + b(i).ButtonDownFcn=@mouse_click; + end + function mouse_click(a,b) + indX=mean(unique(a.XData(~isnan(a.XData)))); + + indY=mean(unique(a.YData(~isnan(a.YData)))); + indZ=(unique(a.ZData(~isnan(a.ZData)),'stable')); + indZ=nonzeros(indZ); + app.TERTLabel_2.Text=[variables{2} " " int2str(indZ(2))]; + app.aLabel.Text=[variables{1} " " int2str(indZ(1))]; + app.DOUBLELabel.Text=[[variables{3} " " int2str(indZ(3))]]; + app.TERTLabel_2.Visible="on"; + app.aLabel.Visible="on"; + app.DOUBLELabel.Visible="on"; + app.ChooseabartoseeitsdetailsLabel.Text=[p(1,indX).Properties.VariableNames "Metabolite mean value for" ]; + end + + + end + + % Callback function + function IDHONLYButtonPushed(app, event) + selected_dir=uigetdir(); + table=app.UITable.Data; + writetable(table(app.IDHIndices(2:end),:),[selected_dir filesep 'IDH.xlsx']); + end + + % Callback function + function TERTONLYButtonPushed(app, event) + selected_dir=uigetdir(); + table=app.UITable.Data; + writetable(table(app.TERTIndices(2:end),:),[selected_dir filesep 'TERT.xlsx']); + end + + % Callback function + function doubleMutButtonPushed(app, event) + selected_dir=uigetdir(); + table=app.UITable.Data; + writetable(table(app.DoubleIndices(2:end),:),[selected_dir filesep 'DoubleMut.xlsx']); + end + + % Value changed function: EditField + function EditFieldValueChanged(app, event) + value = app.EditField.Value; + + if ~isempty(value) + if isempty(str2num(value)) + msgbox("Please insert only numerical inputs", 'modal',"error"); + app.EditField.Value=""; + end + end + + end + + % Button pushed function: EnterButton + function EnterButtonPushed(app, event) + index=find(strcmp(app.MetaboliteMenuDropDown.Items,(app.MetaboliteMenuDropDown.Value))); + cel2={app.MetaboliteMenuDropDown.Value ' = ' app.EditField.Value}; + try + app.MetaboliteMenuDropDown.Value=app.MetaboliteMenuDropDown.Items(index+1); + catch + end + app.ListBox.Items{index}=[cel2{:}]; + app.ListBox.Value=app.ListBox.Items{index}; + app.manualControl(index)=1; + app.manualValues(index)=str2num(app.EditField.Value); + if isempty(find(app.manualControl==0)); + app.Classify.Enable="on"; + end + end + + % Value changed function: ListBox + function ListBoxValueChanged(app, event) + value = app.ListBox.Value; + + end + + % Selection change function: MR_Spectroscopy + function MR_SpectroscopySelectionChanged(app, event) + selectedTab = app.MR_Spectroscopy.SelectedTab; + startupFcn(app); + switch selectedTab.Title + case "Manual Entry" + f=fieldnames(app.models); + a=app.Tree3.Children; + a.delete; + for i=1:length(f) + + cat1=uitreenode(app.Tree3,'Text',f{i}); + + + end + case "Excel Entry" + f=fieldnames(app.models); + app.MODELSListBox.Items=f; + + case "LC Model Raw" + f=fieldnames(app.models); + app.lcmodelraw.Items=f; + + end + end + + % Button pushed function: Classify + function ClassifyButtonPushed(app, event) + + sec=app.Tree3.SelectedNodes.Text; + app.NaNLabel.Text=num2str(100*app.Defmodels.(sec).plots.Accuracy); + app.NaNLabel_2.Text=num2str(100*app.Defmodels.(sec).plots.specificity{2}); + app.NaNLabel_3.Text=num2str(100*app.Defmodels.(sec).plots.sensitivity{2}); + app.manualValues + res=app.Defmodels.(sec).predictFcn(array2table(app.manualValues,'VariableNames'... + ,app.Defmodels.(sec).Classification.PredictorNames)); + app.NaNLabel_4.Text=app.Defmodels.(sec).classes{res+1}; + app.ModelMetricsPanel.Visible="on"; + + + end + + % Callback function + function Button_5ValueChanged(app, event) + value = app.Button_5.Value; + web('https://doi.org/10.1002/jmri.26964'); + end + + % Callback function + function LCmodelLOADPushed(app, event) + [app.tabledata,app.metabs,app.corrMatrix,app.sp,app.bg,app.fit,app.coord_filename]= load_lcmodel(app); + test=sqrt(length(app.tabledata)); + app.lcmodelpanel.AutoResizeChildren="off"; + sub=ceil(test); + col=round(test); + app.coord_filename; + linewidth=2; + color=[1,1,1]; + objs=get(app.lcmodelpanel,'Children'); + + delete(objs) + + for i=1:length(app.tabledata) + + if length(app.tabledata)>1 + + app.ax{i}= subplot(sub,col,i,'Parent',app.lcmodelpanel); + app.lcmodelpanel.Visible="on"; + else + app.ax{i}=subplot(sub,col,i,'Parent',app.lcmodelpanel); + app.lcmodelpanel.Visible="on"; + end + + + ppm=app.bg{i}.ppm; + legendtext=''; + legendtext{1}=('\color{white}In vivo'); + legendtext{2}=('\color{white}Baseline'); + legendtext{3}=('\color{white}Fit'); + + app.GliomaIDHMutationDiagnosisToolUIFigure.AutoResizeChildren='off'; + pt_axis=0; + + b(i,1)=plot(app.ax{i},ppm, fliplr(app.sp{i}.specs'),'LineWidth',linewidth,'Color',color); + + text(app.ax{i},ppm(1)+ppm(1)*0.01,app.sp{i}.specs(end), legendtext{1},"Color",color); + pt_axis=pt_axis-max(app.bg{i}.specs')*1.10+mean(app.bg{i}.specs); + + hold (app.ax{i},'on') + b(i,2)=plot(app.ax{i},ppm,fliplr(app.bg{i}.specs')+pt_axis,'LineWidth',linewidth,'Color',color); %!!!! + text(app.ax{i},ppm(1)+ppm(1)*0.01,app.bg{i}.specs(end)+pt_axis, legendtext{2},"Color",color); + pt_axis=pt_axis-max(app.fit{i}.specs')*1.10+mean(app.fit{i}.specs); + + + b(i,3)=plot(app.ax{i},[ppm], fliplr(app.fit{i}.specs')+pt_axis,'LineWidth',linewidth,'Color',color); + text(app.ax{i},ppm(1)+ppm(1)*0.01,app.fit{i}.specs(end)+pt_axis, legendtext{3},"Color",color); + + + hold (app.ax{i},'off'); + app.LCMODELRAWLIST.Items={'In vivo','Baseline','Fit',app.tabledata{i}.name{:}}; + app.LCMODELRAWLIST.ItemsData=cellstr(string([1:length(app.tabledata{i}.name)+3])); + app.LCMODELVALUES.Items=cellstr(string([0,0,0,app.tabledata{i}.concentration])); + app.LCMODELVALUES.ItemsData=cellstr(string([1:length(app.tabledata{i}.concentration)+3])); + set(app.ax{i},'Color',app.ReportPanel.BackgroundColor); + finalt=strsplit(string(app.coord_filename{i}),filesep ); + title(app.ax{i},['\color{white}' finalt{end}]); + set(app.ax{i},'ytick',[]); + set(app.ax{i},'yticklabel',[ppm(end):ppm(1)]); + set(app.ax{i},'xtick',[ppm(end):0.5:ppm(1)]); + + set(app.ax{i},'xticklabel',[ppm(end):0.5:ppm(1)]); + + xlim(app.ax{i},[ppm(end),ppm(1)+ppm(1)*0.2]); + ylim(app.ax{i},[pt_axis*1.50,max(b(i,1).YData)*1.15]); + app.ax{i}.ButtonDownFcn=@app.axClick; + app.position{i}=app.ax{i}.OuterPosition; + hold (app.ax{i},'off'); + + end + + + end + + % Selection changed function: Tree + function TreeSelectionChanged(app, event) + selectedNodes = app.Tree.SelectedNodes; + + try + app.MR_Diffusion.Visible="off"; + app.MR_Spectroscopy.Visible="OFF"; + app.AdvancedUser.Visible="OFF"; + app.About.Visible="off"; + app.MassSpectroscopy.Visible="off"; + app.Tree.SelectedNodes.NodeData + app.(app.Tree.SelectedNodes.NodeData).Visible='on'; + + catch + + end + + end + + % Callback function + function Button_8Pushed(app, event) + + end + + % Selection change function: MR_Diffusion + function MR_DiffusionSelectionChanged(app, event) + selectedTab = app.MR_Diffusion.SelectedTab; + + end + + % Callback function + function LCDRAWPushed2(app, event) + %legendtext{1}=('\color{white} In vivo'); + %legendtext{2}=('\color{white} Baseline'); + %legendtext{3}=('\color{white} Fit'); + app.Panel.Visible="off"; + linewidth=2; + test=sqrt(length(app.tabledata)); + app.lcmodelpanel.AutoResizeChildren="off"; + sub=ceil(test); + col=round(test); + app.coord_filename; + linewidth=1; + linecolor=[1,1,1]; + FontSize=4; + wait=waitbar(0.1,"Plotting Spectra"); + for i=1:length(app.tabledata) + %cla(app.ax{i},'reset'); + + app.ax{i}= subplot(sub,col,i,'Parent',app.lcmodelpanel,'Color',app.ReportPanel.BackgroundColor); + + app.lcmodelpanel.Visible="on"; + + + ppm=app.bg{1}.ppm; + values=app.LCMODELRAWLIST.Value; + modplot=str2double(values); + waitbar((i)/length(app.tabledata),wait,"Plotting Spectra(s)") + app.plotSpectra(modplot,i,ppm,linewidth,app.ax{i},linecolor,FontSize); + + + + end + close(wait); + ax.AutoResizeChildren="on"; + + end + + % Callback function + function LCMODELRAWLISTValueChanged(app, event) + value = app.LCMODELRAWLIST.Value; + app.LCMODELVALUES.Value=value; + end + + % Callback function + function LClassifyButtonPushed(app, event) + values=app.LCMODELVALUES.Items + metabs2=app.LCMODELRAWLIST.Items + + tert=app.net; + idh=app.net2; + doble=app.net3; + for i=1:length(app.tabledata) + if (app.Panel.Visible=="off") + [tert2,idh2,double2]=scripttester(app,app.tabledata{i},app.metabs{i},tert,idh,doble); + res{i}=[tert2,idh2,double2]; + else + msgbox('alekta') + end + + + end + app.panel2.AutoResizeChildren="off"; + ax=subplot(1,1,1,'Parent',app.panel2); + modelResPlot(ax,res,{'TERT','IDH','Double'}) + + + return; + + + valNum=str2double(values); + values1=(valNum([9,12,13])); + values3=(valNum([9,12,13])); + VAL=app.VAL; + values4=(valNum(VAL)); + + SD=app.tabledata.SDpct(VAL); + VAL2=VAL(find(SD>=30)); + sdLarger={''}; + for i=1:length(VAL2) + sdLarger{i}=['Metab=' metabs2{VAL2(i)} ' Value=' values{VAL2(i)} ' SD=' num2str(app.tabledata.SDpct(VAL2(i)))]; + + end + + app.SDLARGER.Items=sdLarger; + app.LCMODELRAWLIST.Value={'9','12','13','14','23'}; + app.LCMODELVALUES.Value={'9','12','13','14','23'}; + + + + cond=1; + if ~isempty(VAL2) + h=questdlg('There are SD threshold violances','something','YES','NO','NO'); + switch h + case 'YES' + %'OK' code here + case 'NO' + cond=0;%abort code + otherwise + cond=0; + end + end + if cond==1 + + x=app.net.predictFcn(array2table(values1 ,'VariableNames',app.net.RequiredVariables)); + x1=app.net3.predictFcn(array2table(values4,'VariableNames',app.net3.RequiredVariables)); + x2=app.net2.predictFcn(array2table(values3,'VariableNames',app.net2.RequiredVariables)); + % app.TERT_OnlyLabel.Text=num2str(x) + % app.IDH_OnlyLaapp.VALbel.Text=num2str(x2) + % app.DoubleMutantLabel.Text=num2str(x1) + + if x1==1 + msgbox('DOUBLE'); + + elseif x2==1 + msgbox('IDH'); + elseif x==1 + msgbox('tert'); + else + + end + + + end + end + + % Callback function + function TrainerLoadButtonPushed(app, event) + if app.UITable2.Visible=="on" & app.TrainingPanel.Visible=="off" + + [a,b]=uigetfile({'*.xlsx;*.xls;*.csv','Excel files (*.xlsx,*.csv)'}); + if a==0 + return ; + end + removeStyle(app.UITable2) + + a=readtable([b filesep a],'ReadVariableNames',true); + app.UITable2.Data=a; + set(app.UITable2, 'ColumnName',a.Properties.VariableNames); + + + app.Variable1DropDown.Items=app.UITable2.Data.Properties.VariableNames; + app.Variable2DropDown.Items=app.UITable2.Data.Properties.VariableNames; + else + app.UITable2.Visible="on"; + app.PREDICTORSListBox.Visible="on"; + app.RESPONSEListBox.Visible="on"; + app.trainertab.Visible="off"; + app.advancedList.Visible="off"; + app.advancedPanel.Visible="off"; + app.TrainingPanel.Visible="off"; + + end + + app.UITable2.BackgroundColor = [1 1 .9; .9 .95 1]; + app.UITable2.ColumnSortable = true; + app.PREDICTORSListBox.Items=app.UITable2.Data.Properties.VariableNames + + end + + % Callback function + function LCDRAWVSButtonPushed(app, event) + %legendtext{1}=('\color{white} In vivo'); + %legendtext{2}=('\color{white} Baseline'); + %legendtext{3}=('\color{white} Fit'); + + + end + + % Callback function + function GLIOMA_GENETIC_DIAGNOSISButton_2ValueChanged(app, event) + value = app.GLIOMA_GENETIC_DIAGNOSISButton_2.Value; + if app.Panel.Visible=="on" + app.Panel.Visible="off"; + else + app.Panel.Visible="on"; + end + + end + + % Button pushed function: plots_2 + function plotsButtonPushed(app, event) + + answer=get(app.PLOTSButtonGroup,'SelectedObject') + app.trainerpanel.AutoResizeChildren="off"; + app.trainerpanel.Visible="on"; + ax1= subplot(1,1,1,'Parent',app.trainerpanel,'Color',app.trainerpanel.BackgroundColor); + + + classes=unique(table2array(app.UITable2.Data(:,app.trainerResp(1,2)))); + + try + classes=classes(~(isnan(classes))); + catch + classes=string(classes(~(classes==""))); + end + rsVar=app.UITable2.Data.Properties.VariableNames{app.trainerResp(1,2)}; + switch answer.Text + case 'Variable Plot' + delete(get(app.trainerpanel,'Children')); + ax1= subplot(1,1,1,'Parent',app.trainerpanel,'Color',app.trainerpanel.BackgroundColor); + + for i=classes' + + + values=(app.UITable2.Data(app.UITable2.Data.(rsVar)==i,:)) + + + scatter(ax1,values.(app.Variable1DropDown.Value),... + values.(app.Variable2DropDown.Value),'Filled','LineWidth',3) + hold (ax1,'on') + ax1.Title.String=[' Variable Distribution Plot of ' rsVar]; + ax1.Title.Color=[0,0,0]; + end + hold(ax1,"off") + legend(ax1,string(num2cell((classes'))),'Color',... + app.trainerpanel.BackgroundColor,'TextColor',[0 0 0]); + ax1.ButtonDownFcn=@app.axClick; + + ax1.XLabel.String=app.Variable1DropDown.Value + ax1.XLabel.ButtonDownFcn=@textHandler; + ax1.YLabel.String=app.Variable2DropDown.Value + ax1.YLabel.ButtonDownFcn=@textHandler; + + case 'Spider Plot' + ii=1 + size1=length(classes); + size1=sqrt(size1); + maxx=0; + obj=get(app.trainerpanel,'Children'); + delete(obj); + for i=classes' + if app.MergeCheckBox.Value + + + ax1=subplot(1,1,1,'Parent',app.trainerpanel,'Color',app.trainerpanel.BackgroundColor); + ax1.Title.String=['All Groups']; + + else + + app.ax{ii}= subplot(round(size1),(ceil(size1)),ii,'Parent',app.trainerpanel,'Color',app.trainerpanel.BackgroundColor); + ax1=app.ax{ii}; + ax1.Title.String=[rsVar '=' num2str(i)]; + + end + values=(app.UITable2.Data(app.UITable2.Data.(rsVar)==i,:)); + app.position{ii}=ax1.Position; + + color=rand(1,3); + values2=table2array(values(:,app.trainerPredictors)); + maxx=radarplotOUT(ax1,{nanmean((values2),1)},... + {values.Properties.VariableNames{app.trainerPredictors}},'WebColor',[0,0,0],'LineColor',color,... + 'FillColor',color,'isFirst',(app.MergeCheckBox.Value-(ii==length(classes)))==1,'max',maxx); + ax1.ButtonDownFcn=@app.axClick; + + + + set(ax1,'XColor',[1,1,1]); + set(ax1,'XColorMode','manual'); + set(ax1,'YColor',[1,1,1]); + set(ax1,'Color',app.trainerpanel.BackgroundColor); + ii=ii+1; + hold (ax1,'on'); + set(ax1,'xcolor',app.trainerpanel.BackgroundColor); + set(ax1,'ycolor',app.trainerpanel.BackgroundColor); + xlim(ax1,[-1.2*maxx,1.2*maxx]); + ylim(ax1,[-1.2*maxx,1.2*maxx]); + end + delete(findobj(ax1,'type','legend')); + + case 'Box Plot' + yl=0; + xl=0; + ii=1 + size1=length(classes); + size1=sqrt(size1); + for i=classes' + app.ax{ii}= subplot(round(size1),(ceil(size1)),ii,'Parent',app.trainerpanel,'Color',app.trainerpanel.BackgroundColor); + ax1=app.ax{ii}; + values=(app.UITable2.Data(app.UITable2.Data.(rsVar)==i,:)); + app.CompactCheckBox_3 + if app.CompactCheckBox_3.Value + try + boxplot(ax1,(values(:,app.trainerPredictors)),'PlotStyle','compact','Notch',... + 'on','Labels',{values.Properties.VariableNames{app.trainerPredictors}},'Colors',[1,1,1]); + catch + boxplot(ax1,([table2array(values(:,app.trainerPredictors)) ;table2array(values(:,app.trainerPredictors)) ]),'PlotStyle','compact','Notch',... + 'on','Labels',{values.Properties.VariableNames{app.trainerPredictors}},'Colors',[1,1,1]); + end + + else + values=(app.UITable2.Data(app.UITable2.Data.(rsVar)==i,:)); + + try + boxplot(ax1,table2array(values(:,app.trainerPredictors)),'Labels',... + {values.Properties.VariableNames{app.trainerPredictors}}) ; + catch + boxplot(ax1,[table2array(values(:,app.trainerPredictors)) ;table2array(values(:,app.trainerPredictors)) ],'Labels',... + {values.Properties.VariableNames{app.trainerPredictors}}) + end + set(ax1,'XTickLabelRotation',90); + lines=findobj(ax1, 'type', 'line','Tag','Upper Whisker') + set(lines,'Color',[0,0,0]); + lines=findobj(ax1, 'type', 'line','Tag','Lower Whisker') + set(lines,'Color',[0,0,0]); + + lines=findobj(ax1, 'type', 'line','Tag','Upper Adjacent Value') + set(lines,'Color',[0,0,0]); + + lines=findobj(ax1, 'type', 'line','Tag','Lower Adjacent Value') + set(lines,'Color',[0,0,0]); + set(lines,'Color',[0,0,0]); + + ax1.ButtonDownFcn=@app.axClick; + title(ax1,['\color{white}' 'Group ' num2str(i)]); + end + set(ax1,'XColor',[0,0,0]) + set(ax1,'XColorMode','manual') + set(ax1,'YColor',[0,0,0]) + set(ax1,'Color',app.trainerpanel.BackgroundColor); + mxlim=get(ax1,'xlim'); + mylim=get(ax1,'ylim'); + if mxlim>xl + xl=mxlim; + end + if mylim>yl; + yl=mylim; + end + ii=ii+1; + end + try + axs=get(app.trainerpanel,'Children'); + for ia=axs + axs.xlim= xl; + axs.ylim=yl; + + end + catch + end + case 'Line Plot' + delete(get(app.trainerpanel,'Children')); + ax1= subplot(1,1,1,'Parent',app.trainerpanel,'Color',app.trainerpanel.BackgroundColor); + data=app.UITable2.Data(:,[app.trainerPredictors app.trainerResp(1,2)]); + + variablePlot(ax1,data,size(data,2),app.ScatterCheck.Value,app.Variable1DropDown.Value,... + app.CheckBox.Value,app.CISpinner.Value); + ax1.ButtonDownFcn=@app.axClick; + if ~app.ScatterCheck.Value + ax1.Title.String='Line Plot of Means of Features'; + else + + ax1.Title.String=app.Variable1DropDown.Value + end + ax1.YLabel.String='Value'; + ax1.XLabel.String='Features'; + case 'Bar Plot' + delete(get(app.trainerpanel,'Children')); + app.ax{1}= subplot(1,1,1,'Parent',app.trainerpanel,'Color',... + app.trainerpanel.BackgroundColor); + data=app.UITable2.Data(:,[app.trainerPredictors app.trainerResp(1,2)]); + app.ax{1}.ButtonDownFcn=@app.axClick; + barplotM(app.ax{1},data,size(data,2)); + app.ax{1}.Title.String='Bar Plot of Metabolites" Means'; + app.ax{1}.YLabel.String='Groups'; + app.ax{1}.XLabel.String='Metabolites'; + case 'PCA Plot' + delete(get(app.trainerpanel,'Children')); + app.ax{1}= subplot(1,2,1,'Parent',app.trainerpanel,'Color'... + ,app.trainerpanel.BackgroundColor); + data=app.UITable2.Data(:,[app.trainerPredictors app.trainerResp(1,2)]) + app.ax{1}.ButtonDownFcn=@app.axClick; + pcaPlot(app.ax{1},data,size(data,2),app.DimensionSpinner.Value,0); + + app.ax{1}.Title.String='PCA Plot With Feature Vectors'; + + + app.ax{2}= subplot(1,2,2,'Parent',app.trainerpanel,'Color',... + app.trainerpanel.BackgroundColor); + pcaPlot(app.ax{2},data,size(data,2),app.DimensionSpinner.Value,1); + app.ax{2}.ButtonDownFcn=@app.axClick; + app.ax{2}.Title.String='PCA Plot of Features'; + + end + end + + % Cell selection callback: UITable2 + function UITable2CellSelection(app, event) + app.subindices = event.Indices + return; + + if ~isempty(app.trainerResp) + app.UITable2.StyleConfigurations.TargetIndex + app.trainerResp(1,2) + try + x=find(cell2mat(app.UITable2.StyleConfigurations.TargetIndex)==app.trainerResp(1,2)) + removeStyle(app.UITable2,x); + catch + try + removeStyle(app.UITable2,2); + catch + end + + end + end + app.trainerResp=indices; + %removeStyle(app.UITable2) + + s = uistyle("BackgroundColor",'blue',"FontColor",'white'); + addStyle(app.UITable2,s,'column',indices(1,2)); + app.RESPONSEListBox.Items=app.UITable2.Data.Properties.VariableNames((indices(1,2))) + + + end + + % Value changed function: Variable1DropDown + function Variable1DropDownValueChanged(app, event) + value = app.Variable1DropDown.Value; + app.Variable2DropDown.Value + app.Variable1DropDown.Value + + end + + % Image clicked function: Image5 + function Image5Clicked(app, event) + try + [ans2,f]=trainer(app,'WeightedKNNS','WeightedKNNLabel',app.trainerResp(1,2),app.trainerPredictors) + if isempty(ans2) + return + end + if app.auto==1 + app.automodels.(ans2{1})=f + elseif app.auto==0 + app.models.(ans2{1})=f; + end + app.currentModel='WeightedKNN'; + catch + + app.currentModel='WeightedKNNS'; + a='WeightedKNNLabel'; + b='Weighted KNN'; + app.(a).BackgroundColor='red'; + app.(a).FontColor="white"; + app.(a).FontWeight="Bold"; + app.(a).Text=[b ' Failed']; + + end + end + + % Button pushed function: trainer32 + function trainer32ButtonPushed(app, event) + + if isempty(app.trainerPredictors) | isempty(app.trainerResp) + + msgbox("Please Select Predictors and Response","ERROR","non-modal"); + + + else + app.TrainingPanel.Visible="on"; + app.AdvancedMenuPanel.Visible="off"; + app.advancedList.Visible="off"; + end + end + + % Callback function + function predictorButtonPushed(app, event) + + + + removeStyle(app.UITable2); + app.trainerPredictors=find(ismember(app.PREDICTORSListBox.Items, app.PREDICTORSListBox.Value)==1) + s = uistyle("BackgroundColor",'green',"FontColor",'red'); + + addStyle(app.UITable2,s,'column',app.trainerPredictors); + + return; + + if ismember(app.trainerPredictors,app.trainerResp(1,2)) + + 'predde' + removeStyle(app.UITable2,'column',app.trainerResp(1,2)); + index = find(strncmpi(app.UITable2.Data.Properties.VariableNames,string(app.UITable2.Data.Properties.VariableNames... + (app.trainerResp(1,2))))) + else + app.predictor.Text="Select Predictor"; + [app.PREDICTORSListBox.Items string(app.UITable2.Data.Properties.VariableNames... + (app.trainerResp(1,2)))] + app.PREDICTORSListBox.Items=[app.PREDICTORSListBox.Items string(app.UITable2.Data.Properties.VariableNames... + (app.trainerResp(1,2)))]; + app.trainerPredictors(end+1)=app.trainerResp(1,2) + removeStyle(app.UITable2) + s = uistyle("BackgroundColor",'green',"FontColor",'white'); + + addStyle(app.UITable2,s,'column',app.trainerPredictors); + end + app.trainerResp=[]; + + end + + % Node expanded function: Tree2 + function Tree2NodeExpanded(app, event) + + + app.advancedList.Visible="on"; + app.advancedPanel.Visible="on"; + txt=''; + node=event.Node; + strct=app.models; + try + structDisp(app,strct,node,"advancedList"); + catch + uiconfirm(app.GliomaIDHMutationDiagnosisToolUIFigure,'Not Supported','Error') + end + %{ + node = event.Node; + x.Text="aa"; + try + x=(node.Parent); + + x.Text + isstring(x.Text) + while isstring(string(x.Text)) + + + txt=insertBefore([txt],1,[x.Text '.']) + x=(x.Parent) + + end + + + catch + disp("catch") + + end + + + if isempty(txt) + f=fieldnames(app.models); + else + + try + ['app.' txt node.Text] + + f=fieldnames((eval(['app.' txt node.Text]))) + catch + msgbox("Not a struct please use plot or show to see data") + eval(['app.' txt node.Text]) + + app.advancedList.Items=string(num2cell((eval(['app.' txt node.Text]))')) + + return; + end + end + a=node.Children; + a.delete; + for i=1:length(f) + + cat1=uitreenode(node,'Text',f{i},'NodeData',[]); + uitreenode(cat1,'Text',f{i},'NodeData',[]); + + end + %} + end + + % Button pushed function: advancedPlot + function advancedPlotButtonPushed(app, event) + app.advancedPanel.AutoResizeChildren="off"; + ax=app.advancedPanel; + app.advancedPanel + close all + if app.SubplotCheckBox.Value + ax=subplot(1,1,1,'Parent',app.advancedPanel,'Color',app.advancedPanel.BackgroundColor); + S = sprintf('%s ', app.advancedList.Items{:}); + D = sscanf(S, '%f'); + plot(ax,D); + set(ax,'Color',app.advancedPanel.BackgroundColor); + else + + end + + + + end + + % Image clicked function: linearsvm + function linearsvmClicked(app, event) + try + + [ans2,f]=trainer(app,'LinearSVM2','LinearSVMLabel',app.trainerResp(1,2),app.trainerPredictors) + if isempty(ans2) + return + end + if app.auto==1 + app.automodels.(ans2{1})=f + else + app.models.(ans2{1})=f; + end + app.currentModel='LinearSVM'; + catch + + app.currentModel='LinearSVM'; + a='LinearSVMLabel'; + b='Linear SVM'; + app.(a).BackgroundColor='red'; + app.(a).FontColor="white"; + app.(a).FontWeight="Bold"; + app.(a).Text=[b ' Failed']; + end + end + + % Size changed function: ManualEntryTab + function ManualEntryTabSizeChanged(app, event) + position = app.ManualEntryTab.Position; + + end + + % Selection changed function: Tree3 + function Tree3SelectionChanged(app, event) + selectedNodes = app.Tree3.SelectedNodes; + + app.ModelMetricsPanel.Visible='off'; + the=app.Defmodels.(selectedNodes.Text).CRLB; + if app.Defmodels.(selectedNodes.Text).CRLB~=-1 + + fig = app.GliomaIDHMutationDiagnosisToolUIFigure; + selection = uiconfirm(fig,['Selected model has CRLB threshold which is ' num2str(the) '. Please enter 0 to the values which are above.'],'Confirm Close',... + 'Icon','warning'); + + + end + + + reqAdder(app,app.Defmodels,{"MetaboliteMenuDropDown","ListBox"},selectedNodes.Text) + app.manualControl=zeros(1,size(app.ListBox.Items,2)); + app.manualValues=zeros(1,size(app.ListBox.Items,2)); + + end + + % Callback function + function MODELSListBoxValueChanged(app, event) + value = app.MODELSListBox.Value; + reqAdder(app,app.models,{"MODELSListBox_2","MODELSListBox_2"},value) + end + + % Callback function + function ModelPlotButtonPushed(app, event) + modelx=(app.lcmodelraw.Value) + app.lcmodelpanel.Visible=true; + model=app.models.(modelx); + app.lcmodelpanel.AutoResizeChildren="off"; + + ax=subplot(2,2,1,'Parent',app.lcmodelpanel); + confusionMatPlot(ax,model.plots.Ygt,model.plots.Ypr); + ax.ButtonDownFcn=@axClick + + ax=subplot(2,2,3,'Parent',app.lcmodelpanel); + confusionMatPlotSideVal1(ax,model.plots.Ygt,model.plots.Ypr); + ax.ButtonDownFcn=@axClick + + + ax=subplot(2,2,4,'Parent',app.lcmodelpanel); + confusionMatPlotSideVal2(ax,model.plots.Ygt,model.plots.Ypr); + ax.ButtonDownFcn=@axClick + + + + modelPlotter(app,model,app.lcmodelpanel,'all','white'); + + + + + + end + + % Image clicked function: quadraticsvm + function quadraticsvmImageClicked(app, event) + try + [ans2,f]=trainer(app,'QuadraticSVM','QuadraticSVMLabel',app.trainerResp(1,2),app.trainerPredictors) + if isempty(ans2) + return + end + if app.auto==1 + app.automodels.(ans2{1})=f + else + app.models.(ans2{1})=f; + end + app.currentModel='QuadraticSVM'; + catch + app.currentModel='QuadraticSVM'; + a='QuadraticSVMLabel'; + b='Quadratic SVM'; + app.(a).BackgroundColor='red'; + app.(a).FontColor="white"; + app.(a).FontWeight="Bold"; + app.(a).Text=[b ' Failed']; + end + end + + % Image clicked function: Image5_5 + function Image5_5Clicked(app, event) + try + [ans2,f]= trainer(app,'CoarseKNNS','CoarseKNNLabel',app.trainerResp(1,2),app.trainerPredictors) + if isempty(ans2) + return + end + if app.auto==1 + app.automodels.(ans2{1})=f + else + app.models.(ans2{1})=f; + end + app.currentModel='CoarseKNN'; + catch + + app.currentModel='CoarseKNN'; + a='CoarseKNNLabel'; + b='Coarse KNN'; + app.(a).BackgroundColor='red'; + app.(a).FontColor="white"; + app.(a).FontWeight="Bold"; + app.(a).Text=[b ' Failed']; + end + end + + % Image clicked function: fineknn + function fineknnImageClicked(app, event) + try + [ans2,f]=trainer(app,'FineKNNS','FineKNNLabel',app.trainerResp(1,2),app.trainerPredictors) + if isempty(ans2) + return + end + if app.auto==1 + app.automodels.(ans2{1})=f + else + app.models.(ans2{1})=f; + end + app.currentModel='FineKNN'; + catch + + app.currentModel='FineKNN'; + + a='FineKNNLabel'; + b='Fine KNN'; + app.(a).BackgroundColor='red'; + app.(a).FontColor="white"; + app.(a).FontWeight="Bold"; + app.(a).Text=[b ' Failed']; + end + end + + % Image clicked function: MediumTree + function MediumTreeClicked(app, event) + try + [ans2,f]=trainer(app,'MediumTree','MediumTreeLabel',app.trainerResp(1,2),app.trainerPredictors) + if isempty(ans2) + return + end + if app.auto==1 + app.automodels.(ans2{1})=f + else + app.models.(ans2{1})=f; + end + app.currentModel='MediumTree'; + catch + + app.currentModel='MediumTree'; + a='MediumTreeLabel'; + b='Medium Tree'; + app.(a).BackgroundColor='red'; + app.(a).FontColor="white"; + app.(a).FontWeight="Bold"; + app.(a).Text=[b ' Failed']; + end + end + + % Image clicked function: CoarseTree + function CoarseTreeImageClicked(app, event) + try + [ans2,f]=trainer(app,'CoarseTreee','CoarseTreeLabel',app.trainerResp(1,2),app.trainerPredictors) + if isempty(ans2) + return + end + if app.auto==1 + app.automodels.(ans2{1})=f + else + app.models.(ans2{1})=f; + end + app.currentModel='CoarseTree'; + catch + + app.currentModel='CoarseTree'; + a='CoarseTreeLabel'; + b='Coarse Tree'; + app.(a).BackgroundColor='red'; + app.(a).FontColor="white"; + app.(a).FontWeight="Bold"; + app.(a).Text=[b ' Failed']; + end + end + + % Callback function + function GLIOMA_GENETIC_DIAGNOSISButton_3ValueChanged(app, event) + value = app.GLIOMA_GENETIC_DIAGNOSISButton_3.Value; + + if app.MODELSListBox.Visible=='on'; + app.MODELSListBoxLabel.Visible="off"; + app.MODELSListBox.Visible="off"; + app.MODELSListBox_2.Visible="off"; + else + app.MODELSListBoxLabel.Visible="on"; + app.MODELSListBox.Visible="on"; + app.MODELSListBox_2.Visible="on"; + end + + + end + + % Image clicked function: fineknn_2 + function fineknn_2ImageClicked(app, event) + try + [ans2,f]=trainer(app,'CubicKNNS','CubicKNNLabel',app.trainerResp(1,2),app.trainerPredictors) + if isempty(ans2) + return + end + if app.auto==1 + app.automodels.(ans2{1})=f + else + app.models.(ans2{1})=f; + end + app.currentModel='CubicKNN'; + catch + + app.currentModel='CubicKNN'; + a='CubicKNNLabel'; + b='Cubic KNN'; + app.(a).BackgroundColor='red'; + app.(a).FontColor="white"; + app.(a).FontWeight="Bold"; + app.(a).Text=[b ' Failed']; + end + end + + % Image clicked function: fineknn_3 + function fineknn_3ImageClicked(app, event) + try + [ans2,f]=trainer(app,'CosineKNNS','CosineKNNLabel',app.trainerResp(1,2),app.trainerPredictors) + if isempty(ans2) + return + end + if app.auto==1 + app.automodels.(ans2{1})=f + else + app.models.(ans2{1})=f; + end + app.currentModel='CosineKNN'; + catch + + app.currentModel='CosineKNN'; + a='CosineKNNLabel'; + b='Cosine KNN'; + app.(a).BackgroundColor='red'; + app.(a).FontColor="white"; + app.(a).FontWeight="Bold"; + app.(a).Text=[b ' Failed']; + end + end + + % Image clicked function: Image5_4 + function Image5_4Clicked(app, event) + try + [ans2,f]=trainer(app,'CubicSVM','CubicSVMLabel',app.trainerResp(1,2),app.trainerPredictors) + if isempty(ans2) + return + end + if app.auto==1 + app.automodels.(ans2{1})=f + else + app.models.(ans2{1})=f; + end + app.currentModel='CubicSVM'; + catch + + app.currentModel='CubicSVM'; + a='CubicSVMLabel'; + b='Cubic SVM'; + app.(a).BackgroundColor='red'; + app.(a).FontColor="white"; + app.(a).FontWeight="Bold"; + app.(a).Text=[b ' Failed']; + end + end + + % Image clicked function: Image5_6 + function Image5_6Clicked(app, event) + try + [ans2,f]=trainer(app,'FGSVM','FineGaussianSVMLabel',app.trainerResp(1,2),app.trainerPredictors) + if isempty(ans2) + return + end + if app.auto==1 + app.automodels.(ans2{1})=f + else + app.models.(ans2{1})=f; + end + app.currentModel='FineGaussianSVM'; + catch + + app.currentModel='FineGaussianSVM'; + a='FineGaussianSVMLabel'; + b='Fine Gaussian SVM'; + app.(a).BackgroundColor='red'; + app.(a).FontColor="white"; + app.(a).FontWeight="Bold"; + app.(a).Text=[b ' Failed']; + end + end + + % Image clicked function: Image5_7 + function Image5_7Clicked(app, event) + try + [ans2,f]=trainer(app,'MediumGaussianSVM','MediumGaussianSVMLabel',app.trainerResp(1,2),app.trainerPredictors) + if isempty(ans2) + return + end + if app.auto==1 + app.automodels.(ans2{1})=f + else + app.models.(ans2{1})=f; + end + app.currentModel='MediumGaussianSVM'; + + catch + + app.currentModel='MediumGaussianSVM'; + a='MediumGaussianSVMLabel'; + b='Medium Gaussian SVM'; + app.(a).BackgroundColor='red'; + app.(a).FontColor="white"; + app.(a).FontWeight="Bold"; + app.(a).Text=[b ' Failed']; + end + end + + % Image clicked function: CoarseTree_2 + function CoarseTree_2ImageClicked(app, event) + try + [ans2,f]=trainer(app,'FineTree','FineTreeLabel',app.trainerResp(1,2),app.trainerPredictors) + if isempty(ans2) + return + end + if app.auto==1 + app.automodels.(ans2{1})=f + else + app.models.(ans2{1})=f; + end + app.currentModel='FineTree'; + catch + + app.currentModel='FineTree'; + a='FineTreeLabel'; + b='Fine Tree'; + app.(a).BackgroundColor='red'; + app.(a).FontColor="white"; + app.(a).FontWeight="Bold"; + app.(a).Text=[b ' Failed']; + end + end + + % Image clicked function: BoostedTrees + function BoostedTreesImageClicked(app, event) + try + [ans2,f]=trainer(app,'BoostedTrees','BoostedTreesLabel',app.trainerResp(1,2),app.trainerPredictors) + if isempty(ans2) + return + end + if app.auto==1 + app.automodels.(ans2{1})=f + else + app.models.(ans2{1})=f; + end + app.currentModel='BoostedTrees'; + catch + + app.currentModel='BoostedTrees'; + a='BoostedTreesLabel'; + b='Boosted Trees'; + app.(a).BackgroundColor='red'; + app.(a).FontColor="white"; + app.(a).FontWeight="Bold"; + app.(a).Text=[b ' Failed']; + end + end + + % Image clicked function: BaggedTree + function BaggedTreeImageClicked(app, event) + try + [ans2,f]=trainer(app,'BaggedTrees','BaggedTreesLabel',app.trainerResp(1,2),app.trainerPredictors) + if isempty(ans2) + return + end + if app.auto==1 + app.automodels.(ans2{1})=f + else + app.models.(ans2{1})=f; + end + app.currentModel='BaggedTrees'; + catch + + app.currentModel='BaggedTrees'; + a='BaggedTreesLabel'; + b='Bagged Trees'; + app.(a).BackgroundColor='red'; + app.(a).FontColor="white"; + app.(a).FontWeight="Bold"; + app.(a).Text=[b ' Failed']; + end + end + + % Image clicked function: Discriminant + function DiscriminantImageClicked(app, event) + try + [ans2,f]=trainer(app,'Discriminant','DiscriminantLabel',app.trainerResp(1,2),app.trainerPredictors) + if isempty(ans2) + return + end + if app.auto==1 + app.automodels.(ans2{1})=f + else + app.models.(ans2{1})=f; + end + app.currentModel='Discriminant'; + catch + + app.currentModel='Discriminant'; + a='DiscriminantLabel'; + b='Discriminant'; + app.(a).BackgroundColor='red'; + app.(a).FontColor="white"; + app.(a).FontWeight="Bold"; + app.(a).Text=[b ' Failed']; + end + end + + % Image clicked function: RUSB + function RUSBImageClicked(app, event) + try + [ans2,f]=trainer(app,'RUSBoosted','RUSBoostedLabel',app.trainerResp(1,2),app.trainerPredictors) + if isempty(ans2) + return + end + if app.auto==1 + app.automodels.(ans2{1})=f; + else + app.models.(ans2{1})=f; + end + app.currentModel='RUSBoosted'; + catch + + app.currentModel='RUSBoosted'; + a='RUSBoostedLabel'; + b='RUSBoosted'; + app.(a).BackgroundColor='red'; + app.(a).FontColor="white"; + app.(a).FontWeight="Bold"; + app.(a).Text=[b ' Failed']; + end + end + + % Button pushed function: RefreshButton + function RefreshButtonPushed(app, event) + app.MODELSListBox_3.Items=fieldnames(app.models); + end + + % Button pushed function: PlotButton_2 + function PlotButton_2Pushed(app, event) + modelx=(app.MODELSListBox_3.Value) + model=app.models.(modelx); + app.Panel_2.AutoResizeChildren="off"; + + ax=subplot(2,2,1,'Parent',app.Panel_2); + confusionMatPlot(ax,model.plots.Ygt,model.plots.Ypr); + + ax.ButtonDownFcn=@axClick + + ax=subplot(2,2,3,'Parent',app.Panel_2); + confusionMatPlotSideVal1(ax,model.plots.Ygt,model.plots.Ypr); + + ax.ButtonDownFcn=@axClick + + ax=subplot(2,2,4,'Parent',app.Panel_2); + confusionMatPlotSideVal2(ax,model.plots.Ygt,model.plots.Ypr); + + ax.ButtonDownFcn=@axClick + + + modelPlotter(app,model,app.Panel_2,'all','white'); + + end + + % Button pushed function: ManualEntryButton + function ManualEntryButtonPushed(app, event) + app.MainMenuPanel.Visible="off"; + app.ManualEntryPan.Visible="on"; + f=fieldnames(app.Defmodels); + a=app.Tree3.Children; + a.delete; + for i=1:length(f) + + cat1=uitreenode(app.Tree3,'Text',f{i}); + + + end + end + + % Image clicked function: Image9 + function Image9Clicked(app, event) + app.MainMenuPanel.Visible="on"; + app.ManualEntryPan.Visible="off"; + app.ModelMetricsPanel.Visible="off"; + end + + % Button pushed function: ExcelEntryButton + function ExcelEntryButtonPushed(app, event) + app.MainMenuPanel.Visible="off"; + app.ExcelEntryPanel.Visible="on"; + app.ButtonPanel.Visible="on"; + app.UITableExcelEntry.Visible="off"; + app.ModelsListBox_3.Items=fieldnames(app.Defmodels); + app.progressbar.Visible="off"; + end + + % Button pushed function: LoadButton + function LoadButtonPushed(app, event) + app.TrueClass=[]; + + + removeStyle(app.UITableExcelEntry); + + [a,b]=uigetfile({'*.xlsx;*.xls;*.csv','Excel files (*.xlsx,*.csv)'}); + + if a==0 + return ; + end + fig = app.GliomaIDHMutationDiagnosisToolUIFigure; + d = uiprogressdlg(fig,'Title','Please Wait',... + 'Message','Loading the table'); + + app.ButtonPanel.Position = [11 35 252 489]; + + % Perform calculations + % ... + d.Value = .33; + d.Message = 'Loading your data'; + + a=readtable([b filesep a],'ReadVariableNames',true); + app.UITableExcelEntry.Data=a; + set(app.UITableExcelEntry, 'ColumnName',a.Properties.VariableNames); + app.indices; + + app.UITableExcelEntry.BackgroundColor = [1 1 .9; .9 .95 1]; + app.UITableExcelEntry.ColumnSortable = true; + d.Value=0.87 + app.ButtonPanel.Position = [11 35 252 489]; + + %msgbox("Excel File Loaded",'Load Complete','none','replace'); + app.UITableExcelEntry.Visible="on"; + delete(d); + end + + % Image clicked function: Image10 + function Image10Clicked(app, event) + app.MainMenuPanel.Visible="on"; + app.ExcelEntryPanel.Visible="off"; + app.ModelMetricsPanel.Visible="off"; + end + + % Cell selection callback: UITableExcelEntry + function UITableExcelEntryCellSelection(app, event) + indices = event.Indices; + app.indices=indices; + end + + % Button pushed function: ClassifyButton + function ClassifyButtonPushed2(app, event) + app.TERTIndices=0; + app.IDHIndices=0; + app.DoubleIndices=0; + app.reqVars; + app.progressbar.Visible="on"; + app.ProcessingLabel.Visible="on"; + step=floor(700/size(app.indices,1)); + app.indices(:,1) + for i=1:size(app.indices,1) + % yellow + gCH=[ones(60,step*i) zeros(60,step*(size(app.indices,1)-i))]; + imshow(cat(3,zeros(size(gCH)),gCH,zeros(size(gCH))),'Parent',app.progressbar); + drawnow(); + app.indices(i,1); + + sec=app.ModelsListBox_3.Value; + table=app.UITableExcelEntry.Data; + values=table(app.indices(i,1),:); + + + vals=(values(:,app.reqVars)) + vals=table2array(vals); + if (app.Defmodels.(sec).CRLB)~=-1 + vals2=table2array(values(:,app.reqVars2))>(app.Defmodels.(sec).CRLB) + else + vals2=ones(1,length(vals)) + end + vals(vals2)=0 + res=app.Defmodels.(sec).predictFcn(array2table(vals,'VariableNames',app.Defmodels.(sec).Classification.PredictorNames)); + disp(['Row ' num2str(app.indices(i,2)) 'classification result is' num2str(res) ]) + + app.NaNLabel.Text=num2str(100*app.Defmodels.(sec).plots.Accuracy); + app.NaNLabel_2.Text=num2str(100*app.Defmodels.(sec).plots.specificity{2}); + app.NaNLabel_3.Text=num2str(100*app.Defmodels.(sec).plots.sensitivity{2}); + app.NaNLabel_4.Text=app.Defmodels.(sec).classes{res+1}; + app.ModelMetricsPanel.Visible="on"; + if res==1 + s = uistyle('BackgroundColor','blue','FontColor','white','FontWeight','Bold'); + addStyle(app.UITableExcelEntry,s,'row',app.indices(i,1)); + app.TrueClass(end+1)=app.indices(i,1); + + else + s = uistyle('BackgroundColor','green','FontColor','black','FontWeight','Bold'); + addStyle(app.UITableExcelEntry,s,'row',app.indices(i,1)); + + end + end + app.progressbar.Visible="off"; + app.ProcessingLabel.Visible="off"; + end + + % Button pushed function: LCModelEntryButton + function LCModelEntryButtonPushed(app, event) + app.LCModelEntryPanel.Visible="on"; + app.MainMenuPanel.Visible="off"; + app.ModelsListBox_2.Items=fieldnames(app.Defmodels); + + end + + % Button pushed function: ExportClassesButton + function ExportClassesButtonPushed(app, event) + + + table=app.UITableExcelEntry.Data; + exporter(table,app.indices(:,1),app.TrueClass) + + end + + % Button pushed function: PlotsButton + function PlotsButtonPushed(app, event) + app.PlotsMenuPanel.Visible= "on"; + app.MainMenuPanel.Visible="off"; + app.PlotsPanel.Visible="on"; + app.ModelMetricsPanel.Visible="off"; + + end + + % Image clicked function: Image11 + function Image11Clicked(app, event) + app.plottype + if app.plottype~=1 + app.MainMenuPanel.Visible="on"; + app.PlotsPanel.Visible="off"; + app.plottingpanels1.Visible="off"; + app.plottingpanels2.Visible="off"; + app.PlotsMenuPanel.Visible="off"; + app.ModelPlotsPanel.Visible="off"; + app.ModelMetricsPanel.Visible="off"; + elseif app.plottype==1 + + app.MainMenuPanel_3.Visible="on"; + app.PlotsPanel.Visible="off"; + app.plottingpanels1.Visible="off"; + app.plottingpanels2.Visible="off"; + app.PlotsMenuPanel.Visible="off"; + app.ModelPlotsPanel.Visible="off"; + app.ModelMetricsPanel.Visible="off"; + app.MR_Spectroscopy.Visible="off"; + app.plottype=0; + app.MassSpectroscopy.Visible="on"; + app.LCMODELPLOTS.Visible="on"; + end + end + + % Button pushed function: ModelPlots + function ModelPlotsButtonPushed(app, event) + app.ModelPlotsPanel.Visible="on"; + app.PlotsMenuPanel.Visible="off"; + app.plottingpanels1.Visible="off"; + app.plottingpanels2.Visible="off"; + end + + % Button pushed function: RefreshButton_2 + function RefreshButton_2Pushed(app, event) + if app.plottype==1 + app.ModelsListBox.Items=fieldnames(app.DefMassmodels); + + else + + app.ModelsListBox.Items=fieldnames(app.Defmodels); + end + end + + % Button pushed function: PlotButton_3 + function PlotButton_3Pushed(app, event) + app.ModelPlotsPanel.Position=[15,88,237,439]; + app.plottingpanels1.Visible="on"; + app.plottingpanels2.Visible="on"; + modelx=(app.ModelsListBox.Value) + if app.plottype==1 + model=app.DefMassmodels.(modelx) + + else + model=app.Defmodels.(modelx) + end + app.plottingpanels1.AutoResizeChildren="off"; + app.plottingpanels2.AutoResizeChildren="off"; + objs=get(app.plottingpanels2,'Children'); + delete(objs); + app.ModelPlotsPanel.Position=[15,88,237,439]; + size(model.plots.Ygt) + size(model.plots.Ypr) + + ax=subplot(2,2,1,'Parent',app.plottingpanels2); + confusionMatPlot(ax,model.plots.Ygt,model.plots.Ypr); + ax.ButtonDownFcn=@axClick + + + ax=subplot(2,2,2,'Parent',app.plottingpanels2); + confusionMatPlotSideVal1(ax,model.plots.Ygt,model.plots.Ypr); + ax.ButtonDownFcn=@axClick + + + ax=subplot(2,2,3,'Parent',app.plottingpanels2); + confusionMatPlotSideVal2(ax,model.plots.Ygt,model.plots.Ypr); + ax.ButtonDownFcn=@axClick + + + + modelPlotter(app,model,app.plottingpanels2,'all','white'); + end + + % Image clicked function: Image12 + function Image12Clicked(app, event) + app.MainMenuPanel.Visible="on"; + app.ModelPlotsPanel.Visible="off"; + app.PlotsPanel.Visible="off"; + app.ModelMetricsPanel.Visible="off"; + + end + + % Image clicked function: Image12_2 + function Image12_2Clicked(app, event) + app.PlotsMenuPanel.Visible="on"; + app.ModelPlotsPanel.Visible="off"; + app.plottingpanels1.Visible="off"; + app.plottingpanels2.Visible="off"; + end + + % Button pushed function: LCMODELPLOTS + function LCMODELPLOTSButtonPushed(app, event) + app.LCModelPlotsPanel.Visible="on"; + app.ModelPlotsPanel.Visible="off"; + app.plottingpanels1.Visible="on"; + delete(get(app.plottingpanels2,'Children')); + app.plottingpanels2.Visible="on"; + end + + % Image clicked function: Image13 + function Image13Clicked(app, event) + app.MainMenuPanel.Visible= "on"; + app.LCModelPlotsPanel.Visible="off"; + app.plottingpanels1.Visible="off"; + app.plottingpanels2.Visible="off"; + app.PlotsMenuPanel.Visible="off"; + app.PlotsPanel.Visible="off"; + objs=get(app.plottingpanels2,'Children'); + delete(objs); + + end + + % Image clicked function: Image13_2 + function Image13_2Clicked(app, event) + app.LCModelPlotsPanel.Visible="off"; + app.plottingpanels1.Visible="off"; + app.plottingpanels2.Visible="off"; + app.PlotsMenuPanel.Visible="on"; + app.PlotsPanel.Visible="on"; + objs=get(app.plottingpanels2,'Children'); + delete(objs); + + end + + % Button pushed function: LoadButton_2 + function LoadButton_2Pushed(app, event) + app.LCModelPlotsPanel.Position=[34,80,338,544]; + + [app.tabledata,app.metabs,app.corrMatrix,app.sp,app.bg,app.fit,app.coord_filename]= load_lcmodel(app); + test=sqrt(length(app.tabledata)); + app.plottingpanels1.AutoResizeChildren="off"; + app.plottingpanels2.AutoResizeChildren="off"; + app.LCModelPlotsPanel.Position=[34,80,338,544]; + col=ceil(test); + sub=round(test); + app.coord_filename; + linewidth=2; + color=[1,1,1]; + objs=get(app.plottingpanels1,'Children') + delete(objs) + objs=get(app.plottingpanels2,'Children') + delete(objs) + + + set(app.LCModelPlotsPanel,'Position',[17,79,248,453]); + for i=1:length(app.tabledata) + + if length(app.tabledata)>1 + + app.ax{i}= subplot(sub,col,i,'Parent',app.plottingpanels2); + app.plottingpanels2.Visible="on"; + else + app.ax{i}=subplot(sub,col,i,'Parent',app.plottingpanels2); + app.plottingpanels2.Visible="on"; + end + + + ppm=app.bg{i}.ppm; + legendtext=''; + legendtext{1}=('In vivo'); + legendtext{2}=('Baseline'); + legendtext{3}=('Fit'); + app.LCModelPlotsPanel.Position=[34,80,338,544]; + + app.GliomaIDHMutationDiagnosisToolUIFigure.AutoResizeChildren='off'; + pt_axis=0; + + b(i,1)=plot(app.ax{i},ppm, fliplr(app.sp{i}.specs'),'LineWidth',linewidth,'Color',color); + + text(app.ax{i},ppm(1)+ppm(1)*0.01,app.sp{i}.specs(end), legendtext{1},"Color",color); + pt_axis=pt_axis-max(app.bg{i}.specs')*1.10+mean(app.bg{i}.specs); + + hold (app.ax{i},'on') + b(i,2)=plot(app.ax{i},ppm,fliplr(app.bg{i}.specs')+pt_axis,'LineWidth',linewidth,'Color',color); %!!!! + text(app.ax{i},ppm(1)+ppm(1)*0.01,app.bg{i}.specs(end)+pt_axis, legendtext{2},"Color",color); + pt_axis=pt_axis-max(app.fit{i}.specs')*1.10+mean(app.fit{i}.specs); + + + b(i,3)=plot(app.ax{i},[ppm], fliplr(app.fit{i}.specs')+pt_axis,'LineWidth',linewidth,'Color',color); + text(app.ax{i},ppm(1)+ppm(1)*0.01,app.fit{i}.specs(end)+pt_axis, legendtext{3},"Color",color); + + + hold (app.ax{i},'off'); + app.MetabolitesListBox.Items={'In vivo','Baseline','Fit',app.tabledata{i}.name{:}}; + app.MetabolitesListBox.ItemsData=cellstr(string([1:length(app.tabledata{i}.name)+3])); + finalt=strsplit(string(app.coord_filename{i}),filesep ); + title(app.ax{i},['\color{white}' finalt{end}]); + set(app.ax{i},'ytick',[]); + set(app.ax{i},'yticklabel',[ppm(end):ppm(1)]); + set(app.ax{i},'xtick',[ppm(end):0.5:ppm(1)]); + set(app.ax{i},'Color',app.plottingpanels1.BackgroundColor); + set(app.ax{i},'xticklabel',[ppm(end):0.5:ppm(1)]); + set(app.ax{i},'BOX',"off"); + set(app.ax{i},'XColor',app.plottingpanels1.BackgroundColor); + set(app.ax{i},'YColor',app.plottingpanels1.BackgroundColor); + app.LCModelPlotsPanel.Position=[34,80,338,544]; + + xlim(app.ax{i},[ppm(end),ppm(1)+ppm(1)*0.2]); + ylim(app.ax{i},[pt_axis*1.50,max(b(i,1).YData)*1.15]); + app.ax{i}.ButtonDownFcn=@app.axClick; + app.position{i}=app.ax{i}.OuterPosition; + hold (app.ax{i},'off'); + + end + end + + % Button pushed function: PlotButton_4 + function PlotButton_4Pushed(app, event) + test=sqrt(length(app.tabledata)); + app.plottingpanels1.AutoResizeChildren="off"; + col=ceil(test); + sub=round(test); + app.coord_filename; + linewidth=1; + linecolor=[1,1,1]; + FontSize=8; + dmaxx=0; + wait=uiprogressdlg(app.GliomaIDHMutationDiagnosisToolUIFigure,"Message",'Plotting Spectra(s)'); + for i=1:length(app.tabledata) + %cla(app.ax{i},'reset'); + + app.ax{i}= subplot(sub,col,i,'Parent',app.plottingpanels2); + + + + + ppm=app.bg{1}.ppm; + values=app.MetabolitesListBox.Value; + modplot=str2double(values); + wait.Value=((i)/length(app.tabledata)) + maxx=app.plotSpectra(modplot,i,ppm,linewidth,app.ax{i},linecolor,FontSize); + %{ + if max(abs(maxx))>max(abs(dmaxx)) + dmaxx=maxx + end + %} + set(app.ax{i},'ylim',maxx) + set(app.ax{i},'Color',app.plottingpanels2.BackgroundColor); + set(app.ax{i},'YColor',app.plottingpanels2.BackgroundColor); + + end + child=findobj(app.plottingpanels2,'type','Axes') + %set(child,'ylim',dmaxx) + + delete(wait); + ax.AutoResizeChildren="on"; + end + + % Image clicked function: Image2 + function Image2Clicked(app, event) + + end + + % Image clicked function: Image14 + function Image14Clicked(app, event) + app.MainMenuPanel.Visible="on"; + app.LCModelEntryPanel.Visible="off"; + app.plottingpanels1.Visible="off"; + app.ModelMetricsPanel.Visible="off"; + app.ResultsPanel.Visible="off"; + end + + % Button pushed function: LoadButton_3 + function LoadButton_3Pushed(app, event) + [app.tabledata,app.metabs,app.corrMatrix,app.sp,app.bg,app.fit,app.coord_filename]= load_lcmodel(app); + test=sqrt(length(app.tabledata)); + app.ResultsPanel.AutoResizeChildren="off"; + app.ResultsPanel.Visible="on"; + sub=ceil(test); + col=round(test); + app.coord_filename; + linewidth=2; + color=[1,1,1]; + objs=get(app.ResultsPanel,'Children') + + delete(objs) + app.CoordFilesListBox.Items=app.coord_filename; + for i=1:length(app.tabledata) + + if length(app.tabledata)>1 + + app.ax{i}= subplot(sub,col,i,'Parent',app.ResultsPanel); + app.plottingpanels1.Visible="on"; + else + app.ax{i}=subplot(sub,col,i,'Parent',app.ResultsPanel); + app.plottingpanels1.Visible="on"; + end + + + ppm=app.bg{i}.ppm; + legendtext=''; + legendtext{1}=('\color{white}In vivo'); + + + pt_axis=0; + + b(i,1)=plot(app.ax{i},ppm, fliplr(app.sp{i}.specs'),'LineWidth',linewidth,'Color',color); + + text(app.ax{i},ppm(1)+ppm(1)*0.01,app.sp{i}.specs(end), legendtext{1},"Color",color); + pt_axis=pt_axis-max(app.bg{i}.specs')*1.10+mean(app.bg{i}.specs); + + + hold (app.ax{i},'off'); + set(app.ax{i},'Color',app.ResultsPanel.BackgroundColor); + set(app.ax{i},'XColor',app.ResultsPanel.BackgroundColor); + set(app.ax{i},'YColor',app.ResultsPanel.BackgroundColor); + + finalt=strsplit(string(app.coord_filename{i}),filesep ); + title(app.ax{i},['\color{white}' finalt{end}]); + set(app.ax{i},'ytick',[]); + set(app.ax{i},'yticklabel',[ppm(end):ppm(1)]); + set(app.ax{i},'xtick',[ppm(end):0.5:ppm(1)]); + + set(app.ax{i},'xticklabel',[ppm(end):0.5:ppm(1)]); + + xlim(app.ax{i},[ppm(end),ppm(1)+ppm(1)*0.2]); + ylim(app.ax{i},[pt_axis*1.50,max(b(i,1).YData)*1.15]); + app.ax{i}.ButtonDownFcn=@app.axClick; + app.position{i}=app.ax{i}.OuterPosition; + hold (app.ax{i},'off'); + + end + + end + + % Button pushed function: ClassifyButton_2 + function ClassifyButton_2Pushed(app, event) + + sec=app.ModelsListBox_2.Value + varss=app.Defmodels.(sec).RequiredVariables + test=~cellfun('isempty',strfind(varss,'Ratio')); + [~,ind]=ismember(app.CoordFilesListBox.Value ,app.CoordFilesListBox.Items); + + if sum(test)>0 + varss=strrep(varss,'Ratio',''); + [~,varInd]=ismember(varss,app.tabledata{ind}.name); + conc=app.tabledata{ind}.relative_conc(varInd) + + + else + + [~,varInd]=ismember(varss,app.tabledata{ind}.name); + + + conc=app.tabledata{ind}.concentration(varInd) + end + + app.NaNLabel.Text=num2str(100*app.Defmodels.(sec).plots.Accuracy); + app.NaNLabel_2.Text=num2str(100*app.Defmodels.(sec).plots.specificity{2}); + app.NaNLabel_3.Text=num2str(100*app.Defmodels.(sec).plots.sensitivity{2}); + res=app.Defmodels.(sec).predictFcn(array2table(conc,'VariableNames',app.Defmodels.(sec).Classification.PredictorNames)) + app.NaNLabel_4.Text=app.Defmodels.(sec).classes{(res)+1}; + + app.ModelMetricsPanel.Visible="on"; + end + + % Value changed function: ModelsListBox_3 + function ModelsListBox_3ValueChanged(app, event) + value = app.ModelsListBox_3.Value; + varss=app.Defmodels.(value).RequiredVariables; + app.Class1Label.Text=app.Defmodels.(value).classes{1}; + app.Class2Label.Text=app.Defmodels.(value).classes{2}; + + [~,inds]=ismember(varss,app.UITableExcelEntry.Data.Properties.VariableNames); + + + message={'This model has been generated with CRLB threshold please assign standard deviations ','Some Metabolites names are NOT Entered Properly '}; + + app.reqVars=inds; + if ~isempty(find(inds==0)) || app.Defmodels.(value).CRLB~=-1 + + answer = questdlg(message((sum(inds==0)>0)+1), ... + 'Warning Menu', ... + 'Select Manually','Show the improper metabolites','Select Manually'); + switch answer + case 'Select Manually' + if ~isempty(find(inds==0)) + [app.reqVars,f]=assignVals(app,varss,app.UITableExcelEntry.Data.Properties.VariableNames); + waitfor(f); + s= uistyle("BackgroundColor",'green',"FontColor",'black','FontWeight','Bold'); + addStyle(app.UITableExcelEntry,s,'column',app.reqVars); + end + if app.Defmodels.(value).CRLB~=-1 + [app.reqVars2,f]=assignVals3(app,varss,app.UITableExcelEntry.Data.Properties.VariableNames); + waitfor(f); + app.reqVars + app.reqVars2 + + s2 = uistyle("BackgroundColor",'red',"FontColor",'white'); + s3= uistyle("BackgroundColor",'black',"FontColor",'white'); + s4= uistyle("BackgroundColor",'yellow',"FontColor",'black'); + addStyle(app.UITableExcelEntry,s4,'column',app.reqVars); + addStyle(app.UITableExcelEntry,s3,'column',app.reqVars2); + + arr=table2array(app.UITableExcelEntry.Data(:,app.reqVars2))0)+1), ... + 'Warning Menu', ... + 'Select Manually','Show the improper metabolites','Select Manually'); + waitfor(answer) + switch answer + case 'Select Manually' + if ~isempty(find(inds==0)) + [app.reqVars,f]=assignVals(app,varss,app.UITable3.Data.Properties.VariableNames); + waitfor(f); + end + if app.models.(value).CRLB~=-1 + [app.reqVars2,f]=assignVals3(app,varss,app.UITable3.Data.Properties.VariableNames); + waitfor(f); + + try + s2 = uistyle("BackgroundColor",'red',"FontColor",'white'); + s3= uistyle("BackgroundColor",'black',"FontColor",'white'); + s4= uistyle("BackgroundColor",'yellow',"FontColor",'black'); + addStyle(app.UITable3,s4,'column',app.reqVars); + addStyle(app.UITable3,s3,'column',app.reqVars2); + + arr=table2array(app.UITable3.Data(:,app.reqVars2))stdsT)>0 & stdsT>0 + + indc=find((stds>stdsT)==1) + + vals((indc))=0 + + str=strjoin({vars{indc}},',') + + + + end + vals + + res=app.models.(sec).predictFcn(array2table(vals,'VariableNames',app.models.(sec).RequiredVariables)); + disp(['Row ' num2str(app.indices(i,2)) ' classification result is ' num2str(res) ]) + + %app.Label_13.Text=string(app.models.(sec).classes{1}); + %app.Class2Label_2.Text=string(app.models.(sec).classes{2}); + + [n,result] = ismember(num2cell(num2str(res)),app.models.(sec).classes)%find([app.models.(sec).classes]==app.models.(sec).classes{res}); + +% if length(stds)*0.5stdsT) +% res=-1; +% end + + s = uistyle('BackgroundColor',colors(result,:),'FontWeight','Bold','FontColor','white'); + + addStyle(app.UITable3,s,'row',app.indices(i,1)); + app.TrueClass(end+1)=app.models.(sec).pseudo_classes{result}; + %app.Class2Label_2.FontColor=colors(res,:) + + + end + + end + + % Callback function: Image21_2, load_single + function Image21_2Clicked(app, event) + app.ClassifierMainPanel.Visible="off"; + app.ManualPanel.Visible="on"; + f=fieldnames(app.models); + a=app.Tree3_2.Children; + a.delete; + for i=1:length(f) + + cat1=uitreenode(app.Tree3_2,'Text',f{i}); + + + end + end + + % Button pushed function: EnterButton_2 + function EnterButton_2Pushed(app, event) + index=find(strcmp(app.MetaboliteMenuDropDown_2.Items,(app.MetaboliteMenuDropDown_2.Value))); + cel2={app.MetaboliteMenuDropDown_2.Value ' = ' app.EditField_2.Value}; + try + app.MetaboliteMenuDropDown_2.Value=app.MetaboliteMenuDropDown_2.Items(index+1); + catch + end + try + app.ListBox_3.Items{index}=[cel2{:}]; + app.ListBox_3.Value=app.ListBox_3.Items{index}; + app.manualControl(index)=1; + app.manualValues(index)=str2num(app.EditField_2.Value); + if isempty(find(app.manualControl==0)); + app.Classify_2.Enable="on"; + end + catch + + end + end + + % Image clicked function: Image9_2 + function Image9_2Clicked(app, event) + app.ManualPanel.Visible="off"; + app.ClassifierMainPanel.Visible="on"; + end + + % Selection changed function: Tree3_2 + function Tree3_2SelectionChanged(app, event) + selectedNodes = app.Tree3_2.SelectedNodes; + + app.ModelMetricsPanel.Visible='off'; + + + reqAdder(app,app.models,{"MetaboliteMenuDropDown_2","ListBox_3"},selectedNodes.Text) + app.manualControl=zeros(1,size(app.ListBox_3.Items,2)); + app.manualValues=zeros(1,size(app.ListBox_3.Items,2)); + + end + + % Button pushed function: Classify_2 + function Classify_2ButtonPushed(app, event) + sec=app.Tree3_2.SelectedNodes.Text; + app.NaNLabel_5.Text=num2str(100*app.models.(sec).plots.Accuracy); + app.NaNLabel_6.Text=num2str(100*app.models.(sec).plots.specificity{2}); + app.NaNLabel_7.Text=num2str(100*app.models.(sec).plots.sensitivity{2}); + vars=app.MetaboliteMenuDropDown_2.Items; + res=app.models.(sec).predictFcn(array2table(app.manualValues,'VariableNames',vars)) + app.NaNLabel_8.Text=num2str(res)%app.models.(sec).classes{res+1}; + app.ModelMetricsPanel_2.Visible="on"; + + end + + % Value changed function: ListBox_3 + function ListBox_3ValueChanged(app, event) + value = app.ListBox_3.Value; + + end + + % Value changed function: EditField_2 + function EditField_2ValueChanged(app, event) + value = app.EditField_2.Value; + + if ~isempty(value) + if isempty(str2num(value)) + msgbox("Please insert only numerical inputs", 'modal',"error"); + app.EditField.Value=""; + end + end + + end + + % Cell selection callback: UITable3 + function UITable3CellSelection(app, event) + indices = event.Indices; + + app.indices=indices; + + end + + % Button pushed function: + % ApplyCRLBThresholdMRSpectroscopyButton + function ApplyCRLBThresholdMRSpectroscopyButtonPushed(app, event) + + + [indx,tf] = listdlg('PromptString',{'If you want to perform CRLB Thresholding to class specific please choose the class.',... + 'Only one file can be selected at a time.',''},'ListString',app.PREDICTORSListBox.Items,... + 'SelectionMode','single','CancelString','Apply to all data','OKString','Apply to selected class only') + if tf==1 + buff=table2array(app.UITable2.Data(:,indx)); + buff2=unique(buff); + lst=num2str(buff2(~isnan(buff2))'); + lst=strsplit(lst,' '); + + [indx,tf] = listdlg('ListString',lst,'PromptString',{'If you want to perform CRLB Thresholding to class specific please choose the class.',... + 'Only one file can be selected at a time.',''},... + 'CancelString','Cancel','OKString','Select') + + switch tf + case 1 + + equalities=strjoin(lst,'== || ') + buff=strjoin('buff',equalities) + + + [data,f,~,app.crlb]=crlbThe(app,app.UITable2.Data()); + waitfor(f); + app.crlb + %app.UITable2.Data=data + %app.PREDICTORSListBox.Items=data.Properties.VariableNames; + %app.ResponseDropDown.Items=data.Properties.VariableNames; + case 0 + + [data,f,~,app.crlb]=crlbThe(app,app.UITable2.Data); + waitfor(f); + app.crlb + end + + else + + [data,f,~,app.crlb]=crlbThe(app,app.UITable2.Data); + waitfor(f); + app.crlb + + end + + + end + + % Button pushed function: RunAllButton + function RunAllButtonPushed(app, event) + app.out=[]; + app.confirmedSelection + strjoin({app.PREDICTORSListBox.Items{app.trainerPredictors}},',') + app.out{2,2}=[app.confirmedSelection ' ' strjoin({app.PREDICTORSListBox.Items{app.trainerPredictors}},',')]; + app.out{2,1}=app.ResponseDropDown.Items{app.trainerResp(1,2)} ; + + + + for i=1:app.RunsSpinner.Value + K=2; + app.variablesOut{i}=['Iteration' num2str(i)] + d = uiprogressdlg(app.GliomaIDHMutationDiagnosisToolUIFigure,'Title','Please Wait',... + 'Message','Learning Started...'); + app.auto=1; + + + Image5Clicked(app, event); + K=reportprepare(app,K,i) + Image5_5Clicked(app, event); + K=reportprepare(app,K,i) + + + fineknnImageClicked(app, event); + K=reportprepare(app,K,i) + + fineknn_2ImageClicked(app, event); + K=reportprepare(app,K,i) + + fineknn_3ImageClicked(app, event); + K=reportprepare(app,K,i) + + d.Value = .25; + d.Message = 'Running.. KNN part has been finished already '; + + linearsvmClicked(app, event); + K=reportprepare(app,K,i) + + quadraticsvmImageClicked(app, event); + + + K=reportprepare(app,K,i) + + + Image5_4Clicked(app, event); + K=reportprepare(app,K,i) + + Image5_6Clicked(app, event); + K=reportprepare(app,K,i) + + Image5_7Clicked(app, event); + + K=reportprepare(app,K,i) + + + + d.Value = .50; + d.Message = 'Running.. SVM part has been finished already '; + + MediumTreeClicked(app, event); + K=reportprepare(app,K,i) + + + CoarseTreeImageClicked(app, event); + K=reportprepare(app,K,i) + + + CoarseTree_2ImageClicked(app, event); + K=reportprepare(app,K,i) + + + BoostedTreesImageClicked(app, event); + + K=reportprepare(app,K,i) + + + d.Value = .75; + d.Message = 'Running.. Tree part has been finished already '; + + BaggedTreeImageClicked(app,event); + K=reportprepare(app,K,i) + + DiscriminantImageClicked(app,event); + K=reportprepare(app,K,i) + + RUSBImageClicked(app,event); + K=reportprepare(app,K,i) + + end + + + try + out=cell(size(app.out,1),size(app.outAll,2)); + out(:,1:size(app.out,2))=app.out + app.outAll=cat(1,app.outAll,out) + catch + out=cell(size(app.outAll,1),size(app.out,2)); + out(:,1:size(app.outAll,2))=app.outAll + app.outAll=cat(1,out,app.out) + + end + groupInd={app.outAll{:,1}} + responses= groupInd(~cellfun('isempty',groupInd)); + responses=unique(responses,'stable'); + [~, groupInd]=ismember(app.ResponseDropDown.Items{app.trainerResp(1,2)},responses) + + groups=app.UITable5.Data(: ,app.trainerResp(1,2)) + groups=table2array(groups) + groups=groups(~isnan(groups)) + + [groups,groupSz]=groupcounts(groups) + + try + app.iterations{groupInd}{end+1}=app.RunsSpinner.Value; + + app.groups{groupInd}{end+1}=groups; + app.groupSz{groupInd}{end+1}=groupSz; + catch + app.iterations{groupInd}=[]; + app.iterations{groupInd}{end+1}=app.RunsSpinner.Value; + app.groups{groupInd}=[]; + app.groupSz{groupInd}=[]; + app.groups{groupInd}{end+1}=groups; + app.groupSz{groupInd}{end+1}=groupSz + end + disp(app.outAll) + d.Value = 1; + d.Message = 'Guess we are all ok. Finished'; + pause(0.5); + close(d); + + app.auto=0; + end + + % Button pushed function: TrainedModelsButton + function TrainedModelsButtonPushed(app, event) + app.MainMenuPanel_2.Visible="off"; + app.ModelParametersPanel.Visible="on"; + app.ListBox_10.Items=fieldnames(app.models); + end + + % Image clicked function: Image22 + function Image22Clicked(app, event) + app.MainMenuPanel_2.Visible="on"; + app.ModelParametersPanel.Visible="off"; + end + + % Image clicked function: Image23 + function Image23Clicked(app, event) + app.ClassifierMainPanel.Visible="on"; + app.ExcelEntry.Visible="off"; + end + + % Button pushed function: LoadButton_6 + function LoadButton_6Pushed(app, event) + removeStyle(app.UITable4); + + [a,b]=uigetfile({'*.xlsx;*.xls;*.csv','Excel files (*.xlsx,*.csv)'}); + + if a==0 + return ; + end + dd = uiprogressdlg(app.GliomaIDHMutationDiagnosisToolUIFigure,'Title','Please Wait',... + 'Message','Loading...'); + dd.Value=0.5; + + a=readtable([b filesep a],'ReadVariableNames',true); + app.UITable4.Data=a; + set(app.UITable4, 'ColumnName',a.Properties.VariableNames); + app.ListBox_5.Items=app.UITable4.Data.Properties.VariableNames; + app.DropDown.Items=app.UITable4.Data.Properties.VariableNames; + app.indices; + dd.Value=0.75; + app.UITable4.BackgroundColor = [1 1 .9; .9 .95 1]; + app.UITable4.ColumnSortable = true; + dd.Value=1; + %msgbox("Excel File Loaded",'Load Complete','none','replace'); + app.UITable4.Visible="on"; + close(dd); + end + + % Button pushed function: ExcelPlots + function ExcelPlotsButtonPushed(app, event) + dd = uiprogressdlg(app.GliomaIDHMutationDiagnosisToolUIFigure,'Title','Please Wait',... + 'Message','Loading...'); + dd.Value=0.5; + removeStyle(app.UITableExcelEntry); + + if app.plottype~=1 + + [a,b]=uigetfile({'*.xlsx;*.xls;*.csv','Excel files (*.xlsx,*.csv)'}); + + if a==0 + return ; + end + + a=readtable([b filesep a],'ReadVariableNames',true); + else + + a=app.UITableExcelEntry.Data; + + + end + try + app.UITable4.Data=a; + set(app.UITable4, 'ColumnName',a.Properties.VariableNames); + app.indices; + dd.Value=0.75; + app.UITable4.BackgroundColor = [1 1 .9; .9 .95 1]; + app.UITable4.ColumnSortable = true; + app.ListBox_5.Items=app.UITable4.Data.Properties.VariableNames; + app.DropDown.Items=app.UITable4.Data.Properties.VariableNames; + catch + end + dd.Value=1; + %msgbox("Excel File Loaded",'Load Complete','none','replace'); + app.UITable4.Visible="on"; + close(dd); + + app.PlotsMenuPanel.Visible="off"; + app.ExcelPlotPanel.Visible="on"; + + end + + % Image clicked function: Image24 + function Image24Clicked(app, event) + app.PlotsMenuPanel.Visible="on"; + app.ExcelPlotPanel.Visible="off"; + end + + % Button pushed function: Plot + function PlotButtonPushed(app, event) + answer=get(app.PlotsButtonGroup,'SelectedObject'); + app.excelpanel.AutoResizeChildren="off"; + app.excelpanel.Visible="on"; + ax1= subplot(1,1,1,'Parent',app.excelpanel,'Color',app.excelpanel.BackgroundColor); + + dd = uiprogressdlg(app.GliomaIDHMutationDiagnosisToolUIFigure,'Title','Please Wait',... + 'Message','Loading...'); + dd.Value=0.5; + classes=unique(table2array(app.UITable4.Data(:,app.excelResp(1,2)))); + + try + classes=classes(~(isnan(classes))); + catch + classes=string(classes(~(classes==""))); + end + rsVar=app.UITable4.Data.Properties.VariableNames{app.excelResp(1,2)}; + switch answer.Text + case 'Bar Plot' + delete(get(app.excelpanel,'Children')); + app.ax{1}= subplot(1,1,1,'Parent',app.excelpanel,'Color',app.excelpanel.BackgroundColor); + data=app.UITable4.Data(:,[app.excelPredictors app.excelResp(1,2)]); + app.ax{1}.ButtonDownFcn=@app.axClick; + barplotM(app.ax{1},data,size(data,2)); + app.ax{1}.Title.String='Bar Plot of Metabolites" Means'; + app.ax{1}.YLabel.String='Groups'; + app.ax{1}.XLabel.String='Metabolites'; + + case 'PCA Plot' + delete(get(app.excelpanel,'Children')); + app.ax{1}= subplot(1,2,1,'Parent',app.excelpanel,'Color',app.excelpanel.BackgroundColor); + data=app.UITable4.Data(:,[app.excelPredictors app.excelResp(1,2)]) + app.ax{1}.ButtonDownFcn=@app.axClick; + pcaPlot(app.ax{1},data,size(data,2),app.PCDimensionSpinner.Value,0); + + app.ax{1}.Title.String='PCA Plot With Feature Vectors'; + + + app.ax{2}= subplot(1,2,2,'Parent',app.excelpanel,'Color',app.excelpanel.BackgroundColor); + pcaPlot(app.ax{2},data,size(data,2),app.PCDimensionSpinner.Value,1); + app.ax{2}.ButtonDownFcn=@app.axClick; + app.ax{2}.Title.String='PCA Plot of Features'; + + + case 'Line Plot' + delete(get(app.excelpanel,'Children')); + ax1= subplot(1,1,1,'Parent',app.excelpanel,'Color',app.excelpanel.BackgroundColor); + data=app.UITable4.Data(:,[app.excelPredictors app.excelResp(1,2)]); + + variablePlot(ax1,data,size(data,2),app.ScatterCheckBox.Value,app.Feature1DropDown.Value,... + app.ConfidenceIntervalCheckBox.Value,app.CI.Value); + ax1.ButtonDownFcn=@app.axClick; + if ~app.ScatterCheckBox.Value + ax1.Title.String='Line Plot of Means of Features'; + else + + ax1.Title.String=app.Feature1DropDown.Value + end + ax1.YLabel.String='Value'; + ax1.XLabel.String='Features'; + case 'Variable Plot' + delete(get(app.excelpanel,'Children')); + ax1= subplot(1,1,1,'Parent',app.excelpanel,'Color',app.excelpanel.BackgroundColor); + + for i=classes' + + + values=(app.UITable4.Data(app.UITable4.Data.(rsVar)==i,:)); + + + scatter(ax1,values.(app.Feature1DropDown.Value),values.(app.Feature2DropDown.Value),'Filled','LineWidth',3); + hold (ax1,'on'); + ax1.Title.String=[' Variable Distribution Plot of ' rsVar]; + ax1.Title.Color=[0,0,0]; + + end + hold(ax1,"off") + legend(ax1,string(num2cell((classes'))),'Color',... + app.excelpanel.BackgroundColor,'TextColor',[0 0 0]); + ax1.ButtonDownFcn=@app.axClick; + + ax1.XLabel.String=app.Feature1DropDown.Value; + ax1.XLabel.ButtonDownFcn=@textHandler; + ax1.YLabel.String=app.Feature2DropDown.Value; + ax1.YLabel.ButtonDownFcn=@textHandler; + + case 'Spider Plot' + ii=1 + size1=length(classes); + size1=sqrt(size1); + maxx=0; + obj=get(app.excelpanel,'Children'); + delete(obj); + for i=classes' + if app.MergeCheckBox_2.Value + + + ax1=subplot(1,1,1,'Parent',app.excelpanel,'Color',app.excelpanel.BackgroundColor); + ax1.Title.String=['All Groups']; + + else + + app.ax{ii}= subplot(round(size1),(ceil(size1)),ii,'Parent',app.excelpanel,'Color',app.excelpanel.BackgroundColor); + ax1=app.ax{ii}; + ax1.Title.String=[rsVar '=' num2str(i)]; + + end + values=(app.UITable4.Data(app.UITable4.Data.(rsVar)==i,:)); + app.position{ii}=ax1.Position; + + color=rand(1,3); + values2=table2array(values(:,app.excelPredictors)); + maxx=radarplotOUT(ax1,{mean((values2),1)},... + {values.Properties.VariableNames{app.excelPredictors}},'WebColor',[0,0,0],'LineColor',color,... + 'FillColor',color,'isFirst',(app.MergeCheckBox_2.Value-(ii==length(classes)))==1,'max',maxx); + ax1.ButtonDownFcn=@app.axClick; + + + + set(ax1,'XColor',[1,1,1]); + set(ax1,'XColorMode','manual'); + set(ax1,'YColor',[1,1,1]); + set(ax1,'Color',app.excelpanel.BackgroundColor); + ii=ii+1; + hold (ax1,'on'); + set(ax1,'xcolor',app.excelpanel.BackgroundColor); + set(ax1,'ycolor',app.excelpanel.BackgroundColor); + xlim(ax1,[-1.2*maxx,1.2*maxx]); + ylim(ax1,[-1.2*maxx,1.2*maxx]); + end + delete(findobj(ax1,'type','legend')); + + case 'Box Plot' + yl=0; + xl=0; + ii=1; + size1=length(classes); + size1=sqrt(size1); + for i=classes' + app.ax{ii}= subplot(round(size1),(ceil(size1)),ii,'Parent',app.excelpanel,'Color',app.excelpanel.BackgroundColor); + ax1=app.ax{ii}; + values=(app.UITable4.Data(app.UITable4.Data.(rsVar)==i,:)); + if app.CompactCheckBox.Value + try + boxplot(ax1,table2array(values(:,app.excelPredictors)),'PlotStyle','compact','Notch',... + 'on','Labels',{values.Properties.VariableNames{app.excelPredictors}},'Colors',[1,1,1]); + catch + boxplot(ax1,[table2array(values(:,app.excelPredictors)) ; table2array(values(:,app.excelPredictors))],'PlotStyle','compact','Notch',... + 'on','Labels',{values.Properties.VariableNames{app.excelPredictors}},'Colors',[1,1,1]); + + end + else + values=(app.UITable4.Data(app.UITable4.Data.(rsVar)==i,:)); + + try + boxplot(ax1,table2array(values(:,app.excelPredictors)),'Labels',... + {values.Properties.VariableNames{app.excelPredictors}}) ; + catch + boxplot(ax1,[table2array(values(:,app.excelPredictors)); table2array(values(:,app.excelPredictors))],'Labels',... + {values.Properties.VariableNames{app.excelPredictors}}) ; + end + + set(ax1,'XTickLabelRotation',90); + lines=findobj(ax1, 'type', 'line','Tag','Upper Whisker'); + set(lines,'Color',[0,0,0]); + lines=findobj(ax1, 'type', 'line','Tag','Lower Whisker'); + set(lines,'Color',[0,0,0]); + + lines=findobj(ax1, 'type', 'line','Tag','Upper Adjacent Value'); + set(lines,'Color',[0,0,0]); + + lines=findobj(ax1, 'type', 'line','Tag','Lower Adjacent Value'); + set(lines,'Color',[0,0,0]); + set(lines,'Color',[0,0,0]); + + ax1.ButtonDownFcn=@app.axClick; + title(ax1,['\color{white}' 'Group ' num2str(i)]); + end + set(ax1,'XColor',[0,0,0]); + set(ax1,'XColorMode','manual'); + set(ax1,'YColor',[0,0,0]); + set(ax1,'Color',app.excelpanel.BackgroundColor); + mxlim=get(ax1,'xlim'); + mylim=get(ax1,'ylim'); + if mxlim>xl + xl=mxlim; + end + if mylim>yl + yl=mylim; + end + ii=ii+1; + ax1.Title.String='Box Plot of Features'; + ax1.XLabel.String='Features'; + end + + try + axs=get(app.excelpanel,'Children'); + for ia=axs + axs.xlim= xl; + axs.ylim=yl; + + end + catch + end + + end + dd.Value=0.7; + close(dd); + scripttester2(app); + end + + % Button pushed function: AssignButton + function AssignButtonPushed(app, event) + + removeStyle(app.UITable4); + app.excelPredictors=find(ismember(app.ListBox_5.Items, app.ListBox_5.Value)==1) + s = uistyle("BackgroundColor",'green','FontColor','black','FontWeight','Bold'); + addStyle(app.UITable4,s,'column',app.excelPredictors); + [~,indices(1,2)]=ismember(app.DropDown.Value,app.DropDown.Items) + app.excelResp=indices; + %removeStyle(app.UITable2) + s = uistyle("BackgroundColor",'blue','FontColor','white','FontWeight','Bold'); + addStyle(app.UITable4,s,'column',indices(1,2)); + str=strjoin(app.ListBox_5.Value,', '); + + app.greenLabel.Text=['*Normal features are selected as ' str]; + app.blueLabel.Text=['*Grouping feature is selected as ' app.DropDown.Value]; + + end + + % Callback function + function PlotsTabSizeChanged(app, event) + + end + + % Selection change function: TabGroup3 + function TabGroup3SelectionChanged(app, event) + selectedTab = app.TabGroup3.SelectedTab; + if isempty(app.excelPredictors) | isempty(app.excelResp) + + msgbox('Please Select Features','ERROR',"non-modal"); + + + else + app.Feature1DropDown.Items={app.ListBox_5.Items{app.excelPredictors}}; + app.Feature2DropDown.Items={app.ListBox_5.Items{app.excelPredictors}}; + + end + end + + % Button pushed function: SyntheticDataButton + function SyntheticDataButtonPushed(app, event) + responses=app.UITable2.Data(:,app.trainerResp(1,2)); + + if sum(~isnan(table2array(unique(responses))))>2 + answer=uiconfirm (app.GliomaIDHMutationDiagnosisToolUIFigure,... + 'Your Data is multi-class. Would you like to continue ?','Warning','Options',... + {'Continue','Abort'},'DefaultOption',1,'CancelOption',2,'Icon','Warning') + else + answer='Continue' + end + + responses=app.UITable2.Data(:,app.trainerResp(1,2)); + responsesUn=unique(table2array(responses)); + maxx=0; + for i=responsesUn(~isnan(responsesUn))' + + if sum(table2array(responses)==i)>maxx + maxx=sum(table2array(responses)==i); + id=i; + end + + end + + switch answer + case 'Continue' + k=1; + + valuesA=app.UITable2.Data(:,app.trainerPredictors); + responseA=app.UITable2.Data(:,app.trainerResp(1,2)); + inp2=zeros(1,size(valuesA,2)) + lbl2=zeros(1,size(responseA,2)) + selection = uiconfirm(app.GliomaIDHMutationDiagnosisToolUIFigure,'Select the method','Select Synthetic Data Generator Method',... + 'Options',{'ADASYN','ASUWO',... + 'SMOTE','Borderline SMOTE'}... + ); + for i=responsesUn(~isnan(responsesUn))' + if i~=id + + response=table2array(responseA) + rows=(response==id)+(response==i) + %rows=isnan(table2array(response)); + values=valuesA; + values=values(find(rows),:); + response=response(find(rows),:); + + responseBuff=response; + ts=-1; + responseBuff(response==i)=ts; + responseBuff(response==id)=1; + + switch selection + case 'ADASYN' + responseBuff(responseBuff==-1)=0; + ts=0; + [inp,lbl]=ADASYN(table2array(values),(responseBuff)); + case 'ASUWO' + [inp, lbl] = ASUWO(table2array(values), responseBuff, 1 , 3, 5,5) + case 'SMOTE' + [inp ,lbl] = SMOTE(table2array(values), responseBuff) + case 'Borderline SMOTE' + [border_min, inp, lbl] = BorSMOTE(table2array(values), responseBuff, 5) + + end + + %size([values response ; inp lbl]) + lblBuff=lbl; + lblBuff(lbl==ts)=i; + lblBuff(lbl==1)=id; + lbl=lblBuff; + if size(lbl)==0 + + str=['Data is well balanced! No synthetic data is generated for class= ' num2str(i)]; + + else + str=['Data is not-well balanced. Class= ' num2str(i) ', now has ' num2str(sum(lbl==i)) ' entries.' ]; + end + + synthetic{k}=length(lbl) + %inp2=[inp2 ; inp]; + %lbl2=[lbl2 ; lbl]; + inp2=inp; + lbl2=lbl; + + selection2 = uiconfirm(app.GliomaIDHMutationDiagnosisToolUIFigure,str,'ADASYN',... + 'Icon','success'); + + + % cz=zeros(size([table2array(values) (response); inp lbl],1),size(app.UITable2.Data,2)) ; + % + % cz(:,[app.trainerPredictors app.trainerResp(1,2)])=[table2array(values) (response)... + % ; inp lbl]; + + + end + end + + zer=zeros(size(inp2,1),size(app.UITable2.Data,2)) + + zer(:,[app.trainerPredictors app.trainerResp(1,2)])=[inp2 lbl2] + + + app.UITable5.Data=array2table(zer,'VariableNames'... + ,app.UITable2.Data.Properties.VariableNames); + set(app.UITable5, 'ColumnName',app.UITable2.Data.Properties.VariableNames); + case 'Abort' + end + + + + end + + % Button pushed function: RankFeaturesButton + function RankFeaturesButtonPushed(app, event) + + + + fig = app.GliomaIDHMutationDiagnosisToolUIFigure; + msg = 'Choose a Feature Selection Method'; + title = 'Feature Selector'; + selection = uiconfirm(fig,msg,title,... + 'Options',{'Lasso','Neighborhood Component Analysis',... + 'Stepwise Regression','Rank Key Features'}... + ); + + switch selection + case 'Rank Key Features' + d = uiprogressdlg(fig,'Message','This process will take few minutes',... + 'Title','Feature Selection'); + d.Value=0.5 + fig = app.GliomaIDHMutationDiagnosisToolUIFigure; + msg = 'Choose the criterion'; + title = 'Feature Selector'; + selection = uiconfirm(fig,msg,title,... + 'Options',{'ttest','entropy',... + 'bhattacharyya','wilcoxon'}... + ) + + try + [features,Z]= rankfeatures(table2array(app.UITable5.Data(:,app.trainerPredictors))',... + table2array(app.UITable5.Data(:,app.trainerResp(1,2))),'Criterion',selection); + catch + uiconfirm(app.GliomaIDHMutationDiagnosisToolUIFigure,'Your Data is not binary-These feature selections work only on binary sets.' ... + ,'Error','Icon','Error','Options',{'Ok'}) + return; + end + delete(d) + case 'Sequential FS' + + case 'Lasso' + d = uiprogressdlg(fig,'Message','This process will take few minutes',... + 'Title','Feature Selection'); + d.Value=0.5 + [features,c,s]=lassoFeature(app.UITable5.Data,app.trainerPredictors... + , app.trainerResp(1,2)) + delete(d) + case 'Neighborhood Component Analysis' + d = uiprogressdlg(fig,'Message','This process will take few minutes',... + 'Title','Feature Selection'); + d.Value=0.5 + features=cnca(app.UITable2.Data,app.trainerPredictors,app.trainerResp(1,2),0); + delete(d) + + + case 'Stepwise Regression' + d = uiprogressdlg(fig,'Message','This process will take few minutes',... + 'Title','Feature Selection'); + d.Value=0.5 + features=stepwiseFeature(app.UITable5.Data,app.trainerPredictors,app.trainerResp(1,2),0); + + delete(d); + end + app.featureselection=selection; + vars={app.UITable2.Data.Properties.VariableNames{app.trainerPredictors}} + + app.ListBox_6.Items={vars{features}}; + app.ListBox_6.Visible="on"; + app.FeaturesRankDescendingOrderLabel.Visible="on"; + app.SelectasPredictorsButton.Visible="on"; + app.SelectedFeaturesLabel.Visible="on"; + end + + % Button pushed function: SelectasPredictorsButton + function SelectasPredictorsButtonPushed(app, event) + + + inds2=find(ismember(app.PREDICTORSListBox.Items, app.ListBox_6.Value)==1) + app.trainerPredictors=inds2; + + str=strjoin(app.ListBox_6.Value,sprintf('\n ,')) + app.SelectedFeaturesLabel.Text=str; + app.confirmedSelection=app.featureselection; + app.Features=str; + end + + % Button pushed function: SequentialFeatureSelectionButton + function SequentialFeatureSelectionButtonPushed(app, event) + + + + + fig = app.GliomaIDHMutationDiagnosisToolUIFigure; + d = uiprogressdlg(fig,'Message','This process will take time',... + 'Title','Feature Selection'); + d.Value=0.5 ; + try + [features,hist]=sequentialFeature61(app.UITable5.Data,... + app.trainerPredictors,app.trainerResp(1,2),1); + catch + uiconfirm(app.GliomaIDHMutationDiagnosisToolUIFigure,'Error! Please see the log. (May caused by multi-class',... + 'Error','Icon','Error','Options',{'Ok'}) + return; + end + features=app.trainerPredictors(features); + d.Value=1; + delete(d); + + vars={app.UITable2.Data.Properties.VariableNames{features}}; + app.featureselection=app.SequentialFeatureSelectionButton.Text + app.ListBox_6.Items=vars; + app.ListBox_6.Visible="on"; + app.FeaturesRankDescendingOrderLabel.Visible="on"; + app.SelectasPredictorsButton.Visible="on"; + app.SelectedFeaturesLabel.Visible="on"; + end + + % Button pushed function: PlotsButton_2 + function PlotsButton_2Pushed(app, event) + app.modelsPlotALLadvanced.Visible="on"; + end + + % Button pushed function: PlotButton_5 + function PlotButton_5Pushed(app, event) + app.Panel_5.Visible="on"; + modelx=(app.ModelsListBox_4.Value) + model=app.models.(modelx) + app.Panel_5.AutoResizeChildren="off"; + objs=get(app.Panel_5,'Children'); + delete(objs); + app.modelsplotpaneladvanced.Position=[35,88,468,439]; + size(model.plots.Ygt) + size(model.plots.Ypr) + + ax=subplot(2,2,1,'Parent',app.Panel_5); + confusionMatPlot(ax,model.plots.Ygt,model.plots.Ypr); + + ax.ButtonDownFcn=@axClick; + ax=subplot(2,2,2,'Parent',app.Panel_5); + confusionMatPlotSideVal1(ax,model.plots.Ygt,model.plots.Ypr); + ax.ButtonDownFcn=@axClick; + + + ax=subplot(2,2,3,'Parent',app.Panel_5); + confusionMatPlotSideVal2(ax,model.plots.Ygt,model.plots.Ypr); + ax.ButtonDownFcn=@axClick; + + + set (app.modelsplotpaneladvanced,'Position',[35,88,468,439]); + + modelPlotter(app,model,app.Panel_5,'all','black'); + + end + + % Button pushed function: RefreshButton_3 + function RefreshButton_3Pushed(app, event) + app.ModelsListBox_4.Items=fieldnames(app.models); + end + + % Image clicked function: Image25 + function Image25Clicked(app, event) + app.MainMenuPanel_2.Visible="on"; + app.modelsPlotALLadvanced.Visible="off"; + end + + % Button pushed function: advancedPlot_2 + function advancedPlot_2ButtonPushed(app, event) + deleter('modelsLog.txt',app.ListBox_10.Value); + app.models=rmfield(app.models,app.ListBox_10.Value); + end + + % Value changed function: PREDICTORSListBox + function PREDICTORSListBoxValueChanged(app, event) + value = app.PREDICTORSListBox.Value; + + end + + % Value changed function: ResponseDropDown + function ResponseDropDownValueChanged(app, event) + value = app.ResponseDropDown.Value; + + end + + % Close request function: + % GliomaIDHMutationDiagnosisToolUIFigure + function GliomaIDHMutationDiagnosisToolUIFigureCloseRequest(app, event) + delete(app) + close all; + end + + % Window button motion function: + % GliomaIDHMutationDiagnosisToolUIFigure + function GliomaIDHMutationDiagnosisToolUIFigureWindowButtonMotion(app, event) + + end + + % Button pushed function: ManualEntryButton_2 + function ManualEntryButton_2Pushed(app, event) + app.MainMenuPanel_3.Visible="off"; + app.ManualEntryPan_2.Visible="on"; + f=fieldnames(app.DefMassmodels); + a=app.Tree3_3.Children; + a.delete; + for i=1:length(f) + + cat1=uitreenode(app.Tree3_3,'Text',f{i}); + + + end + end + + % Selection changed function: Tree3_3 + function Tree3_3SelectionChanged(app, event) + selectedNodes = app.Tree3_3.SelectedNodes; + + app.ModelMetricsPanel_3.Visible='off'; + the=app.DefMassmodels.(selectedNodes.Text).CRLB; + + + + reqAdder(app,app.DefMassmodels,{"MetaboliteMenuDropDown_3","ListBox_7"},selectedNodes.Text) + app.manualControl=zeros(1,size(app.ListBox_7.Items,2)); + app.manualValues=zeros(1,size(app.ListBox_7.Items,2)); + + end + + % Button pushed function: EnterButton_3 + function EnterButton_3Pushed(app, event) + index=find(strcmp(app.MetaboliteMenuDropDown_3.Items,(app.MetaboliteMenuDropDown_3.Value))); + cel2={app.MetaboliteMenuDropDown_3.Value ' = ' app.EditField_3.Value}; + try + app.MetaboliteMenuDropDown_3.Value=app.MetaboliteMenuDropDown_3.Items(index+1); + catch + end + app.ListBox_7.Items{index}=[cel2{:}]; + app.ListBox_7.Value=app.ListBox_7.Items{index}; + app.manualControl(index)=1; + app.manualValues(index)=str2num(app.EditField_3.Value); + if isempty(find(app.manualControl==0)); + app.Classify_3.Enable="on"; + end + end + + % Button pushed function: Classify_3 + function Classify_3ButtonPushed(app, event) + sec=app.Tree3_3.SelectedNodes.Text; + app.NaNLabel_9.Text=num2str(100*app.DefMassmodels.(sec).plots.Accuracy); + app.NaNLabel_10.Text=num2str(100*app.DefMassmodels.(sec).plots.specificity{2}); + app.NaNLabel_11.Text=num2str(100*app.DefMassmodels.(sec).plots.sensitivity{2}); + app.manualValues + res=app.DefMassmodels.(sec).predictFcn(array2table(app.manualValues,'VariableNames'... + ,app.DefMassmodels.(sec).Classification.PredictorNames)); + app.NaNLabel_12.Text=app.DefMassmodels.(sec).classes{res+1}; + app.ModelMetricsPanel_3.Visible="on"; + + + end + + % Image clicked function: Image9_3 + function Image9_3Clicked(app, event) + app.MainMenuPanel_3.Visible="on"; + app.ManualEntryPan_2.Visible="off"; + app.ModelMetricsPanel_3.Visible="off"; + end + + % Image clicked function: Image15_3 + function Image15_3Clicked(app, event) + + end + + % Image clicked function: Image2_2 + function Image2_2Clicked(app, event) + + app.MainMenuPanel_3.Visible="on"; + app.ManualEntryPan_2.Visible="off"; + app.ModelMetricsPanel_3.Visible="off"; + end + + % Button pushed function: ExcelEntryButton_2 + function ExcelEntryButton_2Pushed(app, event) + app.MainMenuPanel_3.Visible="off"; + app.ExcelEntryPanel_2.Visible="on"; + app.ButtonPanel_2.Visible="on"; + app.ButtonPanel_2.Position = [513,131,252,393]; + app.UITableExcelEntry_2.Visible="off"; + app.ModelsListBox_5.Items=fieldnames(app.DefMassmodels); + app.progressbar_2.Visible="off"; + end + + % Button pushed function: LoadButton_7 + function LoadButton_7Pushed(app, event) + app.ButtonPanel_2.Position = [11 111 252 393]; + + app.TrueClass=[]; + removeStyle(app.UITableExcelEntry); + + [a,b]=uigetfile({'*.xlsx;*.xls;*.csv','Excel files (*.xlsx,*.csv)'}); + + if a==0 + return ; + end + fig = app.GliomaIDHMutationDiagnosisToolUIFigure; + d = uiprogressdlg(fig,'Title','Please Wait',... + 'Message','Loading the table'); + + app.ButtonPanel_2.Position = [11 111 252 393]; + + % Perform calculations + % ... + d.Value = .33; + d.Message = 'Loading your data'; + + a=readtable([b filesep a],'ReadVariableNames',true); + app.UITableExcelEntry_2.Data=a; + set(app.UITableExcelEntry_2', 'ColumnName',a.Properties.VariableNames); + app.indices; + + app.UITableExcelEntry_2.BackgroundColor = [1 1 .9; .9 .95 1]; + app.UITableExcelEntry_2.ColumnSortable = true; + app.ButtonPanel_2.Position = [11 111 252 393]; + d.Value=0.87 + app.ButtonPanel_2.Position = [11 111 252 393]; + + %msgbox("Excel File Loaded",'Load Complete','none','replace'); + app.UITableExcelEntry_2.Visible="on"; + delete(d); + end + + % Button pushed function: ClassifyButton_4 + function ClassifyButton_4Pushed(app, event) + app.TERTIndices=0; + app.IDHIndices=0; + app.DoubleIndices=0; + app.reqVars; + app.progressbar_2.Visible="on"; + app.ProcessingLabel_2.Visible="on"; + step=floor(700/size(app.indices,1)); + app.indices(:,1) + for i=1:size(app.indices,1) + % yellow + gCH=[ones(60,step*i) zeros(60,step*(size(app.indices,1)-i))]; + imshow(cat(3,zeros(size(gCH)),gCH,zeros(size(gCH))),'Parent',app.progressbar_2); + drawnow(); + app.indices(i,1); + + sec=app.ModelsListBox_5.Value; + table=app.UITableExcelEntry_2.Data; + values=table(app.indices(i,1),:); + + + vals=(values(:,app.reqVars)) + vals=table2array(vals); + try + vals(app.reqVars2>app.DefMassmodels.(sec).CRLB)=0; + catch + end + res=app.DefMassmodels.(sec).predictFcn(array2table(vals,'VariableNames',app.DefMassmodels.(sec).RequiredVariables )); + disp(['Row ' num2str(app.indices(i,2)) 'classification result is' num2str(res) ]) + + + if res==1 + s = uistyle('BackgroundColor','blue','FontColor','white','FontWeight','Bold'); + addStyle(app.UITableExcelEntry_2,s,'row',app.indices(i,1)); + app.TrueClass(end+1)=app.indices(i,1); + + else + s = uistyle('BackgroundColor','green','FontColor','black','FontWeight','Bold'); + addStyle(app.UITableExcelEntry_2,s,'row',app.indices(i,1)); + + end + end + app.progressbar_2.Visible="off"; + app.ProcessingLabel_2.Visible="off"; + end + + % Button pushed function: ExportClassesButton_3 + function ExportClassesButton_3Pushed(app, event) + table=app.UITableExcelEntry_2.Data; + exporter(table,app.indices(:,1),app.TrueClass) + + end + + % Value changed function: ModelsListBox_5 + function ModelsListBox_5ValueChanged(app, event) + value = app.ModelsListBox_5.Value; + varss=app.DefMassmodels.(value).RequiredVariables; + app.Label_12.Text=app.DefMassmodels.(value).classes{1}; + app.Class2Label_3.Text=app.DefMassmodels.(value).classes{2}; + + [~,inds]=ismember(varss,app.UITableExcelEntry_2.Data.Properties.VariableNames); + + + message={'This model has been generated with CRLB threshold please assign standard deviations ','Some Metabolites names are NOT Entered Properly '}; + + app.reqVars=inds; + if ~isempty(find(inds==0, 1)) || app.DefMassmodels.(value).CRLB~=-1 + + answer = questdlg(message((sum(inds==0)>0)+1), ... + 'Warning Menu', ... + 'Select Manually','Show the improper metabolites','Select Manually'); + switch answer + case 'Select Manually' + if ~isempty(find(inds==0)) + [app.reqVars,f]=assignVals(app,varss,app.UITableExcelEntry_2.Data.Properties.VariableNames); + waitfor(f); + s= uistyle("BackgroundColor",'green',"FontColor",'black','FontWeight','Bold'); + addStyle(app.UITableExcelEntry_2,s,'column',app.reqVars); + end + if app.DefMassmodels.(value).CRLB~=-1 + [app.reqVars2,f]=assignVals3(app,varss,app.UITableExcelEntry_2.Data.Properties.VariableNames); + waitfor(f); + app.reqVars + app.reqVars2 + + s2 = uistyle("BackgroundColor",'red',"FontColor",'white'); + s3= uistyle("BackgroundColor",'black',"FontColor",'white'); + s4= uistyle("BackgroundColor",'yellow',"FontColor",'black'); + addStyle(app.UITableExcelEntry_2,s4,'column',app.reqVars); + addStyle(app.UITableExcelEntry_2,s3,'column',app.reqVars2); + + arr=table2array(app.UITableExcelEntry_2.Data(:,app.reqVars2))max(len) + + indices=[inds{:}] + + else + [~,mx]=max(len) + indic=randi(len(mx),[1,floor(min(len)*1.5)]); + buff=inds{mx}; + inds{mx}=buff(indic); + + + + indices=[inds{:}] + + + + end + + app.UITable2.Data=app.UITable2.Data(indices,:); + app.UITable5.Data=app.UITable2.Data; + filter={'*.txt';'*.xlsx'} + [file,path]=uiputfile(filter); + table=app.UITable2.Data + writetable(table,[path filesep file]); + + catch + + + + + + + end + end + end + + % Button pushed function: ExportClassesButton_4 + function ExportClassesButton_4Pushed(app, event) + + end + + % Button pushed function: statisticaltests + function statisticaltestsButtonPushed(app, event) + + try + app.trainerPredictors + app.trainerResp + catch + + end + end + end + + % Component initialization + methods (Access = private) + + % Create UIFigure and components + function createComponents(app) + + % Create GliomaIDHMutationDiagnosisToolUIFigure and hide until all components are created + app.GliomaIDHMutationDiagnosisToolUIFigure = uifigure('Visible', 'off'); + app.GliomaIDHMutationDiagnosisToolUIFigure.Color = [1 1 1]; + app.GliomaIDHMutationDiagnosisToolUIFigure.Position = [15 100 1507 671]; + app.GliomaIDHMutationDiagnosisToolUIFigure.Name = 'Glioma IDH-Mutation Diagnosis Tool'; + app.GliomaIDHMutationDiagnosisToolUIFigure.CloseRequestFcn = createCallbackFcn(app, @GliomaIDHMutationDiagnosisToolUIFigureCloseRequest, true); + app.GliomaIDHMutationDiagnosisToolUIFigure.WindowButtonMotionFcn = createCallbackFcn(app, @GliomaIDHMutationDiagnosisToolUIFigureWindowButtonMotion, true); + app.GliomaIDHMutationDiagnosisToolUIFigure.Scrollable = 'on'; + + % Create MR_Spectroscopy + app.MR_Spectroscopy = uitabgroup(app.GliomaIDHMutationDiagnosisToolUIFigure); + app.MR_Spectroscopy.SelectionChangedFcn = createCallbackFcn(app, @MR_SpectroscopySelectionChanged, true); + app.MR_Spectroscopy.Position = [172 -6 1338 678]; + + % Create ManualEntryTab + app.ManualEntryTab = uitab(app.MR_Spectroscopy); + app.ManualEntryTab.AutoResizeChildren = 'off'; + app.ManualEntryTab.SizeChangedFcn = createCallbackFcn(app, @ManualEntryTabSizeChanged, true); + app.ManualEntryTab.Title = 'Manual Entry'; + app.ManualEntryTab.BackgroundColor = [0.502 0.502 0.502]; + + % Create ManualEntryPan + app.ManualEntryPan = uipanel(app.ManualEntryTab); + app.ManualEntryPan.AutoResizeChildren = 'off'; + app.ManualEntryPan.BorderType = 'none'; + app.ManualEntryPan.Visible = 'off'; + app.ManualEntryPan.BackgroundColor = [0.502 0.502 0.502]; + app.ManualEntryPan.FontWeight = 'bold'; + app.ManualEntryPan.Position = [417 58 479 493]; + + % Create Classify + app.Classify = uibutton(app.ManualEntryPan, 'push'); + app.Classify.ButtonPushedFcn = createCallbackFcn(app, @ClassifyButtonPushed, true); + app.Classify.Icon = 'output-onlinepngtools (11).png'; + app.Classify.BackgroundColor = [0.251 0.3216 0.2]; + app.Classify.FontName = 'Arial'; + app.Classify.FontSize = 18; + app.Classify.FontWeight = 'bold'; + app.Classify.FontColor = [0.902 0.902 0.902]; + app.Classify.Enable = 'off'; + app.Classify.Position = [172 45 178 45]; + app.Classify.Text = ''; + + % Create EnterButton + app.EnterButton = uibutton(app.ManualEntryPan, 'push'); + app.EnterButton.ButtonPushedFcn = createCallbackFcn(app, @EnterButtonPushed, true); + app.EnterButton.Icon = 'plus.png'; + app.EnterButton.BackgroundColor = [0.502 0.502 0.502]; + app.EnterButton.FontName = 'Arial'; + app.EnterButton.FontSize = 14; + app.EnterButton.FontWeight = 'bold'; + app.EnterButton.FontColor = [0.902 0.902 0.902]; + app.EnterButton.Position = [349 428 111 50]; + app.EnterButton.Text = 'Enter'; + + % Create MetaboliteMenuDropDown + app.MetaboliteMenuDropDown = uidropdown(app.ManualEntryPan); + app.MetaboliteMenuDropDown.Items = {'Glyc', 'GSH', 'HG2', 'Ins', 'Lac', 'GPc_Pch', 'tNAA', 'tCR', 'Glx'}; + app.MetaboliteMenuDropDown.FontName = 'Arial'; + app.MetaboliteMenuDropDown.Position = [119 438 153 26]; + app.MetaboliteMenuDropDown.Value = 'Glyc'; + + % Create Image2 + app.Image2 = uiimage(app.ManualEntryPan); + app.Image2.ImageClickedFcn = createCallbackFcn(app, @Image2Clicked, true); + app.Image2.Position = [58 422 38 61]; + app.Image2.ImageSource = 'multiple-variable-lines-graphic.png'; + + % Create EditField + app.EditField = uieditfield(app.ManualEntryPan, 'text'); + app.EditField.ValueChangedFcn = createCallbackFcn(app, @EditFieldValueChanged, true); + app.EditField.BackgroundColor = [0.902 0.902 0.902]; + app.EditField.Position = [281 438 51 26]; + + % Create ListBox + app.ListBox = uilistbox(app.ManualEntryPan); + app.ListBox.Items = {}; + app.ListBox.ValueChangedFcn = createCallbackFcn(app, @ListBoxValueChanged, true); + app.ListBox.FontName = 'Arial'; + app.ListBox.FontSize = 14; + app.ListBox.FontWeight = 'bold'; + app.ListBox.BackgroundColor = [0.502 0.502 0.502]; + app.ListBox.Position = [271 100 201 305]; + app.ListBox.Value = {}; + + % Create Tree3 + app.Tree3 = uitree(app.ManualEntryPan); + app.Tree3.SelectionChangedFcn = createCallbackFcn(app, @Tree3SelectionChanged, true); + app.Tree3.FontName = 'Bodoni MT'; + app.Tree3.FontColor = [1 1 1]; + app.Tree3.BackgroundColor = [0.502 0.502 0.502]; + app.Tree3.Position = [46 99 204 308]; + + % Create modelsd + app.modelsd = uitreenode(app.Tree3); + app.modelsd.Text = 'models'; + + % Create MetaboliteConcentrationEntryLabel + app.MetaboliteConcentrationEntryLabel = uilabel(app.ManualEntryPan); + app.MetaboliteConcentrationEntryLabel.FontName = 'Arial'; + app.MetaboliteConcentrationEntryLabel.FontSize = 14; + app.MetaboliteConcentrationEntryLabel.FontAngle = 'italic'; + app.MetaboliteConcentrationEntryLabel.Position = [60 471 239 31]; + app.MetaboliteConcentrationEntryLabel.Text = 'Metabolite Concentration Entry'; + + % Create Image9 + app.Image9 = uiimage(app.ManualEntryPan); + app.Image9.ImageClickedFcn = createCallbackFcn(app, @Image9Clicked, true); + app.Image9.Position = [15 15 23 45]; + app.Image9.ImageSource = 'left-arrow.png'; + + % Create BacktoMainMenuLabel + app.BacktoMainMenuLabel = uilabel(app.ManualEntryPan); + app.BacktoMainMenuLabel.FontName = 'Arial'; + app.BacktoMainMenuLabel.FontColor = [1 1 1]; + app.BacktoMainMenuLabel.Position = [46 15 103 45]; + app.BacktoMainMenuLabel.Text = {'Back to Main Menu'; ''}; + + % Create ModelMetricsPanel + app.ModelMetricsPanel = uipanel(app.ManualEntryTab); + app.ModelMetricsPanel.AutoResizeChildren = 'off'; + app.ModelMetricsPanel.ForegroundColor = [1 1 1]; + app.ModelMetricsPanel.BorderType = 'none'; + app.ModelMetricsPanel.Title = 'Model Metrics'; + app.ModelMetricsPanel.Visible = 'off'; + app.ModelMetricsPanel.BackgroundColor = [0.502 0.502 0.502]; + app.ModelMetricsPanel.FontName = 'Arial'; + app.ModelMetricsPanel.FontAngle = 'italic'; + app.ModelMetricsPanel.Position = [916 72 333 460]; + + % Create ListBox_2 + app.ListBox_2 = uilistbox(app.ModelMetricsPanel); + app.ListBox_2.Items = {}; + app.ListBox_2.Visible = 'off'; + app.ListBox_2.FontName = 'Arial'; + app.ListBox_2.FontSize = 14; + app.ListBox_2.FontWeight = 'bold'; + app.ListBox_2.BackgroundColor = [0.502 0.502 0.502]; + app.ListBox_2.Position = [21 100 10 321]; + app.ListBox_2.Value = {}; + + % Create Image8 + app.Image8 = uiimage(app.ModelMetricsPanel); + app.Image8.Position = [31 354 40 38]; + app.Image8.ImageSource = 'output-onlinepngtools (18).png'; + + % Create Image8_2 + app.Image8_2 = uiimage(app.ModelMetricsPanel); + app.Image8_2.Position = [31 274 40 38]; + app.Image8_2.ImageSource = 'precision.png'; + + % Create Image8_3 + app.Image8_3 = uiimage(app.ModelMetricsPanel); + app.Image8_3.Position = [31 194 40 38]; + app.Image8_3.ImageSource = 'call-center.png'; + + % Create AccuracyLabel + app.AccuracyLabel = uilabel(app.ModelMetricsPanel); + app.AccuracyLabel.FontName = 'Arial'; + app.AccuracyLabel.FontSize = 14; + app.AccuracyLabel.FontColor = [0.302 0.7451 0.9333]; + app.AccuracyLabel.Position = [94 363 65 22]; + app.AccuracyLabel.Text = 'Accuracy'; + + % Create SpecificityLabel + app.SpecificityLabel = uilabel(app.ModelMetricsPanel); + app.SpecificityLabel.FontName = 'Arial'; + app.SpecificityLabel.FontSize = 14; + app.SpecificityLabel.Position = [94 285 176 22]; + app.SpecificityLabel.Text = 'Specificity'; + + % Create SensitivityLabel + app.SensitivityLabel = uilabel(app.ModelMetricsPanel); + app.SensitivityLabel.FontName = 'Arial'; + app.SensitivityLabel.FontSize = 14; + app.SensitivityLabel.Position = [94 196 244 36]; + app.SensitivityLabel.Text = 'Sensitivity'; + + % Create NaNLabel + app.NaNLabel = uilabel(app.ModelMetricsPanel); + app.NaNLabel.FontName = 'Arial'; + app.NaNLabel.FontSize = 16; + app.NaNLabel.FontColor = [0.302 0.7451 0.9333]; + app.NaNLabel.Position = [183 343 175 66]; + app.NaNLabel.Text = 'NaN'; + + % Create NaNLabel_2 + app.NaNLabel_2 = uilabel(app.ModelMetricsPanel); + app.NaNLabel_2.FontName = 'Arial'; + app.NaNLabel_2.FontSize = 16; + app.NaNLabel_2.Position = [183 283 175 22]; + app.NaNLabel_2.Text = 'NaN'; + + % Create NaNLabel_3 + app.NaNLabel_3 = uilabel(app.ModelMetricsPanel); + app.NaNLabel_3.FontName = 'Arial'; + app.NaNLabel_3.FontSize = 16; + app.NaNLabel_3.Position = [181 196 197 31]; + app.NaNLabel_3.Text = 'NaN'; + + % Create Image15 + app.Image15 = uiimage(app.ModelMetricsPanel); + app.Image15.Position = [31 110 40 38]; + app.Image15.ImageSource = 'analysis.png'; + + % Create ResultLabel + app.ResultLabel = uilabel(app.ModelMetricsPanel); + app.ResultLabel.FontName = 'Arial'; + app.ResultLabel.FontSize = 14; + app.ResultLabel.Position = [94 118 65 22]; + app.ResultLabel.Text = 'Result'; + + % Create NaNLabel_4 + app.NaNLabel_4 = uilabel(app.ModelMetricsPanel); + app.NaNLabel_4.FontName = 'Arial'; + app.NaNLabel_4.FontSize = 16; + app.NaNLabel_4.Position = [181 116 197 31]; + app.NaNLabel_4.Text = 'NaN'; + + % Create MainMenuPanel + app.MainMenuPanel = uipanel(app.ManualEntryTab); + app.MainMenuPanel.AutoResizeChildren = 'off'; + app.MainMenuPanel.ForegroundColor = [0.302 0.7451 0.9333]; + app.MainMenuPanel.BorderType = 'none'; + app.MainMenuPanel.TitlePosition = 'centertop'; + app.MainMenuPanel.Title = 'Main Menu'; + app.MainMenuPanel.BackgroundColor = [0.502 0.502 0.502]; + app.MainMenuPanel.FontName = 'Arial'; + app.MainMenuPanel.FontWeight = 'bold'; + app.MainMenuPanel.Position = [522 72 344 460]; + + % Create ManualEntryButton + app.ManualEntryButton = uibutton(app.MainMenuPanel, 'push'); + app.ManualEntryButton.ButtonPushedFcn = createCallbackFcn(app, @ManualEntryButtonPushed, true); + app.ManualEntryButton.BackgroundColor = [0.502 0.502 0.502]; + app.ManualEntryButton.FontWeight = 'bold'; + app.ManualEntryButton.FontColor = [1 1 1]; + app.ManualEntryButton.Position = [101 324 138 44]; + app.ManualEntryButton.Text = 'Manual Entry'; + + % Create ExcelEntryButton + app.ExcelEntryButton = uibutton(app.MainMenuPanel, 'push'); + app.ExcelEntryButton.ButtonPushedFcn = createCallbackFcn(app, @ExcelEntryButtonPushed, true); + app.ExcelEntryButton.BackgroundColor = [0.502 0.502 0.502]; + app.ExcelEntryButton.FontWeight = 'bold'; + app.ExcelEntryButton.FontColor = [1 1 1]; + app.ExcelEntryButton.Position = [101 273 138 36]; + app.ExcelEntryButton.Text = 'Excel Entry'; + + % Create LCModelEntryButton + app.LCModelEntryButton = uibutton(app.MainMenuPanel, 'push'); + app.LCModelEntryButton.ButtonPushedFcn = createCallbackFcn(app, @LCModelEntryButtonPushed, true); + app.LCModelEntryButton.BackgroundColor = [0.502 0.502 0.502]; + app.LCModelEntryButton.FontWeight = 'bold'; + app.LCModelEntryButton.FontColor = [1 1 1]; + app.LCModelEntryButton.Position = [101 211 138 39]; + app.LCModelEntryButton.Text = 'LC Model Entry'; + + % Create PlotsButton + app.PlotsButton = uibutton(app.MainMenuPanel, 'push'); + app.PlotsButton.ButtonPushedFcn = createCallbackFcn(app, @PlotsButtonPushed, true); + app.PlotsButton.BackgroundColor = [0.4667 0.6745 0.1882]; + app.PlotsButton.FontWeight = 'bold'; + app.PlotsButton.FontColor = [1 1 1]; + app.PlotsButton.Position = [101 63 138 46]; + app.PlotsButton.Text = {'Plots'; ''}; + + % Create ExcelEntryPanel + app.ExcelEntryPanel = uipanel(app.ManualEntryTab); + app.ExcelEntryPanel.AutoResizeChildren = 'off'; + app.ExcelEntryPanel.ForegroundColor = [0.502 0.502 0.502]; + app.ExcelEntryPanel.BorderType = 'none'; + app.ExcelEntryPanel.Visible = 'off'; + app.ExcelEntryPanel.BackgroundColor = [0.502 0.502 0.502]; + app.ExcelEntryPanel.Position = [10 24 1339 596]; + + % Create ButtonPanel + app.ButtonPanel = uipanel(app.ExcelEntryPanel); + app.ButtonPanel.AutoResizeChildren = 'off'; + app.ButtonPanel.ForegroundColor = [0 1 0]; + app.ButtonPanel.BorderType = 'none'; + app.ButtonPanel.TitlePosition = 'centertop'; + app.ButtonPanel.Title = 'Excel Entry'; + app.ButtonPanel.Visible = 'off'; + app.ButtonPanel.BackgroundColor = [0.502 0.502 0.502]; + app.ButtonPanel.FontWeight = 'bold'; + app.ButtonPanel.Position = [513 35 252 509]; + + % Create progressbar + app.progressbar = uiaxes(app.ButtonPanel); + app.progressbar.DataAspectRatio = [1 1 1]; + app.progressbar.XTick = []; + app.progressbar.YTick = []; + app.progressbar.Visible = 'off'; + app.progressbar.BackgroundColor = [0.502 0.502 0.502]; + app.progressbar.Position = [68 282 127 35]; + + % Create LoadButton + app.LoadButton = uibutton(app.ButtonPanel, 'push'); + app.LoadButton.ButtonPushedFcn = createCallbackFcn(app, @LoadButtonPushed, true); + app.LoadButton.BackgroundColor = [0.502 0.502 0.502]; + app.LoadButton.FontName = 'Arial'; + app.LoadButton.FontWeight = 'bold'; + app.LoadButton.FontColor = [1 1 1]; + app.LoadButton.Position = [76 433 100 34]; + app.LoadButton.Text = 'Load'; + + % Create ClassifyButton + app.ClassifyButton = uibutton(app.ButtonPanel, 'push'); + app.ClassifyButton.ButtonPushedFcn = createCallbackFcn(app, @ClassifyButtonPushed2, true); + app.ClassifyButton.BackgroundColor = [0.502 0.502 0.502]; + app.ClassifyButton.FontName = 'Arial'; + app.ClassifyButton.FontWeight = 'bold'; + app.ClassifyButton.FontColor = [1 1 1]; + app.ClassifyButton.Position = [76 366 100 35]; + app.ClassifyButton.Text = 'Classify'; + + % Create ExportClassesButton + app.ExportClassesButton = uibutton(app.ButtonPanel, 'push'); + app.ExportClassesButton.ButtonPushedFcn = createCallbackFcn(app, @ExportClassesButtonPushed, true); + app.ExportClassesButton.BackgroundColor = [0.1451 0.5529 0.7294]; + app.ExportClassesButton.FontWeight = 'bold'; + app.ExportClassesButton.FontColor = [1 1 1]; + app.ExportClassesButton.Position = [76 79 102 38]; + app.ExportClassesButton.Text = 'Export Classes'; + + % Create Image10 + app.Image10 = uiimage(app.ButtonPanel); + app.Image10.ImageClickedFcn = createCallbackFcn(app, @Image10Clicked, true); + app.Image10.Position = [15 29 28 22]; + app.Image10.ImageSource = 'left-arrow.png'; + + % Create BacktoMainMenuLabel_2 + app.BacktoMainMenuLabel_2 = uilabel(app.ButtonPanel); + app.BacktoMainMenuLabel_2.FontName = 'Arial'; + app.BacktoMainMenuLabel_2.FontColor = [1 1 1]; + app.BacktoMainMenuLabel_2.Position = [48 24 103 35]; + app.BacktoMainMenuLabel_2.Text = 'Back to Main Menu'; + + % Create ProcessingLabel + app.ProcessingLabel = uilabel(app.ButtonPanel); + app.ProcessingLabel.FontSize = 15; + app.ProcessingLabel.FontWeight = 'bold'; + app.ProcessingLabel.FontColor = [1 1 1]; + app.ProcessingLabel.Visible = 'off'; + app.ProcessingLabel.Position = [58 320 139 27]; + app.ProcessingLabel.Text = 'Processing..'; + + % Create ModelsListBox_3Label + app.ModelsListBox_3Label = uilabel(app.ButtonPanel); + app.ModelsListBox_3Label.HorizontalAlignment = 'right'; + app.ModelsListBox_3Label.FontWeight = 'bold'; + app.ModelsListBox_3Label.FontColor = [1 1 1]; + app.ModelsListBox_3Label.Position = [1 244 47 22]; + app.ModelsListBox_3Label.Text = 'Models'; + + % Create ModelsListBox_3 + app.ModelsListBox_3 = uilistbox(app.ButtonPanel); + app.ModelsListBox_3.Items = {}; + app.ModelsListBox_3.ValueChangedFcn = createCallbackFcn(app, @ModelsListBox_3ValueChanged, true); + app.ModelsListBox_3.FontWeight = 'bold'; + app.ModelsListBox_3.FontColor = [1 1 1]; + app.ModelsListBox_3.BackgroundColor = [0.502 0.502 0.502]; + app.ModelsListBox_3.Position = [63 135 190 133]; + app.ModelsListBox_3.Value = {}; + + % Create LoadButton_4 + app.LoadButton_4 = uibutton(app.ButtonPanel, 'push'); + app.LoadButton_4.ButtonPushedFcn = createCallbackFcn(app, @LoadButton_4Pushed, true); + app.LoadButton_4.BackgroundColor = [0.502 0.502 0.502]; + app.LoadButton_4.FontName = 'Arial'; + app.LoadButton_4.FontWeight = 'bold'; + app.LoadButton_4.FontColor = [1 1 1]; + app.LoadButton_4.Visible = 'off'; + app.LoadButton_4.Position = [96 413 52 20]; + app.LoadButton_4.Text = 'Load'; + + % Create UITableExcelEntry + app.UITableExcelEntry = uitable(app.ExcelEntryPanel); + app.UITableExcelEntry.ColumnName = {''}; + app.UITableExcelEntry.RowName = {}; + app.UITableExcelEntry.CellSelectionCallback = createCallbackFcn(app, @UITableExcelEntryCellSelection, true); + app.UITableExcelEntry.Visible = 'off'; + app.UITableExcelEntry.FontName = 'Arial'; + app.UITableExcelEntry.Position = [268 88 979 416]; + + % Create Class1Label + app.Class1Label = uilabel(app.ExcelEntryPanel); + app.Class1Label.FontName = 'Arial'; + app.Class1Label.FontWeight = 'bold'; + app.Class1Label.FontAngle = 'italic'; + app.Class1Label.FontColor = [0 1 0]; + app.Class1Label.Position = [240 43 270 22]; + app.Class1Label.Text = '*Class1'; + + % Create Class2Label + app.Class2Label = uilabel(app.ExcelEntryPanel); + app.Class2Label.FontName = 'Arial'; + app.Class2Label.FontWeight = 'bold'; + app.Class2Label.FontAngle = 'italic'; + app.Class2Label.FontColor = [0 0 1]; + app.Class2Label.Position = [240 23 271 22]; + app.Class2Label.Text = '*Class2'; + + % Create PlotsPanel + app.PlotsPanel = uipanel(app.ManualEntryTab); + app.PlotsPanel.AutoResizeChildren = 'off'; + app.PlotsPanel.BorderType = 'none'; + app.PlotsPanel.TitlePosition = 'centertop'; + app.PlotsPanel.Visible = 'off'; + app.PlotsPanel.BackgroundColor = [0.502 0.502 0.502]; + app.PlotsPanel.Position = [10 28 1239 563]; + + % Create PlotsMenuPanel + app.PlotsMenuPanel = uipanel(app.PlotsPanel); + app.PlotsMenuPanel.AutoResizeChildren = 'off'; + app.PlotsMenuPanel.ForegroundColor = [1 1 1]; + app.PlotsMenuPanel.BorderType = 'none'; + app.PlotsMenuPanel.TitlePosition = 'centertop'; + app.PlotsMenuPanel.Title = 'Plots Menu'; + app.PlotsMenuPanel.BackgroundColor = [0.502 0.502 0.502]; + app.PlotsMenuPanel.FontWeight = 'bold'; + app.PlotsMenuPanel.Position = [501 79 257 452]; + + % Create ModelPlots + app.ModelPlots = uibutton(app.PlotsMenuPanel, 'push'); + app.ModelPlots.ButtonPushedFcn = createCallbackFcn(app, @ModelPlotsButtonPushed, true); + app.ModelPlots.BackgroundColor = [0.502 0.502 0.502]; + app.ModelPlots.FontWeight = 'bold'; + app.ModelPlots.FontColor = [1 1 1]; + app.ModelPlots.Position = [77 267 100 46]; + app.ModelPlots.Text = 'Model Plots'; + + % Create LCMODELPLOTS + app.LCMODELPLOTS = uibutton(app.PlotsMenuPanel, 'push'); + app.LCMODELPLOTS.ButtonPushedFcn = createCallbackFcn(app, @LCMODELPLOTSButtonPushed, true); + app.LCMODELPLOTS.BackgroundColor = [0.502 0.502 0.502]; + app.LCMODELPLOTS.FontWeight = 'bold'; + app.LCMODELPLOTS.FontColor = [1 1 1]; + app.LCMODELPLOTS.Position = [76 89 102 46]; + app.LCMODELPLOTS.Text = 'LC Model Plots'; + + % Create ExcelPlots + app.ExcelPlots = uibutton(app.PlotsMenuPanel, 'push'); + app.ExcelPlots.ButtonPushedFcn = createCallbackFcn(app, @ExcelPlotsButtonPushed, true); + app.ExcelPlots.BackgroundColor = [0.502 0.502 0.502]; + app.ExcelPlots.FontWeight = 'bold'; + app.ExcelPlots.FontColor = [1 1 1]; + app.ExcelPlots.Position = [77 177 100 46]; + app.ExcelPlots.Text = 'Excel Plots'; + + % Create Image11 + app.Image11 = uiimage(app.PlotsMenuPanel); + app.Image11.ImageClickedFcn = createCallbackFcn(app, @Image11Clicked, true); + app.Image11.Position = [8 400 20 23]; + app.Image11.ImageSource = 'left-arrow.png'; + + % Create BacktoMainMenuLabel_3 + app.BacktoMainMenuLabel_3 = uilabel(app.PlotsMenuPanel); + app.BacktoMainMenuLabel_3.FontColor = [1 1 1]; + app.BacktoMainMenuLabel_3.Position = [37 401 113 22]; + app.BacktoMainMenuLabel_3.Text = 'Back to Main Menu'; + + % Create plottingpanels1 + app.plottingpanels1 = uipanel(app.PlotsPanel); + app.plottingpanels1.AutoResizeChildren = 'off'; + app.plottingpanels1.BorderType = 'none'; + app.plottingpanels1.BackgroundColor = [0.502 0.502 0.502]; + app.plottingpanels1.Position = [15 50 454 500]; + + % Create plottingpanels2 + app.plottingpanels2 = uipanel(app.PlotsPanel); + app.plottingpanels2.AutoResizeChildren = 'off'; + app.plottingpanels2.BorderType = 'none'; + app.plottingpanels2.Visible = 'off'; + app.plottingpanels2.BackgroundColor = [0.502 0.502 0.502]; + app.plottingpanels2.Position = [386 50 826 497]; + + % Create ModelPlotsPanel + app.ModelPlotsPanel = uipanel(app.PlotsPanel); + app.ModelPlotsPanel.AutoResizeChildren = 'off'; + app.ModelPlotsPanel.ForegroundColor = [1 1 1]; + app.ModelPlotsPanel.BorderType = 'none'; + app.ModelPlotsPanel.TitlePosition = 'centertop'; + app.ModelPlotsPanel.Title = 'Model Plots'; + app.ModelPlotsPanel.Visible = 'off'; + app.ModelPlotsPanel.BackgroundColor = [0.502 0.502 0.502]; + app.ModelPlotsPanel.Position = [503 88 237 439]; + + % Create RefreshButton_2 + app.RefreshButton_2 = uibutton(app.ModelPlotsPanel, 'push'); + app.RefreshButton_2.ButtonPushedFcn = createCallbackFcn(app, @RefreshButton_2Pushed, true); + app.RefreshButton_2.BackgroundColor = [0.4549 0.902 0.4235]; + app.RefreshButton_2.FontWeight = 'bold'; + app.RefreshButton_2.Position = [25 61 87 39]; + app.RefreshButton_2.Text = 'Refresh'; + + % Create PlotButton_3 + app.PlotButton_3 = uibutton(app.ModelPlotsPanel, 'push'); + app.PlotButton_3.ButtonPushedFcn = createCallbackFcn(app, @PlotButton_3Pushed, true); + app.PlotButton_3.BackgroundColor = [0.6 0.8549 0.8784]; + app.PlotButton_3.FontWeight = 'bold'; + app.PlotButton_3.Position = [131 61 91 39]; + app.PlotButton_3.Text = 'Plot'; + + % Create ModelsListBoxLabel + app.ModelsListBoxLabel = uilabel(app.ModelPlotsPanel); + app.ModelsListBoxLabel.BackgroundColor = [0.502 0.502 0.502]; + app.ModelsListBoxLabel.HorizontalAlignment = 'right'; + app.ModelsListBoxLabel.FontColor = [1 1 1]; + app.ModelsListBoxLabel.Position = [96 377 42 22]; + app.ModelsListBoxLabel.Text = 'Models'; + + % Create ModelsListBox + app.ModelsListBox = uilistbox(app.ModelPlotsPanel); + app.ModelsListBox.Items = {}; + app.ModelsListBox.FontColor = [1 1 1]; + app.ModelsListBox.BackgroundColor = [0.502 0.502 0.502]; + app.ModelsListBox.Position = [25 169 197 209]; + app.ModelsListBox.Value = {}; + + % Create Image12 + app.Image12 = uiimage(app.ModelPlotsPanel); + app.Image12.ImageClickedFcn = createCallbackFcn(app, @Image12Clicked, true); + app.Image12.Position = [26 23 27 21]; + app.Image12.ImageSource = 'left-arrow.png'; + + % Create Image12_2 + app.Image12_2 = uiimage(app.ModelPlotsPanel); + app.Image12_2.ImageClickedFcn = createCallbackFcn(app, @Image12_2Clicked, true); + app.Image12_2.Position = [25 3 28 21]; + app.Image12_2.ImageSource = 'left-arrow.png'; + + % Create BacktoMainMenuLabel_4 + app.BacktoMainMenuLabel_4 = uilabel(app.ModelPlotsPanel); + app.BacktoMainMenuLabel_4.FontColor = [1 1 1]; + app.BacktoMainMenuLabel_4.Position = [63 23 103 22]; + app.BacktoMainMenuLabel_4.Text = 'Back to Main Menu'; + + % Create BacktopreviousMenuLabel + app.BacktopreviousMenuLabel = uilabel(app.ModelPlotsPanel); + app.BacktopreviousMenuLabel.FontColor = [1 1 1]; + app.BacktopreviousMenuLabel.Position = [63 3 123 22]; + app.BacktopreviousMenuLabel.Text = 'Back to previous Menu'; + + % Create LCModelPlotsPanel + app.LCModelPlotsPanel = uipanel(app.PlotsPanel); + app.LCModelPlotsPanel.AutoResizeChildren = 'off'; + app.LCModelPlotsPanel.ForegroundColor = [0 1 0]; + app.LCModelPlotsPanel.BorderType = 'none'; + app.LCModelPlotsPanel.TitlePosition = 'centertop'; + app.LCModelPlotsPanel.Title = 'LC Model Plots'; + app.LCModelPlotsPanel.Visible = 'off'; + app.LCModelPlotsPanel.BackgroundColor = [0.502 0.502 0.502]; + app.LCModelPlotsPanel.Position = [485 79 273 453]; + + % Create LoadButton_2 + app.LoadButton_2 = uibutton(app.LCModelPlotsPanel, 'push'); + app.LoadButton_2.ButtonPushedFcn = createCallbackFcn(app, @LoadButton_2Pushed, true); + app.LoadButton_2.BackgroundColor = [0.302 0.7451 0.9333]; + app.LoadButton_2.FontWeight = 'bold'; + app.LoadButton_2.Position = [80 336 100 39]; + app.LoadButton_2.Text = 'Load'; + + % Create PlotButton_4 + app.PlotButton_4 = uibutton(app.LCModelPlotsPanel, 'push'); + app.PlotButton_4.ButtonPushedFcn = createCallbackFcn(app, @PlotButton_4Pushed, true); + app.PlotButton_4.BackgroundColor = [0.502 0.502 0.502]; + app.PlotButton_4.FontWeight = 'bold'; + app.PlotButton_4.FontColor = [1 1 1]; + app.PlotButton_4.Position = [80 250 100 39]; + app.PlotButton_4.Text = 'Plot'; + + % Create Image13 + app.Image13 = uiimage(app.LCModelPlotsPanel); + app.Image13.ImageClickedFcn = createCallbackFcn(app, @Image13Clicked, true); + app.Image13.Position = [49 70 28 21]; + app.Image13.ImageSource = 'left-arrow.png'; + + % Create Image13_2 + app.Image13_2 = uiimage(app.LCModelPlotsPanel); + app.Image13_2.ImageClickedFcn = createCallbackFcn(app, @Image13_2Clicked, true); + app.Image13_2.Position = [26 50 71 21]; + app.Image13_2.ImageSource = 'left-arrow.png'; + + % Create BacktoMainMenuLabel_5 + app.BacktoMainMenuLabel_5 = uilabel(app.LCModelPlotsPanel); + app.BacktoMainMenuLabel_5.FontColor = [1 1 1]; + app.BacktoMainMenuLabel_5.Position = [86 70 103 22]; + app.BacktoMainMenuLabel_5.Text = 'Back to Main Menu'; + + % Create BacktoPreviousMenuLabel + app.BacktoPreviousMenuLabel = uilabel(app.LCModelPlotsPanel); + app.BacktoPreviousMenuLabel.FontColor = [1 1 1]; + app.BacktoPreviousMenuLabel.Position = [86 50 124 22]; + app.BacktoPreviousMenuLabel.Text = 'Back to Previous Menu'; + + % Create MetabolitesListBoxLabel + app.MetabolitesListBoxLabel = uilabel(app.LCModelPlotsPanel); + app.MetabolitesListBoxLabel.HorizontalAlignment = 'right'; + app.MetabolitesListBoxLabel.FontColor = [1 1 1]; + app.MetabolitesListBoxLabel.Position = [5 209 63 22]; + app.MetabolitesListBoxLabel.Text = 'Metabolites'; + + % Create MetabolitesListBox + app.MetabolitesListBox = uilistbox(app.LCModelPlotsPanel); + app.MetabolitesListBox.Items = {}; + app.MetabolitesListBox.Multiselect = 'on'; + app.MetabolitesListBox.FontWeight = 'bold'; + app.MetabolitesListBox.FontColor = [1 1 1]; + app.MetabolitesListBox.BackgroundColor = [0.502 0.502 0.502]; + app.MetabolitesListBox.Position = [76 99 107 134]; + app.MetabolitesListBox.Value = {}; + + % Create ExcelPlotPanel + app.ExcelPlotPanel = uipanel(app.PlotsPanel); + app.ExcelPlotPanel.AutoResizeChildren = 'off'; + app.ExcelPlotPanel.ForegroundColor = [1 1 1]; + app.ExcelPlotPanel.BorderType = 'none'; + app.ExcelPlotPanel.TitlePosition = 'centertop'; + app.ExcelPlotPanel.Title = 'Excel Plot'; + app.ExcelPlotPanel.Visible = 'off'; + app.ExcelPlotPanel.BackgroundColor = [0.502 0.502 0.502]; + app.ExcelPlotPanel.FontWeight = 'bold'; + app.ExcelPlotPanel.Position = [15 19 1225 541]; + + % Create TabGroup3 + app.TabGroup3 = uitabgroup(app.ExcelPlotPanel); + app.TabGroup3.AutoResizeChildren = 'off'; + app.TabGroup3.SelectionChangedFcn = createCallbackFcn(app, @TabGroup3SelectionChanged, true); + app.TabGroup3.Position = [1 0 1225 516]; + + % Create DataTab + app.DataTab = uitab(app.TabGroup3); + app.DataTab.AutoResizeChildren = 'off'; + app.DataTab.Title = 'Data'; + app.DataTab.BackgroundColor = [1 1 1]; + + % Create LoadButton_6 + app.LoadButton_6 = uibutton(app.DataTab, 'push'); + app.LoadButton_6.ButtonPushedFcn = createCallbackFcn(app, @LoadButton_6Pushed, true); + app.LoadButton_6.BackgroundColor = [1 1 1]; + app.LoadButton_6.Position = [17 406 154 44]; + app.LoadButton_6.Text = 'Load'; + + % Create UITable4 + app.UITable4 = uitable(app.DataTab); + app.UITable4.ColumnName = {'Column 1'; 'Column 2'; 'Column 3'; 'Column 4'}; + app.UITable4.RowName = {}; + app.UITable4.Position = [204 48 974 434]; + + % Create AssignButton + app.AssignButton = uibutton(app.DataTab, 'push'); + app.AssignButton.ButtonPushedFcn = createCallbackFcn(app, @AssignButtonPushed, true); + app.AssignButton.BackgroundColor = [1 1 1]; + app.AssignButton.Position = [17 63 162 43]; + app.AssignButton.Text = 'Assign'; + + % Create ListBox_5Label + app.ListBox_5Label = uilabel(app.DataTab); + app.ListBox_5Label.HorizontalAlignment = 'right'; + app.ListBox_5Label.FontWeight = 'bold'; + app.ListBox_5Label.Position = [-2 368 67 22]; + app.ListBox_5Label.Text = 'Features'; + + % Create ListBox_5 + app.ListBox_5 = uilistbox(app.DataTab); + app.ListBox_5.Multiselect = 'on'; + app.ListBox_5.FontWeight = 'bold'; + app.ListBox_5.Position = [68 190 128 198]; + app.ListBox_5.Value = {'Item 1'}; + + % Create GroupingFeatureLabel + app.GroupingFeatureLabel = uilabel(app.DataTab); + app.GroupingFeatureLabel.HorizontalAlignment = 'right'; + app.GroupingFeatureLabel.FontWeight = 'bold'; + app.GroupingFeatureLabel.Position = [36 154 118 17]; + app.GroupingFeatureLabel.Text = 'Grouping Feature'; + + % Create DropDown + app.DropDown = uidropdown(app.DataTab); + app.DropDown.FontWeight = 'bold'; + app.DropDown.BackgroundColor = [1 1 1]; + app.DropDown.Position = [23 127 173 21]; + + % Create Image24 + app.Image24 = uiimage(app.DataTab); + app.Image24.ImageClickedFcn = createCallbackFcn(app, @Image24Clicked, true); + app.Image24.Position = [52 9 19 16]; + app.Image24.ImageSource = 'left-arrow.png'; + + % Create BacktoPlotsMenuLabel + app.BacktoPlotsMenuLabel = uilabel(app.DataTab); + app.BacktoPlotsMenuLabel.Position = [75 9 105 17]; + app.BacktoPlotsMenuLabel.Text = 'Back to Plots Menu'; + + % Create greenLabel + app.greenLabel = uilabel(app.DataTab); + app.greenLabel.FontWeight = 'bold'; + app.greenLabel.FontAngle = 'italic'; + app.greenLabel.FontColor = [0 1 0]; + app.greenLabel.Position = [204 22 892 22]; + app.greenLabel.Text = '*green'; + + % Create blueLabel + app.blueLabel = uilabel(app.DataTab); + app.blueLabel.FontWeight = 'bold'; + app.blueLabel.FontAngle = 'italic'; + app.blueLabel.FontColor = [0 0 1]; + app.blueLabel.Position = [207 2 889 22]; + app.blueLabel.Text = '*blue'; + + % Create PlotsTab + app.PlotsTab = uitab(app.TabGroup3); + app.PlotsTab.AutoResizeChildren = 'off'; + app.PlotsTab.Title = 'Plots'; + app.PlotsTab.BackgroundColor = [1 1 1]; + + % Create excelpanel + app.excelpanel = uipanel(app.PlotsTab); + app.excelpanel.AutoResizeChildren = 'off'; + app.excelpanel.BorderType = 'none'; + app.excelpanel.BackgroundColor = [1 1 1]; + app.excelpanel.Position = [17 2 825 473]; + + % Create Plot + app.Plot = uibutton(app.PlotsTab, 'push'); + app.Plot.ButtonPushedFcn = createCallbackFcn(app, @PlotButtonPushed, true); + app.Plot.BackgroundColor = [0.4667 0.6745 0.1882]; + app.Plot.FontName = 'Arial Black'; + app.Plot.FontWeight = 'bold'; + app.Plot.FontColor = [1 1 1]; + app.Plot.Position = [946 34 172 39]; + app.Plot.Text = 'Plot'; + + % Create PlotsButtonGroup + app.PlotsButtonGroup = uibuttongroup(app.PlotsTab); + app.PlotsButtonGroup.AutoResizeChildren = 'off'; + app.PlotsButtonGroup.TitlePosition = 'centertop'; + app.PlotsButtonGroup.Title = 'Plots'; + app.PlotsButtonGroup.BackgroundColor = [1 1 1]; + app.PlotsButtonGroup.Position = [852 89 360 280]; + + % Create VariablePlotButton_2 + app.VariablePlotButton_2 = uitogglebutton(app.PlotsButtonGroup); + app.VariablePlotButton_2.Text = 'Variable Plot'; + app.VariablePlotButton_2.Position = [11 227 100 22]; + app.VariablePlotButton_2.Value = true; + + % Create SpiderPlotButton_2 + app.SpiderPlotButton_2 = uitogglebutton(app.PlotsButtonGroup); + app.SpiderPlotButton_2.Text = 'Spider Plot'; + app.SpiderPlotButton_2.Position = [11 196 100 22]; + + % Create PCAPlotButton + app.PCAPlotButton = uitogglebutton(app.PlotsButtonGroup); + app.PCAPlotButton.Text = 'PCA Plot'; + app.PCAPlotButton.Position = [11 165 100 22]; + + % Create BoxPlotButton_2 + app.BoxPlotButton_2 = uitogglebutton(app.PlotsButtonGroup); + app.BoxPlotButton_2.Text = 'Box Plot'; + app.BoxPlotButton_2.Position = [11 135 100 22]; + + % Create BarPlotButton + app.BarPlotButton = uitogglebutton(app.PlotsButtonGroup); + app.BarPlotButton.Text = 'Bar Plot'; + app.BarPlotButton.Position = [11 105 100 22]; + + % Create LinePlotButton + app.LinePlotButton = uitogglebutton(app.PlotsButtonGroup); + app.LinePlotButton.Text = 'Line Plot'; + app.LinePlotButton.Position = [11 75 100 22]; + + % Create ConfidenceIntervalCheckBox + app.ConfidenceIntervalCheckBox = uicheckbox(app.PlotsButtonGroup); + app.ConfidenceIntervalCheckBox.Text = 'Confidence Interval'; + app.ConfidenceIntervalCheckBox.Position = [160 75 121 22]; + app.ConfidenceIntervalCheckBox.Value = true; + + % Create ScatterCheckBox + app.ScatterCheckBox = uicheckbox(app.PlotsButtonGroup); + app.ScatterCheckBox.Text = 'Scatter'; + app.ScatterCheckBox.Position = [291 73 59 22]; + + % Create CI + app.CI = uieditfield(app.PlotsButtonGroup, 'numeric'); + app.CI.Limits = [0 1]; + app.CI.Position = [114 74 33 23]; + app.CI.Value = 0.95; + + % Create MergeCheckBox_2 + app.MergeCheckBox_2 = uicheckbox(app.PlotsButtonGroup); + app.MergeCheckBox_2.Text = 'Merge'; + app.MergeCheckBox_2.Position = [125 195 54 22]; + + % Create CompactCheckBox + app.CompactCheckBox = uicheckbox(app.PlotsButtonGroup); + app.CompactCheckBox.Text = 'Compact'; + app.CompactCheckBox.Position = [125 134 70 23]; + + % Create PCDimensionSpinnerLabel + app.PCDimensionSpinnerLabel = uilabel(app.PlotsButtonGroup); + app.PCDimensionSpinnerLabel.HorizontalAlignment = 'right'; + app.PCDimensionSpinnerLabel.Position = [178 164 88 22]; + app.PCDimensionSpinnerLabel.Text = 'PC Dimension'; + + % Create PCDimensionSpinner + app.PCDimensionSpinner = uispinner(app.PlotsButtonGroup); + app.PCDimensionSpinner.Limits = [2 3]; + app.PCDimensionSpinner.Position = [125 164 54 22]; + app.PCDimensionSpinner.Value = 2; + + % Create Feature1DropDownLabel + app.Feature1DropDownLabel = uilabel(app.PlotsTab); + app.Feature1DropDownLabel.BackgroundColor = [1 1 1]; + app.Feature1DropDownLabel.HorizontalAlignment = 'right'; + app.Feature1DropDownLabel.Position = [868 422 55 22]; + app.Feature1DropDownLabel.Text = 'Feature 1'; + + % Create Feature1DropDown + app.Feature1DropDown = uidropdown(app.PlotsTab); + app.Feature1DropDown.BackgroundColor = [1 1 1]; + app.Feature1DropDown.Position = [938 422 264 22]; + + % Create Feature2DropDownLabel + app.Feature2DropDownLabel = uilabel(app.PlotsTab); + app.Feature2DropDownLabel.BackgroundColor = [1 1 1]; + app.Feature2DropDownLabel.HorizontalAlignment = 'right'; + app.Feature2DropDownLabel.Position = [868 391 55 22]; + app.Feature2DropDownLabel.Text = 'Feature 2'; + + % Create Feature2DropDown + app.Feature2DropDown = uidropdown(app.PlotsTab); + app.Feature2DropDown.BackgroundColor = [1 1 1]; + app.Feature2DropDown.Position = [938 391 268 22]; + + % Create ResultsPanel + app.ResultsPanel = uipanel(app.ManualEntryTab); + app.ResultsPanel.AutoResizeChildren = 'off'; + app.ResultsPanel.ForegroundColor = [0 1 0]; + app.ResultsPanel.BorderType = 'none'; + app.ResultsPanel.TitlePosition = 'centertop'; + app.ResultsPanel.Title = 'Results'; + app.ResultsPanel.Visible = 'off'; + app.ResultsPanel.BackgroundColor = [0.502 0.502 0.502]; + app.ResultsPanel.FontWeight = 'bold'; + app.ResultsPanel.Position = [26 67 407 462]; + + % Create LCModelEntryPanel + app.LCModelEntryPanel = uipanel(app.ManualEntryTab); + app.LCModelEntryPanel.AutoResizeChildren = 'off'; + app.LCModelEntryPanel.ForegroundColor = [1 1 1]; + app.LCModelEntryPanel.BorderType = 'none'; + app.LCModelEntryPanel.TitlePosition = 'centertop'; + app.LCModelEntryPanel.Title = 'LC Model Entry'; + app.LCModelEntryPanel.Visible = 'off'; + app.LCModelEntryPanel.BackgroundColor = [0.502 0.502 0.502]; + app.LCModelEntryPanel.FontName = 'Arial'; + app.LCModelEntryPanel.Position = [454 126 334 461]; + + % Create LoadButton_3 + app.LoadButton_3 = uibutton(app.LCModelEntryPanel, 'push'); + app.LoadButton_3.ButtonPushedFcn = createCallbackFcn(app, @LoadButton_3Pushed, true); + app.LoadButton_3.BackgroundColor = [0.502 0.502 0.502]; + app.LoadButton_3.FontWeight = 'bold'; + app.LoadButton_3.FontColor = [1 1 1]; + app.LoadButton_3.Position = [110 347 100 42]; + app.LoadButton_3.Text = 'Load'; + + % Create ClassifyButton_2 + app.ClassifyButton_2 = uibutton(app.LCModelEntryPanel, 'push'); + app.ClassifyButton_2.ButtonPushedFcn = createCallbackFcn(app, @ClassifyButton_2Pushed, true); + app.ClassifyButton_2.BackgroundColor = [0.4667 0.6745 0.1882]; + app.ClassifyButton_2.FontWeight = 'bold'; + app.ClassifyButton_2.FontColor = [1 1 1]; + app.ClassifyButton_2.Position = [110 103 100 42]; + app.ClassifyButton_2.Text = 'Classify'; + + % Create ModelsListBox_2Label + app.ModelsListBox_2Label = uilabel(app.LCModelEntryPanel); + app.ModelsListBox_2Label.BackgroundColor = [0.502 0.502 0.502]; + app.ModelsListBox_2Label.HorizontalAlignment = 'right'; + app.ModelsListBox_2Label.FontColor = [1 1 1]; + app.ModelsListBox_2Label.Position = [65 310 42 22]; + app.ModelsListBox_2Label.Text = 'Models'; + + % Create ModelsListBox_2 + app.ModelsListBox_2 = uilistbox(app.LCModelEntryPanel); + app.ModelsListBox_2.FontColor = [1 1 1]; + app.ModelsListBox_2.BackgroundColor = [0.502 0.502 0.502]; + app.ModelsListBox_2.Position = [40 168 105 140]; + + % Create CoordFilesListBoxLabel + app.CoordFilesListBoxLabel = uilabel(app.LCModelEntryPanel); + app.CoordFilesListBoxLabel.BackgroundColor = [0.502 0.502 0.502]; + app.CoordFilesListBoxLabel.HorizontalAlignment = 'right'; + app.CoordFilesListBoxLabel.FontColor = [1 1 1]; + app.CoordFilesListBoxLabel.Position = [192 310 65 22]; + app.CoordFilesListBoxLabel.Text = 'Coord Files'; + + % Create CoordFilesListBox + app.CoordFilesListBox = uilistbox(app.LCModelEntryPanel); + app.CoordFilesListBox.Items = {}; + app.CoordFilesListBox.FontColor = [1 1 1]; + app.CoordFilesListBox.BackgroundColor = [0.502 0.502 0.502]; + app.CoordFilesListBox.Position = [169 168 111 140]; + app.CoordFilesListBox.Value = {}; + + % Create Image14 + app.Image14 = uiimage(app.LCModelEntryPanel); + app.Image14.ImageClickedFcn = createCallbackFcn(app, @Image14Clicked, true); + app.Image14.Position = [22 29 24 19]; + app.Image14.ImageSource = 'left-arrow.png'; + + % Create BacktoMainMenuLabel_6 + app.BacktoMainMenuLabel_6 = uilabel(app.LCModelEntryPanel); + app.BacktoMainMenuLabel_6.FontColor = [1 1 1]; + app.BacktoMainMenuLabel_6.Position = [52 28 103 22]; + app.BacktoMainMenuLabel_6.Text = 'Back to Main Menu'; + + % Create MR_Diffusion + app.MR_Diffusion = uitabgroup(app.GliomaIDHMutationDiagnosisToolUIFigure); + app.MR_Diffusion.Visible = 'off'; + app.MR_Diffusion.SelectionChangedFcn = createCallbackFcn(app, @MR_DiffusionSelectionChanged, true); + app.MR_Diffusion.Position = [176 -4 1332 676]; + + % Create Tab_3 + app.Tab_3 = uitab(app.MR_Diffusion); + app.Tab_3.Title = 'Tab'; + app.Tab_3.BackgroundColor = [1 1 1]; + + % Create Tab2_3 + app.Tab2_3 = uitab(app.MR_Diffusion); + app.Tab2_3.Title = 'Tab2'; + + % Create Tree + app.Tree = uitree(app.GliomaIDHMutationDiagnosisToolUIFigure); + app.Tree.SelectionChangedFcn = createCallbackFcn(app, @TreeSelectionChanged, true); + app.Tree.FontName = 'Arial'; + app.Tree.FontWeight = 'bold'; + app.Tree.Position = [1 471 172 202]; + + % Create NormalUserNode + app.NormalUserNode = uitreenode(app.Tree); + app.NormalUserNode.NodeData = 'MR_Spectroscopy'; + app.NormalUserNode.Text = 'Normal User'; + + % Create MRSpectroscopyNode + app.MRSpectroscopyNode = uitreenode(app.NormalUserNode); + app.MRSpectroscopyNode.NodeData = 'MR_Spectroscopy'; + app.MRSpectroscopyNode.Text = 'MR Spectroscopy'; + + % Create MassSpectroscopyNode + app.MassSpectroscopyNode = uitreenode(app.NormalUserNode); + app.MassSpectroscopyNode.NodeData = 'MassSpectroscopy'; + app.MassSpectroscopyNode.Text = 'Mass Spectroscopy'; + + % Create AdvancedUserNode + app.AdvancedUserNode = uitreenode(app.Tree); + app.AdvancedUserNode.NodeData = 'AdvancedUser'; + app.AdvancedUserNode.Text = 'Advanced User'; + + % Create AboutNode + app.AboutNode = uitreenode(app.Tree); + app.AboutNode.NodeData = 'About'; + app.AboutNode.Text = 'About'; + + % Create AdvancedUser + app.AdvancedUser = uitabgroup(app.GliomaIDHMutationDiagnosisToolUIFigure); + app.AdvancedUser.Position = [172 -7 1336 680]; + + % Create TrainerTab + app.TrainerTab = uitab(app.AdvancedUser); + app.TrainerTab.Title = 'Trainer'; + app.TrainerTab.BackgroundColor = [0.902 0.902 0.902]; + + % Create trainertab + app.trainertab = uitabgroup(app.TrainerTab); + app.trainertab.Visible = 'off'; + app.trainertab.Position = [1 2 1360 653]; + + % Create VariablePlotsTab + app.VariablePlotsTab = uitab(app.trainertab); + app.VariablePlotsTab.Title = 'Variable Plots'; + + % Create trainerpanel + app.trainerpanel = uipanel(app.VariablePlotsTab); + app.trainerpanel.ForegroundColor = [1 1 1]; + app.trainerpanel.BackgroundColor = [1 1 1]; + app.trainerpanel.Position = [2 49 828 579]; + + % Create Variable1DropDownLabel + app.Variable1DropDownLabel = uilabel(app.VariablePlotsTab); + app.Variable1DropDownLabel.HorizontalAlignment = 'right'; + app.Variable1DropDownLabel.Position = [854 559 55 22]; + app.Variable1DropDownLabel.Text = 'Variable1'; + + % Create Variable1DropDown + app.Variable1DropDown = uidropdown(app.VariablePlotsTab); + app.Variable1DropDown.ValueChangedFcn = createCallbackFcn(app, @Variable1DropDownValueChanged, true); + app.Variable1DropDown.Position = [924 559 230 22]; + + % Create Variable2DropDownLabel + app.Variable2DropDownLabel = uilabel(app.VariablePlotsTab); + app.Variable2DropDownLabel.HorizontalAlignment = 'right'; + app.Variable2DropDownLabel.Position = [854 487 55 22]; + app.Variable2DropDownLabel.Text = 'Variable2'; + + % Create Variable2DropDown + app.Variable2DropDown = uidropdown(app.VariablePlotsTab); + app.Variable2DropDown.Position = [924 487 231 22]; + + % Create plots_2 + app.plots_2 = uibutton(app.VariablePlotsTab, 'push'); + app.plots_2.ButtonPushedFcn = createCallbackFcn(app, @plotsButtonPushed, true); + app.plots_2.BackgroundColor = [0.0902 0.5804 0.0824]; + app.plots_2.FontWeight = 'bold'; + app.plots_2.FontColor = [1 1 1]; + app.plots_2.Position = [875 241 256 29]; + app.plots_2.Text = 'NEW PLOT'; + + % Create PLOTSButtonGroup + app.PLOTSButtonGroup = uibuttongroup(app.VariablePlotsTab); + app.PLOTSButtonGroup.BorderType = 'none'; + app.PLOTSButtonGroup.Title = 'PLOTS'; + app.PLOTSButtonGroup.Position = [844 292 336 171]; + + % Create VariablePlotButton + app.VariablePlotButton = uitogglebutton(app.PLOTSButtonGroup); + app.VariablePlotButton.Text = 'Variable Plot'; + app.VariablePlotButton.Position = [11 119 100 22]; + app.VariablePlotButton.Value = true; + + % Create SpiderPlotButton + app.SpiderPlotButton = uitogglebutton(app.PLOTSButtonGroup); + app.SpiderPlotButton.Text = 'Spider Plot'; + app.SpiderPlotButton.Position = [11 98 100 22]; + + % Create BoxPlotButton + app.BoxPlotButton = uitogglebutton(app.PLOTSButtonGroup); + app.BoxPlotButton.Text = 'Box Plot'; + app.BoxPlotButton.Position = [11 77 100 22]; + + % Create LinePlotButton_3 + app.LinePlotButton_3 = uitogglebutton(app.PLOTSButtonGroup); + app.LinePlotButton_3.Text = 'Line Plot'; + app.LinePlotButton_3.Position = [11 57 100 22]; + + % Create CompactCheckBox_3 + app.CompactCheckBox_3 = uicheckbox(app.PLOTSButtonGroup); + app.CompactCheckBox_3.Text = 'Compact'; + app.CompactCheckBox_3.Position = [121 78 70 22]; + + % Create MeanSpiderCheckBox + app.MeanSpiderCheckBox = uicheckbox(app.PLOTSButtonGroup); + app.MeanSpiderCheckBox.Text = 'Mean Spider'; + app.MeanSpiderCheckBox.Position = [121 100 87 23]; + + % Create MergeCheckBox + app.MergeCheckBox = uicheckbox(app.PLOTSButtonGroup); + app.MergeCheckBox.Text = 'Merge'; + app.MergeCheckBox.Position = [207 99 54 22]; + + % Create BarPlotButton_3 + app.BarPlotButton_3 = uitogglebutton(app.PLOTSButtonGroup); + app.BarPlotButton_3.Text = 'Bar Plot'; + app.BarPlotButton_3.Position = [11 37 100 22]; + + % Create ScatterCheck + app.ScatterCheck = uicheckbox(app.PLOTSButtonGroup); + app.ScatterCheck.Text = 'Scatter'; + app.ScatterCheck.Position = [229 58 59 22]; + + % Create CISpinnerLabel + app.CISpinnerLabel = uilabel(app.PLOTSButtonGroup); + app.CISpinnerLabel.HorizontalAlignment = 'right'; + app.CISpinnerLabel.Position = [141 54 10 22]; + app.CISpinnerLabel.Text = 'CI'; + + % Create CISpinner + app.CISpinner = uispinner(app.PLOTSButtonGroup); + app.CISpinner.Step = 0.01; + app.CISpinner.Limits = [0 1]; + app.CISpinner.Position = [157 55 54 22]; + app.CISpinner.Value = 0.95; + + % Create CheckBox + app.CheckBox = uicheckbox(app.PLOTSButtonGroup); + app.CheckBox.Text = ''; + app.CheckBox.Position = [121 54 25 22]; + + % Create PCAPlotButton_3 + app.PCAPlotButton_3 = uitogglebutton(app.PLOTSButtonGroup); + app.PCAPlotButton_3.Text = 'PCA Plot'; + app.PCAPlotButton_3.Position = [11 17 100 22]; + + % Create DimensionSpinnerLabel + app.DimensionSpinnerLabel = uilabel(app.PLOTSButtonGroup); + app.DimensionSpinnerLabel.HorizontalAlignment = 'right'; + app.DimensionSpinnerLabel.Position = [121 17 58 22]; + app.DimensionSpinnerLabel.Text = 'Dimension'; + + % Create DimensionSpinner + app.DimensionSpinner = uispinner(app.PLOTSButtonGroup); + app.DimensionSpinner.Limits = [2 3]; + app.DimensionSpinner.Position = [193 17 68 22]; + app.DimensionSpinner.Value = 2; + + % Create Image16 + app.Image16 = uiimage(app.VariablePlotsTab); + app.Image16.ImageClickedFcn = createCallbackFcn(app, @Image16Clicked, true); + app.Image16.Position = [858 124 33 16]; + app.Image16.ImageSource = 'left-arrow.png'; + + % Create BacktomainmenuLabel + app.BacktomainmenuLabel = uilabel(app.VariablePlotsTab); + app.BacktomainmenuLabel.Position = [888 121 106 22]; + app.BacktomainmenuLabel.Text = 'Back to main menu'; + + % Create Image16_2 + app.Image16_2 = uiimage(app.VariablePlotsTab); + app.Image16_2.ImageClickedFcn = createCallbackFcn(app, @Image16_2Clicked, true); + app.Image16_2.Position = [858 104 33 16]; + app.Image16_2.ImageSource = 'left-arrow.png'; + + % Create BacktopreviousmenuLabel + app.BacktopreviousmenuLabel = uilabel(app.VariablePlotsTab); + app.BacktopreviousmenuLabel.Position = [888 101 126 22]; + app.BacktopreviousmenuLabel.Text = 'Back to previous menu'; + + % Create ModelPlotsTab + app.ModelPlotsTab = uitab(app.trainertab); + app.ModelPlotsTab.Title = 'Model Plots'; + + % Create Panel_2 + app.Panel_2 = uipanel(app.ModelPlotsTab); + app.Panel_2.BackgroundColor = [0.2706 0.2549 0.2549]; + app.Panel_2.Position = [12 71 860 549]; + + % Create MODELSListBox_3Label + app.MODELSListBox_3Label = uilabel(app.ModelPlotsTab); + app.MODELSListBox_3Label.HorizontalAlignment = 'right'; + app.MODELSListBox_3Label.Position = [1009 593 55 22]; + app.MODELSListBox_3Label.Text = 'MODELS'; + + % Create MODELSListBox_3 + app.MODELSListBox_3 = uilistbox(app.ModelPlotsTab); + app.MODELSListBox_3.Items = {}; + app.MODELSListBox_3.Position = [908 185 294 404]; + app.MODELSListBox_3.Value = {}; + + % Create RefreshButton + app.RefreshButton = uibutton(app.ModelPlotsTab, 'push'); + app.RefreshButton.ButtonPushedFcn = createCallbackFcn(app, @RefreshButtonPushed, true); + app.RefreshButton.BackgroundColor = [0.302 0.7451 0.9333]; + app.RefreshButton.Position = [913 145 138 27]; + app.RefreshButton.Text = 'Refresh'; + + % Create PlotButton_2 + app.PlotButton_2 = uibutton(app.ModelPlotsTab, 'push'); + app.PlotButton_2.ButtonPushedFcn = createCallbackFcn(app, @PlotButton_2Pushed, true); + app.PlotButton_2.BackgroundColor = [0.4667 0.6745 0.1882]; + app.PlotButton_2.FontColor = [1 1 1]; + app.PlotButton_2.Position = [1064 145 138 27]; + app.PlotButton_2.Text = 'Plot '; + + % Create TrainingPanel + app.TrainingPanel = uipanel(app.TrainerTab); + app.TrainingPanel.BorderType = 'none'; + app.TrainingPanel.Title = 'Training'; + app.TrainingPanel.Visible = 'off'; + app.TrainingPanel.BackgroundColor = [0.9412 0.9412 0.9412]; + app.TrainingPanel.FontName = 'Arial Black'; + app.TrainingPanel.FontWeight = 'bold'; + app.TrainingPanel.FontSize = 16; + app.TrainingPanel.Position = [1 10 1359 647]; + + % Create KNN + app.KNN = uipanel(app.TrainingPanel); + app.KNN.BorderType = 'none'; + app.KNN.Title = 'KNN'; + app.KNN.BackgroundColor = [0.9412 0.9412 0.9412]; + app.KNN.FontName = 'Arial'; + app.KNN.FontWeight = 'bold'; + app.KNN.Position = [14 395 1085 87]; + + % Create Image5 + app.Image5 = uiimage(app.KNN); + app.Image5.ImageClickedFcn = createCallbackFcn(app, @Image5Clicked, true); + app.Image5.HorizontalAlignment = 'right'; + app.Image5.Position = [25 14 51 40]; + app.Image5.ImageSource = 'grain.png'; + + % Create WeightedKNNLabel + app.WeightedKNNLabel = uilabel(app.KNN); + app.WeightedKNNLabel.FontWeight = 'bold'; + app.WeightedKNNLabel.Position = [87 23 144 22]; + app.WeightedKNNLabel.Text = 'Weighted KNN'; + + % Create CoarseKNNLabel + app.CoarseKNNLabel = uilabel(app.KNN); + app.CoarseKNNLabel.FontWeight = 'bold'; + app.CoarseKNNLabel.Position = [308 23 140 22]; + app.CoarseKNNLabel.Text = 'Coarse KNN'; + + % Create Image5_5 + app.Image5_5 = uiimage(app.KNN); + app.Image5_5.ImageClickedFcn = createCallbackFcn(app, @Image5_5Clicked, true); + app.Image5_5.HorizontalAlignment = 'right'; + app.Image5_5.Position = [241 14 51 40]; + app.Image5_5.ImageSource = 'grain.png'; + + % Create fineknn + app.fineknn = uiimage(app.KNN); + app.fineknn.ImageClickedFcn = createCallbackFcn(app, @fineknnImageClicked, true); + app.fineknn.HorizontalAlignment = 'right'; + app.fineknn.Position = [447 14 51 40]; + app.fineknn.ImageSource = 'grain.png'; + + % Create FineKNNLabel + app.FineKNNLabel = uilabel(app.KNN); + app.FineKNNLabel.FontWeight = 'bold'; + app.FineKNNLabel.Position = [514 23 133 22]; + app.FineKNNLabel.Text = 'Fine KNN'; + + % Create fineknn_2 + app.fineknn_2 = uiimage(app.KNN); + app.fineknn_2.ImageClickedFcn = createCallbackFcn(app, @fineknn_2ImageClicked, true); + app.fineknn_2.HorizontalAlignment = 'right'; + app.fineknn_2.Position = [653 14 51 40]; + app.fineknn_2.ImageSource = 'grain.png'; + + % Create CubicKNNLabel + app.CubicKNNLabel = uilabel(app.KNN); + app.CubicKNNLabel.FontWeight = 'bold'; + app.CubicKNNLabel.Position = [714 23 133 22]; + app.CubicKNNLabel.Text = 'Cubic KNN'; + + % Create fineknn_3 + app.fineknn_3 = uiimage(app.KNN); + app.fineknn_3.ImageClickedFcn = createCallbackFcn(app, @fineknn_3ImageClicked, true); + app.fineknn_3.HorizontalAlignment = 'right'; + app.fineknn_3.Position = [859 14 51 40]; + app.fineknn_3.ImageSource = 'grain.png'; + + % Create CosineKNNLabel + app.CosineKNNLabel = uilabel(app.KNN); + app.CosineKNNLabel.FontWeight = 'bold'; + app.CosineKNNLabel.Position = [920 23 172 22]; + app.CosineKNNLabel.Text = 'Cosine KNN'; + + % Create SVM + app.SVM = uipanel(app.TrainingPanel); + app.SVM.BorderType = 'none'; + app.SVM.Title = 'SVM'; + app.SVM.BackgroundColor = [0.9412 0.9412 0.9412]; + app.SVM.FontName = 'Arial'; + app.SVM.FontWeight = 'bold'; + app.SVM.Position = [14 299 1206 89]; + + % Create linearsvm + app.linearsvm = uiimage(app.SVM); + app.linearsvm.ImageClickedFcn = createCallbackFcn(app, @linearsvmClicked, true); + app.linearsvm.HorizontalAlignment = 'right'; + app.linearsvm.Position = [25 12 51 40]; + app.linearsvm.ImageSource = 'vector.png'; + + % Create LinearSVMLabel + app.LinearSVMLabel = uilabel(app.SVM); + app.LinearSVMLabel.FontName = 'Arial'; + app.LinearSVMLabel.FontWeight = 'bold'; + app.LinearSVMLabel.Position = [87 21 144 22]; + app.LinearSVMLabel.Text = 'Linear SVM'; + + % Create QuadraticSVMLabel + app.QuadraticSVMLabel = uilabel(app.SVM); + app.QuadraticSVMLabel.FontName = 'Arial'; + app.QuadraticSVMLabel.FontWeight = 'bold'; + app.QuadraticSVMLabel.Position = [308 21 132 22]; + app.QuadraticSVMLabel.Text = 'Quadratic SVM'; + + % Create quadraticsvm + app.quadraticsvm = uiimage(app.SVM); + app.quadraticsvm.ImageClickedFcn = createCallbackFcn(app, @quadraticsvmImageClicked, true); + app.quadraticsvm.HorizontalAlignment = 'right'; + app.quadraticsvm.Position = [241 12 51 40]; + app.quadraticsvm.ImageSource = 'vector.png'; + + % Create Image5_4 + app.Image5_4 = uiimage(app.SVM); + app.Image5_4.ImageClickedFcn = createCallbackFcn(app, @Image5_4Clicked, true); + app.Image5_4.HorizontalAlignment = 'right'; + app.Image5_4.Position = [447 12 51 40]; + app.Image5_4.ImageSource = 'vector.png'; + + % Create CubicSVMLabel + app.CubicSVMLabel = uilabel(app.SVM); + app.CubicSVMLabel.FontName = 'Arial'; + app.CubicSVMLabel.FontWeight = 'bold'; + app.CubicSVMLabel.Position = [514 21 133 22]; + app.CubicSVMLabel.Text = 'Cubic SVM'; + + % Create Image5_6 + app.Image5_6 = uiimage(app.SVM); + app.Image5_6.ImageClickedFcn = createCallbackFcn(app, @Image5_6Clicked, true); + app.Image5_6.HorizontalAlignment = 'right'; + app.Image5_6.Position = [653 12 51 40]; + app.Image5_6.ImageSource = 'vector.png'; + + % Create FineGaussianSVMLabel + app.FineGaussianSVMLabel = uilabel(app.SVM); + app.FineGaussianSVMLabel.FontName = 'Arial'; + app.FineGaussianSVMLabel.FontWeight = 'bold'; + app.FineGaussianSVMLabel.Position = [720 21 140 22]; + app.FineGaussianSVMLabel.Text = 'Fine Gaussian SVM'; + + % Create Image5_7 + app.Image5_7 = uiimage(app.SVM); + app.Image5_7.ImageClickedFcn = createCallbackFcn(app, @Image5_7Clicked, true); + app.Image5_7.HorizontalAlignment = 'right'; + app.Image5_7.Position = [859 12 51 40]; + app.Image5_7.ImageSource = 'vector.png'; + + % Create MediumGaussianSVMLabel + app.MediumGaussianSVMLabel = uilabel(app.SVM); + app.MediumGaussianSVMLabel.FontName = 'Arial'; + app.MediumGaussianSVMLabel.FontWeight = 'bold'; + app.MediumGaussianSVMLabel.Position = [926 21 166 22]; + app.MediumGaussianSVMLabel.Text = 'Medium Gaussian SVM'; + + % Create Forest + app.Forest = uipanel(app.TrainingPanel); + app.Forest.BorderType = 'none'; + app.Forest.Title = 'Forest'; + app.Forest.BackgroundColor = [0.9412 0.9412 0.9412]; + app.Forest.FontName = 'Arial'; + app.Forest.FontWeight = 'bold'; + app.Forest.Position = [15 189 996 108]; + + % Create CoarseTree + app.CoarseTree = uiimage(app.Forest); + app.CoarseTree.ImageClickedFcn = createCallbackFcn(app, @CoarseTreeImageClicked, true); + app.CoarseTree.HorizontalAlignment = 'right'; + app.CoarseTree.Position = [241 19 51 40]; + app.CoarseTree.ImageSource = 'algorithm2.png'; + + % Create MediumTree + app.MediumTree = uiimage(app.Forest); + app.MediumTree.ImageClickedFcn = createCallbackFcn(app, @MediumTreeClicked, true); + app.MediumTree.HorizontalAlignment = 'right'; + app.MediumTree.Position = [28 20 51 40]; + app.MediumTree.ImageSource = 'algorithm2.png'; + + % Create MediumTreeLabel + app.MediumTreeLabel = uilabel(app.Forest); + app.MediumTreeLabel.FontName = 'Arial'; + app.MediumTreeLabel.FontWeight = 'bold'; + app.MediumTreeLabel.Position = [87 28 144 22]; + app.MediumTreeLabel.Text = 'Medium Tree'; + + % Create CoarseTreeLabel + app.CoarseTreeLabel = uilabel(app.Forest); + app.CoarseTreeLabel.FontName = 'Arial'; + app.CoarseTreeLabel.FontWeight = 'bold'; + app.CoarseTreeLabel.Position = [308 28 132 22]; + app.CoarseTreeLabel.Text = 'Coarse Tree'; + + % Create CoarseTree_2 + app.CoarseTree_2 = uiimage(app.Forest); + app.CoarseTree_2.ImageClickedFcn = createCallbackFcn(app, @CoarseTree_2ImageClicked, true); + app.CoarseTree_2.HorizontalAlignment = 'right'; + app.CoarseTree_2.Position = [447 19 51 40]; + app.CoarseTree_2.ImageSource = 'algorithm2.png'; + + % Create FineTreeLabel + app.FineTreeLabel = uilabel(app.Forest); + app.FineTreeLabel.FontName = 'Arial'; + app.FineTreeLabel.FontWeight = 'bold'; + app.FineTreeLabel.Position = [514 28 132 22]; + app.FineTreeLabel.Text = 'Fine Tree'; + + % Create Ensemble + app.Ensemble = uipanel(app.TrainingPanel); + app.Ensemble.BorderType = 'none'; + app.Ensemble.Title = 'Ensemble'; + app.Ensemble.BackgroundColor = [0.9412 0.9412 0.9412]; + app.Ensemble.FontName = 'Arial'; + app.Ensemble.FontWeight = 'bold'; + app.Ensemble.Position = [15 92 996 92]; + + % Create BoostedTrees + app.BoostedTrees = uiimage(app.Ensemble); + app.BoostedTrees.ImageClickedFcn = createCallbackFcn(app, @BoostedTreesImageClicked, true); + app.BoostedTrees.HorizontalAlignment = 'right'; + app.BoostedTrees.Position = [28 16 51 40]; + app.BoostedTrees.ImageSource = 'intersection.png'; + + % Create BoostedTreesLabel + app.BoostedTreesLabel = uilabel(app.Ensemble); + app.BoostedTreesLabel.FontName = 'Arial'; + app.BoostedTreesLabel.FontWeight = 'bold'; + app.BoostedTreesLabel.Position = [87 24 144 22]; + app.BoostedTreesLabel.Text = 'Boosted Trees'; + + % Create BaggedTree + app.BaggedTree = uiimage(app.Ensemble); + app.BaggedTree.ImageClickedFcn = createCallbackFcn(app, @BaggedTreeImageClicked, true); + app.BaggedTree.HorizontalAlignment = 'right'; + app.BaggedTree.Position = [241 15 51 40]; + app.BaggedTree.ImageSource = 'intersection.png'; + + % Create BaggedTreesLabel + app.BaggedTreesLabel = uilabel(app.Ensemble); + app.BaggedTreesLabel.FontName = 'Arial'; + app.BaggedTreesLabel.FontWeight = 'bold'; + app.BaggedTreesLabel.Position = [308 24 132 22]; + app.BaggedTreesLabel.Text = 'Bagged Trees'; + + % Create Discriminant + app.Discriminant = uiimage(app.Ensemble); + app.Discriminant.ImageClickedFcn = createCallbackFcn(app, @DiscriminantImageClicked, true); + app.Discriminant.HorizontalAlignment = 'right'; + app.Discriminant.Position = [447 16 51 40]; + app.Discriminant.ImageSource = 'intersection.png'; + + % Create DiscriminantLabel + app.DiscriminantLabel = uilabel(app.Ensemble); + app.DiscriminantLabel.FontName = 'Arial'; + app.DiscriminantLabel.FontWeight = 'bold'; + app.DiscriminantLabel.Position = [514 27 132 22]; + app.DiscriminantLabel.Text = 'Discriminant'; + + % Create RUSB + app.RUSB = uiimage(app.Ensemble); + app.RUSB.ImageClickedFcn = createCallbackFcn(app, @RUSBImageClicked, true); + app.RUSB.HorizontalAlignment = 'right'; + app.RUSB.Position = [653 16 51 40]; + app.RUSB.ImageSource = 'intersection.png'; + + % Create RUSBoostedLabel + app.RUSBoostedLabel = uilabel(app.Ensemble); + app.RUSBoostedLabel.FontName = 'Arial'; + app.RUSBoostedLabel.FontWeight = 'bold'; + app.RUSBoostedLabel.Position = [720 26 132 22]; + app.RUSBoostedLabel.Text = 'RUSBoosted'; + + % Create KFoldCrossValidationLabel + app.KFoldCrossValidationLabel = uilabel(app.TrainingPanel); + app.KFoldCrossValidationLabel.FontName = 'Arial'; + app.KFoldCrossValidationLabel.FontWeight = 'bold'; + app.KFoldCrossValidationLabel.FontColor = [0 0 1]; + app.KFoldCrossValidationLabel.Position = [150 554 148 39]; + app.KFoldCrossValidationLabel.Text = 'K-Fold Cross Validation'; + + % Create Image18 + app.Image18 = uiimage(app.TrainingPanel); + app.Image18.Position = [36 554 49 39]; + app.Image18.ImageSource = 'map-folded-paper (1).png'; + + % Create Spinner + app.Spinner = uispinner(app.TrainingPanel); + app.Spinner.Limits = [1 Inf]; + app.Spinner.ValueDisplayFormat = '%.0f'; + app.Spinner.HorizontalAlignment = 'center'; + app.Spinner.Position = [88 564 51 19]; + app.Spinner.Value = 5; + + % Create Image18_2 + app.Image18_2 = uiimage(app.TrainingPanel); + app.Image18_2.ImageClickedFcn = createCallbackFcn(app, @Image18_2Clicked, true); + app.Image18_2.Position = [408 552 45 41]; + app.Image18_2.ImageSource = 'border.png'; + + % Create Image19 + app.Image19 = uiimage(app.TrainingPanel); + app.Image19.ImageClickedFcn = createCallbackFcn(app, @Image19Clicked, true); + app.Image19.Position = [36 42 57 23]; + app.Image19.ImageSource = 'left-arrow.png'; + + % Create BacktoMainMenuLabel_8 + app.BacktoMainMenuLabel_8 = uilabel(app.TrainingPanel); + app.BacktoMainMenuLabel_8.FontWeight = 'bold'; + app.BacktoMainMenuLabel_8.Position = [88 43 113 22]; + app.BacktoMainMenuLabel_8.Text = 'Back to Main Menu'; + + % Create Image19_2 + app.Image19_2 = uiimage(app.TrainingPanel); + app.Image19_2.ImageClickedFcn = createCallbackFcn(app, @Image19_2Clicked, true); + app.Image19_2.Position = [15 22 98 23]; + app.Image19_2.ImageSource = 'left-arrow.png'; + + % Create BacktoPreviousMenuLabel_2 + app.BacktoPreviousMenuLabel_2 = uilabel(app.TrainingPanel); + app.BacktoPreviousMenuLabel_2.FontWeight = 'bold'; + app.BacktoPreviousMenuLabel_2.Position = [88 23 137 22]; + app.BacktoPreviousMenuLabel_2.Text = 'Back to Previous Menu'; + + % Create HoldOutSliderLabel + app.HoldOutSliderLabel = uilabel(app.TrainingPanel); + app.HoldOutSliderLabel.HorizontalAlignment = 'right'; + app.HoldOutSliderLabel.FontWeight = 'bold'; + app.HoldOutSliderLabel.FontColor = [0 0 1]; + app.HoldOutSliderLabel.Position = [452 571 55 22]; + app.HoldOutSliderLabel.Text = 'Hold Out'; + + % Create HoldOutSlider + app.HoldOutSlider = uislider(app.TrainingPanel); + app.HoldOutSlider.Limits = [0 50]; + app.HoldOutSlider.MajorTicks = [0 10 20 30 40 50]; + app.HoldOutSlider.MajorTickLabels = {'0', '10', '20', '30', '40', '50'}; + app.HoldOutSlider.MinorTicks = [0 10 20 30 40 50]; + app.HoldOutSlider.Enable = 'off'; + app.HoldOutSlider.FontWeight = 'bold'; + app.HoldOutSlider.FontColor = [0 0 1]; + app.HoldOutSlider.Position = [528 580 150 3]; + + % Create RunAllButton + app.RunAllButton = uibutton(app.TrainingPanel, 'push'); + app.RunAllButton.ButtonPushedFcn = createCallbackFcn(app, @RunAllButtonPushed, true); + app.RunAllButton.BackgroundColor = [0 0.451 0.7412]; + app.RunAllButton.FontWeight = 'bold'; + app.RunAllButton.FontColor = [1 1 1]; + app.RunAllButton.Position = [42 503 303 31]; + app.RunAllButton.Text = 'Run All'; + + % Create SyntheticDataButton + app.SyntheticDataButton = uibutton(app.TrainingPanel, 'push'); + app.SyntheticDataButton.ButtonPushedFcn = createCallbackFcn(app, @SyntheticDataButtonPushed, true); + app.SyntheticDataButton.BackgroundColor = [0.502 0.502 0.502]; + app.SyntheticDataButton.FontWeight = 'bold'; + app.SyntheticDataButton.FontColor = [1 1 1]; + app.SyntheticDataButton.Position = [727 503 119 31]; + app.SyntheticDataButton.Text = {'Synthetic Data'; ''}; + + % Create RankFeaturesButton + app.RankFeaturesButton = uibutton(app.TrainingPanel, 'push'); + app.RankFeaturesButton.ButtonPushedFcn = createCallbackFcn(app, @RankFeaturesButtonPushed, true); + app.RankFeaturesButton.BackgroundColor = [0.502 0.502 0.502]; + app.RankFeaturesButton.FontWeight = 'bold'; + app.RankFeaturesButton.FontColor = [1 1 1]; + app.RankFeaturesButton.Position = [1054 503 112 31]; + app.RankFeaturesButton.Text = 'Rank Features'; + + % Create ListBox_6 + app.ListBox_6 = uilistbox(app.TrainingPanel); + app.ListBox_6.Multiselect = 'on'; + app.ListBox_6.Visible = 'off'; + app.ListBox_6.FontWeight = 'bold'; + app.ListBox_6.BackgroundColor = [0.9412 0.9412 0.9412]; + app.ListBox_6.Position = [1180 296 123 236]; + app.ListBox_6.Value = {'Item 1'}; + + % Create FeaturesRankDescendingOrderLabel + app.FeaturesRankDescendingOrderLabel = uilabel(app.TrainingPanel); + app.FeaturesRankDescendingOrderLabel.Visible = 'off'; + app.FeaturesRankDescendingOrderLabel.Position = [1180 532 123 61]; + app.FeaturesRankDescendingOrderLabel.Text = {'Features'' Rank'; ''; '(Descending Order)'}; + + % Create SelectasPredictorsButton + app.SelectasPredictorsButton = uibutton(app.TrainingPanel, 'push'); + app.SelectasPredictorsButton.ButtonPushedFcn = createCallbackFcn(app, @SelectasPredictorsButtonPushed, true); + app.SelectasPredictorsButton.Visible = 'off'; + app.SelectasPredictorsButton.Position = [1173 253 121 22]; + app.SelectasPredictorsButton.Text = 'Select as Predictors'; + + % Create SelectedFeaturesLabel + app.SelectedFeaturesLabel = uilabel(app.TrainingPanel); + app.SelectedFeaturesLabel.VerticalAlignment = 'top'; + app.SelectedFeaturesLabel.Visible = 'off'; + app.SelectedFeaturesLabel.Position = [1165 85 138 162]; + app.SelectedFeaturesLabel.Text = 'Selected Features'; + + % Create SequentialFeatureSelectionButton + app.SequentialFeatureSelectionButton = uibutton(app.TrainingPanel, 'push'); + app.SequentialFeatureSelectionButton.ButtonPushedFcn = createCallbackFcn(app, @SequentialFeatureSelectionButtonPushed, true); + app.SequentialFeatureSelectionButton.BackgroundColor = [0.502 0.502 0.502]; + app.SequentialFeatureSelectionButton.FontWeight = 'bold'; + app.SequentialFeatureSelectionButton.FontColor = [1 1 1]; + app.SequentialFeatureSelectionButton.Position = [855 503 192 31]; + app.SequentialFeatureSelectionButton.Text = 'Sequential Feature Selection'; + + % Create RunsSpinner + app.RunsSpinner = uispinner(app.TrainingPanel); + app.RunsSpinner.Limits = [1 Inf]; + app.RunsSpinner.HorizontalAlignment = 'center'; + app.RunsSpinner.FontWeight = 'bold'; + app.RunsSpinner.FontColor = [1 1 1]; + app.RunsSpinner.BackgroundColor = [0 0.4471 0.7412]; + app.RunsSpinner.Position = [410 508 65 22]; + app.RunsSpinner.Value = 1; + + % Create RunsSpinnerLabel + app.RunsSpinnerLabel = uilabel(app.TrainingPanel); + app.RunsSpinnerLabel.HorizontalAlignment = 'right'; + app.RunsSpinnerLabel.FontWeight = 'bold'; + app.RunsSpinnerLabel.Position = [360 508 35 22]; + app.RunsSpinnerLabel.Text = 'Runs'; + + % Create ReportTrainer + app.ReportTrainer = uipanel(app.TrainingPanel); + app.ReportTrainer.BorderType = 'none'; + app.ReportTrainer.Position = [1096 8 243 63]; + + % Create ReportAll + app.ReportAll = uibutton(app.ReportTrainer, 'push'); + app.ReportAll.ButtonPushedFcn = createCallbackFcn(app, @ReportAllPushed, true); + app.ReportAll.BackgroundColor = [0.502 0.502 0.502]; + app.ReportAll.FontWeight = 'bold'; + app.ReportAll.FontColor = [1 1 1]; + app.ReportAll.Position = [59 3 149 42]; + app.ReportAll.Text = 'Reporter'; + + % Create AdvancedMenuPanel + app.AdvancedMenuPanel = uipanel(app.TrainerTab); + app.AdvancedMenuPanel.ForegroundColor = [0 0.4471 0.7412]; + app.AdvancedMenuPanel.TitlePosition = 'centertop'; + app.AdvancedMenuPanel.Title = 'Advanced Menu'; + app.AdvancedMenuPanel.Visible = 'off'; + app.AdvancedMenuPanel.FontName = 'Arial'; + app.AdvancedMenuPanel.FontWeight = 'bold'; + app.AdvancedMenuPanel.FontSize = 16; + app.AdvancedMenuPanel.Position = [1 28 1334 628]; + + % Create UITable2 + app.UITable2 = uitable(app.AdvancedMenuPanel); + app.UITable2.ColumnName = {''}; + app.UITable2.RowName = {}; + app.UITable2.CellSelectionCallback = createCallbackFcn(app, @UITable2CellSelection, true); + app.UITable2.Visible = 'off'; + app.UITable2.FontName = 'Arial'; + app.UITable2.Position = [373 46 880 534]; + + % Create Panel_3 + app.Panel_3 = uipanel(app.AdvancedMenuPanel); + app.Panel_3.BorderType = 'none'; + app.Panel_3.Position = [488 2 334 582]; + + % Create RESPONSEListBoxLabel + app.RESPONSEListBoxLabel = uilabel(app.Panel_3); + app.RESPONSEListBoxLabel.BackgroundColor = [0.3098 0.3608 0.4]; + app.RESPONSEListBoxLabel.HorizontalAlignment = 'right'; + app.RESPONSEListBoxLabel.FontColor = [1 1 1]; + app.RESPONSEListBoxLabel.Visible = 'off'; + app.RESPONSEListBoxLabel.Position = [103 106 71 22]; + app.RESPONSEListBoxLabel.Text = 'RESPONSE'; + + % Create RESPONSEListBox + app.RESPONSEListBox = uilistbox(app.Panel_3); + app.RESPONSEListBox.Items = {}; + app.RESPONSEListBox.Visible = 'off'; + app.RESPONSEListBox.FontColor = [1 1 1]; + app.RESPONSEListBox.BackgroundColor = [0.3098 0.3608 0.4]; + app.RESPONSEListBox.Position = [99 96 241 10]; + app.RESPONSEListBox.Value = {}; + + % Create trainer32 + app.trainer32 = uibutton(app.Panel_3, 'push'); + app.trainer32.ButtonPushedFcn = createCallbackFcn(app, @trainer32ButtonPushed, true); + app.trainer32.BackgroundColor = [0 0.451 0.7412]; + app.trainer32.FontName = 'Arial'; + app.trainer32.FontWeight = 'bold'; + app.trainer32.FontColor = [1 1 1]; + app.trainer32.Position = [99 358 130 42]; + app.trainer32.Text = 'Training'; + + % Create PREDICTORSListBoxLabel + app.PREDICTORSListBoxLabel = uilabel(app.Panel_3); + app.PREDICTORSListBoxLabel.BackgroundColor = [0.9412 0.9412 0.9412]; + app.PREDICTORSListBoxLabel.HorizontalAlignment = 'right'; + app.PREDICTORSListBoxLabel.FontName = 'Arial'; + app.PREDICTORSListBoxLabel.FontWeight = 'bold'; + app.PREDICTORSListBoxLabel.Position = [120 331 85 22]; + app.PREDICTORSListBoxLabel.Text = 'PREDICTORS'; + + % Create PREDICTORSListBox + app.PREDICTORSListBox = uilistbox(app.Panel_3); + app.PREDICTORSListBox.Items = {}; + app.PREDICTORSListBox.Multiselect = 'on'; + app.PREDICTORSListBox.ValueChangedFcn = createCallbackFcn(app, @PREDICTORSListBoxValueChanged, true); + app.PREDICTORSListBox.Tooltip = {'You can choose predictors from this listbox by clicking "Select Predictor"'}; + app.PREDICTORSListBox.FontName = 'Arial'; + app.PREDICTORSListBox.FontWeight = 'bold'; + app.PREDICTORSListBox.BackgroundColor = [0.9412 0.9412 0.9412]; + app.PREDICTORSListBox.Position = [43 211 250 118]; + app.PREDICTORSListBox.Value = {}; + + % Create TrainerLoad + app.TrainerLoad = uibutton(app.Panel_3, 'push'); + app.TrainerLoad.ButtonPushedFcn = createCallbackFcn(app, @TrainerLoadButtonPushed2, true); + app.TrainerLoad.BackgroundColor = [0.9412 0.9412 0.9412]; + app.TrainerLoad.FontName = 'Arial Black'; + app.TrainerLoad.Position = [112 478 102 52]; + app.TrainerLoad.Text = 'Load'; + + % Create predictor + app.predictor = uibutton(app.Panel_3, 'push'); + app.predictor.ButtonPushedFcn = createCallbackFcn(app, @predictorButtonPushed2, true); + app.predictor.BackgroundColor = [0.4706 0.6706 0.1882]; + app.predictor.FontName = 'Arial'; + app.predictor.FontWeight = 'bold'; + app.predictor.FontColor = [0.149 0.149 0.149]; + app.predictor.Position = [43 123 250 37]; + app.predictor.Text = 'Assign Predictors/Response'; + + % Create plots_3 + app.plots_3 = uibutton(app.Panel_3, 'push'); + app.plots_3.ButtonPushedFcn = createCallbackFcn(app, @plots_3ButtonPushed, true); + app.plots_3.BackgroundColor = [0.9412 0.9412 0.9412]; + app.plots_3.FontName = 'Arial'; + app.plots_3.FontWeight = 'bold'; + app.plots_3.FontColor = [0.149 0.149 0.149]; + app.plots_3.Position = [99 404 130 35]; + app.plots_3.Text = 'Plots'; + + % Create Image17 + app.Image17 = uiimage(app.Panel_3); + app.Image17.ImageClickedFcn = createCallbackFcn(app, @Image17Clicked, true); + app.Image17.Position = [31 10 22 19]; + app.Image17.ImageSource = 'left-arrow.png'; + + % Create BacktoMainMenuLabel_7 + app.BacktoMainMenuLabel_7 = uilabel(app.Panel_3); + app.BacktoMainMenuLabel_7.Position = [60 3 103 35]; + app.BacktoMainMenuLabel_7.Text = 'Back to Main Menu'; + + % Create ResponseDropDownLabel + app.ResponseDropDownLabel = uilabel(app.Panel_3); + app.ResponseDropDownLabel.BackgroundColor = [0.9412 0.9412 0.9412]; + app.ResponseDropDownLabel.HorizontalAlignment = 'right'; + app.ResponseDropDownLabel.FontName = 'Arial'; + app.ResponseDropDownLabel.FontWeight = 'bold'; + app.ResponseDropDownLabel.Position = [10 160 63 35]; + app.ResponseDropDownLabel.Text = 'Response'; + + % Create ResponseDropDown + app.ResponseDropDown = uidropdown(app.Panel_3); + app.ResponseDropDown.Items = {}; + app.ResponseDropDown.ValueChangedFcn = createCallbackFcn(app, @ResponseDropDownValueChanged, true); + app.ResponseDropDown.BackgroundColor = [1 1 1]; + app.ResponseDropDown.Position = [88 163 205 25]; + app.ResponseDropDown.Value = {}; + + % Create ApplyCRLBThresholdMRSpectroscopyButton + app.ApplyCRLBThresholdMRSpectroscopyButton = uibutton(app.Panel_3, 'push'); + app.ApplyCRLBThresholdMRSpectroscopyButton.ButtonPushedFcn = createCallbackFcn(app, @ApplyCRLBThresholdMRSpectroscopyButtonPushed, true); + app.ApplyCRLBThresholdMRSpectroscopyButton.Position = [42 89 241 25]; + app.ApplyCRLBThresholdMRSpectroscopyButton.Text = {'Apply CRLB Threshold-(MR Spectroscopy)'; ''}; + + % Create Selectsubtab + app.Selectsubtab = uibutton(app.Panel_3, 'push'); + app.Selectsubtab.ButtonPushedFcn = createCallbackFcn(app, @SelectsubtabButtonPushed, true); + app.Selectsubtab.BackgroundColor = [1 1 1]; + app.Selectsubtab.FontName = 'Arial'; + app.Selectsubtab.FontWeight = 'bold'; + app.Selectsubtab.FontColor = [0.149 0.149 0.149]; + app.Selectsubtab.Position = [22 51 133 31]; + app.Selectsubtab.Text = 'SelectSubTab'; + + % Create statisticaltests + app.statisticaltests = uibutton(app.Panel_3, 'push'); + app.statisticaltests.ButtonPushedFcn = createCallbackFcn(app, @statisticaltestsButtonPushed, true); + app.statisticaltests.BackgroundColor = [1 1 1]; + app.statisticaltests.FontName = 'Arial'; + app.statisticaltests.FontWeight = 'bold'; + app.statisticaltests.FontColor = [0.149 0.149 0.149]; + app.statisticaltests.Visible = 'off'; + app.statisticaltests.Position = [164 51 147 33]; + app.statisticaltests.Text = 'Perform Statistical Tests'; + + % Create PredictorsLabel + app.PredictorsLabel = uilabel(app.AdvancedMenuPanel); + app.PredictorsLabel.FontName = 'Arial'; + app.PredictorsLabel.FontWeight = 'bold'; + app.PredictorsLabel.FontAngle = 'italic'; + app.PredictorsLabel.FontColor = [0.4667 0.6745 0.1882]; + app.PredictorsLabel.Visible = 'off'; + app.PredictorsLabel.Position = [381 20 650 22]; + app.PredictorsLabel.Text = '*Predictors'; + + % Create ResponseLabel + app.ResponseLabel = uilabel(app.AdvancedMenuPanel); + app.ResponseLabel.FontName = 'Arial'; + app.ResponseLabel.FontWeight = 'bold'; + app.ResponseLabel.FontAngle = 'italic'; + app.ResponseLabel.FontColor = [0 0 1]; + app.ResponseLabel.Visible = 'off'; + app.ResponseLabel.Position = [381 2 665 21]; + app.ResponseLabel.Text = '*Response'; + + % Create UITable5 + app.UITable5 = uitable(app.AdvancedMenuPanel); + app.UITable5.ColumnName = {'Column 1'; 'Column 2'; 'Column 3'; 'Column 4'}; + app.UITable5.RowName = {}; + app.UITable5.Visible = 'off'; + app.UITable5.Position = [397 465 59 75]; + + % Create ModelParametersPanel + app.ModelParametersPanel = uipanel(app.TrainerTab); + app.ModelParametersPanel.BorderType = 'none'; + app.ModelParametersPanel.Title = 'Model Parameters'; + app.ModelParametersPanel.Visible = 'off'; + app.ModelParametersPanel.BackgroundColor = [0.902 0.902 0.902]; + app.ModelParametersPanel.Position = [13 61 1260 493]; + + % Create Tree2 + app.Tree2 = uitree(app.ModelParametersPanel); + app.Tree2.NodeExpandedFcn = createCallbackFcn(app, @Tree2NodeExpanded, true); + app.Tree2.FontWeight = 'bold'; + app.Tree2.BackgroundColor = [0.902 0.902 0.902]; + app.Tree2.Position = [3 166 318 260]; + + % Create models2 + app.models2 = uitreenode(app.Tree2); + app.models2.Text = 'models'; + + % Create Node2 + app.Node2 = uitreenode(app.models2); + app.Node2.Text = 'Node2'; + + % Create advancedList + app.advancedList = uilistbox(app.ModelParametersPanel); + app.advancedList.Items = {}; + app.advancedList.BackgroundColor = [0.902 0.902 0.902]; + app.advancedList.Position = [486 33 153 388]; + app.advancedList.Value = {}; + + % Create advancedPlot + app.advancedPlot = uibutton(app.ModelParametersPanel, 'push'); + app.advancedPlot.ButtonPushedFcn = createCallbackFcn(app, @advancedPlotButtonPushed, true); + app.advancedPlot.BackgroundColor = [0.4706 0.4471 0.4471]; + app.advancedPlot.FontWeight = 'bold'; + app.advancedPlot.FontColor = [1 1 1]; + app.advancedPlot.Position = [24 96 83 32]; + app.advancedPlot.Text = 'Plot'; + + % Create SubplotCheckBox + app.SubplotCheckBox = uicheckbox(app.ModelParametersPanel); + app.SubplotCheckBox.Text = 'Subplot'; + app.SubplotCheckBox.Position = [126 101 192 22]; + + % Create advancedPanel + app.advancedPanel = uipanel(app.ModelParametersPanel); + app.advancedPanel.BorderType = 'none'; + app.advancedPanel.BackgroundColor = [0.902 0.902 0.902]; + app.advancedPanel.Position = [650 35 611 386]; + + % Create Image22 + app.Image22 = uiimage(app.ModelParametersPanel); + app.Image22.ImageClickedFcn = createCallbackFcn(app, @Image22Clicked, true); + app.Image22.Position = [38 16 15 26]; + app.Image22.ImageSource = 'left-arrow.png'; + + % Create BacktoMainMenuLabel_11 + app.BacktoMainMenuLabel_11 = uilabel(app.ModelParametersPanel); + app.BacktoMainMenuLabel_11.Position = [59 17 103 26]; + app.BacktoMainMenuLabel_11.Text = 'Back to Main Menu'; + + % Create advancedPlot_2 + app.advancedPlot_2 = uibutton(app.ModelParametersPanel, 'push'); + app.advancedPlot_2.ButtonPushedFcn = createCallbackFcn(app, @advancedPlot_2ButtonPushed, true); + app.advancedPlot_2.BackgroundColor = [0.6392 0.0784 0.1804]; + app.advancedPlot_2.FontWeight = 'bold'; + app.advancedPlot_2.FontColor = [1 1 1]; + app.advancedPlot_2.Position = [332 120 146 37]; + app.advancedPlot_2.Text = 'Delete'; + + % Create ListBox_10 + app.ListBox_10 = uilistbox(app.ModelParametersPanel); + app.ListBox_10.Items = {}; + app.ListBox_10.FontWeight = 'bold'; + app.ListBox_10.BackgroundColor = [0.902 0.902 0.902]; + app.ListBox_10.Position = [332 171 150 254]; + app.ListBox_10.Value = {}; + + % Create MainMenuPanel_2 + app.MainMenuPanel_2 = uipanel(app.TrainerTab); + app.MainMenuPanel_2.ForegroundColor = [0 0.4471 0.7412]; + app.MainMenuPanel_2.BorderType = 'none'; + app.MainMenuPanel_2.TitlePosition = 'centertop'; + app.MainMenuPanel_2.Title = 'Main Menu'; + app.MainMenuPanel_2.BackgroundColor = [0.902 0.902 0.902]; + app.MainMenuPanel_2.FontName = 'Arial Black'; + app.MainMenuPanel_2.FontWeight = 'bold'; + app.MainMenuPanel_2.Position = [522 41 368 523]; + + % Create TrainNewModelButton + app.TrainNewModelButton = uibutton(app.MainMenuPanel_2, 'push'); + app.TrainNewModelButton.ButtonPushedFcn = createCallbackFcn(app, @TrainNewModelButtonPushed, true); + app.TrainNewModelButton.BackgroundColor = [0 0.4471 0.7412]; + app.TrainNewModelButton.FontWeight = 'bold'; + app.TrainNewModelButton.FontColor = [1 1 1]; + app.TrainNewModelButton.Position = [131 336 112 75]; + app.TrainNewModelButton.Text = 'Train New Model'; + + % Create TrainedModelsButton + app.TrainedModelsButton = uibutton(app.MainMenuPanel_2, 'push'); + app.TrainedModelsButton.ButtonPushedFcn = createCallbackFcn(app, @TrainedModelsButtonPushed, true); + app.TrainedModelsButton.BackgroundColor = [0.9412 0.9412 0.9412]; + app.TrainedModelsButton.FontName = 'Arial'; + app.TrainedModelsButton.FontWeight = 'bold'; + app.TrainedModelsButton.FontColor = [0 0.4471 0.7412]; + app.TrainedModelsButton.Position = [115 88 156 60]; + app.TrainedModelsButton.Text = 'Trained Models'; + + % Create PlotsButton_2 + app.PlotsButton_2 = uibutton(app.MainMenuPanel_2, 'push'); + app.PlotsButton_2.ButtonPushedFcn = createCallbackFcn(app, @PlotsButton_2Pushed, true); + app.PlotsButton_2.BackgroundColor = [0.4667 0.6745 0.1882]; + app.PlotsButton_2.FontName = 'Arial'; + app.PlotsButton_2.FontWeight = 'bold'; + app.PlotsButton_2.FontColor = [1 1 1]; + app.PlotsButton_2.Position = [115 39 156 36]; + app.PlotsButton_2.Text = 'Plots'; + + % Create Image20 + app.Image20 = uiimage(app.TrainerTab); + app.Image20.ImageClickedFcn = createCallbackFcn(app, @Image20Clicked, true); + app.Image20.Visible = 'off'; + app.Image20.Position = [662 300 131 89]; + app.Image20.ImageSource = 'dowload.png'; + + % Create ClicktoLoadDataLabel + app.ClicktoLoadDataLabel = uilabel(app.TrainerTab); + app.ClicktoLoadDataLabel.Visible = 'off'; + app.ClicktoLoadDataLabel.Position = [609 387 264 71]; + app.ClicktoLoadDataLabel.Text = 'Click to Load Data'; + + % Create BacktoMainMenuLabel_9 + app.BacktoMainMenuLabel_9 = uilabel(app.TrainerTab); + app.BacktoMainMenuLabel_9.Visible = 'off'; + app.BacktoMainMenuLabel_9.Position = [629 221 129 50]; + app.BacktoMainMenuLabel_9.Text = 'Back to Main Menu'; + + % Create Image20_2 + app.Image20_2 = uiimage(app.TrainerTab); + app.Image20_2.ImageClickedFcn = createCallbackFcn(app, @Image20_2Clicked, true); + app.Image20_2.Visible = 'off'; + app.Image20_2.Position = [592 236 23 22]; + app.Image20_2.ImageSource = 'left-arrow.png'; + + % Create modelsPlotALLadvanced + app.modelsPlotALLadvanced = uipanel(app.TrainerTab); + app.modelsPlotALLadvanced.Visible = 'off'; + app.modelsPlotALLadvanced.Position = [1 2 1358 611]; + + % Create modelsplotpaneladvanced + app.modelsplotpaneladvanced = uipanel(app.modelsPlotALLadvanced); + app.modelsplotpaneladvanced.BorderType = 'none'; + app.modelsplotpaneladvanced.TitlePosition = 'centertop'; + app.modelsplotpaneladvanced.Title = 'MODELS PLOT'; + app.modelsplotpaneladvanced.FontWeight = 'bold'; + app.modelsplotpaneladvanced.Position = [33 59 465 467]; + + % Create RefreshButton_3 + app.RefreshButton_3 = uibutton(app.modelsplotpaneladvanced, 'push'); + app.RefreshButton_3.ButtonPushedFcn = createCallbackFcn(app, @RefreshButton_3Pushed, true); + app.RefreshButton_3.BackgroundColor = [0 1 1]; + app.RefreshButton_3.FontWeight = 'bold'; + app.RefreshButton_3.Position = [106 136 135 30]; + app.RefreshButton_3.Text = 'Refresh'; + + % Create PlotButton_5 + app.PlotButton_5 = uibutton(app.modelsplotpaneladvanced, 'push'); + app.PlotButton_5.ButtonPushedFcn = createCallbackFcn(app, @PlotButton_5Pushed, true); + app.PlotButton_5.BackgroundColor = [0.4667 0.6745 0.1882]; + app.PlotButton_5.FontWeight = 'bold'; + app.PlotButton_5.FontColor = [1 1 1]; + app.PlotButton_5.Position = [247 136 146 30]; + app.PlotButton_5.Text = 'Plot'; + + % Create Image25 + app.Image25 = uiimage(app.modelsplotpaneladvanced); + app.Image25.ImageClickedFcn = createCallbackFcn(app, @Image25Clicked, true); + app.Image25.Position = [113 81 20 20]; + app.Image25.ImageSource = 'left-arrow.png'; + + % Create BacktoMainMenuLabel_13 + app.BacktoMainMenuLabel_13 = uilabel(app.modelsplotpaneladvanced); + app.BacktoMainMenuLabel_13.Position = [148 80 103 22]; + app.BacktoMainMenuLabel_13.Text = 'Back to Main Menu'; + + % Create ModelsListBox_4Label + app.ModelsListBox_4Label = uilabel(app.modelsplotpaneladvanced); + app.ModelsListBox_4Label.HorizontalAlignment = 'right'; + app.ModelsListBox_4Label.FontWeight = 'bold'; + app.ModelsListBox_4Label.Position = [8 414 47 22]; + app.ModelsListBox_4Label.Text = 'Models'; + + % Create ModelsListBox_4 + app.ModelsListBox_4 = uilistbox(app.modelsplotpaneladvanced); + app.ModelsListBox_4.Items = {}; + app.ModelsListBox_4.FontWeight = 'bold'; + app.ModelsListBox_4.BackgroundColor = [0.9412 0.9412 0.9412]; + app.ModelsListBox_4.Position = [102 185 302 253]; + app.ModelsListBox_4.Value = {}; + + % Create Panel_5 + app.Panel_5 = uipanel(app.modelsPlotALLadvanced); + app.Panel_5.Visible = 'off'; + app.Panel_5.BackgroundColor = [1 1 1]; + app.Panel_5.Position = [530 70 729 494]; + + % Create load_html + app.load_html = uihtml(app.TrainerTab); + app.load_html.DataChangedFcn = createCallbackFcn(app, @Image20Clicked, true); + app.load_html.Visible = 'off'; + app.load_html.Position = [652 290 141 99]; + + % Create Classifier + app.Classifier = uitab(app.AdvancedUser); + app.Classifier.Title = 'Classifier'; + app.Classifier.BackgroundColor = [1 1 1]; + + % Create ClassifierMainPanel + app.ClassifierMainPanel = uipanel(app.Classifier); + app.ClassifierMainPanel.ForegroundColor = [0.0745 0.6235 1]; + app.ClassifierMainPanel.BorderType = 'none'; + app.ClassifierMainPanel.TitlePosition = 'centertop'; + app.ClassifierMainPanel.Title = 'Classifier Main'; + app.ClassifierMainPanel.BackgroundColor = [1 1 1]; + app.ClassifierMainPanel.FontWeight = 'bold'; + app.ClassifierMainPanel.FontSize = 14; + app.ClassifierMainPanel.Position = [510 52 336 557]; + + % Create Image21 + app.Image21 = uiimage(app.ClassifierMainPanel); + app.Image21.ImageClickedFcn = createCallbackFcn(app, @Image21Clicked, true); + app.Image21.Visible = 'off'; + app.Image21.Position = [110 327 130 63]; + app.Image21.ImageSource = 'table.png'; + + % Create TableEntryLabel + app.TableEntryLabel = uilabel(app.ClassifierMainPanel); + app.TableEntryLabel.FontName = 'Arial'; + app.TableEntryLabel.FontSize = 14; + app.TableEntryLabel.FontWeight = 'bold'; + app.TableEntryLabel.Position = [127 405 131 43]; + app.TableEntryLabel.Text = {'Table Entry'; ''}; + + % Create Image21_2 + app.Image21_2 = uiimage(app.ClassifierMainPanel); + app.Image21_2.ImageClickedFcn = createCallbackFcn(app, @Image21_2Clicked, true); + app.Image21_2.Visible = 'off'; + app.Image21_2.Position = [113 138 127 76]; + app.Image21_2.ImageSource = 'rec.png'; + + % Create SingleDataPointEntryLabel + app.SingleDataPointEntryLabel = uilabel(app.ClassifierMainPanel); + app.SingleDataPointEntryLabel.FontName = 'Arial'; + app.SingleDataPointEntryLabel.FontSize = 14; + app.SingleDataPointEntryLabel.FontWeight = 'bold'; + app.SingleDataPointEntryLabel.Position = [100 229 162 63]; + app.SingleDataPointEntryLabel.Text = 'Single Data Point Entry'; + + % Create load_table + app.load_table = uihtml(app.ClassifierMainPanel); + app.load_table.DataChangedFcn = createCallbackFcn(app, @Image21Clicked, true); + app.load_table.Position = [136 290 143 113]; + + % Create load_single + app.load_single = uihtml(app.ClassifierMainPanel); + app.load_single.DataChangedFcn = createCallbackFcn(app, @Image21_2Clicked, true); + app.load_single.Position = [136 114 143 123]; + + % Create ExcelEntry + app.ExcelEntry = uipanel(app.Classifier); + app.ExcelEntry.BorderType = 'none'; + app.ExcelEntry.Visible = 'off'; + app.ExcelEntry.BackgroundColor = [1 1 1]; + app.ExcelEntry.Position = [34 51 1226 545]; + + % Create UITable3 + app.UITable3 = uitable(app.ExcelEntry); + app.UITable3.ColumnName = {'Column 1'; 'Column 2'; 'Column 3'; 'Column 4'}; + app.UITable3.RowName = {}; + app.UITable3.CellSelectionCallback = createCallbackFcn(app, @UITable3CellSelection, true); + app.UITable3.Position = [329 67 888 456]; + + % Create LoadButton_5 + app.LoadButton_5 = uibutton(app.ExcelEntry, 'push'); + app.LoadButton_5.ButtonPushedFcn = createCallbackFcn(app, @LoadButton_5Pushed, true); + app.LoadButton_5.BackgroundColor = [1 1 1]; + app.LoadButton_5.FontWeight = 'bold'; + app.LoadButton_5.Position = [39 446 257 46]; + app.LoadButton_5.Text = 'Load'; + + % Create MODELSListBox_4Label + app.MODELSListBox_4Label = uilabel(app.ExcelEntry); + app.MODELSListBox_4Label.HorizontalAlignment = 'right'; + app.MODELSListBox_4Label.FontWeight = 'bold'; + app.MODELSListBox_4Label.FontColor = [0 0 1]; + app.MODELSListBox_4Label.Position = [29 351 57 22]; + app.MODELSListBox_4Label.Text = 'MODELS'; + + % Create MODELSListBox_4 + app.MODELSListBox_4 = uilistbox(app.ExcelEntry); + app.MODELSListBox_4.Items = {}; + app.MODELSListBox_4.ValueChangedFcn = createCallbackFcn(app, @MODELSListBox_4ValueChanged, true); + app.MODELSListBox_4.Position = [101 147 194 228]; + app.MODELSListBox_4.Value = {}; + + % Create ClassifyButton_3 + app.ClassifyButton_3 = uibutton(app.ExcelEntry, 'push'); + app.ClassifyButton_3.ButtonPushedFcn = createCallbackFcn(app, @ClassifyButton_3Pushed, true); + app.ClassifyButton_3.BackgroundColor = [1 1 1]; + app.ClassifyButton_3.FontWeight = 'bold'; + app.ClassifyButton_3.Position = [39 397 256 40]; + app.ClassifyButton_3.Text = {'Classify'; ''}; + + % Create ExportClassesButton_2 + app.ExportClassesButton_2 = uibutton(app.ExcelEntry, 'push'); + app.ExportClassesButton_2.ButtonPushedFcn = createCallbackFcn(app, @ExportClassesButton_2Pushed, true); + app.ExportClassesButton_2.BackgroundColor = [0 0 1]; + app.ExportClassesButton_2.FontWeight = 'bold'; + app.ExportClassesButton_2.FontColor = [1 1 1]; + app.ExportClassesButton_2.Position = [39 67 258 26]; + app.ExportClassesButton_2.Text = {'Export Classes'; ''}; + + % Create Image23 + app.Image23 = uiimage(app.ExcelEntry); + app.Image23.ImageClickedFcn = createCallbackFcn(app, @Image23Clicked, true); + app.Image23.Position = [55 30 18 19]; + app.Image23.ImageSource = 'left-arrow.png'; + + % Create BacktoMainMenuLabel_12 + app.BacktoMainMenuLabel_12 = uilabel(app.ExcelEntry); + app.BacktoMainMenuLabel_12.Position = [83 29 103 22]; + app.BacktoMainMenuLabel_12.Text = 'Back to Main Menu'; + + % Create Label_13 + app.Label_13 = uilabel(app.ExcelEntry); + app.Label_13.FontWeight = 'bold'; + app.Label_13.FontAngle = 'italic'; + app.Label_13.Position = [348 37 615 22]; + app.Label_13.Text = ''; + + % Create Class2Label_2 + app.Class2Label_2 = uilabel(app.ExcelEntry); + app.Class2Label_2.FontWeight = 'bold'; + app.Class2Label_2.FontAngle = 'italic'; + app.Class2Label_2.FontColor = [0.3922 0.8314 0.0745]; + app.Class2Label_2.Visible = 'off'; + app.Class2Label_2.Position = [348 23 196 16]; + app.Class2Label_2.Text = '*Class 2'; + + % Create Label_11 + app.Label_11 = uilabel(app.ExcelEntry); + app.Label_11.FontWeight = 'bold'; + app.Label_11.FontAngle = 'italic'; + app.Label_11.FontColor = [1 0 0]; + app.Label_11.Position = [349 -3 25 22]; + app.Label_11.Text = ''; + + % Create ExportClassesButton_4 + app.ExportClassesButton_4 = uibutton(app.ExcelEntry, 'push'); + app.ExportClassesButton_4.ButtonPushedFcn = createCallbackFcn(app, @ExportClassesButton_4Pushed, true); + app.ExportClassesButton_4.BackgroundColor = [0 0 1]; + app.ExportClassesButton_4.FontWeight = 'bold'; + app.ExportClassesButton_4.FontColor = [1 1 1]; + app.ExportClassesButton_4.Visible = 'off'; + app.ExportClassesButton_4.Position = [264 -9 53 61]; + app.ExportClassesButton_4.Text = {'Export Classes'; ''}; + + % Create classes_res + app.classes_res = uihtml(app.ExcelEntry); + app.classes_res.Position = [398 1 817 30]; + + % Create ManualPanel + app.ManualPanel = uipanel(app.Classifier); + app.ManualPanel.ForegroundColor = [0.4667 0.6745 0.1882]; + app.ManualPanel.BorderType = 'none'; + app.ManualPanel.TitlePosition = 'centertop'; + app.ManualPanel.Title = 'Manual'; + app.ManualPanel.Visible = 'off'; + app.ManualPanel.BackgroundColor = [1 1 1]; + app.ManualPanel.FontWeight = 'bold'; + app.ManualPanel.Position = [329 49 888 532]; + + % Create Classify_2 + app.Classify_2 = uibutton(app.ManualPanel, 'push'); + app.Classify_2.ButtonPushedFcn = createCallbackFcn(app, @Classify_2ButtonPushed, true); + app.Classify_2.Icon = 'output-onlinepngtools (11).png'; + app.Classify_2.BackgroundColor = [0.251 0.3216 0.2]; + app.Classify_2.FontName = 'Arial'; + app.Classify_2.FontSize = 18; + app.Classify_2.FontWeight = 'bold'; + app.Classify_2.FontColor = [0.902 0.902 0.902]; + app.Classify_2.Enable = 'off'; + app.Classify_2.Position = [165 46 178 45]; + app.Classify_2.Text = ''; + + % Create EnterButton_2 + app.EnterButton_2 = uibutton(app.ManualPanel, 'push'); + app.EnterButton_2.ButtonPushedFcn = createCallbackFcn(app, @EnterButton_2Pushed, true); + app.EnterButton_2.Icon = 'plus.png'; + app.EnterButton_2.BackgroundColor = [1 1 1]; + app.EnterButton_2.FontName = 'Arial'; + app.EnterButton_2.FontSize = 14; + app.EnterButton_2.FontWeight = 'bold'; + app.EnterButton_2.Position = [342 429 111 50]; + app.EnterButton_2.Text = 'Enter'; + + % Create MetaboliteMenuDropDown_2 + app.MetaboliteMenuDropDown_2 = uidropdown(app.ManualPanel); + app.MetaboliteMenuDropDown_2.Items = {}; + app.MetaboliteMenuDropDown_2.FontName = 'Arial'; + app.MetaboliteMenuDropDown_2.BackgroundColor = [1 1 1]; + app.MetaboliteMenuDropDown_2.Position = [39 439 226 26]; + app.MetaboliteMenuDropDown_2.Value = {}; + + % Create EditField_2 + app.EditField_2 = uieditfield(app.ManualPanel, 'text'); + app.EditField_2.ValueChangedFcn = createCallbackFcn(app, @EditField_2ValueChanged, true); + app.EditField_2.Position = [274 439 51 26]; + + % Create ListBox_3 + app.ListBox_3 = uilistbox(app.ManualPanel); + app.ListBox_3.Items = {}; + app.ListBox_3.ValueChangedFcn = createCallbackFcn(app, @ListBox_3ValueChanged, true); + app.ListBox_3.FontName = 'Arial'; + app.ListBox_3.FontSize = 14; + app.ListBox_3.FontWeight = 'bold'; + app.ListBox_3.Position = [264 101 201 305]; + app.ListBox_3.Value = {}; + + % Create Tree3_2 + app.Tree3_2 = uitree(app.ManualPanel); + app.Tree3_2.SelectionChangedFcn = createCallbackFcn(app, @Tree3_2SelectionChanged, true); + app.Tree3_2.FontName = 'Bodoni MT'; + app.Tree3_2.Position = [39 100 204 308]; + + % Create modelsd_2 + app.modelsd_2 = uitreenode(app.Tree3_2); + app.modelsd_2.Text = 'models'; + + % Create PredictorsLabel_2 + app.PredictorsLabel_2 = uilabel(app.ManualPanel); + app.PredictorsLabel_2.FontName = 'Arial'; + app.PredictorsLabel_2.FontSize = 14; + app.PredictorsLabel_2.FontAngle = 'italic'; + app.PredictorsLabel_2.Position = [53 472 239 31]; + app.PredictorsLabel_2.Text = 'Predictors'; + + % Create Image9_2 + app.Image9_2 = uiimage(app.ManualPanel); + app.Image9_2.ImageClickedFcn = createCallbackFcn(app, @Image9_2Clicked, true); + app.Image9_2.Position = [8 16 23 45]; + app.Image9_2.ImageSource = 'left-arrow.png'; + + % Create BacktoMainMenuLabel_10 + app.BacktoMainMenuLabel_10 = uilabel(app.ManualPanel); + app.BacktoMainMenuLabel_10.FontName = 'Arial'; + app.BacktoMainMenuLabel_10.Position = [39 16 103 45]; + app.BacktoMainMenuLabel_10.Text = {'Back to Main Menu'; ''}; + + % Create ModelMetricsPanel_2 + app.ModelMetricsPanel_2 = uipanel(app.ManualPanel); + app.ModelMetricsPanel_2.BorderType = 'none'; + app.ModelMetricsPanel_2.Title = 'Model Metrics'; + app.ModelMetricsPanel_2.Visible = 'off'; + app.ModelMetricsPanel_2.BackgroundColor = [1 1 1]; + app.ModelMetricsPanel_2.FontName = 'Arial'; + app.ModelMetricsPanel_2.FontAngle = 'italic'; + app.ModelMetricsPanel_2.Position = [527 45 289 450]; + + % Create ListBox_4 + app.ListBox_4 = uilistbox(app.ModelMetricsPanel_2); + app.ListBox_4.Items = {}; + app.ListBox_4.Visible = 'off'; + app.ListBox_4.FontName = 'Arial'; + app.ListBox_4.FontSize = 14; + app.ListBox_4.FontWeight = 'bold'; + app.ListBox_4.BackgroundColor = [0.502 0.502 0.502]; + app.ListBox_4.Position = [21 90 10 321]; + app.ListBox_4.Value = {}; + + % Create Image8_4 + app.Image8_4 = uiimage(app.ModelMetricsPanel_2); + app.Image8_4.Position = [31 344 40 38]; + app.Image8_4.ImageSource = 'output-onlinepngtools (18).png'; + + % Create Image8_5 + app.Image8_5 = uiimage(app.ModelMetricsPanel_2); + app.Image8_5.Position = [31 264 40 38]; + app.Image8_5.ImageSource = 'precision.png'; + + % Create Image8_6 + app.Image8_6 = uiimage(app.ModelMetricsPanel_2); + app.Image8_6.Position = [31 184 40 38]; + app.Image8_6.ImageSource = 'call-center.png'; + + % Create AccuracyLabel_2 + app.AccuracyLabel_2 = uilabel(app.ModelMetricsPanel_2); + app.AccuracyLabel_2.FontName = 'Arial'; + app.AccuracyLabel_2.FontSize = 14; + app.AccuracyLabel_2.FontColor = [0.302 0.7451 0.9333]; + app.AccuracyLabel_2.Position = [94 353 65 22]; + app.AccuracyLabel_2.Text = 'Accuracy'; + + % Create SpecificityLabel_2 + app.SpecificityLabel_2 = uilabel(app.ModelMetricsPanel_2); + app.SpecificityLabel_2.FontName = 'Arial'; + app.SpecificityLabel_2.FontSize = 14; + app.SpecificityLabel_2.Position = [94 275 176 22]; + app.SpecificityLabel_2.Text = 'Specificity'; + + % Create SensitivityLabel_2 + app.SensitivityLabel_2 = uilabel(app.ModelMetricsPanel_2); + app.SensitivityLabel_2.FontName = 'Arial'; + app.SensitivityLabel_2.FontSize = 14; + app.SensitivityLabel_2.Position = [94 186 244 36]; + app.SensitivityLabel_2.Text = 'Sensitivity'; + + % Create NaNLabel_5 + app.NaNLabel_5 = uilabel(app.ModelMetricsPanel_2); + app.NaNLabel_5.FontName = 'Arial'; + app.NaNLabel_5.FontSize = 16; + app.NaNLabel_5.FontColor = [0.302 0.7451 0.9333]; + app.NaNLabel_5.Position = [183 333 175 66]; + app.NaNLabel_5.Text = 'NaN'; + + % Create NaNLabel_6 + app.NaNLabel_6 = uilabel(app.ModelMetricsPanel_2); + app.NaNLabel_6.FontName = 'Arial'; + app.NaNLabel_6.FontSize = 16; + app.NaNLabel_6.Position = [183 273 175 22]; + app.NaNLabel_6.Text = 'NaN'; + + % Create NaNLabel_7 + app.NaNLabel_7 = uilabel(app.ModelMetricsPanel_2); + app.NaNLabel_7.FontName = 'Arial'; + app.NaNLabel_7.FontSize = 16; + app.NaNLabel_7.Position = [181 186 197 31]; + app.NaNLabel_7.Text = 'NaN'; + + % Create Image15_2 + app.Image15_2 = uiimage(app.ModelMetricsPanel_2); + app.Image15_2.Position = [31 100 40 38]; + app.Image15_2.ImageSource = 'analysis.png'; + + % Create ResultLabel_2 + app.ResultLabel_2 = uilabel(app.ModelMetricsPanel_2); + app.ResultLabel_2.FontName = 'Arial'; + app.ResultLabel_2.FontSize = 14; + app.ResultLabel_2.Position = [94 108 65 22]; + app.ResultLabel_2.Text = 'Result'; + + % Create NaNLabel_8 + app.NaNLabel_8 = uilabel(app.ModelMetricsPanel_2); + app.NaNLabel_8.FontName = 'Arial'; + app.NaNLabel_8.FontSize = 16; + app.NaNLabel_8.Position = [181 106 197 31]; + app.NaNLabel_8.Text = 'NaN'; + + % Create About + app.About = uitabgroup(app.GliomaIDHMutationDiagnosisToolUIFigure); + app.About.Position = [172 -7 1338 680]; + + % Create AcknowledgementsTab + app.AcknowledgementsTab = uitab(app.About); + app.AcknowledgementsTab.Title = 'Acknowledgements'; + app.AcknowledgementsTab.BackgroundColor = [1 1 1]; + + % Create Label + app.Label = uilabel(app.AcknowledgementsTab); + app.Label.FontName = 'Arial Black'; + app.Label.FontSize = 16; + app.Label.FontWeight = 'bold'; + app.Label.Position = [145 518 1476 63]; + app.Label.Text = {'This application software has been funded by TÜBÿTAK 1003 grant 216S432.'; ''}; + + % Create Image4 + app.Image4 = uiimage(app.AcknowledgementsTab); + app.Image4.Position = [477 125 127 131]; + app.Image4.ImageSource = 'Boÿaziçi_Üniversitesi_Logo.png'; + + % Create Image4_2 + app.Image4_2 = uiimage(app.AcknowledgementsTab); + app.Image4_2.ScaleMethod = 'fill'; + app.Image4_2.Position = [605 17 448 341]; + app.Image4_2.ImageSource = 'ACU.jpg'; + + % Create ProjectTeamTab + app.ProjectTeamTab = uitab(app.About); + app.ProjectTeamTab.Title = 'Project Team'; + app.ProjectTeamTab.BackgroundColor = [1 1 1]; + + % Create Image3 + app.Image3 = uiimage(app.ProjectTeamTab); + app.Image3.Position = [-65 67 1439 588]; + app.Image3.ImageSource = '1.jpg'; + + % Create PublicationsTab + app.PublicationsTab = uitab(app.About); + app.PublicationsTab.Title = 'Publications'; + app.PublicationsTab.BackgroundColor = [1 1 1]; + + % Create PublicationsLabel + app.PublicationsLabel = uilabel(app.PublicationsTab); + app.PublicationsLabel.FontName = 'Arial'; + app.PublicationsLabel.FontSize = 25; + app.PublicationsLabel.FontWeight = 'bold'; + app.PublicationsLabel.Position = [17 574 225 67]; + app.PublicationsLabel.Text = 'Publications'; + + % Create Label_2 + app.Label_2 = uilabel(app.PublicationsTab); + app.Label_2.Position = [92 519 1107 27]; + app.Label_2.Text = {'1. Ozturk-Isik, E., Cengiz, S., Ozcan, A., Yakicier, C., A. Danyeli, E., Pamir, M. N., et al.. (2019). Identification of IDH and TERTp mutation status using 1H-MRS in 112 hemispheric diffuse gliomas. Journal of '; ' Magnetic Resonance Imaging.Retrieved from https://doi.org/10.1002/jmri.26964'}; + + % Create Label_3 + app.Label_3 = uilabel(app.PublicationsTab); + app.Label_3.Position = [92 475 1107 27]; + app.Label_3.Text = {'2. Aras FK, Halilibrahimoglu H, Renkli N, Kaykayoglu A, Ozduman K, Ozturk-Isik E, Pamir N, Dincer A, Ozcan A. Investigating Distal ADC Distribution for Radiogenomic Classification of Gliomas via Machine '; ' Learning. European Society of Magnetic Resonance in Medicine and Biology Annual Conference. Virtual Meeting, September 30 ÿ October 2, 2020. (e-poster presentation)'}; + + % Create Label_4 + app.Label_4 = uilabel(app.PublicationsTab); + app.Label_4.Position = [92 431 1108 27]; + app.Label_4.Text = {'3. Ozturk-Isik E, Sacli-Bilmez B, Danyeli AE, Ozcan A, Yakicier C, Pamir MN, Ozduman, Dincer A. The effect of Tumor Grade within IDH Wild-Type and IDH Mutant Gliomas Assessed by Proton Magnetic '; ' Resonance Spectroscopy at 3T. International Society for Magnetic Resonance in Medicine. Virtual Meeting, August 8-14, 2020. (oral presentation)'}; + + % Create Label_5 + app.Label_5 = uilabel(app.PublicationsTab); + app.Label_5.Position = [94 387 1107 27]; + app.Label_5.Text = {'4. Sacli-Bilmez B, Gursan A, Danyeli AE, Yakicier C, Pamir MN, Ozduman, Dincer A, Ozturk-Isik E. MR Spectroscopic Differences of Low and High Grade TERTp-only Gliomas. International Society for '; ' Magnetic Resonance in Medicine. Virtual Meeting, August 8-14, 2020. (e-poster)'}; + + % Create Label_6 + app.Label_6 = uilabel(app.PublicationsTab); + app.Label_6.Position = [92 343 1111 27]; + app.Label_6.Text = {'5. Gursan A, Sahin H, Altun B, Talas AT, Hatay GH, Kocaturk O, Garipcan B, Dincer A, Ozturk-Isik E. An MRS Phantom Design with Multiple Compartments for Mimicking IDH Mutant and IDH Wild-Type Brain '; ' Tumors. European Society of Magnetic Resonance in Medicine and Biology Annual Conference. Rotterdam, Netherlands, October 3-5, 2019. (e-poster)'}; + + % Create Label_7 + app.Label_7 = uilabel(app.PublicationsTab); + app.Label_7.Position = [94 299 1110 27]; + app.Label_7.Text = {'6. Gursan A, Hatay GH, Yakcer C, Pamir MN, Ozduman K, Dincer A, Ozturk-Isik E. Comparison of MEGA-PRESS and Short Echo Time PRESS on Classification of IDH Mutation Using Machine Learning at '; ' 3T. International Society for Magnetic Resonance in Medicine. Montreal, Canada, May 11-16, 2019. (digital poster)'}; + + % Create Label_8 + app.Label_8 = uilabel(app.PublicationsTab); + app.Label_8.Position = [94 255 1112 27]; + app.Label_8.Text = {'7. Halilibrahimoglu H, Polat K, Keskin S, Aslan O, Genc O, Ozduman K, Yakicier C, Ozturk-Isik E, Pamir MN, Dincer A, Ozcan A. Testing Machine Learning Algorithms using Anisotropy Indices of Normal '; ' Appearing White Matter as Predictors of Molecular Group of Gliomas. International Society for Magnetic Resonance in Medicine. Montreal, Canada, May 11-16, 2019. (digital poster)'}; + + % Create Label_9 + app.Label_9 = uilabel(app.PublicationsTab); + app.Label_9.Position = [94 211 1109 27]; + app.Label_9.Text = {'8. Ozturk-Isik E, Cengiz S, Ozcan A, Yakicier C, Pamir MN, Ozduman K, and Dincer A. Magnetic Resonance Spectroscopic Differences of Diffuse Glioma Groups Classified by ÿDH and TERT Promoter'; ' Mutations at 3T. International Society for Magnetic Resonance in Medicine. Paris, France, June 16-21, 2018. (oral presentation)'}; + + % Create Label_10 + app.Label_10 = uilabel(app.PublicationsTab); + app.Label_10.Position = [94 166 1117 27]; + app.Label_10.Text = {'9. Ozturk-Isik E, Cengiz S, Ozduman K, Ozcan A, Yakicier C, Pamir MN, Dincer A. Prediction of IDH-Mutation Status of Diffuse-Gliomas Based on Short- Echo Time Magnetic Resonance Spectroscopy at 3T. '; ' International Society of Magnetic Resonance in Medicine Annual Conference, Honolulu, HI, USA, 22-27 April 2017. (e-poster)'}; + + % Create MassSpectroscopy + app.MassSpectroscopy = uitabgroup(app.GliomaIDHMutationDiagnosisToolUIFigure); + app.MassSpectroscopy.Visible = 'off'; + app.MassSpectroscopy.Position = [172 -8 1359 682]; + + % Create MassSpectroscopyTab + app.MassSpectroscopyTab = uitab(app.MassSpectroscopy); + app.MassSpectroscopyTab.Title = 'Mass Spectroscopy'; + app.MassSpectroscopyTab.BackgroundColor = [1 1 1]; + app.MassSpectroscopyTab.Scrollable = 'on'; + + % Create ManualEntryPan_2 + app.ManualEntryPan_2 = uipanel(app.MassSpectroscopyTab); + app.ManualEntryPan_2.BorderType = 'none'; + app.ManualEntryPan_2.Visible = 'off'; + app.ManualEntryPan_2.BackgroundColor = [1 1 1]; + app.ManualEntryPan_2.FontWeight = 'bold'; + app.ManualEntryPan_2.Position = [417 58 467 493]; + + % Create Classify_3 + app.Classify_3 = uibutton(app.ManualEntryPan_2, 'push'); + app.Classify_3.ButtonPushedFcn = createCallbackFcn(app, @Classify_3ButtonPushed, true); + app.Classify_3.Icon = 'output-onlinepngtools (11).png'; + app.Classify_3.BackgroundColor = [0.251 0.3216 0.2]; + app.Classify_3.FontName = 'Arial'; + app.Classify_3.FontSize = 18; + app.Classify_3.FontWeight = 'bold'; + app.Classify_3.FontColor = [0.902 0.902 0.902]; + app.Classify_3.Enable = 'off'; + app.Classify_3.Position = [172 45 178 45]; + app.Classify_3.Text = ''; + + % Create EnterButton_3 + app.EnterButton_3 = uibutton(app.ManualEntryPan_2, 'push'); + app.EnterButton_3.ButtonPushedFcn = createCallbackFcn(app, @EnterButton_3Pushed, true); + app.EnterButton_3.Icon = 'plus.png'; + app.EnterButton_3.BackgroundColor = [1 1 1]; + app.EnterButton_3.FontName = 'Arial'; + app.EnterButton_3.FontSize = 14; + app.EnterButton_3.FontWeight = 'bold'; + app.EnterButton_3.Position = [349 428 111 50]; + app.EnterButton_3.Text = 'Enter'; + + % Create MetaboliteMenuDropDown_3 + app.MetaboliteMenuDropDown_3 = uidropdown(app.ManualEntryPan_2); + app.MetaboliteMenuDropDown_3.Items = {'Glyc', 'GSH', 'HG2', 'Ins', 'Lac', 'GPc_Pch', 'tNAA', 'tCR', 'Glx'}; + app.MetaboliteMenuDropDown_3.FontName = 'Arial'; + app.MetaboliteMenuDropDown_3.BackgroundColor = [1 1 1]; + app.MetaboliteMenuDropDown_3.Position = [119 438 153 26]; + app.MetaboliteMenuDropDown_3.Value = 'Glyc'; + + % Create Image2_2 + app.Image2_2 = uiimage(app.ManualEntryPan_2); + app.Image2_2.ImageClickedFcn = createCallbackFcn(app, @Image2_2Clicked, true); + app.Image2_2.Position = [58 422 38 61]; + app.Image2_2.ImageSource = 'multiple-variable-lines-graphic.png'; + + % Create EditField_3 + app.EditField_3 = uieditfield(app.ManualEntryPan_2, 'text'); + app.EditField_3.Position = [281 438 51 26]; + + % Create ListBox_7 + app.ListBox_7 = uilistbox(app.ManualEntryPan_2); + app.ListBox_7.Items = {}; + app.ListBox_7.FontName = 'Arial'; + app.ListBox_7.FontSize = 14; + app.ListBox_7.FontWeight = 'bold'; + app.ListBox_7.Position = [271 100 201 305]; + app.ListBox_7.Value = {}; + + % Create Tree3_3 + app.Tree3_3 = uitree(app.ManualEntryPan_2); + app.Tree3_3.SelectionChangedFcn = createCallbackFcn(app, @Tree3_3SelectionChanged, true); + app.Tree3_3.FontName = 'Bodoni MT'; + app.Tree3_3.Position = [46 99 204 308]; + + % Create modelsd_3 + app.modelsd_3 = uitreenode(app.Tree3_3); + app.modelsd_3.Text = 'models'; + + % Create MetaboliteConcentrationEntryLabel_2 + app.MetaboliteConcentrationEntryLabel_2 = uilabel(app.ManualEntryPan_2); + app.MetaboliteConcentrationEntryLabel_2.FontName = 'Arial'; + app.MetaboliteConcentrationEntryLabel_2.FontSize = 14; + app.MetaboliteConcentrationEntryLabel_2.FontAngle = 'italic'; + app.MetaboliteConcentrationEntryLabel_2.Position = [60 471 239 31]; + app.MetaboliteConcentrationEntryLabel_2.Text = 'Metabolite Concentration Entry'; + + % Create Image9_3 + app.Image9_3 = uiimage(app.ManualEntryPan_2); + app.Image9_3.ImageClickedFcn = createCallbackFcn(app, @Image9_3Clicked, true); + app.Image9_3.Position = [15 15 23 45]; + app.Image9_3.ImageSource = 'left-arrow.png'; + + % Create BacktoMainMenuLabel_14 + app.BacktoMainMenuLabel_14 = uilabel(app.ManualEntryPan_2); + app.BacktoMainMenuLabel_14.FontName = 'Arial'; + app.BacktoMainMenuLabel_14.Position = [46 15 103 45]; + app.BacktoMainMenuLabel_14.Text = {'Back to Main Menu'; ''}; + + % Create ModelMetricsPanel_3 + app.ModelMetricsPanel_3 = uipanel(app.MassSpectroscopyTab); + app.ModelMetricsPanel_3.BorderType = 'none'; + app.ModelMetricsPanel_3.Title = 'Model Metrics'; + app.ModelMetricsPanel_3.Visible = 'off'; + app.ModelMetricsPanel_3.BackgroundColor = [1 1 1]; + app.ModelMetricsPanel_3.FontName = 'Arial'; + app.ModelMetricsPanel_3.FontAngle = 'italic'; + app.ModelMetricsPanel_3.Position = [916 72 321 460]; + + % Create ListBox_8 + app.ListBox_8 = uilistbox(app.ModelMetricsPanel_3); + app.ListBox_8.Items = {}; + app.ListBox_8.Visible = 'off'; + app.ListBox_8.FontName = 'Arial'; + app.ListBox_8.FontSize = 14; + app.ListBox_8.FontWeight = 'bold'; + app.ListBox_8.BackgroundColor = [0.502 0.502 0.502]; + app.ListBox_8.Position = [21 100 10 321]; + app.ListBox_8.Value = {}; + + % Create Image8_7 + app.Image8_7 = uiimage(app.ModelMetricsPanel_3); + app.Image8_7.Position = [31 354 40 38]; + app.Image8_7.ImageSource = 'output-onlinepngtools (18).png'; + + % Create Image8_8 + app.Image8_8 = uiimage(app.ModelMetricsPanel_3); + app.Image8_8.Position = [31 274 40 38]; + app.Image8_8.ImageSource = 'precision.png'; + + % Create Image8_9 + app.Image8_9 = uiimage(app.ModelMetricsPanel_3); + app.Image8_9.Position = [31 194 40 38]; + app.Image8_9.ImageSource = 'call-center.png'; + + % Create AccuracyLabel_3 + app.AccuracyLabel_3 = uilabel(app.ModelMetricsPanel_3); + app.AccuracyLabel_3.FontName = 'Arial'; + app.AccuracyLabel_3.FontSize = 14; + app.AccuracyLabel_3.FontColor = [0.302 0.7451 0.9333]; + app.AccuracyLabel_3.Position = [94 363 65 22]; + app.AccuracyLabel_3.Text = 'Accuracy'; + + % Create SpecificityLabel_3 + app.SpecificityLabel_3 = uilabel(app.ModelMetricsPanel_3); + app.SpecificityLabel_3.FontName = 'Arial'; + app.SpecificityLabel_3.FontSize = 14; + app.SpecificityLabel_3.Position = [94 285 176 22]; + app.SpecificityLabel_3.Text = 'Specificity'; + + % Create SensitivityLabel_3 + app.SensitivityLabel_3 = uilabel(app.ModelMetricsPanel_3); + app.SensitivityLabel_3.FontName = 'Arial'; + app.SensitivityLabel_3.FontSize = 14; + app.SensitivityLabel_3.Position = [94 196 244 36]; + app.SensitivityLabel_3.Text = 'Sensitivity'; + + % Create NaNLabel_9 + app.NaNLabel_9 = uilabel(app.ModelMetricsPanel_3); + app.NaNLabel_9.FontName = 'Arial'; + app.NaNLabel_9.FontSize = 16; + app.NaNLabel_9.FontColor = [0.302 0.7451 0.9333]; + app.NaNLabel_9.Position = [183 343 175 66]; + app.NaNLabel_9.Text = 'NaN'; + + % Create NaNLabel_10 + app.NaNLabel_10 = uilabel(app.ModelMetricsPanel_3); + app.NaNLabel_10.FontName = 'Arial'; + app.NaNLabel_10.FontSize = 16; + app.NaNLabel_10.Position = [183 283 175 22]; + app.NaNLabel_10.Text = 'NaN'; + + % Create NaNLabel_11 + app.NaNLabel_11 = uilabel(app.ModelMetricsPanel_3); + app.NaNLabel_11.FontName = 'Arial'; + app.NaNLabel_11.FontSize = 16; + app.NaNLabel_11.Position = [181 196 197 31]; + app.NaNLabel_11.Text = 'NaN'; + + % Create Image15_3 + app.Image15_3 = uiimage(app.ModelMetricsPanel_3); + app.Image15_3.ImageClickedFcn = createCallbackFcn(app, @Image15_3Clicked, true); + app.Image15_3.Position = [31 110 40 38]; + app.Image15_3.ImageSource = 'analysis.png'; + + % Create ResultLabel_3 + app.ResultLabel_3 = uilabel(app.ModelMetricsPanel_3); + app.ResultLabel_3.FontName = 'Arial'; + app.ResultLabel_3.FontSize = 14; + app.ResultLabel_3.Position = [94 118 65 22]; + app.ResultLabel_3.Text = 'Result'; + + % Create NaNLabel_12 + app.NaNLabel_12 = uilabel(app.ModelMetricsPanel_3); + app.NaNLabel_12.FontName = 'Arial'; + app.NaNLabel_12.FontSize = 16; + app.NaNLabel_12.Position = [181 116 197 31]; + app.NaNLabel_12.Text = 'NaN'; + + % Create MainMenuPanel_3 + app.MainMenuPanel_3 = uipanel(app.MassSpectroscopyTab); + app.MainMenuPanel_3.ForegroundColor = [0.302 0.7451 0.9333]; + app.MainMenuPanel_3.BorderType = 'none'; + app.MainMenuPanel_3.TitlePosition = 'centertop'; + app.MainMenuPanel_3.Title = 'Main Menu'; + app.MainMenuPanel_3.BackgroundColor = [1 1 1]; + app.MainMenuPanel_3.FontName = 'Arial'; + app.MainMenuPanel_3.FontWeight = 'bold'; + app.MainMenuPanel_3.FontSize = 14; + app.MainMenuPanel_3.Position = [522 72 332 460]; + + % Create ManualEntryButton_2 + app.ManualEntryButton_2 = uibutton(app.MainMenuPanel_3, 'push'); + app.ManualEntryButton_2.ButtonPushedFcn = createCallbackFcn(app, @ManualEntryButton_2Pushed, true); + app.ManualEntryButton_2.BackgroundColor = [1 1 1]; + app.ManualEntryButton_2.FontWeight = 'bold'; + app.ManualEntryButton_2.Position = [101 322 138 44]; + app.ManualEntryButton_2.Text = 'Manual Entry'; + + % Create ExcelEntryButton_2 + app.ExcelEntryButton_2 = uibutton(app.MainMenuPanel_3, 'push'); + app.ExcelEntryButton_2.ButtonPushedFcn = createCallbackFcn(app, @ExcelEntryButton_2Pushed, true); + app.ExcelEntryButton_2.BackgroundColor = [1 1 1]; + app.ExcelEntryButton_2.FontWeight = 'bold'; + app.ExcelEntryButton_2.Position = [101 271 138 36]; + app.ExcelEntryButton_2.Text = 'Excel Entry'; + + % Create PlotsButton_3 + app.PlotsButton_3 = uibutton(app.MainMenuPanel_3, 'push'); + app.PlotsButton_3.ButtonPushedFcn = createCallbackFcn(app, @PlotsButton_3Pushed, true); + app.PlotsButton_3.BackgroundColor = [0.4667 0.6745 0.1882]; + app.PlotsButton_3.FontWeight = 'bold'; + app.PlotsButton_3.FontColor = [1 1 1]; + app.PlotsButton_3.Position = [101 61 138 46]; + app.PlotsButton_3.Text = {'Plots'; ''}; + + % Create ExcelEntryPanel_2 + app.ExcelEntryPanel_2 = uipanel(app.MassSpectroscopyTab); + app.ExcelEntryPanel_2.BorderType = 'none'; + app.ExcelEntryPanel_2.Visible = 'off'; + app.ExcelEntryPanel_2.BackgroundColor = [1 1 1]; + app.ExcelEntryPanel_2.Position = [10 24 1327 596]; + + % Create ButtonPanel_2 + app.ButtonPanel_2 = uipanel(app.ExcelEntryPanel_2); + app.ButtonPanel_2.ForegroundColor = [0 1 0]; + app.ButtonPanel_2.BorderType = 'none'; + app.ButtonPanel_2.TitlePosition = 'centertop'; + app.ButtonPanel_2.Title = 'Excel Entry'; + app.ButtonPanel_2.BackgroundColor = [1 1 1]; + app.ButtonPanel_2.FontWeight = 'bold'; + app.ButtonPanel_2.Position = [513 35 252 489]; + + % Create progressbar_2 + app.progressbar_2 = uiaxes(app.ButtonPanel_2); + app.progressbar_2.DataAspectRatio = [1 1 1]; + app.progressbar_2.XTick = []; + app.progressbar_2.YTick = []; + app.progressbar_2.Visible = 'off'; + app.progressbar_2.BackgroundColor = [1 1 1]; + app.progressbar_2.Position = [68 262 127 35]; + + % Create LoadButton_7 + app.LoadButton_7 = uibutton(app.ButtonPanel_2, 'push'); + app.LoadButton_7.ButtonPushedFcn = createCallbackFcn(app, @LoadButton_7Pushed, true); + app.LoadButton_7.BackgroundColor = [0.502 0.502 0.502]; + app.LoadButton_7.FontName = 'Arial'; + app.LoadButton_7.FontWeight = 'bold'; + app.LoadButton_7.FontColor = [1 1 1]; + app.LoadButton_7.Position = [76 413 100 34]; + app.LoadButton_7.Text = 'Load'; + + % Create ClassifyButton_4 + app.ClassifyButton_4 = uibutton(app.ButtonPanel_2, 'push'); + app.ClassifyButton_4.ButtonPushedFcn = createCallbackFcn(app, @ClassifyButton_4Pushed, true); + app.ClassifyButton_4.BackgroundColor = [0.502 0.502 0.502]; + app.ClassifyButton_4.FontName = 'Arial'; + app.ClassifyButton_4.FontWeight = 'bold'; + app.ClassifyButton_4.FontColor = [1 1 1]; + app.ClassifyButton_4.Position = [76 346 100 35]; + app.ClassifyButton_4.Text = 'Classify'; + + % Create ExportClassesButton_3 + app.ExportClassesButton_3 = uibutton(app.ButtonPanel_2, 'push'); + app.ExportClassesButton_3.ButtonPushedFcn = createCallbackFcn(app, @ExportClassesButton_3Pushed, true); + app.ExportClassesButton_3.BackgroundColor = [0.1451 0.5529 0.7294]; + app.ExportClassesButton_3.FontWeight = 'bold'; + app.ExportClassesButton_3.FontColor = [1 1 1]; + app.ExportClassesButton_3.Position = [76 59 102 38]; + app.ExportClassesButton_3.Text = 'Export Classes'; + + % Create Image10_2 + app.Image10_2 = uiimage(app.ButtonPanel_2); + app.Image10_2.ImageClickedFcn = createCallbackFcn(app, @Image10_2Clicked, true); + app.Image10_2.Position = [15 9 28 22]; + app.Image10_2.ImageSource = 'left-arrow.png'; + + % Create BacktoMainMenuLabel_15 + app.BacktoMainMenuLabel_15 = uilabel(app.ButtonPanel_2); + app.BacktoMainMenuLabel_15.FontName = 'Arial'; + app.BacktoMainMenuLabel_15.Position = [48 4 103 35]; + app.BacktoMainMenuLabel_15.Text = 'Back to Main Menu'; + + % Create ProcessingLabel_2 + app.ProcessingLabel_2 = uilabel(app.ButtonPanel_2); + app.ProcessingLabel_2.FontSize = 15; + app.ProcessingLabel_2.FontWeight = 'bold'; + app.ProcessingLabel_2.FontColor = [1 1 1]; + app.ProcessingLabel_2.Visible = 'off'; + app.ProcessingLabel_2.Position = [58 300 139 27]; + app.ProcessingLabel_2.Text = 'Processing..'; + + % Create ModelsListBox_5Label + app.ModelsListBox_5Label = uilabel(app.ButtonPanel_2); + app.ModelsListBox_5Label.HorizontalAlignment = 'right'; + app.ModelsListBox_5Label.FontWeight = 'bold'; + app.ModelsListBox_5Label.FontColor = [1 1 1]; + app.ModelsListBox_5Label.Position = [1 224 47 22]; + app.ModelsListBox_5Label.Text = 'Models'; + + % Create ModelsListBox_5 + app.ModelsListBox_5 = uilistbox(app.ButtonPanel_2); + app.ModelsListBox_5.Items = {}; + app.ModelsListBox_5.ValueChangedFcn = createCallbackFcn(app, @ModelsListBox_5ValueChanged, true); + app.ModelsListBox_5.FontWeight = 'bold'; + app.ModelsListBox_5.Position = [63 115 190 133]; + app.ModelsListBox_5.Value = {}; + + % Create LoadButton_8 + app.LoadButton_8 = uibutton(app.ButtonPanel_2, 'push'); + app.LoadButton_8.BackgroundColor = [0.502 0.502 0.502]; + app.LoadButton_8.FontName = 'Arial'; + app.LoadButton_8.FontWeight = 'bold'; + app.LoadButton_8.FontColor = [1 1 1]; + app.LoadButton_8.Visible = 'off'; + app.LoadButton_8.Position = [96 393 52 20]; + app.LoadButton_8.Text = 'Load'; + + % Create UITableExcelEntry_2 + app.UITableExcelEntry_2 = uitable(app.ExcelEntryPanel_2); + app.UITableExcelEntry_2.ColumnName = {''}; + app.UITableExcelEntry_2.RowName = {}; + app.UITableExcelEntry_2.CellSelectionCallback = createCallbackFcn(app, @UITableExcelEntry_2CellSelection, true); + app.UITableExcelEntry_2.Visible = 'off'; + app.UITableExcelEntry_2.FontName = 'Arial'; + app.UITableExcelEntry_2.Position = [268 88 979 416]; + + % Create Label_12 + app.Label_12 = uilabel(app.ExcelEntryPanel_2); + app.Label_12.FontName = 'Arial'; + app.Label_12.FontWeight = 'bold'; + app.Label_12.FontAngle = 'italic'; + app.Label_12.FontColor = [0 1 0]; + app.Label_12.Position = [240 43 270 22]; + app.Label_12.Text = ''; + + % Create Class2Label_3 + app.Class2Label_3 = uilabel(app.ExcelEntryPanel_2); + app.Class2Label_3.FontName = 'Arial'; + app.Class2Label_3.FontWeight = 'bold'; + app.Class2Label_3.FontAngle = 'italic'; + app.Class2Label_3.FontColor = [0 0 1]; + app.Class2Label_3.Position = [240 23 271 22]; + app.Class2Label_3.Text = '*Class2'; + + % Create PlotsPanel_2 + app.PlotsPanel_2 = uipanel(app.MassSpectroscopyTab); + app.PlotsPanel_2.BorderType = 'none'; + app.PlotsPanel_2.TitlePosition = 'centertop'; + app.PlotsPanel_2.Visible = 'off'; + app.PlotsPanel_2.BackgroundColor = [0.502 0.502 0.502]; + app.PlotsPanel_2.Position = [10 28 1227 563]; + + % Create PlotsMenuPanel_2 + app.PlotsMenuPanel_2 = uipanel(app.PlotsPanel_2); + app.PlotsMenuPanel_2.ForegroundColor = [1 1 1]; + app.PlotsMenuPanel_2.BorderType = 'none'; + app.PlotsMenuPanel_2.TitlePosition = 'centertop'; + app.PlotsMenuPanel_2.Title = 'Plots Menu'; + app.PlotsMenuPanel_2.BackgroundColor = [0.502 0.502 0.502]; + app.PlotsMenuPanel_2.FontWeight = 'bold'; + app.PlotsMenuPanel_2.Position = [501 79 257 452]; + + % Create ModelPlots_2 + app.ModelPlots_2 = uibutton(app.PlotsMenuPanel_2, 'push'); + app.ModelPlots_2.BackgroundColor = [0.502 0.502 0.502]; + app.ModelPlots_2.FontWeight = 'bold'; + app.ModelPlots_2.FontColor = [1 1 1]; + app.ModelPlots_2.Position = [77 267 100 46]; + app.ModelPlots_2.Text = 'Model Plots'; + + % Create LCMODELPLOTS_2 + app.LCMODELPLOTS_2 = uibutton(app.PlotsMenuPanel_2, 'push'); + app.LCMODELPLOTS_2.BackgroundColor = [0.502 0.502 0.502]; + app.LCMODELPLOTS_2.FontWeight = 'bold'; + app.LCMODELPLOTS_2.FontColor = [1 1 1]; + app.LCMODELPLOTS_2.Position = [76 89 102 46]; + app.LCMODELPLOTS_2.Text = 'LC Model Plots'; + + % Create ExcelPlots_2 + app.ExcelPlots_2 = uibutton(app.PlotsMenuPanel_2, 'push'); + app.ExcelPlots_2.BackgroundColor = [0.502 0.502 0.502]; + app.ExcelPlots_2.FontWeight = 'bold'; + app.ExcelPlots_2.FontColor = [1 1 1]; + app.ExcelPlots_2.Position = [77 177 100 46]; + app.ExcelPlots_2.Text = 'Excel Plots'; + + % Create Image11_2 + app.Image11_2 = uiimage(app.PlotsMenuPanel_2); + app.Image11_2.Position = [8 400 20 23]; + app.Image11_2.ImageSource = 'left-arrow.png'; + + % Create BacktoMainMenuLabel_16 + app.BacktoMainMenuLabel_16 = uilabel(app.PlotsMenuPanel_2); + app.BacktoMainMenuLabel_16.FontColor = [1 1 1]; + app.BacktoMainMenuLabel_16.Position = [37 401 113 22]; + app.BacktoMainMenuLabel_16.Text = 'Back to Main Menu'; + + % Create plottingpanels1_2 + app.plottingpanels1_2 = uipanel(app.PlotsPanel_2); + app.plottingpanels1_2.BorderType = 'none'; + app.plottingpanels1_2.BackgroundColor = [0.502 0.502 0.502]; + app.plottingpanels1_2.Position = [15 50 454 500]; + + % Create plottingpanels2_2 + app.plottingpanels2_2 = uipanel(app.PlotsPanel_2); + app.plottingpanels2_2.BorderType = 'none'; + app.plottingpanels2_2.Visible = 'off'; + app.plottingpanels2_2.BackgroundColor = [0.502 0.502 0.502]; + app.plottingpanels2_2.Position = [386 50 826 497]; + + % Create ModelPlotsPanel_2 + app.ModelPlotsPanel_2 = uipanel(app.PlotsPanel_2); + app.ModelPlotsPanel_2.ForegroundColor = [1 1 1]; + app.ModelPlotsPanel_2.BorderType = 'none'; + app.ModelPlotsPanel_2.TitlePosition = 'centertop'; + app.ModelPlotsPanel_2.Title = 'Model Plots'; + app.ModelPlotsPanel_2.Visible = 'off'; + app.ModelPlotsPanel_2.BackgroundColor = [0.502 0.502 0.502]; + app.ModelPlotsPanel_2.Position = [503 88 237 439]; + + % Create RefreshButton_4 + app.RefreshButton_4 = uibutton(app.ModelPlotsPanel_2, 'push'); + app.RefreshButton_4.BackgroundColor = [0.4549 0.902 0.4235]; + app.RefreshButton_4.FontWeight = 'bold'; + app.RefreshButton_4.Position = [25 61 87 39]; + app.RefreshButton_4.Text = 'Refresh'; + + % Create PlotButton_6 + app.PlotButton_6 = uibutton(app.ModelPlotsPanel_2, 'push'); + app.PlotButton_6.BackgroundColor = [0.6 0.8549 0.8784]; + app.PlotButton_6.FontWeight = 'bold'; + app.PlotButton_6.Position = [131 61 91 39]; + app.PlotButton_6.Text = 'Plot'; + + % Create ModelsListBox_6Label + app.ModelsListBox_6Label = uilabel(app.ModelPlotsPanel_2); + app.ModelsListBox_6Label.BackgroundColor = [0.502 0.502 0.502]; + app.ModelsListBox_6Label.HorizontalAlignment = 'right'; + app.ModelsListBox_6Label.FontColor = [1 1 1]; + app.ModelsListBox_6Label.Position = [96 377 42 22]; + app.ModelsListBox_6Label.Text = 'Models'; + + % Create ModelsListBox_6 + app.ModelsListBox_6 = uilistbox(app.ModelPlotsPanel_2); + app.ModelsListBox_6.Items = {}; + app.ModelsListBox_6.FontColor = [1 1 1]; + app.ModelsListBox_6.BackgroundColor = [0.502 0.502 0.502]; + app.ModelsListBox_6.Position = [25 169 197 209]; + app.ModelsListBox_6.Value = {}; + + % Create Image12_3 + app.Image12_3 = uiimage(app.ModelPlotsPanel_2); + app.Image12_3.Position = [26 23 27 21]; + app.Image12_3.ImageSource = 'left-arrow.png'; + + % Create Image12_4 + app.Image12_4 = uiimage(app.ModelPlotsPanel_2); + app.Image12_4.Position = [25 3 28 21]; + app.Image12_4.ImageSource = 'left-arrow.png'; + + % Create BacktoMainMenuLabel_17 + app.BacktoMainMenuLabel_17 = uilabel(app.ModelPlotsPanel_2); + app.BacktoMainMenuLabel_17.FontColor = [1 1 1]; + app.BacktoMainMenuLabel_17.Position = [63 23 103 22]; + app.BacktoMainMenuLabel_17.Text = 'Back to Main Menu'; + + % Create BacktopreviousMenuLabel_2 + app.BacktopreviousMenuLabel_2 = uilabel(app.ModelPlotsPanel_2); + app.BacktopreviousMenuLabel_2.FontColor = [1 1 1]; + app.BacktopreviousMenuLabel_2.Position = [63 3 123 22]; + app.BacktopreviousMenuLabel_2.Text = 'Back to previous Menu'; + + % Create LCModelPlotsPanel_2 + app.LCModelPlotsPanel_2 = uipanel(app.PlotsPanel_2); + app.LCModelPlotsPanel_2.ForegroundColor = [0 1 0]; + app.LCModelPlotsPanel_2.BorderType = 'none'; + app.LCModelPlotsPanel_2.TitlePosition = 'centertop'; + app.LCModelPlotsPanel_2.Title = 'LC Model Plots'; + app.LCModelPlotsPanel_2.Visible = 'off'; + app.LCModelPlotsPanel_2.BackgroundColor = [0.502 0.502 0.502]; + app.LCModelPlotsPanel_2.Position = [485 79 273 453]; + + % Create LoadButton_9 + app.LoadButton_9 = uibutton(app.LCModelPlotsPanel_2, 'push'); + app.LoadButton_9.BackgroundColor = [0.302 0.7451 0.9333]; + app.LoadButton_9.FontWeight = 'bold'; + app.LoadButton_9.Position = [80 336 100 39]; + app.LoadButton_9.Text = 'Load'; + + % Create PlotButton_7 + app.PlotButton_7 = uibutton(app.LCModelPlotsPanel_2, 'push'); + app.PlotButton_7.BackgroundColor = [0.502 0.502 0.502]; + app.PlotButton_7.FontWeight = 'bold'; + app.PlotButton_7.FontColor = [1 1 1]; + app.PlotButton_7.Position = [80 250 100 39]; + app.PlotButton_7.Text = 'Plot'; + + % Create Image13_3 + app.Image13_3 = uiimage(app.LCModelPlotsPanel_2); + app.Image13_3.Position = [49 70 28 21]; + app.Image13_3.ImageSource = 'left-arrow.png'; + + % Create Image13_4 + app.Image13_4 = uiimage(app.LCModelPlotsPanel_2); + app.Image13_4.Position = [26 50 71 21]; + app.Image13_4.ImageSource = 'left-arrow.png'; + + % Create BacktoMainMenuLabel_18 + app.BacktoMainMenuLabel_18 = uilabel(app.LCModelPlotsPanel_2); + app.BacktoMainMenuLabel_18.FontColor = [1 1 1]; + app.BacktoMainMenuLabel_18.Position = [86 70 103 22]; + app.BacktoMainMenuLabel_18.Text = 'Back to Main Menu'; + + % Create BacktoPreviousMenuLabel_3 + app.BacktoPreviousMenuLabel_3 = uilabel(app.LCModelPlotsPanel_2); + app.BacktoPreviousMenuLabel_3.FontColor = [1 1 1]; + app.BacktoPreviousMenuLabel_3.Position = [86 50 124 22]; + app.BacktoPreviousMenuLabel_3.Text = 'Back to Previous Menu'; + + % Create MetabolitesListBox_2Label + app.MetabolitesListBox_2Label = uilabel(app.LCModelPlotsPanel_2); + app.MetabolitesListBox_2Label.HorizontalAlignment = 'right'; + app.MetabolitesListBox_2Label.FontColor = [1 1 1]; + app.MetabolitesListBox_2Label.Position = [5 209 63 22]; + app.MetabolitesListBox_2Label.Text = 'Metabolites'; + + % Create MetabolitesListBox_2 + app.MetabolitesListBox_2 = uilistbox(app.LCModelPlotsPanel_2); + app.MetabolitesListBox_2.Items = {}; + app.MetabolitesListBox_2.Multiselect = 'on'; + app.MetabolitesListBox_2.FontWeight = 'bold'; + app.MetabolitesListBox_2.FontColor = [1 1 1]; + app.MetabolitesListBox_2.BackgroundColor = [0.502 0.502 0.502]; + app.MetabolitesListBox_2.Position = [76 99 107 134]; + app.MetabolitesListBox_2.Value = {}; + + % Create ExcelPlotPanel_2 + app.ExcelPlotPanel_2 = uipanel(app.PlotsPanel_2); + app.ExcelPlotPanel_2.ForegroundColor = [1 1 1]; + app.ExcelPlotPanel_2.BorderType = 'none'; + app.ExcelPlotPanel_2.TitlePosition = 'centertop'; + app.ExcelPlotPanel_2.Title = 'Excel Plot'; + app.ExcelPlotPanel_2.Visible = 'off'; + app.ExcelPlotPanel_2.BackgroundColor = [0.502 0.502 0.502]; + app.ExcelPlotPanel_2.FontWeight = 'bold'; + app.ExcelPlotPanel_2.Position = [15 19 1225 541]; + + % Create TabGroup3_2 + app.TabGroup3_2 = uitabgroup(app.ExcelPlotPanel_2); + app.TabGroup3_2.Position = [1 0 1225 516]; + + % Create DataTab_2 + app.DataTab_2 = uitab(app.TabGroup3_2); + app.DataTab_2.Title = 'Data'; + app.DataTab_2.BackgroundColor = [1 1 1]; + + % Create LoadButton_10 + app.LoadButton_10 = uibutton(app.DataTab_2, 'push'); + app.LoadButton_10.BackgroundColor = [1 1 1]; + app.LoadButton_10.Position = [17 406 154 44]; + app.LoadButton_10.Text = 'Load'; + + % Create UITable4_2 + app.UITable4_2 = uitable(app.DataTab_2); + app.UITable4_2.ColumnName = {'Column 1'; 'Column 2'; 'Column 3'; 'Column 4'}; + app.UITable4_2.RowName = {}; + app.UITable4_2.Position = [204 48 974 434]; + + % Create AssignButton_2 + app.AssignButton_2 = uibutton(app.DataTab_2, 'push'); + app.AssignButton_2.BackgroundColor = [1 1 1]; + app.AssignButton_2.Position = [17 63 162 43]; + app.AssignButton_2.Text = 'Assign'; + + % Create ListBox_5Label_2 + app.ListBox_5Label_2 = uilabel(app.DataTab_2); + app.ListBox_5Label_2.HorizontalAlignment = 'right'; + app.ListBox_5Label_2.FontWeight = 'bold'; + app.ListBox_5Label_2.Position = [-2 368 67 22]; + app.ListBox_5Label_2.Text = 'Features'; + + % Create ListBox_9 + app.ListBox_9 = uilistbox(app.DataTab_2); + app.ListBox_9.Multiselect = 'on'; + app.ListBox_9.FontWeight = 'bold'; + app.ListBox_9.Position = [68 190 128 198]; + app.ListBox_9.Value = {'Item 1'}; + + % Create GroupingFeatureLabel_2 + app.GroupingFeatureLabel_2 = uilabel(app.DataTab_2); + app.GroupingFeatureLabel_2.HorizontalAlignment = 'right'; + app.GroupingFeatureLabel_2.FontWeight = 'bold'; + app.GroupingFeatureLabel_2.Position = [36 154 118 17]; + app.GroupingFeatureLabel_2.Text = 'Grouping Feature'; + + % Create DropDown_2 + app.DropDown_2 = uidropdown(app.DataTab_2); + app.DropDown_2.FontWeight = 'bold'; + app.DropDown_2.BackgroundColor = [1 1 1]; + app.DropDown_2.Position = [23 127 173 21]; + + % Create Image24_2 + app.Image24_2 = uiimage(app.DataTab_2); + app.Image24_2.Position = [52 9 19 16]; + app.Image24_2.ImageSource = 'left-arrow.png'; + + % Create BacktoPlotsMenuLabel_2 + app.BacktoPlotsMenuLabel_2 = uilabel(app.DataTab_2); + app.BacktoPlotsMenuLabel_2.Position = [75 9 105 17]; + app.BacktoPlotsMenuLabel_2.Text = 'Back to Plots Menu'; + + % Create greenLabel_2 + app.greenLabel_2 = uilabel(app.DataTab_2); + app.greenLabel_2.FontWeight = 'bold'; + app.greenLabel_2.FontAngle = 'italic'; + app.greenLabel_2.FontColor = [0 1 0]; + app.greenLabel_2.Position = [204 22 892 22]; + app.greenLabel_2.Text = '*green'; + + % Create blueLabel_2 + app.blueLabel_2 = uilabel(app.DataTab_2); + app.blueLabel_2.FontWeight = 'bold'; + app.blueLabel_2.FontAngle = 'italic'; + app.blueLabel_2.FontColor = [0 0 1]; + app.blueLabel_2.Position = [207 2 889 22]; + app.blueLabel_2.Text = '*blue'; + + % Create PlotsTab_2 + app.PlotsTab_2 = uitab(app.TabGroup3_2); + app.PlotsTab_2.Title = 'Plots'; + app.PlotsTab_2.BackgroundColor = [1 1 1]; + + % Create excelpanel_2 + app.excelpanel_2 = uipanel(app.PlotsTab_2); + app.excelpanel_2.BorderType = 'none'; + app.excelpanel_2.BackgroundColor = [1 1 1]; + app.excelpanel_2.Position = [17 2 825 473]; + + % Create Plot_2 + app.Plot_2 = uibutton(app.PlotsTab_2, 'push'); + app.Plot_2.BackgroundColor = [0.4667 0.6745 0.1882]; + app.Plot_2.FontName = 'Arial Black'; + app.Plot_2.FontWeight = 'bold'; + app.Plot_2.FontColor = [1 1 1]; + app.Plot_2.Position = [946 34 172 39]; + app.Plot_2.Text = 'Plot'; + + % Create PlotsButtonGroup_2 + app.PlotsButtonGroup_2 = uibuttongroup(app.PlotsTab_2); + app.PlotsButtonGroup_2.TitlePosition = 'centertop'; + app.PlotsButtonGroup_2.Title = 'Plots'; + app.PlotsButtonGroup_2.BackgroundColor = [1 1 1]; + app.PlotsButtonGroup_2.Position = [852 89 360 280]; + + % Create VariablePlotButton_3 + app.VariablePlotButton_3 = uitogglebutton(app.PlotsButtonGroup_2); + app.VariablePlotButton_3.Text = 'Variable Plot'; + app.VariablePlotButton_3.Position = [11 227 100 22]; + app.VariablePlotButton_3.Value = true; + + % Create SpiderPlotButton_3 + app.SpiderPlotButton_3 = uitogglebutton(app.PlotsButtonGroup_2); + app.SpiderPlotButton_3.Text = 'Spider Plot'; + app.SpiderPlotButton_3.Position = [11 196 100 22]; + + % Create PCAPlotButton_2 + app.PCAPlotButton_2 = uitogglebutton(app.PlotsButtonGroup_2); + app.PCAPlotButton_2.Text = 'PCA Plot'; + app.PCAPlotButton_2.Position = [11 165 100 22]; + + % Create BoxPlotButton_3 + app.BoxPlotButton_3 = uitogglebutton(app.PlotsButtonGroup_2); + app.BoxPlotButton_3.Text = 'Box Plot'; + app.BoxPlotButton_3.Position = [11 135 100 22]; + + % Create BarPlotButton_2 + app.BarPlotButton_2 = uitogglebutton(app.PlotsButtonGroup_2); + app.BarPlotButton_2.Text = 'Bar Plot'; + app.BarPlotButton_2.Position = [11 105 100 22]; + + % Create LinePlotButton_2 + app.LinePlotButton_2 = uitogglebutton(app.PlotsButtonGroup_2); + app.LinePlotButton_2.Text = 'Line Plot'; + app.LinePlotButton_2.Position = [11 75 100 22]; + + % Create ConfidenceIntervalCheckBox_2 + app.ConfidenceIntervalCheckBox_2 = uicheckbox(app.PlotsButtonGroup_2); + app.ConfidenceIntervalCheckBox_2.Text = 'Confidence Interval'; + app.ConfidenceIntervalCheckBox_2.Position = [160 75 121 22]; + app.ConfidenceIntervalCheckBox_2.Value = true; + + % Create ScatterCheckBox_2 + app.ScatterCheckBox_2 = uicheckbox(app.PlotsButtonGroup_2); + app.ScatterCheckBox_2.Text = 'Scatter'; + app.ScatterCheckBox_2.Position = [291 73 59 22]; + + % Create CI_2 + app.CI_2 = uieditfield(app.PlotsButtonGroup_2, 'numeric'); + app.CI_2.Limits = [0 1]; + app.CI_2.Position = [114 74 33 23]; + app.CI_2.Value = 0.95; + + % Create MergeCheckBox_3 + app.MergeCheckBox_3 = uicheckbox(app.PlotsButtonGroup_2); + app.MergeCheckBox_3.Text = 'Merge'; + app.MergeCheckBox_3.Position = [125 195 54 22]; + + % Create CompactCheckBox_2 + app.CompactCheckBox_2 = uicheckbox(app.PlotsButtonGroup_2); + app.CompactCheckBox_2.Text = 'Compact'; + app.CompactCheckBox_2.Position = [125 134 70 23]; + + % Create PCDimensionSpinner_2Label + app.PCDimensionSpinner_2Label = uilabel(app.PlotsButtonGroup_2); + app.PCDimensionSpinner_2Label.HorizontalAlignment = 'right'; + app.PCDimensionSpinner_2Label.Position = [178 164 88 22]; + app.PCDimensionSpinner_2Label.Text = 'PC Dimension'; + + % Create PCDimensionSpinner_2 + app.PCDimensionSpinner_2 = uispinner(app.PlotsButtonGroup_2); + app.PCDimensionSpinner_2.Limits = [2 3]; + app.PCDimensionSpinner_2.Position = [125 164 54 22]; + app.PCDimensionSpinner_2.Value = 2; + + % Create Feature1DropDown_2Label + app.Feature1DropDown_2Label = uilabel(app.PlotsTab_2); + app.Feature1DropDown_2Label.BackgroundColor = [1 1 1]; + app.Feature1DropDown_2Label.HorizontalAlignment = 'right'; + app.Feature1DropDown_2Label.Position = [868 422 55 22]; + app.Feature1DropDown_2Label.Text = 'Feature 1'; + + % Create Feature1DropDown_2 + app.Feature1DropDown_2 = uidropdown(app.PlotsTab_2); + app.Feature1DropDown_2.BackgroundColor = [1 1 1]; + app.Feature1DropDown_2.Position = [938 422 264 22]; + + % Create Feature2DropDown_2Label + app.Feature2DropDown_2Label = uilabel(app.PlotsTab_2); + app.Feature2DropDown_2Label.BackgroundColor = [1 1 1]; + app.Feature2DropDown_2Label.HorizontalAlignment = 'right'; + app.Feature2DropDown_2Label.Position = [868 391 55 22]; + app.Feature2DropDown_2Label.Text = 'Feature 2'; + + % Create Feature2DropDown_2 + app.Feature2DropDown_2 = uidropdown(app.PlotsTab_2); + app.Feature2DropDown_2.BackgroundColor = [1 1 1]; + app.Feature2DropDown_2.Position = [938 391 268 22]; + + % Create ResultsPanel_2 + app.ResultsPanel_2 = uipanel(app.MassSpectroscopyTab); + app.ResultsPanel_2.ForegroundColor = [0 1 0]; + app.ResultsPanel_2.BorderType = 'none'; + app.ResultsPanel_2.TitlePosition = 'centertop'; + app.ResultsPanel_2.Title = 'Results'; + app.ResultsPanel_2.Visible = 'off'; + app.ResultsPanel_2.BackgroundColor = [0.502 0.502 0.502]; + app.ResultsPanel_2.FontWeight = 'bold'; + app.ResultsPanel_2.Position = [27 67 395 462]; + + % Create Image26 + app.Image26 = uiimage(app.GliomaIDHMutationDiagnosisToolUIFigure); + app.Image26.ImageClickedFcn = createCallbackFcn(app, @Image26Clicked, true); + app.Image26.Position = [11 105 51 55]; + app.Image26.ImageSource = 'manual.png'; + + % Create Panel_6 + app.Panel_6 = uipanel(app.GliomaIDHMutationDiagnosisToolUIFigure); + app.Panel_6.BorderType = 'none'; + app.Panel_6.BackgroundColor = [1 1 1]; + app.Panel_6.Position = [1 179 164 301]; + + % Create UserManualLabel + app.UserManualLabel = uilabel(app.Panel_6); + app.UserManualLabel.FontWeight = 'bold'; + app.UserManualLabel.Visible = 'off'; + app.UserManualLabel.Position = [59 244 79 22]; + app.UserManualLabel.Text = 'User Manual'; + + % Create sidebar_html + app.sidebar_html = uihtml(app.Panel_6); + app.sidebar_html.HTMLSource = '{}'; + app.sidebar_html.Position = [1 5 173 281]; + + % Create HTML + app.HTML = uihtml(app.GliomaIDHMutationDiagnosisToolUIFigure); + app.HTML.HTMLSource = '{}'; + app.HTML.Position = [61 88 104 80]; + + % Create HTML2 + app.HTML2 = uihtml(app.GliomaIDHMutationDiagnosisToolUIFigure); + app.HTML2.HTMLSource = ''; + app.HTML2.Position = [11 24 142 48]; + + % Show the figure after all components are created + app.GliomaIDHMutationDiagnosisToolUIFigure.Visible = 'on'; + end + end + + % App creation and deletion + methods (Access = public) + + % Construct app + function app = iris + + % Create UIFigure and components + createComponents(app) + + % Register the app with App Designer + registerApp(app, app.GliomaIDHMutationDiagnosisToolUIFigure) + + % Execute the startup function + runStartupFcn(app, @startupFcn) + + if nargout == 0 + clear app + end + end + + % Code that executes before app deletion + function delete(app) + + % Delete UIFigure when app is deleted + delete(app.GliomaIDHMutationDiagnosisToolUIFigure) + end + end +end \ No newline at end of file