245 lines
8.4 KiB
Matlab
Executable File
245 lines
8.4 KiB
Matlab
Executable File
global SWgrowthArea
|
|
global scLst
|
|
global ImParMat
|
|
global projectScansDir
|
|
global matFile
|
|
global fhconsole
|
|
global easyResultsDir
|
|
global printResultsDir
|
|
global pointMapsResultsDir
|
|
global fotosResultsDir
|
|
global matDir
|
|
global ImWidth
|
|
global ImHeigth
|
|
global numRows
|
|
global numCols
|
|
global scan
|
|
global scanMax
|
|
global tptLength
|
|
global easyDir
|
|
|
|
numRows=24; % for Single Vertical
|
|
numCols=16; % for Single Vertical
|
|
|
|
% CIRCLE related
|
|
doCircle=1; % use Circle area analysis 14_0807
|
|
radius=14;
|
|
ImParMat(10)=radius;
|
|
ImParMat(11)=doCircle;
|
|
|
|
% TODO what is this for?
|
|
Fflg=1;
|
|
|
|
% Don't think we need this
|
|
% fclose('all'); % close all open files
|
|
|
|
% Unset some vars just in case they are already set
|
|
clear('scanIntens','Scanfiles','pathname','tifFileLstP4');
|
|
|
|
try
|
|
clf(fhconsole,'reset');
|
|
catch
|
|
end
|
|
|
|
% No idea why we're doing this so commenting out
|
|
% close
|
|
% EASYconsole
|
|
|
|
if exist(matFile, 'file')
|
|
bkUpMatFile=fullfile(matFile, '.bk');
|
|
copyfile(matFile,bkUpMatFile);
|
|
end
|
|
|
|
% Reloacated from 'PTmats' to prevent potential overwrite when PTmats is
|
|
% copied into new job when the PT template is about the same. We also
|
|
% now have a default template if one is not made. i.e., when the images
|
|
% from the new experiment are too sketchy to make a good pintool
|
|
% template. By moving it to 'Fotos' we avoid possible issues due to
|
|
% copying the Nbdg.mat file along with the default template '.mat' files.
|
|
% A copy of Ndbg.mat is placed also saved to the 'PTmats' directory
|
|
% after each run to allow previous version of EASY to access data made
|
|
% by EASY versions after 20_0819.
|
|
try
|
|
load(fullfile(fotosResultsDir,'Nbdg')); % modified to load from 'Fotos' 20_0819
|
|
catch
|
|
load(fullfile(pointMapsResultsDir,'Nbdg')); % left in to accomodate loads of work before 20_0819
|
|
end
|
|
% Load Fotos stored data
|
|
fotosToLoad={'Coordinates', 'BGatTpts', 'anlZones', 'NCFparms'};
|
|
for i=1:length(fotosToLoad)
|
|
try
|
|
load(fullfile(fotosResultsDir, fotosToLoad{i}));
|
|
catch
|
|
load(fullfile(easyDir,'parameters'));
|
|
end
|
|
end
|
|
|
|
% Get Print Times
|
|
PrintTimes=[];
|
|
scLst={};
|
|
|
|
% Parameter Entry
|
|
NImParamRadiusGui(projectScansDir); % Ncode 122111replaced removed ,numOfPrtTimes)
|
|
width=24;
|
|
widthEx=width-1; % width extention from reference point
|
|
dither=ImParMat(6);
|
|
radius=ImParMat(10);
|
|
NIcircle;
|
|
|
|
% Load Stuff
|
|
lastPlateOnLastScan=1; % Ncode
|
|
|
|
if size(scLst,1)==1
|
|
SWsingleSc=1;
|
|
else
|
|
SWsingleSc=0;
|
|
end
|
|
|
|
dvec=datevec(datestr(floor(now))); %method to get current offset year '01-Jan-"currentyr"'
|
|
dvec(2)=1;
|
|
dvec(3)=1;
|
|
% yrOffset=datenum('01-Jan-2012');%(dvec); %('01-Jan-2009'); %time num default is currentyear jan1
|
|
numScans=size(scLst,1);
|
|
|
|
if(isequal(SWsingleSc,1))
|
|
selScan=str2double(char(scLst(1)));
|
|
else
|
|
% startScan=1;
|
|
end
|
|
|
|
SWgrowthArea=ImParMat(9);
|
|
load(fullfile(pointMapsResultsDir,'NPTmapSearch'));
|
|
PTmapPos=detPos;
|
|
selScanNumLst=[];
|
|
Scanfiles=[];
|
|
pathname=[];
|
|
|
|
for ii=1:length(scLst)
|
|
if (SWsingleSc == 1)
|
|
% TODO proably need to make this more explicit with paths
|
|
[Scanfiles, pathname]=uigetfile('*.bmp', 'Select files','MultiSelect','on'); % change '*hr*.bmp' 12/20/2011
|
|
if ischar(Scanfiles)
|
|
scd=imread(char(Scanfiles));
|
|
tptLength=1;
|
|
else
|
|
scd=imread(char(Scanfiles(1,1)));
|
|
tptLength=length(Scanfiles);
|
|
end
|
|
ImHeigth=size(scd,1);
|
|
ImWidth=size(scd,2);
|
|
sc=scd(1:ImHeigth,1:ImWidth);
|
|
end
|
|
|
|
numFiles=size(Scanfiles,2);
|
|
|
|
% Initialize tifFilesLst for parfor loop
|
|
dir(fullfile(projectScansDir, char(scLst(ii)), '*.bmp'));
|
|
numFiles=length(tifFileLst4MultiT);
|
|
tptLength=numFiles;
|
|
tifFileLstP4{ii}={tifFileLst4MultiT.name};
|
|
end
|
|
|
|
for jj=1:numScans % startScan:numScans
|
|
selScan=str2double(char(scLst(jj)));
|
|
selScanNumLst(jj)=selScan;
|
|
end
|
|
selScanNumLst2=selScanNumLst; % function passthrough, passback to par4gbl_Main 20_0205
|
|
|
|
% Preallocation
|
|
scCount=[];
|
|
TmpexpScanIntens00=cell(1); % cell(1,scanMax);
|
|
TmpFexpScanSpots00=cell(1); % cell(1,scanMax);
|
|
TmpFexpScanBMtp00=cell(1); % cell(1,scanMax);
|
|
TmpanlZoneRefs00=cell(1); % cell(1,scanMax);
|
|
Tmpsbdg00=cell(1);
|
|
TmpexpScanIntens4=cell(1,numScans);
|
|
TmpFexpScanSpots4=cell(1,numScans);
|
|
TmpFexpScanBMtp4=cell(1,numScans);
|
|
TmpanlZoneRefs4=cell(1,numScans);
|
|
Tmpsbdg4=cell(1,numScans);
|
|
TmpexpScanIntens5=cell(1,numScans);
|
|
TmpFexpScanSpots5=cell(1,numScans);
|
|
TmpFexpScanBMtp5=cell(1,numScans);
|
|
TmpanlZoneRefs5=cell(1,numScans);
|
|
Tmpsbdg5=cell(1,numScans);
|
|
p4L00=cell(18,1);
|
|
p4L0=p4L00;
|
|
p4L4=cell(18,numScans);
|
|
p4L5=p4L4;
|
|
Ag=ones(384);
|
|
CFscanIntens=zeros(16,24);
|
|
|
|
[p4L4,TmpexpScanIntens5,TmpFexpScanSpots5,TmpFexpScanBMtp5,TmpanlZoneRefs5,Tmpsbdg5]= ...
|
|
p4loop8c(parMat,tptLength,numScans,selScanNumLst,SWsingleSc,Fflg,PTmapPos,optCirMask,diaExt,doCircle,cirPixA,cirMask,width, ...
|
|
TmpexpScanIntens00,TmpFexpScanSpots00,TmpFexpScanBMtp00,TmpanlZoneRefs00,scCount,tifFileLstP4,pathname,ImParMat, ...
|
|
numRows,numCols,scLst,easyResultsDir,projectScansDir, p4L00,TmpexpScanIntens4,TmpFexpScanSpots4,TmpFexpScanBMtp4,TmpanlZoneRefs4, ...
|
|
Tmpsbdg00,Tmpsbdg4);
|
|
|
|
for scanCnt=1:numScans
|
|
selScan=p4L4{16,scanCnt}; % determine the actual scan in the scanCnt parfor distributed "id"
|
|
scan(selScan).plate(1).tSeries=cell2mat(p4L4(1,scanCnt));
|
|
scan(selScan).plate(1).t0Series=cell2mat(p4L4(2,scanCnt));
|
|
scan(selScan).plate(1).printTm=cell2mat(p4L4(3,scanCnt));
|
|
scan(selScan).plate(1).intens=cell2mat(p4L4(4,scanCnt));
|
|
scan(selScan).plate(1).rc=p4L4(5,scanCnt);
|
|
scan(selScan).plate(1).pIndx=cell2mat(p4L4(6,scanCnt));
|
|
scan(selScan).plate(1).Ag=cell2mat(p4L4(7,scanCnt));
|
|
scan(selScan).plate(1).selIntens=p4L4(8,scanCnt);
|
|
scan(selScan).plate(1).selTimes=p4L4(9,scanCnt);
|
|
scan(selScan).plate(1).filterTimes=p4L4(10,scanCnt);
|
|
scan(selScan).plate(1).normIntens=p4L4(11,scanCnt);
|
|
% scan(selScan).plate(1).CFparameters=p4L4(12,scanCnt); %Need to convert to a matrix form like Old versions
|
|
CFparm(1:384)=p4L4{12,scanCnt}(1:384);
|
|
scan(selScan).plate(1).CFparameters=CFparm;
|
|
scan(selScan).plate(1).CFdate=p4L4(13,scanCnt);
|
|
scan(selScan).plate(1).CFout=cell2mat(p4L4(14,scanCnt));
|
|
scan(selScan).plate(1).CFoutStd=cell2mat(p4L4(15,scanCnt));
|
|
scan(selScan).Awindow=cell2mat(p4L4(17,scanCnt));
|
|
scan(selScan).Idate=cell2mat(p4L4(18,scanCnt));
|
|
expScanIntens(selScan)=TmpexpScanIntens5(scanCnt);
|
|
FexpScanSpots(selScan)=TmpFexpScanSpots5(scanCnt);
|
|
FexpScanBMtp(selScan)=TmpFexpScanBMtp5(scanCnt);
|
|
anlZoneRefs(selScan)=TmpanlZoneRefs5(scanCnt);
|
|
if ~isempty(Tmpsbdg5{scanCnt})
|
|
sbdg(selScan)=Tmpsbdg5(scanCnt);
|
|
else
|
|
sbdg{selScan}=uint8(zeros(24,16,4));
|
|
end
|
|
end
|
|
|
|
% Save data in .mat files
|
|
save(matFile,'scan');
|
|
% save((fullfile(easyResultsDir,'PTmats','Nbdg')), 'sbdg'); % legacy location can probably get rid of in time
|
|
save((fullfile(fotosResultsDir,'Nbdg')), 'sbdg');
|
|
save((fullfile(fotosResultsDir,'Coordinates')),'FexpScanSpots') % saves frames at each tPt
|
|
save((fullfile(fotosResultsDir,'BGatTpts')),'FexpScanBMtp')
|
|
save((fullfile(fotosResultsDir,'anlZones')),'anlZoneRefs') % saves anl Positions at each tPt
|
|
|
|
% Print FitResults
|
|
fileExt='.txt';
|
|
filePrefix='FitResults_';
|
|
for scanCnt=1:numScans
|
|
selScan=p4L4{16,scanCnt}; % determine the actual scan in the scanCnt parfor distributed "id"
|
|
fileSuffix=sprintf('Scan%d_Plate%d', selScan, 1);
|
|
fileNamePlate=[filePrefix fileSuffix fileExt];
|
|
fileName=fullfile(printResultsDir, fileNamePlate); % [outputDirectory fileNamePlate];
|
|
|
|
% This,fprint for loop,is an very old legacy feature which slows processing. Could be
|
|
% removed but allows easy observation of how a run is progressing and can be
|
|
% used as a diagnostic tool.
|
|
outCprint=p4L4;
|
|
|
|
fid=fopen(fileName,'w');
|
|
fprintf(fid, 'Num.\tAUC\tMSR\tK\tr\tl\tR-squared\tK-lower\tK-upper\tr-lower\tr-upper\tl-upper\tl-lower\tArea\tLastInten\tSpineMaxRateTimePt\tLastFitTimePt\n');
|
|
for n=1:384 % startCount:numCultures
|
|
fprintf(fid,'%d\t',n);
|
|
fprintf(fid, '%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\t%.5f\n',...
|
|
outCprint{14,scanCnt}(n,1),outCprint{14,scanCnt}(n,2),outCprint{14,scanCnt}(n,3),outCprint{14,scanCnt}(n,4),...
|
|
outCprint{14,scanCnt}(n,5),outCprint{14,scanCnt}(n,6),outCprint{14,scanCnt}(n,7),outCprint{14,scanCnt}(n,8),...
|
|
outCprint{14,scanCnt}(n,9),outCprint{14,scanCnt}(n,10),outCprint{14,scanCnt}(n,11),outCprint{14,scanCnt}(n,12),...
|
|
outCprint{14,scanCnt}(n,13),outCprint{14,scanCnt}(n,14),outCprint{14,scanCnt}(n,15),outCprint{14,scanCnt}(n,16));
|
|
end
|
|
fclose(fid);
|
|
end
|
|
|