First EZview test

This commit is contained in:
2024-07-29 17:26:51 -04:00
parent 5e0af19181
commit 78f33a0120
77 changed files with 1669 additions and 45679 deletions

View File

@@ -12,148 +12,201 @@
>EZmultiDayGui
>EZmultiDay
>EZmultiExLoad
%}
w=pwd;
%*****Single Exp or Chronological Study*********************************************
% Construct a questdlg with three options
%}
global Expaa
global Expbb
global expType
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 EASY 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
w=pwd;
% Single Exp or Chronological Study
% Construct a questdlg with three options
Exp(expN).expLoadCnt= 0;
%Initiation for composite plotting cPlots
% Initiation for composite plotting cPlots
Exp(expN).cTraceN= 1;
Exp(expN).cTraceIndx= 1;
Exp(expN).CompositPlot= 0;
%****************************************
choice= 'Cancel';
choice='Cancel';
expType=0;
choice = questdlg('Choose Single Exp, Chronological Study OR Multi Exp', ...
'Experiment Type Menu', ...
'Single Exp','Chronological Study','Multi Exp','Single Exp');
choice=questdlg('Choose Single Exp, Chronological Study OR Multi Exp', ...
'Experiment Type Menu', ...
'Single Exp','Chronological Study','Multi Exp','Single Exp');
% Handle response
switch choice
case 'Single Exp'
disp([choice 'Single Exp Selected'])
expType = 1;
case 'Chronological Study'
disp([choice 'Chronological Study Selected'])
expType = 2;
case 'Multi Exp'
disp([choice 'Multi Exp Selected'])
expType = 3;
case 'Cancel'
disp('Cancel Load Exp')
expType = 0
case 'Single Exp'
disp([choice 'Single Exp Selected'])
expType=1;
case 'Chronological Study'
disp([choice 'Chronological Study Selected'])
expType=2;
case 'Multi Exp'
disp([choice 'Multi Exp Selected'])
expType=3;
case 'Cancel'
disp('Cancel Load Exp')
expType=0
end
expType
if expType==0, return; end
%****************************************************
zonePB= expN;
%Pre Load setup incase failure to Load occurs*****************
%updated 230818 to migrate to AppDesigner
fprintf('expType=%d\n',expType);
if expType==0, return; end
zonePB=expN;
% Pre Load setup incase failure to Load occurs
% updated 230818 to migrate to AppDesigner
if expN==1
set(handles.zonePB1,'value',1)
set(handles.zonePB2,'value',0)
set(handles.zonePB3,'value',0)
set(handles.zonePB1,'BackgroundColor',[1.0 0.6 0.6])
set(handles.zonePB2,'BackgroundColor',[1.0 1.0 1.0])
set(handles.zonePB3,'BackgroundColor',[1.0 1.0 1.0])
set(handles.zonePB1,'value',1);
set(handles.zonePB2,'value',0);
set(handles.zonePB3,'value',0);
set(handles.zonePB1,'BackgroundColor',[1.0 0.6 0.6]);
set(handles.zonePB2,'BackgroundColor',[1.0 1.0 1.0]);
set(handles.zonePB3,'BackgroundColor',[1.0 1.0 1.0]);
end
if expN==2
set(handles.zonePB2,'value',1)
set(handles.zonePB1,'value',0)
set(handles.zonePB3,'value',0)
set(handles.zonePB2,'BackgroundColor',[1.0 0.6 0.6])
set(handles.zonePB1,'BackgroundColor',[1.0 1.0 1.0])
set(handles.zonePB3,'BackgroundColor',[1.0 1.0 1.0])
set(handles.zonePB2,'value',1);
set(handles.zonePB1,'value',0);
set(handles.zonePB3,'value',0);
set(handles.zonePB2,'BackgroundColor',[1.0 0.6 0.6]);
set(handles.zonePB1,'BackgroundColor',[1.0 1.0 1.0]);
set(handles.zonePB3,'BackgroundColor',[1.0 1.0 1.0]);
end
if expN==3
set(handles.zonePB3,'value',1)
set(handles.zonePB1,'value',0)
set(handles.zonePB2,'value',0)
set(handles.zonePB3,'BackgroundColor',[1.0 0.6 0.6]);
set(handles.zonePB1,'BackgroundColor',[1.0 1.0 1.0]);
set(handles.zonePB2,'BackgroundColor',[1.0 1.0 1.0]);
set(handles.zonePB3,'value',1);
set(handles.zonePB1,'value',0);
set(handles.zonePB2,'value',0);
set(handles.zonePB3,'BackgroundColor',[1.0 0.6 0.6]);
set(handles.zonePB1,'BackgroundColor',[1.0 1.0 1.0]);
set(handles.zonePB2,'BackgroundColor',[1.0 1.0 1.0]);
end
Exp(expN).htmapRFanswer= {'G','L'}; %ZoneData
%_____________________-------------------__________________________
if expType==1
Exp(expN).DexpType= 'single';
%Test for Bad MP cell array (usually 384 [NaN}'s)
%replaced length(Exp(expN).Dexp(1).MP) with MPnum
for mx=1:length(Exp(expN).Dexp(1).MP)
try
char((Exp(expN).Dexp(1).MP(mx).genename{1}(384)))
MPnum=mx;
catch
break
end
end
%*************************************************
%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
%if isunix,cd (fullfile('~','ExpJobs'));end
%if ismac, cd (fullfile('~','ExpJobs'));end
%catch ME
% cd(w)
%end
datacursormode off;
%*************************************************
%try to use user selected 'ExpJobs' folder otherwise use a default
%directory in the uigetfile to load the experiment .mat file.
try
load('ExpJobsFldr')
catch
disp('Fail to load ExpJobsFldr.mat file from code directory. Create one under the [File] Menu option.');
end
%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
Exp(expN).DexpType= 'single';
try
[openExpfile,openExppath] = uigetfile('.mat','Open Experiment folder and data storage .mat file name','MultiSelect','off')
catch ME
catchissue='Ln50'
ME
cd(w)
return
end
% Test for Bad MP cell array (usually 384 [NaN}'s)
% replaced length(Exp(expN).Dexp(1).MP) with MPnum
for mx=1:length(Exp(expN).Dexp(1).MP)
try
char((Exp(expN).Dexp(1).MP(mx).genename{1}(384)))
MPnum=mx;
catch
break
end
end
% TODO don't want to cd here
try
cd(usrExpJobsDir);
catch
if ispc
cd(fullfile('C:\')); %end % \Easy\Experiments'));
else
cd(fullfile('/mnt/data/scans'))
end
end
datacursormode off;
if ispc
try
cd(usrExpJobsDir);
catch
cd(fullfile('C:\')); %end % \Easy\Experiments'));
end
else
try
cd(usrExpJobsDir);
catch
cd(fullfile('~'));
end
end
try
[openExpfile,openExppath] = uigetfile('.mat','Open Experiment folder and data storage .mat file name','MultiSelect','off')
catch ME
catchissue='Ln50'
ME
cd(w)
return
end
%Return without execution if user cancels or doesn't select a .mat file
try
if openExpfile==0 || openExppath==0, cd(w), return, end
@@ -228,15 +281,15 @@ Exp(expN).Dexp((Exp(expN).DexpLength+1):end)= [];
%Load new ExpJOb*****************
% Load new ExpJob
if expN==1,
%Exp(1).traceN=0;
% Exp(1).traceN=0;
tPtsSize=size(FexpScanBMtp{1,1},3);
set(handles.MPsldr1,'max',length(MP));
set(handles.DMsldr1,'max',length(DM.drug));
set(handles.Tptsldr1,'max',tPtsSize);
%MPnum=length(Exp(expN).Dexp(1).MP);
% MPnum=length(Exp(expN).Dexp(1).MP);
set(handles.MPsldr1,'min',1) %,'max',MPnum+.1)
DMnum= length(Exp(expN).Dexp(1).DM.drug);
set(handles.DMsldr1,'min',1,'max',DMnum)
@@ -326,13 +379,11 @@ Exp(expN).Dexp(1).srtGnLst={('CheckMP/MPDMfile')};
Exp(expN).Dexp(1).srtOrfLst={('CheckMP/MPDMfile')};
set(handles.listboxGnOrf,'string',Exp(expN).Dexp(1).srtGnLst)
set(handles.listboxGnOrf,'string',Exp(expN).Dexp(1).srtOrfLst)
%--------------------------------------------------------------------------
%*********************
EZVimDisplay %*
%*********************
%*****************Capture Exp Name*****************************************
EZVimDisplay
% Capture Exp Name
try
xp=char(Exp(expN).Dexp(1).resDir);
if ispc,
@@ -348,15 +399,13 @@ try
if expN==3,set(handles.expName3,'string',expStrn);end
catch
catchissue='Ln198'
end %nested try-catch-end
end % nested try-catch-end
%*************************************************************************
%****Compile GeneList and OrfList,****************************************
%****Sort and add the medians of Ref Plates if RF1,RF2 exist**************
%Added 17-1023 For User Addition of Gene Composites to ListBox
% Compile GeneList and OrfList
% Sort and add the medians of Ref Plates if RF1,RF2 exist
% Added 17-1023 For User Addition of Gene Composites to ListBox
Expaa{expN,1}= []; Expbb{expN,1}= [];
%*************************************************************************
lstindx=0;
lstindxOrf=0;
spN=0;
@@ -368,12 +417,12 @@ for mp=1:MPnum %length(Exp(expN).Dexp(1).MP)
for ind384=1:384
spN=spN+1;
try %temp find data error
try % Temp find data error
r= ceil(ind384/24);
if rem(ind384,24)==0, c=24; else c=rem(ind384,24); end
%Insert test for numeric in genename and orf if isnumeric
%Correct common EXCEL problem of converting OCT1 into a date numeric
% Insert test for numeric in genename and orf if isnumeric
% Correct common EXCEL problem of converting OCT1 into a date numeric
if cell2mat(Exp(expN).Dexp(1).MP(mp).genename{1}(ind384))==38991,
Exp(expN).Dexp(1).MP(mp).genename{1}(ind384)={'OCT1_'};
elseif isnumeric(cell2mat(Exp(expN).Dexp(1).MP(mp).genename{1}(ind384)))