EZspotview.m 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. function EZspotview(expN,DexpN, imLoc,OLresDir,OLplateNum,NoOLay)
  2. global Exp
  3. global ghandles
  4. datacursormode(gcf)
  5. w=pwd;
  6. aCnt=0;
  7. prevExp=0;
  8. if NoOLay==0
  9. cd(fullfile(char(OLresDir)))
  10. cd ..
  11. expDir=pwd;
  12. cd(w)
  13. %expDir=fullfile(char(OLresDir),'..');
  14. if ~isequal(expDir, char(fullfile(Exp(expN).Dexp(DexpN).ExpFoldr)))
  15. prevExp=1;
  16. end
  17. if prevExp==0
  18. expDir=Exp(expN).Dexp(DexpN).ExpFoldr;
  19. else
  20. cd(fullfile(char(OLresDir)))
  21. cd ..
  22. expDir=pwd;
  23. cd(w)
  24. %expDir=fullfile(char(OLresDir),'..');
  25. end
  26. else
  27. expDir=Exp(expN).Dexp(DexpN).ExpFoldr
  28. end
  29. %ExpHmDir=char(Exp(expN).Dexp(DexpN).resDir);
  30. try close(ghandles.hfstrip), catch, end % hfIm
  31. % CIRCLE related
  32. doCircle=1;
  33. radius=14;
  34. diaExt=2*(radius+1);
  35. EZvNIcircle
  36. rIm=imLoc(1); % use the "picture/Image' r and c not the plate annotation r c)
  37. cIm=imLoc(2);
  38. plateNum=Exp(expN).Dexp(DexpN).plateNum;
  39. if prevExp==0
  40. FexpScanSpots=Exp(expN).Dexp(DexpN).FexpScanSpots;
  41. FexpScanBMtp=Exp(expN).Dexp(DexpN).FexpScanBMtp;
  42. anlZoneRefs=Exp(expN).Dexp(DexpN).anlZoneRefs;
  43. ImParMat=Exp(expN).Dexp(DexpN).ImParMat;
  44. else
  45. % check if the request expJob is already loaded in one of the other zones
  46. matchfound=0;
  47. for j=1:3
  48. if isequal(expDir, char(fullfile(Exp(j).ExpFoldr)))
  49. FexpScanSpots=Exp(j).FexpScanSpots;
  50. FexpScanBMtp=Exp(j).FexpScanBMtp;
  51. anlZoneRefs=Exp(j).anlZoneRefs;
  52. ImParMat=Exp(j).ImParMat;
  53. matchfound=1;
  54. break
  55. end
  56. end
  57. if matchfound==0
  58. % if not, load data for previous experiment again.
  59. load(fullfile(char(OLresDir),'Fotos','Coordinates'))
  60. load(fullfile(char(OLresDir),'Fotos','anlZones'))
  61. load(fullfile(char(OLresDir),'Fotos','BGatTpts'))
  62. load(fullfile(char(OLresDir),'PTmats','NImParameters'))
  63. end
  64. end
  65. % Parameter Entry
  66. width=ImParMat(5);
  67. widthEx=width-1; %width extention from reference point
  68. % Start Spot selection and Manipulation section
  69. Fcutsc=[];
  70. Fstrip=[];
  71. %{
  72. cd(fullfile(char(OLresDir)))
  73. cd ..
  74. expDir=pwd;
  75. cd(w)
  76. %}
  77. % tPtsSize=size(Exp(expN).Dexp(DexpN).FexpScanBMtp{1,1},(3));
  78. tPtsSize=size(FexpScanBMtp{1,plateNum},(3)); % tPtsSize=size(FexpScanBMtp{1,1},(3)); 20160110
  79. %bmpFileLst=dirfullfile(char(OLresDir),num2str(plateNum),'*.bmp')); %(fullfile(expDir, char(ScLst(ScLstCnt)), '*.bmp'));
  80. hsafety=figure;
  81. dc=get(datacursormode)
  82. imInterval=1;
  83. try,imInterval=str2double(Exp(4).SpotVintervPar),catch,end
  84. try
  85. for tPt=1:imInterval:tPtsSize %tPtLength
  86. coord=[];
  87. try
  88. % FtifFile=fullfile(Exp(expN).Dexp(DexpN).ExpFoldr,num2str(plateNum),strcat(num2str(tPt),'.bmp')); %char(tifFileLst(tPt));
  89. FtifFile=fullfile(char(expDir),num2str(plateNum),strcat(num2str(tPt),'.bmp'));
  90. Fimg=imread(FtifFile);
  91. % For Visualization Purposes
  92. Fram=ones(2075,1400); %(size(Empsc,1),size(Empsc,2));
  93. % FRAME ANALYSIS AREA
  94. if size(FexpScanSpots,2)>1
  95. coord=FexpScanSpots{plateNum}{rIm,cIm,tPt};
  96. else
  97. coord=FexpScanSpots{plateNum,1,1}{rIm,cIm,tPt};
  98. end
  99. if size(anlZoneRefs,2)>1
  100. xyLoc=anlZoneRefs{plateNum}{rIm,cIm,tPt}; %F_Snum
  101. else
  102. xyLoc=anlZoneRefs{F_Snum,1,1}{rIm,cIm,tPt};
  103. end
  104. xLoc=xyLoc(2);
  105. yLoc=xyLoc(1);
  106. % CIRCLE related
  107. doCircle=1; % temp test value insertion to get square images
  108. if doCircle==1
  109. Fram=FoptCirMask;
  110. else
  111. % 1->2 across rt 1, 2-4
  112. Fram(yLoc,xLoc:(xLoc+widthEx))=0.8;
  113. % 1->4 down lf 1-3, 2
  114. Fram((yLoc+1):(yLoc+1+widthEx),xLoc)=0.8;
  115. % 2->3 down rt 1-3, 4
  116. Fram(yLoc:(yLoc+widthEx),(xLoc+1+widthEx))=0.8;
  117. % 4->3 Bot Across rt 1, 2-4
  118. Fram((yLoc+1+widthEx),(xLoc+1):(xLoc+1+widthEx))=0.8;
  119. Fram=Fram(coord(1):coord(3),coord(2):coord(4));
  120. end
  121. % Cut Spot Out Of Image
  122. % Fbg=FexpScanBMtp{selScan,1}(rIm,cIm,tPt);
  123. Fbg=FexpScanBMtp{plateNum}(rIm,cIm,tPt); %{selScan,1}
  124. % Fimg=imread(FtifFile); %,'PixelRegion', {[coord(1),coord(3)],[coord(2),coord(4)]});
  125. Fcutsc=Fimg(coord(1):coord(3),coord(2):coord(4));
  126. if doCircle==1
  127. %varExt=size(Fcutsc)-size(Fram);
  128. varExtPre=[((yLoc-0)-coord(1)) ((xLoc-0)-coord(2))];
  129. varExtPost=[(coord(3)-(yLoc+diaExt+1)) (coord(4)-(xLoc+diaExt+1))];
  130. % Fram=padarray(Fram,[expansion expansion],1,'pre');
  131. Fram=padarray(Fram,[varExtPre],1,'pre');
  132. Fram=padarray(Fram,[varExtPost],1,'post');
  133. % Fram=padarray(Fram,rem(varExt,2),1,'post');
  134. %Fram=padarray(Fram,floor((varExt-2)./2),1);
  135. end
  136. % Invert Image
  137. Fcutsc=double(Fcutsc) .* Fram;
  138. %Fcutsc=Fcutsc .* uint8(Fram);
  139. Fcutsc=uint8(Fcutsc);
  140. %Fcutsc=255 - (Fcutsc-Fbg);
  141. Fcutsc=(Fcutsc-Fbg);
  142. %Time series annotation**************************
  143. tmPtTx=[];
  144. tenths=(round(10*(Exp(expN).Dexp(DexpN).scan(plateNum).plate(1).tSeries(tPt)))) ./10;
  145. tmPtTx=strcat(num2str(tenths),'h');
  146. % imwrite(Fcutsc,(fullfile(resDir,'Fotos',strcat('FScan',num2str(selScan),'_timePt-',num2str(tPt),'.jpg'))),'jpg');
  147. aCnt=aCnt+1;
  148. if aCnt==1 %||tPt==1
  149. EZvapendLabel
  150. Fstrip=vertcat(Fcutsc,Bspace);
  151. Hspace=zeros(size(Fstrip,1),4)+1200; %+255
  152. Fstrip=horzcat(Fstrip,Hspace);
  153. end
  154. makeVis=1;
  155. if aCnt>1
  156. EZvapendLabel
  157. vcat=vertcat(Fcutsc,Bspace);
  158. %Hspace=zeros(size(Fstrip,1),4)+255;
  159. Fstrip=horzcat(Fstrip,vcat,Hspace);
  160. end
  161. % For Visualization Purposes only
  162. if makeVis==1
  163. % if aCnt==1,figure;end
  164. % resIm=uint8((double(BGsc) + OptmapOnesDbl) .* double(fullsc));
  165. % clear('OptmapOnesDbl')
  166. hfstrip=imagesc(Fcutsc); colormap(gray); %hfstrip=imshow(Fcutsc); colormap(gray); %hfscanIm=imagesc(Fcutsc); colormap(gray);
  167. ghandles.hfstrip=gcf;
  168. haxis=gca;
  169. title(strcat('Scan',num2str(plateNum),'->timePt-',num2str(tPt)));
  170. clf(hfstrip,'reset'); colormap(gray); %clf(hfscanIm,'reset'); colormap(gray);
  171. set(ghandles.hfstrip,'NumberTitle','off')
  172. end
  173. expLabel=strcat('->',char(fullfile(char(OLresDir),num2str(OLplateNum))))
  174. % catch
  175. % expLabel=strcat('->',char(fullfile(Exp(expN).Dexp(DexpN).ExpFoldr,num2str(plateNum))))
  176. if expN==1
  177. set(ghandles.hfstrip,'Name', strcat(char(get(ghandles.OLay1,'string')),expLabel)) %ghandles.hfIm %{'ExpOutmat'} %strcat('EASYconsole- ',char(resDir)))
  178. elseif expN==2
  179. set(ghandles.hfstrip,'Name', strcat(char(get(ghandles.OLay2,'string')),expLabel))
  180. elseif expN==3
  181. set(ghandles.hfstrip,'Name', strcat(char(get(ghandles.OLay3,'string')),expLabel))
  182. end
  183. %hgsave(fullfile(resDir,'Fotos',strcat('FScan',num2str(selScan),'_timePt-',num2str(tPt))));
  184. catch
  185. end
  186. end
  187. catch
  188. end
  189. %figure(ghandles.hFstrip)
  190. imshow(Fstrip);
  191. %{
  192. %if tPt==tPtLength %length(tifFileLst)
  193. %imwrite(Fstrip,(fullfile(resDir,'Fotos',strcat('Fstrip','S',num2str(selScan),'P',num2str(F_Pnum),'r',num2str(F_Rusrnum),'c',num2str(F_Cusrnum),'.jpg'))),'jpg');
  194. F_name=strcat(fnamemod,'_Fstrip','.jpg');
  195. %dfname=(fullfile(resDir,'Fotos',char(F_name)));
  196. %delete(dfname); % imwrite nolonger overwrites ??why 14_0729
  197. imwrite(Fstrip,(fullfile(resDir,'Fotos',char(F_name))),'jpg','Quality',100);
  198. F_name=strcat(fnamemod,'_Fstrip','.tif');
  199. %dfname=(fullfile(resDir,'Fotos',char(F_name)));
  200. %delete(dfname); % imwrite nolonger overwrites ??why
  201. imwrite(Fstrip,(fullfile(resDir,'Fotos',char(F_name))),'tif');
  202. %end
  203. %}
  204. %[output_txt]=datatipp(obj,event_obj);
  205. %datacursormode off;
  206. %datacursormode on;
  207. %close(figure(hsafety))
  208. end