🔥 内容介绍
引言: 面部形态和头颅对称性是评估人类面容美学和疾病诊断的重要指标。随着计算机技术和三维成像的发展,研究人员可以使用三维头影测量方案来量化面部形态和头颅对称性。本文将介绍一种基于三维头影测量的方法,用于量化颅面对称性和面部生长,并提供相应的代码示例。
背景: 面部形态和头颅对称性在美学和医学领域具有重要意义。对于美学来说,面部对称性被认为是面容美的重要因素之一。而在医学领域,颅面对称性的异常可能与某些疾病和疾病的发展有关。因此,准确评估面部形态和头颅对称性对于美学和医学研究具有重要意义。
方法: 本研究采用了一种基于三维头影测量的方法,用于量化颅面对称性和面部生长。该方法使用了三维成像技术,如三维摄影或激光扫描,以获取面部和头颅的三维模型。然后,通过计算面部和头颅的对称性指标,可以量化颅面对称性的程度。此外,通过比较不同年龄组的三维头影数据,可以评估面部生长的变化。
讨论: 通过使用三维头影测量方案,我们可以准确地量化颅面对称性和面部生长。这种方法具有许多优点,包括非侵入性、高精度和可重复性。通过使用面部模型和代码示例,研究人员可以更好地理解面部形态和头颅对称性的变化,并在美学和医学研究中应用这些知识。
结论: 本文介绍了一种基于三维头影测量的方法,用于量化颅面对称性和面部生长。该方法可以帮助研究人员评估面部形态和头颅对称性的变化,并在美学和医学领域中应用这些知识。通过提供代码示例,我们希望能够帮助读者更好地理解和应用这种方法。未来,我们期待这种方法在面部美学和疾病诊断中的广泛应用。
📣 部分代码
function varargout = opt_rbf(varargin)
% OPT_RBF MATLAB code for opt_rbf.fig
% OPT_RBF, by itself, creates a new OPT_RBF or raises the existing
% singleton*.
%
% H = OPT_RBF returns the handle to a new OPT_RBF or the handle to
% the existing singleton*.
%
% OPT_RBF('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in OPT_RBF.M with the given input arguments.
%
% OPT_RBF('Property','Value',...) creates a new OPT_RBF or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before opt_rbf_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to opt_rbf_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help opt_rbf
% Last Modified by GUIDE v2.5 31-May-2017 14:18:12
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @opt_rbf_OpeningFcn, ...
'gui_OutputFcn', @opt_rbf_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before opt_rbf is made visible.
function opt_rbf_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to opt_rbf (see VARARGIN)
% Choose default command line output for opt_rbf
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes opt_rbf wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = opt_rbf_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
global pathname
pathname=[cd,'\'];
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
global pathname
pathname=[cd,'\'];
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global pathname
[Xcalname,pathname]=uigetfile([pathname,'\*.*']);
set(handles.edit1,'String',Xcalname)
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global pathname
[ycalname,pathname]=uigetfile([pathname,'\*.*']);
set(handles.edit2,'String',ycalname)
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global pathname C R w Nf Nresp Xcalname ycalname ...
Xtestname ytestname
clc
Xcalname=get(handles.edit1,'String');
eval(['load ','''',[pathname,Xcalname,'''']])
Xcal=eval(strtok(Xcalname,'.'));
ycalname=get(handles.edit2,'String');
eval(['load ','''',[pathname,ycalname,'''']])
ycal=eval(strtok(ycalname,'.'));
Nf=size(Xcal,2);
deltaX=zeros(1,Nf);
MMX=zeros(1,Nf);
X=zeros(size(Xcal));
for i=1:Nf
deltaX(i)=max(Xcal(:,i))-min(Xcal(:,i));
MMX(i)=min(Xcal(:,i))+max(Xcal(:,i));
X(:,i)=(2*Xcal(:,i)-MMX(i))/deltaX(i);
end
Nresp=size(ycal,2);
deltay=zeros(1,Nresp);
MMy=zeros(1,Nresp);
y=zeros(size(ycal));
for i=1:Nresp
deltay(i)=max(ycal(:,i))-min(ycal(:,i));
MMy(i)=min(ycal(:,i))+max(ycal(:,i));
y(:,i)=(2*ycal(:,i)-MMy(i))/deltay(i);
end
disp('Training results')
C=cell(Nresp,1);
w=cell(Nresp,1);
% Finds replicates
Nrep=0;
Irep=[];
Nexp=size(X,1);
for i=1:Nexp-1
cont=0;
for j=i+1:Nexp
if norm(X(i,:)-X(j,:))==0
cont=cont+1;
if cont==1
Nrep=Nrep+1;
Irep=[Irep,[i,j]];
end
end
end
end
Irep=[Irep(1),Irep(2:2:end-1),Irep(end)];
for i=1:Nresp
[yp(:,i),Nh(i),C{i},R(i),w{i}]=prueba(X,y(:,i));
%Estimates pure error Ep
Ep=.5*deltay(i)*std(y(Irep,i));
disp(' ')
disp(['Response ',int2str(i)])
disp(['Architecture: ',mat2str([size(X,2),Nh(i),1])])
coco=corrcoef(y(:,i),yp(:,i));
disp(['R2 = ',num2str(coco(1,2))])
SD=.5*deltay(i)*norm(y(:,i)-yp(:,i))/sqrt(size(ycal,1));
disp(['Std. Dev. = ',num2str(SD)])
disp(['CV(%) = ',num2str(50*deltay(i)*norm(y(:,i)-yp(:,i))/(sqrt(size(ycal,1))*mean(ycal(:,i))))])
disp(['Pure error = ',num2str(Ep)])
pLOF=probabi([SD^2/Ep^2,Nexp,Nrep]);
disp(['p(LOF) = ',num2str(pLOF)])
% [y-yp]
end
arch=[size(X,2),Nh(1),1];
strnr='Resp. 1: ';
ray=' - ';
for i=2:Nresp
arch=[arch;[size(X,2),Nh(i),1]];
if i<10
strnr=[strnr;['Resp. ',int2str(i),': ']];
else
strnr=[strnr;['Resp.',int2str(i),': ']];
end
ray=[ray;' - '];
end
set(handles.popupmenu5,'String',[strnr,num2str(arch(:,1)),ray,...
num2str(arch(:,2)),ray,num2str(arch(:,3))])
% Plots
leg=''' 1 ';
for i=2:Nresp
leg=[leg,''','' ',int2str(i)];
end
leg=[leg,''''];
figure(1),close 1, figure(1)
set(gcf,'Numbertitle','off')
set(gcf,'Name','Training results')
plot(y,yp,'o','Linewidth',2)
hold on
plot([min(y(:)),max(y(:))],[min(y(:)),max(y(:))],'--r','Linewidth',1.5)
axis tight
title('Training results','Fontsize',14)
set(gca,'LineWidth',2)
xlabel('Nominal response','Fontsize',14)
ylabel('Estimated response','Fontsize',14)
eval(['legend(',leg,')']);
figure(2),close 2, figure(2)
set(gcf,'Numbertitle','off')
set(gcf,'Name','Training errors')
subplot(2,1,1),plot(y,yp-y,'o','Linewidth',2)
hold on
plot([min(y(:)),max(y(:))],[0,0],'--r','Linewidth',1.5)
axis tight
title('Training errors','Fontsize',14)
set(gca,'LineWidth',2)
xlabel('Nominal response','Fontsize',14)
ylabel('Residual','Fontsize',14)
eval(['legend(',leg,')']);
subplot(2,1,2),plot(yp-y,'o','Linewidth',2)
axis tight
set(gca,'LineWidth',2)
xlabel('Sample number','Fontsize',14)
ylabel('Residual','Fontsize',14)
eval(['legend(',leg,')']);
% Outliers
for i=1:size(yp,2)
ypred(:,i)=(yp(:,i)*deltay(i)+MMy(i))/2;
criti=fcrt([0.05,1,length(ypred(:,i))]);
d=(ycal(:,i)-ypred(:,i)).^2;
for j=1:length(ypred(:,i))
Fprac=(length(ypred(:,i))-1)*d(j)/(sum(d)-d(j));
ratout(i,j)=Fprac/criti;
end
end
% ratout'
for iresp=1:size(y,2)
figure(2+iresp),close (2+iresp), figure(2+iresp)
set(gcf,'Numbertitle','off')
set(gcf,'Name','Outliers and normal plots')
dy=yp(:,iresp)-y(:,iresp);
subplot(2,1,1),normplot(dy)
title(['Normal probability plot: response ',int2str(iresp)],'Fontsize',14)
subplot(2,1,2),bar(ratout(iresp,:))
xlabel('Sample number')
ylabel('F ratio')
title(['Outlier F ratio: response ',int2str(iresp)],'Fontsize',14)
end
strnf=['Factor 1'];
for i=2:Nf
strnf=[strnf;['Factor ',int2str(i)]];
end
set(handles.popupmenu1,'String',strnf)
strnr=['Response 1'];
for i=2:Nresp
if i<10
strnr=[strnr;['Response ',int2str(i)]];
else
strnr=[strnr;['Response',int2str(i)]];
end
end
set(handles.popupmenu3,'String',strnr)
for i=1:size(yp,2)
ypred(:,i)=(yp(:,i)*deltay(i)+MMy(i))/2;
end
trainres=[ycal,ypred,ycal-ypred];
eval(['save ','''',[pathname,'trainresults.txt',''''],' trainres -ascii'])
h=msgbox(['Training results (nominal, predicted, residuals) saved in ',pathname,'trainresults.txt']);
% Fcrit
function F=fcrt(x)
p=x(1);
k1=x(2);
k2=x(3);
g1 = 2.30753;
g2 = 0.27061;
g3 = 0.99229;
g4 = 0.04481;
p0 = 0.5 - sign(0.5 - p) * (0.5 - p);
z1 = sqrt(-2 * log(p0));
z = z1 - (g1 + g2 * z1) / (1 + z1 * (g3 + g4 * z1));
z = z * sign(0.5 - p);
if k2 <= 3
k4 = z / k2 ^ (0.75);
z = z / (0.64 + 0.36 * (k4 + (1 - k4 + 0.25 * k4 ^ 4) / (1 + k4 ^ 8)));
end
k8 = 2 / (9 * k1);
k9 = 2 / (9 * k2);
k5 = (1 - k9) ^ 2 - k9 * z ^ 2;
k6 = -(1 - k8) * (1 - k9);
k7 = (1 - k8) ^ 2 - k8 * z ^ 2;
F = ((sqrt(k6 ^ 2 - k5 * k7) - k6) / k5) ^ 3;
% p(LOF)
function y=probabi(x)
f=x(1);
k1=x(2);
k2=x(3);
d1 = 0.049867347;
d2 = 0.0211410061;
d3 = 0.0032776263;
d4 = 0.0000380036;
d5 = 0.0000488906;
d6 = 0.000005383;
f3 = f ^ (1 / 3);
k8 = 2 / (9 * k1);
k9 = 2 / (9 * k2);
z = ((1 - k9) * f3 - 1 + k8) / sqrt(k9 * f3 * f3 + k8);
if k2 <= 3
z = z * (1 + 0.08 * z * (z / k2) ^ 3);
end
z9 = abs(z);
z9d6 = z9 * d6;
p = 1 + z9 * (d1 + z9 * (d2 + z9 * (d3 + z9 * (d4 + z9 * (d5 + z9d6)))));
p = 0.5 / p ^ 16;
p = sign(z) * (p - 0.5) + 0.5;
p = round(p * 1000 + 0.5) / 1000;
y=p;
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global pathname C R w Xcalname ycalname Xtestname ytestname
netname=get(handles.edit3,'String');
eval(['save ','''',[pathname,netname,''''],' C R w Xcalname ycalname Xtestname ytestname'])
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global pathname C R w Nf Nresp decides0 w_s0 targets lows0 highs0 ...
decides0f w_s0f targetsf lows0f highs0f netname
netname=get(handles.edit4,'String');
eval(['load ','''',[pathname,netname,'''']])
set(handles.popupmenu1,'Value',1)
set(handles.popupmenu3,'Value',1)
set(handles.popupmenu4,'Value',1)
Nf=size(C{1},2)-1;
strnf=['Factor 1'];
for i=2:Nf
strnf=[strnf;['Factor ',int2str(i)]];
end
set(handles.popupmenu1,'String',strnf)
set(handles.edit1,'String',Xcalname)
set(handles.edit2,'String',ycalname)
if exist('Xtestname')==1
set(handles.edit13,'String',Xtestname)
end
if exist('ytestname')==1
set(handles.edit14,'String',ytestname)
end
Nresp=size(C,1);
strnr=['Response 1'];
for i=2:Nresp
if i<10
strnr=[strnr;['Response ',int2str(i)]];
else
strnr=[strnr;['Response',int2str(i)]];
end
end
set(handles.popupmenu3,'String',strnr)
decides0=5*ones(1,Nresp);
w_s0=ones(1,Nresp);
targets=NaN*w_s0;
lows0=NaN*w_s0;
highs0=NaN*w_s0;
decides0f=5*ones(1,Nf);
w_s0f=ones(1,Nf);
targetsf=NaN*w_s0f;
lows0f=NaN*w_s0f;
highs0f=NaN*w_s0f;
arch=[Nf,size(C{1},1),1];
strnr='Resp. 1: ';
ray=' - ';
for i=2:Nresp
arch=[arch;[Nf,size(C{i},2),1]];
if i<10
strnr=[strnr;['Resp. ',int2str(i),': ']];
else
strnr=[strnr;['Resp.',int2str(i),': ']];
end
ray=[ray;' - '];
end
set(handles.popupmenu5,'String',[strnr,num2str(arch(:,1)),ray,...
num2str(arch(:,2)),ray,num2str(arch(:,3))])
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit3 as text
% str2double(get(hObject,'String')) returns contents of edit3 as a double
% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit4_Callback(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit4 as text
% str2double(get(hObject,'String')) returns contents of edit4 as a double
% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global pathname netname
[netname,pathname]=uigetfile([pathname,'\*.mat*']);
set(handles.edit4,'String',netname)
% --------------------------------------------------------------------
% function Untitled_1_Callback(hObject, eventdata, handles)
% hObject handle to Untitled_1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
set(handles.popupmenu2,'Value',1)
set(handles.edit5,'String','')
set(handles.edit6,'String','')
set(handles.edit9,'String','')
set(handles.edit11,'String','')
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu2
global decides0f targetsf lows0f highs0f w_s0f Xcalname ycalname ...
pathname
% Xcalname=get(handles.edit1,'String');
% eval(['load ','''',[pathname,Xcalname,'''']])
% Xcal=eval(strtok(Xcalname,'.'));
% ycalname=get(handles.edit2,'String');
% eval(['load ','''',[pathname,ycalname,'''']])
% ycal=eval(strtok(ycalname,'.'));
fresp=get(handles.popupmenu1,'Value');
decides0f(fresp)=get(handles.popupmenu2,'Value');
if isempty(get(handles.edit9,'String'))==0
targetsf(fresp)=str2num(get(handles.edit9,'String'));
else
targetsf(fresp)=NaN;
end
if isempty(get(handles.edit5,'String'))==0
lows0f(fresp)=str2num(get(handles.edit5,'String'));
else
lows0f(fresp)=NaN;
end
if isempty(get(handles.edit6,'String'))==0
highs0f(fresp)=str2num(get(handles.edit6,'String'));
else
highs0f(fresp)=NaN;
end
if isempty(get(handles.edit11,'String'))==0
w_s0f(fresp)=str2num(get(handles.edit11,'String'));
else
w_s0f(fresp)=1;
end
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu3.
function popupmenu3_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu3 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu3
set(handles.popupmenu4,'Value',1)
set(handles.edit7,'String','')
set(handles.edit8,'String','')
set(handles.edit10,'String','')
set(handles.edit12,'String','')
% --- Executes during object creation, after setting all properties.
function popupmenu3_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu4.
function popupmenu4_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu4 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu4
global decides0 targets lows0 highs0 w_s0
iresp=get(handles.popupmenu3,'Value');
decides0(iresp)=get(handles.popupmenu4,'Value');
if isempty(get(handles.edit10,'String'))==0
targets(iresp)=str2num(get(handles.edit10,'String'));
else
targets(iresp)=NaN;
end
if isempty(get(handles.edit7,'String'))==0
lows0(iresp)=str2num(get(handles.edit7,'String'));
else
lows0(iresp)=NaN;
end
if isempty(get(handles.edit8,'String'))==0
highs0(iresp)=str2num(get(handles.edit8,'String'));
else
highs0(iresp)=NaN;
end
if isempty(get(handles.edit12,'String'))==0
w_s0(iresp)=str2num(get(handles.edit12,'String'));
else
w_s0(iresp)=1;
end
% --- Executes during object creation, after setting all properties.
function popupmenu4_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit5_Callback(hObject, eventdata, handles)
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit5 as text
% str2double(get(hObject,'String')) returns contents of edit5 as a double
% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit6_Callback(hObject, eventdata, handles)
% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit6 as text
% str2double(get(hObject,'String')) returns contents of edit6 as a double
% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit7_Callback(hObject, eventdata, handles)
% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit7 as text
% str2double(get(hObject,'String')) returns contents of edit7 as a double
% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit8_Callback(hObject, eventdata, handles)
% hObject handle to edit8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit8 as text
% str2double(get(hObject,'String')) returns contents of edit8 as a double
% --- Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global decides0 w_s0 lows0 highs0 targets Nf Xcalname ycalname netname ...
resul Nresp decides0f w_s0f lows0f highs0f targetsf resulf Xtestname ...
ytestname pathname
decides0(decides0==1)=5;
targets(decides0~=4)=NaN;
decides=decides0-1;
w_s=w_s0;
resul=[decides',w_s0',targets',lows0',highs0'];
decides0f(decides0f==1)=5;
targetsf(decides0f~=4)=NaN;
decidesf=decides0f-1;
w_s=w_s0f;
resulf=[decidesf',w_s0f',targetsf',lows0f',highs0f'];
status=close(table_opt);
if status==0
close table_opt
end
Xcalname=get(handles.edit1,'String');
eval(['load ','''',[pathname,Xcalname,'''']])
Xcal=eval(strtok(Xcalname,'.'));
ycalname=get(handles.edit2,'String');
eval(['load ','''',[pathname,ycalname,'''']])
ycal=eval(strtok(ycalname,'.'));
for i=1:size(ycal,2)
if isnan(resul(i,4))==1
% resul(i,4)=min(ycal(:,i));
end
if isnan(resul(i,5))==1
% resul(i,5)=max(ycal(:,i));
end
end
for i=1:size(Xcal,2)
if isnan(resulf(i,4))==1
% resulf(i,4)=min(Xcal(:,i));
end
if isnan(resulf(i,5))==1
% resulf(i,5)=max(Xcal(:,i));
end
end
table_opt
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function edit10_Callback(hObject, eventdata, handles)
% hObject handle to edit10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit10 as text
% str2double(get(hObject,'String')) returns contents of edit10 as a double
% --- Executes during object creation, after setting all properties.
function edit10_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit9_Callback(hObject, eventdata, handles)
% hObject handle to edit9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit9 as text
% str2double(get(hObject,'String')) returns contents of edit9 as a double
% --- Executes during object creation, after setting all properties.
function edit9_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit11_Callback(hObject, eventdata, handles)
% hObject handle to edit11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit11 as text
% str2double(get(hObject,'String')) returns contents of edit11 as a double
% --- Executes during object creation, after setting all properties.
function edit11_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit12_Callback(hObject, eventdata, handles)
% hObject handle to edit12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit12 as text
% str2double(get(hObject,'String')) returns contents of edit12 as a double
% --- Executes during object creation, after setting all properties.
function edit12_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit14_Callback(hObject, eventdata, handles)
% hObject handle to edit14 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit14 as text
% str2double(get(hObject,'String')) returns contents of edit14 as a double
% --- Executes during object creation, after setting all properties.
function edit14_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit14 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit13_Callback(hObject, eventdata, handles)
% hObject handle to edit13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit13 as text
% str2double(get(hObject,'String')) returns contents of edit13 as a double
% --- Executes during object creation, after setting all properties.
function edit13_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global pathname ytestname
[ytestname,pathname]=uigetfile([pathname,'\*.*']);
set(handles.edit14,'String',ytestname)
% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global pathname Xtestname
[Xtestname,pathname]=uigetfile([pathname,'\*.*']);
set(handles.edit13,'String',Xtestname)
% --- Executes on button press in pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global pathname C R w Nf Nresp Xcalname ycalname Xtestname ytestname
clc
Xcalname=get(handles.edit1,'String');
eval(['load ','''',[pathname,Xcalname,'''']])
Xcal=eval(strtok(Xcalname,'.'));
Xtestname=get(handles.edit13,'String');
eval(['load ','''',[pathname,Xtestname,'''']])
Xtest=eval(strtok(Xtestname,'.'));
ycalname=get(handles.edit2,'String');
eval(['load ','''',[pathname,ycalname,'''']])
ycal=eval(strtok(ycalname,'.'));
ytestname=get(handles.edit14,'String');
eval(['load ','''',[pathname,ytestname,'''']])
ytest=eval(strtok(ytestname,'.'));
Nf=size(Xcal,2);
for i=1:Nf
deltaX(i)=max(Xcal(:,i))-min(Xcal(:,i));
MMX(i)=min(Xcal(:,i))+max(Xcal(:,i));
X(:,i)=(2*Xcal(:,i)-MMX(i))/deltaX(i);
Xt(:,i)=(2*Xtest(:,i)-MMX(i))/deltaX(i);
end
Nresp=size(ycal,2);
for i=1:Nresp
deltay(i)=max(ycal(:,i))-min(ycal(:,i));
MMy(i)=min(ycal(:,i))+max(ycal(:,i));
y(:,i)=(2*ycal(:,i)-MMy(i))/deltay(i);
yt(:,i)=(2*ytest(:,i)-MMy(i))/deltay(i);
end
disp('Test results')
for i=1:Nresp
[ypt(:,i)]=prueba2(Xt',C{i},R(i),w{i});
disp(' ')
disp(['Response ',int2str(i)])
coco=corrcoef(yt(:,i),ypt(:,i));
disp(['R2 = ',num2str(coco(1,2))])
disp(['Std. Dev. = ',num2str(.5*deltay(i)*norm(yt(:,i)-ypt(:,i))/sqrt(size(ytest,i)))])
disp(['CV(%) = ',num2str(50*deltay(i)*norm(yt(:,i)-ypt(:,i))/(sqrt(size(ytest,i))*mean(ytest(:,i))))])
end
% Plots
leg=''' 1 ';
for i=2:Nresp
leg=[leg,''','' ',int2str(i)];
end
leg=[leg,''''];
figure(1),close 1,figure(1)
set(gcf,'Numbertitle','off')
set(gcf,'Name','Test results')
plot(yt,ypt,'o','Linewidth',2)
hold on
plot([min(yt(:)),max(yt(:))],[min(yt(:)),max(yt(:))],'--r','Linewidth',1.5)
axis tight
set(gca,'LineWidth',2)
title('Test results','Fontsize',14)
xlabel('Nominal response','Fontsize',14)
ylabel('Estimated response','Fontsize',14)
eval(['legend(',leg,',0)']);
figure(2),close 2,figure(2)
set(gcf,'Numbertitle','off')
set(gcf,'Name','Test errors')
plot(yt,ypt-yt,'o','Linewidth',2)
hold on
plot([min(yt(:)),max(yt(:))],[0,0],'--r','Linewidth',1.5)
axis tight
set(gca,'LineWidth',2)
title('Test errors','Fontsize',14)
xlabel('Nominal response','Fontsize',14)
ylabel('Residual','Fontsize',14)
eval(['legend(',leg,',0)']);
for i=1:size(yt,2)
ypred(:,i)=(ypt(:,i)*deltay(i)+MMy(i))/2;
ynom(:,i)=(yt(:,i)*deltay(i)+MMy(i))/2;
end
testres=[ynom,ypred,ynom-ypred];
eval(['save ','''',[pathname,'testresults.txt',''''],' testres -ascii'])
h=msgbox(['Test results (nominal, predicted, residuals) saved in ',pathname,'testresults.txt']);
function edit15_Callback(hObject, eventdata, handles)
% hObject handle to edit15 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit15 as text
% str2double(get(hObject,'String')) returns contents of edit15 as a double
% --- Executes during object creation, after setting all properties.
function edit15_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit15 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu5.
function popupmenu5_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu5 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu5
% --- Executes during object creation, after setting all properties.
function popupmenu5_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end