|
@@ -15,7 +15,7 @@ function [D_full, w_fin, Geometry, optGoal] = NLP_optimizer_v3(varargin)
|
|
% Inputs:
|
|
% Inputs:
|
|
% () OR
|
|
% () OR
|
|
% (Pat_path, path2goal) OR
|
|
% (Pat_path, path2goal) OR
|
|
-% (Pat_path, path2goal, beamlet_weights)
|
|
|
|
|
|
+% (Pat_path, path2goal, path2NLP_result)
|
|
% Pat_path, path2goal = strings to patient folder and optimal goals
|
|
% Pat_path, path2goal = strings to patient folder and optimal goals
|
|
% beamlet_weights = initial beamlet weights
|
|
% beamlet_weights = initial beamlet weights
|
|
%
|
|
%
|
|
@@ -24,6 +24,7 @@ function [D_full, w_fin, Geometry, optGoal] = NLP_optimizer_v3(varargin)
|
|
%
|
|
%
|
|
% Made by Peter Ferjancic 1. May 2018
|
|
% Made by Peter Ferjancic 1. May 2018
|
|
% Last updated: 1. April 2019
|
|
% Last updated: 1. April 2019
|
|
|
|
+dialogue_box = 'no';
|
|
|
|
|
|
if nargin<2
|
|
if nargin<2
|
|
load('WiscPlan_preferences.mat')
|
|
load('WiscPlan_preferences.mat')
|
|
@@ -32,14 +33,22 @@ if nargin<2
|
|
|
|
|
|
path2geometry = [Pat_path, '\matlab_files\Geometry.mat'];
|
|
path2geometry = [Pat_path, '\matlab_files\Geometry.mat'];
|
|
path2goal = [Goal_path, Goal_file];
|
|
path2goal = [Goal_path, Goal_file];
|
|
|
|
+elseif nargin ==2
|
|
|
|
+ Pat_path = varargin{1};
|
|
|
|
+ path2geometry = [Pat_path, '\matlab_files\Geometry.mat'];
|
|
|
|
+ path2goal = varargin{2};
|
|
|
|
+ [Goal_path,Goal_file,ext] = fileparts(path2goal);
|
|
else
|
|
else
|
|
Pat_path = varargin{1};
|
|
Pat_path = varargin{1};
|
|
path2geometry = [Pat_path, '\matlab_files\Geometry.mat'];
|
|
path2geometry = [Pat_path, '\matlab_files\Geometry.mat'];
|
|
path2goal = varargin{2};
|
|
path2goal = varargin{2};
|
|
[Goal_path,Goal_file,ext] = fileparts(path2goal);
|
|
[Goal_path,Goal_file,ext] = fileparts(path2goal);
|
|
|
|
+ path2NLPres = varargin{3};
|
|
|
|
+ load(path2NLPres);
|
|
|
|
+ dialogue_box = 'pass';
|
|
|
|
+ pre_beamWeights = 'yS';
|
|
end
|
|
end
|
|
|
|
|
|
-dialogue_box = 'no'
|
|
|
|
switch dialogue_box
|
|
switch dialogue_box
|
|
case 'yes'
|
|
case 'yes'
|
|
str = inputdlg({'N of iterations for initial calc', 'N of iterations for full calc', ...
|
|
str = inputdlg({'N of iterations for initial calc', 'N of iterations for full calc', ...
|
|
@@ -52,6 +61,9 @@ switch dialogue_box
|
|
N_fcallback1 = 1e5;
|
|
N_fcallback1 = 1e5;
|
|
N_fcallback2 = 2e6; % 500000;
|
|
N_fcallback2 = 2e6; % 500000;
|
|
pre_beamWeights = 'n';
|
|
pre_beamWeights = 'n';
|
|
|
|
+ case 'pass'
|
|
|
|
+ N_fcallback1 = 1e5;
|
|
|
|
+ N_fcallback2 = 2e6; % 500000;
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
@@ -65,6 +77,8 @@ switch pre_beamWeights
|
|
if numel(all_beams) ~= numel(w_beamlets)
|
|
if numel(all_beams) ~= numel(w_beamlets)
|
|
error('Provided weight number does not match beamlet number!')
|
|
error('Provided weight number does not match beamlet number!')
|
|
end
|
|
end
|
|
|
|
+ case 'yS'
|
|
|
|
+ w_beamlets = NLP_result.weights;
|
|
case 'n'
|
|
case 'n'
|
|
disp('Initial beam weights will be calculated.')
|
|
disp('Initial beam weights will be calculated.')
|
|
end
|
|
end
|
|
@@ -153,7 +167,8 @@ for i_goal = 1:size(OptGoals.goals,1)
|
|
optGoal{i_goal}.beamlets_pruned(i_supVox,:) = sparse(mean(beamlets(idxList, :),1));
|
|
optGoal{i_goal}.beamlets_pruned(i_supVox,:) = sparse(mean(beamlets(idxList, :),1));
|
|
|
|
|
|
if isfield(OptGoals.data{i_goal}, 'wgt_map')
|
|
if isfield(OptGoals.data{i_goal}, 'wgt_map')
|
|
- optGoal{i_goal}.vox_wgt(i_supVox) = sum(tabula_wgtmap(idxList));
|
|
|
|
|
|
+% optGoal{i_goal}.vox_wgt(i_supVox) = sum(tabula_wgtmap(idxList));
|
|
|
|
+ optGoal{i_goal}.vox_wgt(i_supVox) = mean(tabula_wgtmap(idxList));
|
|
end
|
|
end
|
|
|
|
|
|
% -- make new indeces
|
|
% -- make new indeces
|
|
@@ -202,6 +217,7 @@ options = optimoptions('fmincon');
|
|
options.MaxFunctionEvaluations = N_fcallback1;
|
|
options.MaxFunctionEvaluations = N_fcallback1;
|
|
options.Display = 'iter';
|
|
options.Display = 'iter';
|
|
options.PlotFcn = 'optimplotfval';
|
|
options.PlotFcn = 'optimplotfval';
|
|
|
|
+options.MaxIterations = 100;
|
|
% options.UseParallel = true;
|
|
% options.UseParallel = true;
|
|
options.UseParallel = false;
|
|
options.UseParallel = false;
|
|
% options.OptimalityTolerance = 1e-9;
|
|
% options.OptimalityTolerance = 1e-9;
|