%% CALLED By p4loop8c.m %% function [p4L2, TmpexpScanIntens3,TmpFexpScanSpots3,TmpFexpScanBMtp3,TmpanlZoneRefs3,Tmpsbdg3]= ... par4GblFnc8c(parMat,tptLength,~,selScanNumLst,~,Fflg,PTmapPos,optCirMask,diaExt,doCircle,cirPixA,cirMask,~,... TmpexpScanIntens,TmpFexpScanSpots,TmpFexpScanBMtp,TmpanlZoneRefs,scCount,tifFileLstP4,~,ImParMat, ... numRows,numCols,scLst,easyResultsDir,projectScansDir,~, Tmpsbdg) global printResultsDir selScan=selScanNumLst(scCount); tptLength0=length(tifFileLstP4{scCount}); % tptLength=numFiles; tifFileLst={tifFileLstP4(scCount)}; % Extract the Imaging time stamps from selected tif files % clear('e','f'); %can't use clear inside a parfor loop. Preallocation % can be larger than useable .bmp files! Therefore must be small and % increased during for loop to maintain cell size integrity between e & f e=cell(1,2); f=cell(1,2); %(tptLength,2); f=cell(tptLength,2); nndx=0; for tPt=1:tptLength0 %size(tifFileLst,1) %length(tifFileLst) tifFileLstP4{scCount}(tPt) scLst; scLst(scCount) char(scLst(scCount)) char(fullfile(projectScansDir,char(scLst(scCount)))) projectScansDir; swCatch=0; nndx=nndx+1; tifFile=char(fullfile(projectScansDir,char(scLst(scCount)), tifFileLstP4{scCount}(tPt))); try info=imfinfo(tifFile); % D:\jwrDevel\DevelCurveFittingJWR\ImageScans\Scan2\020hr002.tif catch ME % Note: During parallel operation Matlab will not open file (fid) % etc. Therefore error message text will not be written.The only way % to get it out would be to pass variable through called function to % the ..Main8c script outside the parfor loop and print to file from % there. Consequently for now it only prints error to file when one % edits p4loop8c.m from 'parfor' to ordinary 'for' loop fFail=((fullfile(printResultsDir,'ImageFileReadFailure.txt'))); fid=fopen(fFail,'a'); %create,open and append % fprintf(fid,'%s \n',char(tifFile)) fclose(fid); nndx=nndx-1; swCatch=1; rep=getReport(ME, 'basic'); rep=strcat('Read info failure for-',tifFile,' -', rep); % fprintf(fid,'%s \n',rep) %See Note: end tptLength=nndx; scTmNumeric=1; %initialize for parfor if swCatch==0 scTmNumeric(nndx)=datenum(info.FileModDate); e(nndx,:)={tifFile, scTmNumeric(nndx)}; % newtifFileLst(nndx)=tifFileLst(tPt); end end % Clear tifFileLst; tifFileLst=cell(nndx,1); f={sortrows(e,2)}; tifFileLst=f{1,1}(:,1); areaOfIntensAboveBG=zeros(24,16,length(tifFileLst)); % Calculate Time series for each Plate of Selected Scan lastPlateOnScan=1; %Ncode tSeriesv=[]; t0Seriesv=[]; if tptLength>0 % added to jump over and fill data for invalid Sscan(plate runs scTmNumv=cell2mat(f{1,1}(:,2)); % (:,2))120613 fix for variant length data prtTmNumv=min(scTmNumv)-.000001; tSeriesv=((scTmNumv-prtTmNumv)*24); t0Seriesv=((scTmNumv-scTmNumv(1))*24); end % Added to jump over and fill data for invalid Sscan(plate runs if tptLength>=3 % Create blank scan ImHeigth=2075; ImWidth=1400; Empsc=zeros(ImHeigth,ImWidth); %Ncode % Start scan loop lastPlateOnScan=1; %Ncode disp('Before call to NIscanIntens.....') % Execute Image conversion into Intensity Data [Tmpsbdg2, scanIntens, ~, ~, ~, TmpexpScanIntens2, TmpFexpScanSpots2, TmpFexpScanBMtp2, TmpanlZoneRefs2,areaOfIntensAboveBG]= ... NIscanIntensBGpar4GblFnc(Fflg,tifFileLst, ImParMat, PTmapPos,optCirMask,diaExt,doCircle,cirPixA,numRows,numCols,ImHeigth,ImWidth,cirMask, ... tptLength,selScan,Empsc,TmpexpScanIntens,TmpFexpScanSpots,TmpFexpScanBMtp,TmpanlZoneRefs,easyResultsDir, Tmpsbdg); TmpexpScanIntens3=TmpexpScanIntens2; TmpFexpScanSpots3=TmpFexpScanSpots2; TmpFexpScanBMtp3=TmpFexpScanBMtp2; TmpanlZoneRefs3=TmpanlZoneRefs2; Tmpsbdg3=Tmpsbdg2; % clear plate CFscanIntens=zeros(384,1); % zeros(16,24); plate=[]; plate=zeros(24,16,tptLength); plate(:,:,:,1)=scanIntens(1:1:24,16:-1:1,:); % TmpexpScanIntens2(1:1:24,16:-1:1,:);%Ncode Dev3Vertical Similar to below % NIcheck: Check for bad scans at time points (swapped plates etc.) % Set up cell arrays for storing each plate in each Scan ..(scan,plate) SWprint=0; % Construct Legacy ...Intens.txt file if SWprint==1 filename=fullfile(easyResultsDir,'PrintResults',(strcat('Plate',num2str(selScan),'_Intens.txt'))); fid=fopen(filename,'w'); end if length(size(plate))==2 % only two dims if only one image numOfImages=1; else numOfImages=size(plate,3); end CFscanIntens=zeros(384,numOfImages); locIndx=0; pl=1; for n=1:numCols % Ncode changed to 16 for Vert for m=1:numRows % Ncode change to 24 for Vert locIndx=locIndx+1; for k=1:numOfImages if SWprint==1 if k==1 && numOfImages==1, fprintf(fid,'%.2f\n',plate(m,n,k,pl));end if k==1 && numOfImages~=1, fprintf(fid,'%.2f',plate(m,n,k,pl));end if k>1 && k=3 line19 20_0928 tSeriesv; %debuggin parfor p4L1{1}=tSeriesv; p4L1{2}=t0Seriesv; p4L1{3}=datestr(prtTmNumv,31); p4L1{4}=CFscanIntens; locIndx=0; for n=1:numCols % Ncode changed to 16 for Vert for m=1:numRows % Ncode change to 24 for Vert locIndx=locIndx+1; rc=[n,m]; p4rcTmp(locIndx)={rc}; p4pIndxTmp(locIndx)=locIndx; end end p4L1{5}=p4rcTmp; p4L1{6}=p4pIndxTmp; p4L1{7}=Ag; p4L1{8}=par4scanselIntensStd; p4L1{9}=par4scanselTimesStd; p4L1{10}=par4scanTimesELr; p4L1{11}=par4scanIntensELr; p4L1{12}=par4scanCFparameters; p4L1{13}=par4scanCFdate; p4L1{14}=outC2; p4L1{15}=outCstd2; p4L1{16}=selScan; p4L1{17}=cirPixA; p4L1{18}=datestr((now),31); % TODO this seems bad p4L2=p4L1; end