EZinterAgingDev0 debug

This commit is contained in:
2024-07-29 19:42:31 -04:00
parent 80aab5e486
commit 1ec1037c82
6 changed files with 485 additions and 566 deletions

View File

@@ -6,6 +6,76 @@ global userPars
global usrExpJobsDir
global zonePB
% Initialize some variables from matlab
ezPath=which(mfilename);
[ezDir,ezFileName]=fileparts(ezPath);
ezDir=fullfile(easyDir);
[parentDir, ~]=fileparts(ezDir);
parentDir=fullfile(parentDir); % ../easy/apps
debug=1;
if debug
disp('Running in debug mode');
disp('Initialized variables:');
whos;
end
% Set scansDir (project scans directory) intelligently
if exist('PROJECT', 'var') && ~isempty(getenv('PROJECT'))
scansDir=getenv('PROJECT');
fprintf('Using project path: %s from environment variable PROJECT\n', scansDir);
disp('This usually indicates that we are in standalone mode');
elseif exist('PROJECT_SCANS_DIR', 'var') && ~isempty(getenv('PROJECT_SCANS_DIR'))
scansDir=getenv('PROJECT_SCANS_DIR');
fprintf('Using scans directory: %s from environment variable PROJECT_SCANS_DIR\n', scansDir);
disp('This usually indicates that we are in module mode');
else
% TODO Lots of this is hardcoded logic, this TODO is just a reminder to change this block
% when changing EZ_DIR and other variables in the parent script
fprintf('Beginning parent scans directory search\n');
fprintf('This usually indicates that we are in stand-alone mode without PROJECT or PROJECT_SCANS_DIR environment variables\n');
dirsToScan={
fullfile(parentDir,'..', '..', 'scans'),
fullfile(parentDir, '..', '..', 'ExpJobs'),
fullfile('/mnt/data/scans'),
fullfile('/mnt/data/ExpJobs'),
fullfile(parentDir, '..', '..', 'templates', 'scans-demo')
};
for d=dirsToScan
if exist(d, 'dir')
subDirs=dir(d);
if ~isempty(subDirs)
fprintf('Found a non-empty parent scans directory in our list: %s\n', d);
fprintf('Scanning inside for a project scan directory\n');
[~, sortedIndices]=sort(datenum({dirs.date}), 'descend'); % sort by newest first
sortedDirs=dirs{sortedIndices};
scansDir=sortedDirs{1};
fprintf('Selected newest project scans directory: %s\n', scansDir);
end
end
end
end
% User sanity check and warning
if exist('PROJECT_USER', 'var') && ~isempty(getenv('PROJECT_USER'))
if ~equal(getenv('PROJECT_USER'), userName)
disp("WARNING: PROJECT_USER does not match the current namespace");
end
end
% Allow module to override hardcoded default EZview directory
if exist('EZVIEW_DIR','var') && ~isempty(getenv('EZVIEW_DIR'))
EZVIEW_DIR=fullfile(getenv('EZVIEW_DIR'));
if ~strcmp(ezDir, EZVIEW_DIR) % sanity check
disp("WARNING: EZVIEW_DIR does not match this script's hardcoded EZview location");
disp("This is probably OK but if strange beahvior arises, we'll need to fix it in code");
ezDir=EZVIEW_DIR;
end
fprintf('Using EZview script directory: %s from environment variable EZVIEW_DIR\n', ezDir);
else
fprintf('Using EZview script directory: %s from hardcoded default\n', ezDir);
end
userPars.BPdefault={'on','on','0.3','8','45','1000'};
userPars.boxplotFlg=1;
userPars.BPoutliers='On';
@@ -16,92 +86,54 @@ userPars.BProt=45;
userPars.Trenddefault={'1000'};
userPars.kfiltLim=str2double(userPars.BPdefault(6));
% Exp(expN).expLoadCnt=0; ??? May need to add in Future
Exp(1).cTraceN= 1; %Added for Cummulative Composite Olay plotting
Exp(2).cTraceN=1;
Exp(3).cTraceN=1;
Exp(1).cTraceIndx(1)=1;
Exp(2).cTraceIndx(1)=1;
Exp(3).cTraceIndx(1)=1;
Exp(1).CompositPlot=0;Exp(2).CompositPlot=0;Exp(3).CompositPlot=0;
w=pwd;
Exp(1).DexpType='single';
Exp(2).DexpType='single';
Exp(3).DexpType='single';
Exp(1).DexpN=1;
Exp(2).DexpN=1;
Exp(3).DexpN=1;
Exp(1).DexpLength=1;
Exp(2).DexpLength=1;
Exp(3).DexpLength=1;
set(handles.DN1,'value',1)
set(handles.DN2,'value',1)
set(handles.DN3,'value',1)
set(handles.GeneOrfTog,'value',0)
% Generate the Exp arrays
numExps=3;
for i=1:numExps
Exp(i).cTraceN=0;
Exp(i).cTraceIndx(1)=1;
end
Exp(1).CompositPlot=0;Exp(2).CompositPlot=0;Exp(3).CompositPlot=0;
for i=1:numExps
Exp(i).DexpType='single';
Exp(i).DexpN=1;
Exp(i).DexpLength=1;
eval(['set(handles.DN' num2str(i) ', ''value'', 1);']); % MATLAB level unlocked
end
set(handles.GeneOrfTog,'value',0)
try
load('EZsgdInfo');
catch
disp('Fail to load EZsgdInfo file from code directory');
end
Exp(4).SGDnum=SGDnum;
Exp(4).SGDtext=SGDtext;
Exp(4).SGDraw=SGDraw;
Exp(4).interacPBsel=0;
Exp(numExps+1).SGDnum=SGDnum;
Exp(numExps+1).SGDtext=SGDtext;
Exp(numExps+1).SGDraw=SGDraw;
Exp(numExps+1).interacPBsel=0;
try %big outer loop try catch to ln844 end ln868
%try to use user selected 'ExpJobs' folder otherwise use a default
%directory in the uigetfile to load the experiment .mat file.
%try %Linux accommodatition
if ispc
try
cd(usrExpJobsDir);
catch
cd(fullfile('C:\')); %end % \Easy\Experiments'));
end
else
try
cd(usrExpJobsDir);
catch
cd(fullfile('~'))
end
end
[openExpfile,openExppath] = uigetfile('.mat','Open Experiment folder and data storage .mat file name','MultiSelect','off')
% Big outer loop try catch to ln844 end ln868
% try to use user selected 'ExpJobs' folder otherwise use a default
% directory in the uigetfile to load the experiment .mat file.
try
[openExpfile,scansDir] = uigetfile('.mat','Open Experiment folder and data storage .mat file name','MultiSelect','off')
try
ExpOutmat= fullfile(openExppath,openExpfile);
load(ExpOutmat);
cd(openExppath)
cd ..;
resDir=pwd;
Exp(1).Dexp(1).resDir=resDir;
Exp(2).Dexp(1).resDir=resDir;
Exp(3).Dexp(1).resDir=resDir;
cd ..;
try
test4imageDir= imread(fullfile(pwd,'1','1.bmp'));
ExpPath=pwd;
Exp(1).Dexp(1).ExpFoldr=ExpPath;
Exp(2).Dexp(1).ExpFoldr=ExpPath;
Exp(3).Dexp(1).ExpFoldr=ExpPath;
catch
try
cd ..
test4imageDir= imread(fullfile(pwd,'1','1.bmp'));
ExpPath=pwd;
Exp(1).Dexp(1).ExpFoldr=ExpPath;
Exp(2).Dexp(1).ExpFoldr=ExpPath;
Exp(3).Dexp(1).ExpFoldr=ExpPath;
catch
cd(w)
end
end
cd(w)
load (fullfile(Exp(1).Dexp(1).ExpFoldr,'MasterPlateFiles','MPDMmat.mat'))
for i=1:numExps
Exp(i).Dexp.DM=;
Exp(i).cTraceIndx(1)=1;
end
Exp(1).Dexp(1).DM=DM;
Exp(2).Dexp(1).DM=DM;
Exp(3).Dexp(1).DM=DM;
@@ -224,7 +256,7 @@ try %big outer loop try catch to ln844 end ln868
msg='LOADing or Setup issue'
%if no load, then Message try SelExp PB to reload or try and different
%Experiment
end %nested try-catch-end from ->ExpOutmat= fullfile(openExppath,openExpfile);
end %nested try-catch-end from ->ExpOutmat= fullfile(scansDir,openExpfile);
try
DNLaxes1= handles.DNLaxes1; DNLaxes2= handles.DNLaxes2; DNLaxes3= handles.DNLaxes3;
@@ -847,14 +879,14 @@ try %big outer loop try catch to ln844 end ln868
Exp(2).Dexp(1).srtOrfLst=cellstr([{'Failed To Load'}; {' '}]);
Exp(3).Dexp(1).srtOrfLst=cellstr([{'Failed To Load'}; {' '}]);
%[openExpfile,openExppath]
%[openExpfile,scansDir]
if isempty(strfind(openExpfile,'.mat'))
cd(openExppath)
cd(scansDir)
cd ..
ExpPath=pwd;
cd(w)
ExpOutImFile= fullfile(openExppath,openExpfile);
ExpOutImFile= fullfile(scansDir,openExpfile);
EZvImagesOnly
end