NImParamRadiusGui.m 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. %% CALLED BY par4Gbl_Main8c.m %%
  2. % TODO Should some of these vars be pulled out higher so they are easier to change?
  3. %
  4. function NImParamRadiusGui(projectScansDir)
  5. global SWsingleSc
  6. global SWgrowthArea
  7. global scan
  8. global scLst
  9. global ImParMat
  10. global searchRangeNum
  11. global defImParMat
  12. global fhImRun
  13. global fhconsole
  14. global easyResultsDir
  15. global fotosResultsDir
  16. global pointMapsResultsDir
  17. global pointMapsFile
  18. global matFile
  19. global numRows
  20. global numCols
  21. global scanSize
  22. global scanMax
  23. global searchRangeFile
  24. % Ncode ImRobot adaptation
  25. % TODO this code block and variables needs explanation
  26. defImParMat=[1,1,15,34,24,1,0,0,1,14,1,18];
  27. if ImParMat(3)==0 || ImParMat(4)==0 ||ImParMat(5)==0 || ImParMat(10)==0 ||ImParMat(11)==0
  28. ImParMat=defImParMat;
  29. end
  30. if size(ImParMat,2)<12
  31. ImParMat(12)=18; % default before user input CsearchRange value
  32. msg='Data made before SearchRange user entry added (ImParMat(12). 18 was the set value and the current default.)';
  33. end
  34. % ImParMat=defImParMat; %Activate for INITIAL USE only
  35. MPnum=1;
  36. destPerMP=1;
  37. selScan=1;
  38. SWgrowthArea=1;
  39. if exist(pointMapsFile, 'file')
  40. load(pointMapsFile);
  41. else
  42. load(fullfile(easyDir, 'PTmats', 'NImParameters')) % hardcoded default
  43. disp('WARNING: Using hardcoded NImParameters.mat')
  44. end
  45. ImParMat;
  46. % if ~exist('searchRangeNum','var') || isempty(searchRangeNum)
  47. if exist(searchRangeFile, 'file')
  48. load(searchRangeFile);
  49. CSearchRange; % TODO, might be an issue, figure out what this is doing
  50. end
  51. % yInitPos=0.30;
  52. xPos=0.05;
  53. btnWid=0.10;
  54. btnHt=0.05;
  55. spacing=0.02;% Spacing between the button and the next command's label
  56. % The ADD Groups button
  57. btnNumber=1;
  58. yPos=0.85-(btnNumber-1)*(btnHt+spacing);
  59. btnPos=[xPos yPos-spacing btnWid btnHt];
  60. fhImParm=gcf;
  61. if exist('easyResultsDir','var')&& ~isempty(easyResultsDir)
  62. set(fhImParm,'NumberTitle','off')
  63. set(fhImParm,'Name',strcat('ImageAnalysis- ',char(easyResultsDir)))
  64. else
  65. set(fhImParm,'NumberTitle','off')
  66. set(fhImParm,'Name','EASYconsole - Exp. Analysis NOT selected.')
  67. end
  68. btnNumber=5;
  69. yPos=0.85-(btnNumber-1)*(btnHt+spacing);
  70. btnPos=[xPos yPos-spacing btnWid btnHt];
  71. srcRadius=ImParMat(10);
  72. hedit=uicontrol(...
  73. 'Style', 'edit',...
  74. 'String',srcRadius,...
  75. 'Units','normalized',...
  76. 'Position', btnPos,... % [.002 .70 .08 .10],...
  77. 'callback',{@entryRadius}); % 'Position', [5 100 60 20])
  78. function entryRadius(source,~)
  79. user_entry=str2double(get(source,'string'));
  80. if (isnan(user_entry)||(user_entry<12)||(user_entry>17))
  81. errordlg('You must enter a numeric value between 12 and 17','Bad Input','modal')
  82. return
  83. end
  84. Radius=user_entry;
  85. ImParMat(10)=Radius;
  86. Radius;
  87. end
  88. btnNumber=6;
  89. yPos=0.85-(btnNumber-1)*(btnHt+spacing);
  90. btnPos=[xPos yPos-spacing btnWid btnHt];
  91. srcDither=ImParMat(6);
  92. hedit=uicontrol(...
  93. 'Style', 'edit',...
  94. 'String',srcDither,...
  95. 'Units','normalized',...
  96. 'Position', btnPos,...
  97. 'callback',{@entryDither});
  98. function entryDither(source,~)
  99. user_entry=str2double(get(source,'string'));
  100. if (isnan(user_entry)||(user_entry<0)||(user_entry>5))
  101. errordlg('You must enter a numeric value between 1 and 4','Bad Input','modal')
  102. return
  103. end
  104. Dither=user_entry;
  105. ImParMat(6)=Dither;
  106. Dither;
  107. end
  108. btnNumber=7;
  109. yPos=0.85-(btnNumber-1)*(btnHt+spacing);
  110. btnPos=[xPos yPos-spacing btnWid btnHt];
  111. % TODO, I don't think these are defined?
  112. try
  113. srchRange=ImParMat(12);
  114. catch % Legacy default value was 18 before being made a user input variable (ImParMat(12)). A preferable value now might be 12 or 14.
  115. srchRange=18;
  116. ImParMat(12)=18;
  117. end
  118. hSearchRange=uicontrol(...
  119. 'Style', 'edit',...
  120. 'Value',searchRangeNum,...
  121. 'Units','normalized',...
  122. 'Position', btnPos,...
  123. 'callback',{@searchRangeCallback});
  124. function searchRangeCallback(source,~)
  125. user_entry=str2double(get(source,'string'));
  126. if (isnan(user_entry)||(user_entry<1)||(user_entry>50)) %originally 18; 19_0729 increased
  127. errordlg('You must enter a numeric value between 1 and 18 12->18 recommended. (ImParMat(12)))','Bad Input','modal')
  128. return
  129. end
  130. searchRangeNum=user_entry;
  131. end
  132. % Ncode 12_0120 for reading in numeric folder names
  133. nlist=dir(fullfile(projectScansDir,'*'));
  134. nnn=0;
  135. for n=1:size(nlist,1)
  136. if (~isempty(str2num(nlist(n).name)))
  137. nnn=nnn+1;
  138. PnumLst(nnn)=(str2num(nlist(n).name));
  139. sl(nnn,1)={(nlist(n).name)};
  140. end
  141. end
  142. scanSize=size(sl,1);
  143. scanMax=max(str2double(sl));
  144. hListbox=uicontrol(...
  145. 'Style', 'listbox',...
  146. 'String',sort(sl),...
  147. 'value',[],...
  148. 'max',1000,...
  149. 'min',1,...
  150. 'Units','normalized',...
  151. 'Position', [.70 .40 .10 .60],...
  152. 'callback',{@load_listbox}); %'uiresume(gcbf)'); 'Position', [5 100 60 20])
  153. function load_listbox(source,~)
  154. userIndx=(get(source,'value'));
  155. userStr=(get(source,'string'));
  156. %scLstIndx=str2num(char(strrep(userStr(userIndx), 'Scan', '')))
  157. user_entry=userStr(userIndx);
  158. scLst=user_entry;
  159. if size(scLst,1)>1
  160. % searchRangeNum=num2str(ImParMat(12))
  161. set(hSearchRange,'string',num2str(ImParMat(12)))
  162. else
  163. try
  164. searchRangeNum=CSearchRange(str2double(scLst));
  165. set(hSearchRange,'string',CSearchRange(str2double(scLst)))
  166. catch
  167. % CSrchRng=num2str(ImParMat(12))
  168. % set(hSearchRange,'string',num2str(ImParMat(12)))
  169. end
  170. end
  171. end
  172. scLst;
  173. btnNumber=10;
  174. yPos=0.85-(btnNumber-1)*(btnHt+spacing);
  175. btnPos=[xPos yPos-spacing btnWid btnHt];
  176. hedit8=uicontrol(...
  177. 'Style', 'pushbutton',...
  178. 'String',{'Continue'},...
  179. 'Units','normalized',...
  180. 'Position', btnPos,...
  181. 'callback','uiresume(gcbf)');
  182. % Labels
  183. xLPos=0.175;
  184. yPos=0;
  185. btnWid=0.20;
  186. lblNumber=5;
  187. yPos=0.85-(lblNumber-1)*(btnHt+spacing);
  188. btnPos=[xLPos yPos-spacing btnWid btnHt];
  189. htxt=uicontrol(...
  190. 'Style', 'text',...
  191. 'String','Radius',... %'String','Width',...
  192. 'Units','normalized',...
  193. 'Position', btnPos);
  194. lblNumber=6;
  195. yPos=0.85-(lblNumber-1)*(btnHt+spacing);
  196. btnPos=[xLPos yPos-spacing btnWid btnHt];
  197. htxt=uicontrol(...
  198. 'Style', 'text',...
  199. 'String','Dither',...
  200. 'Units','normalized',...
  201. 'Position', btnPos);
  202. lblNumber=7;
  203. yPos=0.85-(lblNumber-1)*(btnHt+spacing);
  204. btnPos=[xLPos yPos-spacing btnWid btnHt];
  205. htxt=uicontrol(...
  206. 'Style', 'text',...
  207. 'String','SearchRange',...
  208. 'Units','normalized',...
  209. 'Position', btnPos);
  210. uiwait(gcf);
  211. for i=1:length(scLst)
  212. CSearchRange(str2double(scLst(i)))=CSrchRng;
  213. ImParMat(12)=CSrchRng;
  214. end
  215. ImParMat;
  216. searchRangeNum;
  217. save(pointMapsFile, 'ImParMat');
  218. save(searchRangeFile,'searchRangeNum');
  219. close
  220. return
  221. end