load('signatures');
z_score_parameters=csvread('z_score_parameters.csv');
num_a_sel1=[358 54 165 293 312 326 340 354 363 368 391];
num_v_sel1=[304 54 26 41 57 293 298 307 312 335 349 357 368 377 395];
num_p_sel1=[400 67 7 72 15 294 318 341 387 31 391 396];
selected_a=[1 2 5 7 8 11];
selected_v=[1 2 5 6 14 15];
selected_p=[1 4 5 7 8 9 10];

%load features
path = '';
cohort = '';
patient_ID = input('patient_ID = ');
load([path '\' cohort '\A\' patient_ID '.mat']);
dataxA=data.feature;
dataxA=(dataxA(num_a_sel1)-z_score_parameters(1,num_a_sel1))./z_score_parameters(2,num_a_sel1);
load([path '\' cohort '\V\' patient_ID '.mat']);
dataxV=data.feature;
dataxV=(dataxV(num_v_sel1)-z_score_parameters(3,num_v_sel1))./z_score_parameters(4,num_v_sel1);
load([path '\' cohort '\p\' patient_ID '.mat']);
dataxp=data.feature;
dataxp=(dataxp(num_p_sel1)-z_score_parameters(5,num_p_sel1))./z_score_parameters(6,num_p_sel1);

%calculate the radiomic signatures
[pyA,~,~] = svmpredict(0,dataxA(selected_a),modelA);
[pyV,~,~] = svmpredict(0,dataxV(selected_v),modelV);
[pyp,~,~] = svmpredict(0,dataxp(selected_p),modelp);

%calculate nomogram value
nomogram=-0.6632+0.5100*pyA+0.6813*pyV+0.4449*(strcmp(CTreport,'N1/N2'))+0.4712*(strcmp(CTreport,'N3a/N3b'));
%risk of N stage >=1
r1=1/(1+exp(-(-1.167+1.618*nomogram)));
%risk of N stage >=2
r2=1/(1+exp(-(-3.844+2.450*nomogram)));
%risk of N stage >=3a
r3a=1/(1+exp(-(-5.200+2.301*nomogram)));
%risk of N stage >=3b
r3b=1/(1+exp(-(-6.467+1.824*nomogram)));

%the possible exact N stage 
if r1<=0.5
    disp('N0 is the possible N stage');
elseif r2<=0.5
    disp('N1 is the possible N stage');
elseif r3a<=0.5
    disp('N2 is the possible N stage');
elseif r3b<=0.5
    disp('N3a is the possible N stage');
else
    disp('N3b is the possible N stage');
end
