Files
hartman-server/workflow/apps/matlab/ezview/EZspotview.m
2024-07-29 12:31:26 -04:00

246 lines
8.2 KiB
Matlab
Executable File

function EZspotview(expN,DexpN, imLoc,OLresDir,OLplateNum,NoOLay)
datacursormode(gcf)
global Exp
global ghandles
w=pwd;
aCnt=0;
prevExp=0;
if NoOLay==0
cd(fullfile(char(OLresDir)))
cd ..
expDir=pwd;
cd(w)
%expDir=fullfile(char(OLresDir),'..');
if ~isequal(expDir, char(fullfile(Exp(expN).Dexp(DexpN).ExpFoldr)))
prevExp=1;
end
if prevExp==0
expDir = Exp(expN).Dexp(DexpN).ExpFoldr;
else
cd(fullfile(char(OLresDir)))
cd ..
expDir=pwd;
cd(w)
%expDir=fullfile(char(OLresDir),'..');
end
else
expDir = Exp(expN).Dexp(DexpN).ExpFoldr
end
%ExpHmDir= char(Exp(expN).Dexp(DexpN).resDir);
try close(ghandles.hfstrip), catch, end %hfIm
%*************CIRCLE related*************************
doCircle=1;
radius=14;
diaExt=2*(radius+1);
%>>>>>>>>>>>>>>>>>>>>>>
EZvNIcircle
%<<<<<<<<<<<<<<<<<<<<<<<
rIm= imLoc(1); %use the "picture/Image' r and c not the plate annotation r c)
cIm= imLoc(2);
plateNum= Exp(expN).Dexp(DexpN).plateNum;
%*****************************************
if prevExp==0
FexpScanSpots=Exp(expN).Dexp(DexpN).FexpScanSpots;
FexpScanBMtp=Exp(expN).Dexp(DexpN).FexpScanBMtp;
anlZoneRefs=Exp(expN).Dexp(DexpN).anlZoneRefs;
ImParMat=Exp(expN).Dexp(DexpN).ImParMat;
else
%check if the request expJob is already loaded in one of the other zones
matchfound=0;
for j=1:3
if isequal(expDir, char(fullfile(Exp(j).ExpFoldr)))
FexpScanSpots=Exp(j).FexpScanSpots;
FexpScanBMtp=Exp(j).FexpScanBMtp;
anlZoneRefs=Exp(j).anlZoneRefs;
ImParMat=Exp(j).ImParMat;
matchfound=1;
break
end
end
if matchfound==0
%if not, load data for previous experiment again.
load(fullfile(char(OLresDir),'Fotos','Coordinates'))
load(fullfile(char(OLresDir),'Fotos','anlZones'))
load(fullfile(char(OLresDir),'Fotos','BGatTpts'))
load(fullfile(char(OLresDir),'PTmats','NImParameters'))
end %if matchfound==1
end %if prevExp==0
%**************Parameter Entry******************
width=ImParMat(5);
widthEx=width-1; %width extention from reference point
%=================================================================
%=================================================================
%++++Start Spot selection and Manipulation section+++++++++++
Fcutsc=[];
Fstrip=[];
%{
cd(fullfile(char(OLresDir)))
cd ..
expDir=pwd;
cd(w)
%}
%tPtsSize=size(Exp(expN).Dexp(DexpN).FexpScanBMtp{1,1},(3));
tPtsSize=size(FexpScanBMtp{1,plateNum},(3)); %tPtsSize=size(FexpScanBMtp{1,1},(3)); 20160110
%bmpFileLst = dirfullfile(char(OLresDir),num2str(plateNum),'*.bmp')); %(fullfile(expDir, char(ScLst(ScLstCnt)), '*.bmp'));
hsafety=figure;
dc= get(datacursormode)
imInterval=1;
try, imInterval= str2double(Exp(4).SpotVintervPar),catch,end
try
for tPt=1:imInterval:tPtsSize %tPtLength
coord=[];
try
%FtifFile= fullfile(Exp(expN).Dexp(DexpN).ExpFoldr,num2str(plateNum),strcat(num2str(tPt),'.bmp')); %char(tifFileLst(tPt));
FtifFile= fullfile(char(expDir),num2str(plateNum),strcat(num2str(tPt),'.bmp'));
Fimg= imread(FtifFile);
% For Visualization Purposes ***********************
Fram= ones(2075,1400); %(size(Empsc,1),size(Empsc,2));
%FRAME ANALYSIS AREA*******************************************************
if size(FexpScanSpots,2)>1
coord=FexpScanSpots{plateNum}{rIm,cIm,tPt};
else
coord=FexpScanSpots{plateNum,1,1}{rIm,cIm,tPt};
end
if size(anlZoneRefs,2)>1
xyLoc=anlZoneRefs{plateNum}{rIm,cIm,tPt}; %F_Snum
else
xyLoc=anlZoneRefs{F_Snum,1,1}{rIm,cIm,tPt};
end
xLoc= xyLoc(2);
yLoc= xyLoc(1);
%*************CIRCLE related*************************
doCircle=1; %Temp test value insertion to get square images
if doCircle==1,
Fram= FoptCirMask;
else
%1->2 across rt 1, 2-4
Fram(yLoc,xLoc:(xLoc+widthEx))=0.8;
%1->4 down lf 1-3, 2
Fram((yLoc+1):(yLoc+1+widthEx),xLoc)=0.8;
%2->3 down rt 1-3, 4
Fram(yLoc:(yLoc+widthEx),(xLoc+1+widthEx))=0.8;
%4->3 Bot Across rt 1, 2-4
Fram((yLoc+1+widthEx),(xLoc+1):(xLoc+1+widthEx))=0.8;
Fram= Fram(coord(1):coord(3),coord(2):coord(4));
end
%CUT SPOT OUT OF IMAGE*****************************************************
%Fbg= FexpScanBMtp{selScan,1}(rIm,cIm,tPt);
Fbg= FexpScanBMtp{plateNum}(rIm,cIm,tPt); %{selScan,1}
%Fimg= imread(FtifFile); %,'PixelRegion', {[coord(1),coord(3)],[coord(2),coord(4)]});
Fcutsc= Fimg(coord(1):coord(3),coord(2):coord(4));
if doCircle==1
%varExt=size(Fcutsc)-size(Fram);
varExtPre= [((yLoc-0)-coord(1)) ((xLoc-0)-coord(2))];
varExtPost= [(coord(3)-(yLoc+diaExt+1)) (coord(4)-(xLoc+diaExt+1))];
% Fram=padarray(Fram,[expansion expansion],1,'pre');
Fram=padarray(Fram,[varExtPre],1,'pre');
Fram=padarray(Fram,[varExtPost],1,'post');
%Fram=padarray(Fram,rem(varExt,2),1,'post');
%Fram=padarray(Fram,floor((varExt-2)./2),1);
end
%INVERT IMGAGE
Fcutsc=double(Fcutsc) .* Fram;
%Fcutsc= Fcutsc .* uint8(Fram);
Fcutsc=uint8(Fcutsc);
%Fcutsc=255 - (Fcutsc-Fbg);
Fcutsc=(Fcutsc-Fbg);
%Time series annotation**************************
tmPtTx=[];
tenths=(round(10*(Exp(expN).Dexp(DexpN).scan(plateNum).plate(1).tSeries(tPt)))) ./10;
tmPtTx= strcat(num2str(tenths),'h');
%imwrite(Fcutsc,(fullfile(resDir,'Fotos',strcat('FScan',num2str(selScan),'_timePt-',num2str(tPt),'.jpg'))),'jpg');
aCnt=aCnt+1;
if aCnt==1 %||tPt==1
EZvapendLabel
Fstrip= vertcat(Fcutsc,Bspace);
Hspace= zeros(size(Fstrip,1),4)+1200; %+255
Fstrip= horzcat(Fstrip,Hspace);
end
makeVis=1;
if aCnt>1
EZvapendLabel
vcat= vertcat(Fcutsc,Bspace);
%Hspace= zeros(size(Fstrip,1),4)+255;
Fstrip= horzcat(Fstrip,vcat,Hspace);
end
% For Visualization Purposes only
if makeVis==1
%if aCnt==1,figure;end
%resIm= uint8((double(BGsc) + OptmapOnesDbl) .* double(fullsc));
%clear('OptmapOnesDbl')
hfstrip=imagesc(Fcutsc); colormap(gray); %hfstrip=imshow(Fcutsc); colormap(gray); %hfscanIm=imagesc(Fcutsc); colormap(gray);
ghandles.hfstrip=gcf;
haxis=gca;
title(strcat('Scan',num2str(plateNum),'->timePt-',num2str(tPt)));
clf(hfstrip,'reset'); colormap(gray); %clf(hfscanIm,'reset'); colormap(gray);
set(ghandles.hfstrip,'NumberTitle','off')
end
expLabel=strcat('->',char(fullfile(char(OLresDir),num2str(OLplateNum))))
%catch
% expLabel=strcat('->',char(fullfile(Exp(expN).Dexp(DexpN).ExpFoldr,num2str(plateNum))))
if expN==1
set(ghandles.hfstrip,'Name', strcat(char(get(ghandles.OLay1,'string')),expLabel)) %ghandles.hfIm %{'ExpOutmat'} %strcat('EASYconsole- ',char(resDir)))
elseif expN==2
set(ghandles.hfstrip,'Name', strcat(char(get(ghandles.OLay2,'string')),expLabel))
elseif expN==3
set(ghandles.hfstrip,'Name', strcat(char(get(ghandles.OLay3,'string')),expLabel))
end
%hgsave(fullfile(resDir,'Fotos',strcat('FScan',num2str(selScan),'_timePt-',num2str(tPt))));
catch
end
end %for tPt=1:tPtsSize end of for Fotos Spot image cutout
catch
end
%figure(ghandles.hFstrip)
imshow(Fstrip);
%{
%if tPt==tPtLength %length(tifFileLst)
%imwrite(Fstrip,(fullfile(resDir,'Fotos',strcat('Fstrip','S',num2str(selScan),'P',num2str(F_Pnum),'r',num2str(F_Rusrnum),'c',num2str(F_Cusrnum),'.jpg'))),'jpg');
F_name= strcat(fnamemod,'_Fstrip','.jpg');
%dfname=(fullfile(resDir,'Fotos',char(F_name)));
%delete(dfname); % imwrite nolonger overwrites ??why 14_0729
imwrite(Fstrip,(fullfile(resDir,'Fotos',char(F_name))),'jpg','Quality',100);
F_name= strcat(fnamemod,'_Fstrip','.tif');
%dfname=(fullfile(resDir,'Fotos',char(F_name)));
%delete(dfname); % imwrite nolonger overwrites ??why
imwrite(Fstrip,(fullfile(resDir,'Fotos',char(F_name))),'tif');
%end
%}
%[output_txt]=datatipp(obj,event_obj);
%datacursormode off;
%datacursormode on;
%close(figure(hsafety))
end %function end
%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX