diff --git a/workflow/templates/easy/DgenResults.m b/workflow/templates/easy/DgenResults.m index 01727e8f..dfc76fb4 100755 --- a/workflow/templates/easy/DgenResults.m +++ b/workflow/templates/easy/DgenResults.m @@ -1,18 +1,21 @@ %% CALLED BY EASYconsole.m %% % Updated 240724 Bryan C Roessler to improve file operations and portability -%Console globals******* -global ExpPath -global resDir -global ExpOutmat -global ImParMat +% +global scansDir +global easyResultsDir +global matFile +global defImParMat +global printResultsDir +global fotosResultsDir +global pointMapsFile ln=1; -%******Version compatability fixes*******assoc'd with diff and solve v11a='7.12.0.635 (R2011a)'; -if verLessThan('matlab','8.3') %original work 23_0227 updated 23_0525 (8.4 changed to 8.3) +% Version compatability fixes +if verLessThan('matlab','8.3') fd4=diff(sym('K / (1 + exp(-r* (t - l )))'),4); sols=solve(fd4); -else %accomodate new matlab changes after 2014a fix 2nd update 23_0227 +else % accomodate new matlab changes after 2014a syms t K r l; fd4=diff(K / (1 + exp(-r* (t - l ))),t,4); sols=solve(fd4); @@ -21,61 +24,62 @@ else %accomodate new matlab changes after 2014a fix 2nd update 23_0227 sols(3)=tmpswap; end -%MPnum=ImParMat(1); -%opt=questdlg('Print Results Only (RES), DB Only (DB), or Both','Results Printout Options','Res','DB','Both','Both'); +% MPnum=ImParMat(1); +% opt=questdlg('Print Results Only (RES), DB Only (DB), or Both','Results Printout Options','Res','DB','Both','Both'); opt='Res'; -if ~exist('ImParMat','var') || isempty(ImParMat) - load ImParameters +if ~exist('defImParMat','var') || isempty(defImParMat) % TODO needs better explanation + load(pointMapsFile); end -destPerMP=ImParMat(2); -load (ExpOutmat); -load (fullfile(ExpPath,'MasterPlateFiles','MPDMmat.mat')) +destPerMP=ImParMat(2); % TODO this is weird, needs explanation +load(matFile); +load(mpdmFile) numOfDrgs=length(DM.drug); numOfMeds=length(DM.media); destPerMP=numOfDrgs; -%Determine the longest set of intensity(tPts) for the Experiment Data Set +% TODO this should be rewritten or is uncessary, what is this for +% Determine the longest set of intensity(tPts) for the Experiment Data Set maxNumIntens=0; for n=1:size(scan,2) for m=1:size(scan(n).plate,2) maxNumIntens=max(maxNumIntens,size(scan(n).plate(m).intens,2)); end end -if length(ExpPath)==max(strfind(ExpPath,'\')) - localExpPath=ExpPath(1:end-1); -else - localExpPath=ExpPath; -end -if ispc %Linux accommodation - expNm=localExpPath(max(strfind(localExpPath,'\'))+1:end); - drivePos=min(strfind(localExpPath,'\')); -elseif ((isunix) || (ismac)) - expNm=localExpPath(max(strfind(localExpPath,'/'))+1:end) - drivePos=min(strfind(localExpPath,'/')); + +% if length(scansDir) == max(strfind(scansDir,'\')) +% localscansDir=scansDir(1:end-1); +% else +% localscansDir=scansDir; +% end + +expNm=scansDir(max(strfind(scansDir,'\'))+1:end); +drivePos=min(strfind(scansDir,'\')); +elseif (isunix || ismac) + expNm=scansDir(max(strfind(scansDir,'/'))+1:end); + drivePos=min(strfind(scansDir,'/')); end -drive=localExpPath(1:(drivePos-1)); +drive=scansDir(1:(drivePos-1)); DBupload=fullfile(drive,'EZdbFiles','DBupLOADfiles'); -%Added to allow backward compatability************************************ -%Test for CFoutStd as indication of 2018version with r_refined fit code;If -%earlier version with only a standard composite fite, Print results to -%!!ResultsStd_...txt only +% Added to allow backward compatability +% Test for CFoutStd as indication of 2018version with r_refined fit code;If +% earlier version with only a standard composite fite, Print results to !!ResultsStd_...txt only try scan(1).plate(1).CFoutStd(1,1); - resultsFilename=fullfile(resDir,'PrintResults', strcat('!!ResultsELr_',expNm,'.txt')); - DBfilename=fullfile(resDir,'PrintResults', strcat('!!DbaseELr_',expNm,'.txt')); + resultsFilename=fullfile(printResultsDir, strcat('!!ResultsELr_',expNm,'.txt')); + DBfilename=fullfile(printResultsDir, strcat('!!DbaseELr_',expNm,'.txt')); catch - resultsFilename=fullfile(resDir,'PrintResults', strcat('!!ResultsStd_',expNm,'.txt')); - DBfilename=fullfile(resDir,'PrintResults', strcat('!!DbaseStd_',expNm,'.txt')); + resultsFilename=fullfile(printResultsDir, strcat('!!ResultsStd_',expNm,'.txt')); + DBfilename=fullfile(printResultsDir, strcat('!!DbaseStd_',expNm,'.txt')); end if isequal(opt,'Res')||isequal(opt,'Both'),fid=fopen(resultsFilename,'w');end -if isequal(opt,'DB')||isequal(opt,'Both'),fid2=fopen(DBfilename,'w');end %121012 Combo +if isequal(opt,'DB')||isequal(opt,'Both'),fid2=fopen(DBfilename,'w');end -if isequal(opt,'Res')||isequal(opt,'Both') %print Results - fprintf(fid,'%d\t',ln); %Results header - fprintf(fid,'%s\t\n',localExpPath); +if isequal(opt,'Res')||isequal(opt,'Both') + fprintf(fid,'%d\t',ln); % Results header + fprintf(fid,'%s\t\n',scansDir); ln=ln+1; fprintf(fid,'%d\t',ln); end @@ -86,13 +90,13 @@ drgCnt=0; medCnt=0; try - load(fullfile(resDir,'Fotos','Nbdg')) %Convolute scan array data into plates + load(fullfile(easyResultsDir,'Fotos','Nbdg')) % Convolute scan array data into plates catch - load(fullfile(resDir,'PTmats','Nbdg')) %Convolute scan array data into plates + load(fullfile(easyResultsDir,'PTmats','Nbdg')) % Convolute scan array data into plates end for s=1:size(scan,2) - %Convolute scan array data into plates DconB for DBcombo + % Convolute scan array data into plates DconB for DBcombo clear Diag try Diag(:,:,:,1)=sbdg{s}(1:1:24,16:-1:1,:); @@ -371,23 +375,19 @@ if isequal(opt,'DB')||isequal(opt,'Both') errordlg(rep) end end -% ln; TODO removed by BCR, this doesn't seem necessary - - %*********************************************************************** - %BEGIN PRINT RESULTS ROUTINE FOR STANDARD METHOD - %*********************************************************************** + +% Print results using the standard method try scan(1).plate(1).CFoutStd(1,1) %Test for 2018 r_refined version ln=1; - resultsFilename= fullfile(resDir,'PrintResults', strcat('!!ResultsStd_',expNm,'.txt')); - DBfilename= fullfile(resDir,'PrintResults', strcat('!!DbaseStd_',expNm,'.txt')); + resultsFilename=fullfile(printResultsDir, strcat('!!ResultsStd_',expNm,'.txt')); + DBfilename=fullfile(printResultsDir, strcat('!!DbaseStd_',expNm,'.txt')); if isequal(opt,'Res')||isequal(opt,'Both'),fid = fopen(resultsFilename,'w');end if isequal(opt,'DB')||isequal(opt,'Both'),fid2 = fopen(DBfilename,'w');end %121012 Combo - if isequal(opt,'Res')||isequal(opt,'Both') %print Results fprintf(fid,'%d\t',ln); %Results header - fprintf(fid,'%s\t\n',localExpPath); + fprintf(fid,'%s\t\n',scansDir); ln=ln+1; fprintf(fid,'%d\t',ln); end @@ -664,9 +664,9 @@ try end end - msgbox(['Printing Script complete. Check !!Results sheets in ../PrintResults folder.']) + msgbox([strcat('Printing Script complete. Check !!Results sheets in ',printResultsDir,' for results.')]) catch ME - errorNstdResults='Catch at line720 for printing ResultsStd' + disp(strcat("Results printing failed with error: ", getReport(ME, 'basic'))) end