EASY refactor: First attempt
This commit is contained in:
@@ -1,29 +1,35 @@
|
||||
%% CALLED BY par4Gbl_Main8c.m %%
|
||||
function NImParamRadiusGui(expDir)
|
||||
% TODO Should some of these vars be pulled out higher so they are easier to change?
|
||||
%
|
||||
|
||||
function NImParamRadiusGui(scansDir)
|
||||
global SWsingleSc
|
||||
global SWgrowthArea
|
||||
%global selScan
|
||||
global scan
|
||||
global scLst
|
||||
global ImParMat
|
||||
%global CSearchRange
|
||||
global CSrchRng
|
||||
global searchRangeNum
|
||||
global defImParMat
|
||||
global fhImRun
|
||||
global fhconsole
|
||||
global resDir
|
||||
global ExpOutmat
|
||||
global numRows;
|
||||
global numCols;
|
||||
global easyResultsDir
|
||||
global fotosResultsDir
|
||||
global pointMapsResultsDir
|
||||
global pointMapsFile
|
||||
global matFile
|
||||
global numRows
|
||||
global numCols
|
||||
global scanSize
|
||||
global scanMax
|
||||
|
||||
defImParMat=[1, 1, 15, 34, 24, 1,0,0,1,14,1,18]; %Ncode ImRobot adaptation
|
||||
% Ncode ImRobot adaptation
|
||||
% TODO this code block and variables needs explanation
|
||||
defImParMat=[1,1,15,34,24,1,0,0,1,14,1,18];
|
||||
if ImParMat(3)==0 || ImParMat(4)==0 ||ImParMat(5)==0 || ImParMat(10)==0 ||ImParMat(11)==0
|
||||
ImParMat=defImParMat;
|
||||
end
|
||||
if size(ImParMat,2)<12
|
||||
ImParMat(12)=18; %Default before user input CsearchRange value
|
||||
ImParMat(12)=18; % default before user input CsearchRange value
|
||||
msg='Data made before SearchRange user entry added (ImParMat(12). 18 was the set value and the current default.)';
|
||||
end
|
||||
% ImParMat=defImParMat; %Activate for INITIAL USE only
|
||||
@@ -31,15 +37,17 @@ function NImParamRadiusGui(expDir)
|
||||
destPerMP=1;
|
||||
selScan=1;
|
||||
SWgrowthArea=1;
|
||||
if exist(fullfile(resDir,'PTmats','NImParameters.mat'))
|
||||
load(fullfile(resDir,'PTmats','NImParameters'));
|
||||
|
||||
if exist(pointMapsFile)
|
||||
load(pointMapsFile);
|
||||
else
|
||||
load NImParameters
|
||||
load(fullfile(PTmats,'NImParameters')) % hardcoded default
|
||||
disp('WARNING: Using hardcoded NImParameters.mat')
|
||||
end
|
||||
ImParMat;
|
||||
%if ~exist('CSearchRange','var') || isempty(CSearchRange)
|
||||
if ~isequal(exist(fullfile(resDir,'Fotos','CSearchRange.mat')),0)
|
||||
load(fullfile(resDir,'Fotos','CSearchRange'))
|
||||
ImParMat
|
||||
% if ~exist('searchRangeNum','var') || isempty(searchRangeNum)
|
||||
if exist(CSearchRangeFile), 'file')
|
||||
load(CSearchRangeFile);
|
||||
CSearchRange;
|
||||
end
|
||||
|
||||
@@ -54,9 +62,9 @@ function NImParamRadiusGui(expDir)
|
||||
yPos=0.85-(btnNumber-1)*(btnHt+spacing);
|
||||
btnPos=[xPos yPos-spacing btnWid btnHt];
|
||||
fhImParm=gcf;
|
||||
if exist('resDir','var')&& ~isempty(resDir)
|
||||
if exist('easyResultsDir','var')&& ~isempty(easyResultsDir)
|
||||
set(fhImParm,'NumberTitle','off')
|
||||
set(fhImParm,'Name',strcat('ImageAnalysis- ',char(resDir)))
|
||||
set(fhImParm,'Name',strcat('ImageAnalysis- ',char(easyResultsDir)))
|
||||
else
|
||||
set(fhImParm,'NumberTitle','off')
|
||||
set(fhImParm,'Name','EASYconsole -Exp. Analysis NOT selected.')
|
||||
@@ -110,32 +118,30 @@ function NImParamRadiusGui(expDir)
|
||||
yPos=0.85-(btnNumber-1)*(btnHt+spacing);
|
||||
btnPos=[xPos yPos-spacing btnWid btnHt];
|
||||
try
|
||||
CSrchRange=ImParMat(12);
|
||||
CSrchRng=ImParMat(12);
|
||||
catch %Legacy default value was 18 before being made a user input variable (ImParMat(12)). A preferable value now might be 12 or 14.
|
||||
CSrchRange=18;
|
||||
srchRange=ImParMat(12);
|
||||
catch % Legacy default value was 18 before being made a user input variable (ImParMat(12)). A preferable value now might be 12 or 14.
|
||||
srchRange=18;
|
||||
ImParMat(12)=18;
|
||||
CSrchRng=ImParMat(12);
|
||||
end
|
||||
|
||||
hSearchRange=uicontrol(...
|
||||
'Style', 'edit',...
|
||||
'String',CSrchRange,...
|
||||
'Value',searchRangeNum,...
|
||||
'Units','normalized',...
|
||||
'Position', btnPos,...
|
||||
'callback',{@CsearchRange});
|
||||
'callback',{@searchRangeCallback});
|
||||
|
||||
function CsearchRange(source,~)
|
||||
function searchRangeCallback(source,~)
|
||||
user_entry=str2double(get(source,'string'));
|
||||
if (isnan(user_entry)||(user_entry<1)||(user_entry>50)) %originally 18; 19_0729 increased
|
||||
errordlg('You must enter a numeric value between 1 and 18 12->18 recommended. (ImParMat(12)))','Bad Input','modal')
|
||||
return
|
||||
end
|
||||
CSrchRng=user_entry;
|
||||
searchRangeNum=user_entry;
|
||||
end
|
||||
|
||||
% Ncode 12_0120 for reading in numeric folder names
|
||||
nlist=dir(fullfile(expDir,'*'));
|
||||
nlist=dir(fullfile(scansDir,'*'));
|
||||
nnn=0;
|
||||
for n=1:size(nlist,1)
|
||||
if (~isempty(str2num(nlist(n).name)))
|
||||
@@ -158,8 +164,7 @@ function NImParamRadiusGui(expDir)
|
||||
'callback',{@load_listbox}); %'uiresume(gcbf)'); 'Position', [5 100 60 20])
|
||||
|
||||
function load_listbox(source,~)
|
||||
%global CSrchRng
|
||||
%global CSrearchRange
|
||||
global
|
||||
userIndx=(get(source,'value'));
|
||||
userStr=(get(source,'string'));
|
||||
%scLstIndx=str2num(char(strrep(userStr(userIndx), 'Scan', '')))
|
||||
@@ -167,11 +172,11 @@ function NImParamRadiusGui(expDir)
|
||||
user_entry=userStr(userIndx);
|
||||
scLst=user_entry;
|
||||
if size(scLst,1)>1
|
||||
%CSrchRng=num2str(ImParMat(12))
|
||||
% searchRangeNum=num2str(ImParMat(12))
|
||||
set(hSearchRange,'string',num2str(ImParMat(12)))
|
||||
else
|
||||
try
|
||||
CSrchRng=CSearchRange(str2double(scLst));
|
||||
searchRangeNum=CSearchRange(str2double(scLst));
|
||||
set(hSearchRange,'string',CSearchRange(str2double(scLst)))
|
||||
catch
|
||||
% CSrchRng=num2str(ImParMat(12))
|
||||
@@ -231,16 +236,10 @@ function NImParamRadiusGui(expDir)
|
||||
end
|
||||
|
||||
ImParMat;
|
||||
CSearchRange;
|
||||
try
|
||||
save('NImParameters','ImParMat')
|
||||
% save('CSearchRange','CSearchRange')
|
||||
catch
|
||||
save(fullfile('\','NImParameters'),'ImParMat')
|
||||
% save(fullfile('\','CSearchRange'),'CSearchRange')
|
||||
end
|
||||
save((fullfile(resDir,'PTmats','NImParameters')), 'ImParMat');
|
||||
save((fullfile(resDir,'Fotos','CSearchRange')),'CSearchRange');
|
||||
searchRangeNum;
|
||||
|
||||
save(pointMapsFile, 'ImParMat');
|
||||
save(CSearchRangeFile,'searchRangeNum');
|
||||
|
||||
close
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user