Files
hartman-server/qhtcp-workflow/apps/matlab/easy/NImParamRadiusGui.m

248 lines
7.0 KiB
Matlab
Executable File

%% CALLED BY par4Gbl_Main8c.m %%
% TODO Should some of these vars be pulled out higher so they are easier to change?
%
function NImParamRadiusGui(projectScansDir)
global SWsingleSc
global SWgrowthArea
global scan
global scLst
global ImParMat
global searchRangeNum
global defImParMat
global fhImRun
global fhconsole
global easyResultsDir
global fotosResultsDir
global pointMapsResultsDir
global pointMapsFile
global matFile
global numRows
global numCols
global scanSize
global scanMax
global searchRangeFile
% 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
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
MPnum=1;
destPerMP=1;
selScan=1;
SWgrowthArea=1;
if exist(pointMapsFile, 'file')
load(pointMapsFile);
else
load(fullfile(easyDir, 'PTmats', 'NImParameters')) % hardcoded default
disp('WARNING: Using hardcoded NImParameters.mat')
end
ImParMat;
% if ~exist('searchRangeNum','var') || isempty(searchRangeNum)
if exist(searchRangeFile, 'file')
load(searchRangeFile);
CSearchRange; % TODO, might be an issue, figure out what this is doing
end
% yInitPos=0.30;
xPos=0.05;
btnWid=0.10;
btnHt=0.05;
spacing=0.02;% Spacing between the button and the next command's label
% The ADD Groups button
btnNumber=1;
yPos=0.85-(btnNumber-1)*(btnHt+spacing);
btnPos=[xPos yPos-spacing btnWid btnHt];
fhImParm=gcf;
if exist('easyResultsDir','var')&& ~isempty(easyResultsDir)
set(fhImParm,'NumberTitle','off')
set(fhImParm,'Name',strcat('ImageAnalysis- ',char(easyResultsDir)))
else
set(fhImParm,'NumberTitle','off')
set(fhImParm,'Name','EASYconsole - Exp. Analysis NOT selected.')
end
btnNumber=5;
yPos=0.85-(btnNumber-1)*(btnHt+spacing);
btnPos=[xPos yPos-spacing btnWid btnHt];
srcRadius=ImParMat(10);
hedit=uicontrol(...
'Style', 'edit',...
'String',srcRadius,...
'Units','normalized',...
'Position', btnPos,... % [.002 .70 .08 .10],...
'callback',{@entryRadius}); % 'Position', [5 100 60 20])
function entryRadius(source,~)
user_entry=str2double(get(source,'string'));
if (isnan(user_entry)||(user_entry<12)||(user_entry>17))
errordlg('You must enter a numeric value between 12 and 17','Bad Input','modal')
return
end
Radius=user_entry;
ImParMat(10)=Radius;
Radius;
end
btnNumber=6;
yPos=0.85-(btnNumber-1)*(btnHt+spacing);
btnPos=[xPos yPos-spacing btnWid btnHt];
srcDither=ImParMat(6);
hedit=uicontrol(...
'Style', 'edit',...
'String',srcDither,...
'Units','normalized',...
'Position', btnPos,...
'callback',{@entryDither});
function entryDither(source,~)
user_entry=str2double(get(source,'string'));
if (isnan(user_entry)||(user_entry<0)||(user_entry>5))
errordlg('You must enter a numeric value between 1 and 4','Bad Input','modal')
return
end
Dither=user_entry;
ImParMat(6)=Dither;
Dither;
end
btnNumber=7;
yPos=0.85-(btnNumber-1)*(btnHt+spacing);
btnPos=[xPos yPos-spacing btnWid btnHt];
% TODO, I don't think these are defined?
try
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;
end
hSearchRange=uicontrol(...
'Style', 'edit',...
'Value',searchRangeNum,...
'Units','normalized',...
'Position', btnPos,...
'callback',{@searchRangeCallback});
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
searchRangeNum=user_entry;
end
% Ncode 12_0120 for reading in numeric folder names
nlist=dir(fullfile(projectScansDir,'*'));
nnn=0;
for n=1:size(nlist,1)
if (~isempty(str2num(nlist(n).name)))
nnn=nnn+1;
PnumLst(nnn)=(str2num(nlist(n).name));
sl(nnn,1)={(nlist(n).name)};
end
end
scanSize=size(sl,1);
scanMax=max(str2double(sl));
hListbox=uicontrol(...
'Style', 'listbox',...
'String',sort(sl),...
'value',[],...
'max',1000,...
'min',1,...
'Units','normalized',...
'Position', [.70 .40 .10 .60],...
'callback',{@load_listbox}); %'uiresume(gcbf)'); 'Position', [5 100 60 20])
function load_listbox(source,~)
userIndx=(get(source,'value'));
userStr=(get(source,'string'));
%scLstIndx=str2num(char(strrep(userStr(userIndx), 'Scan', '')))
user_entry=userStr(userIndx);
scLst=user_entry;
if size(scLst,1)>1
% searchRangeNum=num2str(ImParMat(12))
set(hSearchRange,'string',num2str(ImParMat(12)))
else
try
searchRangeNum=CSearchRange(str2double(scLst));
set(hSearchRange,'string',CSearchRange(str2double(scLst)))
catch
% CSrchRng=num2str(ImParMat(12))
% set(hSearchRange,'string',num2str(ImParMat(12)))
end
end
end
scLst;
btnNumber=10;
yPos=0.85-(btnNumber-1)*(btnHt+spacing);
btnPos=[xPos yPos-spacing btnWid btnHt];
hedit8=uicontrol(...
'Style', 'pushbutton',...
'String',{'Continue'},...
'Units','normalized',...
'Position', btnPos,...
'callback','uiresume(gcbf)');
% Labels
xLPos=0.175;
yPos=0;
btnWid=0.20;
lblNumber=5;
yPos=0.85-(lblNumber-1)*(btnHt+spacing);
btnPos=[xLPos yPos-spacing btnWid btnHt];
htxt=uicontrol(...
'Style', 'text',...
'String','Radius',... %'String','Width',...
'Units','normalized',...
'Position', btnPos);
lblNumber=6;
yPos=0.85-(lblNumber-1)*(btnHt+spacing);
btnPos=[xLPos yPos-spacing btnWid btnHt];
htxt=uicontrol(...
'Style', 'text',...
'String','Dither',...
'Units','normalized',...
'Position', btnPos);
lblNumber=7;
yPos=0.85-(lblNumber-1)*(btnHt+spacing);
btnPos=[xLPos yPos-spacing btnWid btnHt];
htxt=uicontrol(...
'Style', 'text',...
'String','SearchRange',...
'Units','normalized',...
'Position', btnPos);
uiwait(gcf);
for i=1:length(scLst)
CSearchRange(str2double(scLst(i)))=CSrchRng;
ImParMat(12)=CSrchRng;
end
ImParMat;
searchRangeNum;
save(pointMapsFile, 'ImParMat');
save(searchRangeFile,'searchRangeNum');
close
return
end