EASYconsole2.m reformat

This commit is contained in:
2024-07-23 13:03:35 -04:00
parent 8a171a348c
commit cbc40c3cac

View File

@@ -1,24 +1,4 @@
%% MAIN WORKING FUNCTION: EASYconsole.m %% % Launch the MATLAB EASY console
%This is a 2023a Expoorted App so that it can be edited in the unfortunate
%new Matlab versions. Created by using the Matlab porting utility in 2023.
% EASYconsole is a function designed to have a variable number of inputs and
% outputs
% These were defined globally in the parent script
% global ExpOutmat
% global ExpPath
% global fhconsole
% global resDir
% global wCodeDir
% global ImParMat
% global openExpfile
% global openExppath
% global newExpfile
% global newExppath
% global SWnewExp
% global matDir
% global scan
function varargout = EASYconsole(varargin) function varargout = EASYconsole(varargin)
% initialize global variables for function EASYconsole % initialize global variables for function EASYconsole
global ExpOutmat global ExpOutmat
@@ -103,28 +83,29 @@ function EASYconsole_OpeningFcn(hObject, ~, handles, varargin)
set(fhconsole,'Name','EASYconsole -Exp. Analysis NOT selected.') set(fhconsole,'Name','EASYconsole -Exp. Analysis NOT selected.')
end end
end end
%% EASYconsole OUTPUT FUNCTION %% %% EASYconsole OUTPUT FUNCTION %%
% Outputs from this function are returned to the command line. % Outputs from this function are returned to the command line.
function varargout = EASYconsole_OutputFcn(~, ~, handles)
% varargout--cell array for returning output args (see VARARGOUT); % varargout--cell array for returning output args (see VARARGOUT);
% hObject--handle to figure % hObject--handle to figure
% eventdata reserved - to be defined in a future version of MATLAB % eventdata reserved - to be defined in a future version of MATLAB
% handles--structure with handles and user data (see GUIDATA) % handles--structure with handles and user data (see GUIDATA)
function varargout = EASYconsole_OutputFcn(~, ~, handles)
% Get default command line output from handles structure % Get default command line output from handles structure
varargout{1} = handles.output; varargout{1} = handles.output;
end end
%% CONSOLE BUTTON INTERFACES %% %% CONSOLE BUTTON INTERFACES %%
% File Button Interface % File Button Interface
function FileMenu_Callback(~, ~, ~) function FileMenu_Callback(~, ~, ~)
global wCodeDir returnHome
cd(wCodeDir)
end end
% Load Experiment Button Interface % Load Experiment Button Interface
function LoadExp_Callback(~, ~, ~) function LoadExp_Callback(~, ~, ~)
global wCodeDir returnHome
cd(wCodeDir)
end end
% New Experiment Button Interface % New Experiment Button Interface
function NewExpDat_Callback(~, ~, ~) function NewExpDat_Callback(~, ~, ~)
global newExpfile global newExpfile
@@ -138,553 +119,332 @@ function NewExpDat_Callback(~, ~, ~)
global fhconsole global fhconsole
global scan global scan
%% RESULTS DIRECTORY CREATION %%
try
% put all users on same working directory % put all users on same working directory
cd(wCodeDir) returnHome
wcode=pwd;
if ispc % Create a new experiment
try try
% first attempt to begin search at current working directory questdlg('\fontsize{20} NAME the file and NAVIGATE to the directory with the image folders.','File Creation','OK', struct('Default','OK','Interpreter','tex'));
cd(fullfile('C:\')); [newExpfile,newExppath] = uiputfile(' .mat');
catch SWnewExp=1;
% if first attempt fails, throw message box and begin the search at the PC's C drive cd (wcode)
msgbox('Failure to find selected default Directory so starting Load search at the C Drive .'); newExpfilePref= strrep(newExpfile,'.mat','');
%cd(fullfile('C:\')); resDirName=strcat('Results',datestr(now,29),newExpfilePref);
wcode
end % creation of the Results file
end if ~exist(fullfile(newExppath,resDirName,'matResults'))
mkdir (fullfile(newExppath,resDirName,'matResults'));
end
if isunix
try % assigning paths to global variables
name = getenv('USER'); resDir= fullfile(newExppath,resDirName);
if isequal(name,'jwrodger') matDir= fullfile(newExppath,resDirName,'matResults');
cd('/mnt/data/ExpJobs') ExpOutmat=fullfile(matDir,strcat(datestr(now,29),newExpfile));
else ExpPath= fullfile(newExppath);
%could provide other contingency options here if desireable for other users
%if fails, just go to EASY code folder per JH %***Added for 'parfor global' to preallocate 'scan' structure 20-0123*****
cd(wcode) %JH has argued strongly to send user to code directory nlist=dir(fullfile(ExpPath,'*'));
end nnn=0;
for n=1:size(nlist,1)
catch if (~isempty(str2num(nlist(n).name)))
msgbox('Failure to find selected default Directory so start Load search at root.'); nnn=nnn+1;
cd(fullfile('/')); PnumLst(nnn)= (str2num(nlist(n).name));
sl(nnn,1)={(nlist(n).name)};
end end
end end
if ismac scanSize= size(sl,1);
cd(wcode) %JH has argued strongly to send user to code directory scanMax= max(str2double(sl));
clear scan;
scan(scanMax)= struct(); %[]; %changed for parfor global 20_0118
save(ExpOutmat,'scan')
% create 'PrintResults' file
if ~exist(fullfile(ExpPath,resDirName,'PrintResults'))
mkdir(fullfile(ExpPath,resDirName,'PrintResults'));
end end
% copy 'figs' file and place it in ExpPath Directory
% CREATE NEW EXPERIMENT % if ~exist(fullfile(ExpPath,resDirName,'figs'))
questdlg('\fontsize{20} NAME the file and NAVIGATE to the directory with the image folders.','File Creation','OK', struct('Default','OK','Interpreter','tex')); copyfile((fullfile(wCodeDir,'figs')), (fullfile(ExpPath,resDirName,'figs')))
[newExpfile,newExppath] = uiputfile(' .mat'); end
SWnewExp=1; % create 'CFfigs' file
cd (wcode) if ~exist(fullfile(ExpPath,resDirName,'CFfigs'))
newExpfilePref= strrep(newExpfile,'.mat',''); mkdir(fullfile(ExpPath,resDirName,'CFfigs'));
resDirName=strcat('Results',datestr(now,29),newExpfilePref); end
% copy 'PTmats' file and place it in ExpPath Directory
% creation of the Results file if ~exist(fullfile(ExpPath,resDirName,'PTmats'))
if ~exist(fullfile(newExppath,resDirName,'matResults')) copyfile((fullfile(wCodeDir,'PTmats')), (fullfile(ExpPath,resDirName,'PTmats')))
mkdir (fullfile(newExppath,resDirName,'matResults')); end
% create 'Fotos' file
if ~exist(fullfile(ExpPath,resDirName,'Fotos'))
mkdir(fullfile(ExpPath,resDirName,'Fotos'));
clear sbdg % reduce possible retention of a previous job sdbg
sbdg= cell(1,scanMax);
save((fullfile(resDir,'Fotos','Nbdg')),'sbdg');
end
% create backup 'Fotos' file
if ~exist(fullfile(ExpPath,resDirName,'Fotos','BkUp'))
mkdir(fullfile(ExpPath,resDirName,'Fotos','BkUp'));
end
catch ME
returnHome
disp('Error Creating a New Experiment')
end end
% assigning paths to global variables
resDir= fullfile(newExppath,resDirName);
matDir= fullfile(newExppath,resDirName,'matResults');
ExpOutmat=fullfile(matDir,strcat(datestr(now,29),newExpfile));
ExpPath= fullfile(newExppath);
%***Added for 'parfor global' to preallocate 'scan' structure 20-0123***** % set the title for fhconsole depending on existence
nlist=dir(fullfile(ExpPath,'*')); if exist('resDir','var')&&~isempty(resDir)
nnn=0; set(fhconsole,'Name',strcat('EASYconsole- ',char(resDir)))
for n=1:size(nlist,1) else
if (~isempty(str2num(nlist(n).name))) set(fhconsole,'Name','EASYconsole -Exp. Analysis NOT selected.')
nnn=nnn+1; end
PnumLst(nnn)= (str2num(nlist(n).name));
sl(nnn,1)={(nlist(n).name)};
end
end
scanSize= size(sl,1);
scanMax= max(str2double(sl));
clear scan;
scan(scanMax)= struct(); %[]; %changed for parfor global 20_0118
%*************************************************************************
save(ExpOutmat,'scan')
% create 'PrintResults' file
if ~exist(fullfile(ExpPath,resDirName,'PrintResults'))
mkdir(fullfile(ExpPath,resDirName,'PrintResults'));
end
% copy 'figs' file and place it in ExpPath Directory
if ~exist(fullfile(ExpPath,resDirName,'figs'))
copyfile((fullfile(wCodeDir,'figs')), (fullfile(ExpPath,resDirName,'figs')))
end
% create 'CFfigs' file
if ~exist(fullfile(ExpPath,resDirName,'CFfigs'))
mkdir(fullfile(ExpPath,resDirName,'CFfigs'));
end
% copy 'PTmats' file and place it in ExpPath Directory
if ~exist(fullfile(ExpPath,resDirName,'PTmats'))
copyfile((fullfile(wCodeDir,'PTmats')), (fullfile(ExpPath,resDirName,'PTmats')))
end
% create 'Fotos' file
if ~exist(fullfile(ExpPath,resDirName,'Fotos'))
mkdir(fullfile(ExpPath,resDirName,'Fotos'));
clear sbdg % reduce possible retention of a previous job sdbg
sbdg= cell(1,scanMax);
save((fullfile(resDir,'Fotos','Nbdg')),'sbdg');
end
% create backup 'Fotos' file
if ~exist(fullfile(ExpPath,resDirName,'Fotos','BkUp'))
mkdir(fullfile(ExpPath,resDirName,'Fotos','BkUp'));
end end
catch ME
cd(wCodeDir)
disp('Error Creating a New Experiment. Loc: EASYconsole.m Lines 106-197')
end
% set the title for fhconsole depending on existence % Load a previous experiment
if exist('resDir','var')&&~isempty(resDir)
set(fhconsole,'Name',strcat('EASYconsole- ',char(resDir)))
else
set(fhconsole,'Name','EASYconsole -Exp. Analysis NOT selected.')
end
end
%% LOAD A PREVIOUS EXPERIMENT %%
%*******LOAD Experiment Analysis directory/file structure
function LoadDatFile_Callback(~, ~, ~) function LoadDatFile_Callback(~, ~, ~)
global openExpfile global openExpfile
global openExppath global openExppath
global SWnewExp global SWnewExp
global ExpOutmat global ExpOutmat
global ExpPath global ExpPath
global matDir global matDir
global resDir global resDir
global wCodeDir global wCodeDir
global fhconsole global fhconsole
global ImParMat global ImParMat
try returnHome
%cd(wCodeDir)
%wcode=pwd;
%cd ..
%cd(wcode)
% put all users on same working directory % TODO this entire try block needs work
cd(wCodeDir) try
wcode=pwd; % TODO this section is highly questionable
questdlg('\fontsize{20} Load file from ExpJobs/YourJob/YourResults/matResults','File Creation','OK', struct('Default','OK','Interpreter','tex'));
if ispc [openExpfile,openExppath] = uigetfile('.mat','Open Experiment folder and data storage .mat file name','MultiSelect','off');
try SWnewExp=0;
% first attempt to begin search at current working directory ExpOutmat= fullfile(openExppath,openExpfile);
cd(fullfile('C:\')); load(ExpOutmat);
catch cd(openExppath)
% if first attempt fails, throw message box and begin the search at the PC's C drive cd ..;
msgbox('Failure to find selected default Directory so starting Load search at the C Drive .'); resDir=pwd;
%cd(fullfile('C:\')); cd ..;
wcode ExpPath=pwd;
end cd (wcode)
end ExpPath= fullfile(ExpPath);
if isunix if isfolder(fullfile(openExppath, '..','..','1')) %If Inovation Vrobot Then
try if exist(fullfile(resDir,'PTmats','NImParameters.mat'))
name = getenv('USER'); load(fullfile(resDir,'PTmats','NImParameters.mat'));
if isequal(name,'jwrodger') else
cd('/mnt/data/ExpJobs') curDir=pwd;
else returnHome
%could provide other contingency options here if desireable for other users load NImParameters.mat
%if fails, just go to EASY code folder per JH cd(curDir)
cd(wcode) %JH has argued strongly to send user to code directory end
end else %If Epson 10Plate Scans Then>
if exist(fullfile(resDir,'PTmats','ImParameters.mat'))
catch load(fullfile(resDir,'PTmats','ImParameters.mat'));
msgbox('Failure to find selected default Directory so start Load search at root.'); else
cd(fullfile('/')); curDir=pwd;
end returnHome
load ImParameters.mat
cd(curDir)
end
end end
if ismac
cd(wcode) %JH has argued strongly to send user to code directory matDir= fullfile(openExppath,'\');
mkdir(fullfile(matDir,'BkUp'));
% create supporting files
if ~exist(fullfile(resDir,'PrintResults'))
mkdir(fullfile(resDir,'PrintResults'));
end end
%****************End if ~exist(fullfile(resDir,'figs'))
%Navigation****************************************** mkdir(fullfile(resDir,'figs'));
end
questdlg('\fontsize{20} Load file from ExpJobs/YourJob/YourResults/matResults','File Creation','OK', struct('Default','OK','Interpreter','tex')); if ~exist(fullfile(resDir,'CFfigs'))
[openExpfile,openExppath] = uigetfile('.mat','Open Experiment folder and data storage .mat file name','MultiSelect','off'); mkdir(fullfile(resDir,'CFfigs'));
SWnewExp=0; end
if ~exist(fullfile(resDir,'PTmats'))
ExpOutmat= fullfile(openExppath,openExpfile); mkdir(fullfile(resDir,'PTmats'));
load(ExpOutmat); end
if ~exist(fullfile(resDir,'Fotos'))
cd(openExppath) mkdir(fullfile(resDir,'Fotos'));
cd ..; end
resDir=pwd; catch
cd ..; returnHome
ExpPath=pwd;
cd (wcode)
ExpPath= fullfile(ExpPath);
if isfolder(fullfile(openExppath, '..','..','1')) %If Inovation Vrobot Then
if exist(fullfile(resDir,'PTmats','NImParameters.mat'))
load(fullfile(resDir,'PTmats','NImParameters.mat'));
else
curDir=pwd;
cd(wCodeDir)
load NImParameters.mat
cd(curDir)
end end
else %If Epson 10Plate Scans Then>
if exist(fullfile(resDir,'PTmats','ImParameters.mat')) clear scan
load(fullfile(resDir,'PTmats','ImParameters.mat'));
if exist('resDir','var')&&~isempty(resDir)
fhconsole= gcf;
set(fhconsole,'Name',strcat('EASYconsole- ',char(resDir)))
else else
curDir=pwd; set(fhconsole,'Name','EASYconsole -Exp. Analysis NOT selected.')
cd(wCodeDir) end
load ImParameters.mat
cd(curDir)
end
end end
matDir= fullfile(openExppath,'\');
mkdir(fullfile(matDir,'BkUp'));
% create supporting files
if ~exist(fullfile(resDir,'PrintResults'))
mkdir(fullfile(resDir,'PrintResults'));
end
if ~exist(fullfile(resDir,'figs'))
mkdir(fullfile(resDir,'figs'));
end
if ~exist(fullfile(resDir,'CFfigs'))
mkdir(fullfile(resDir,'CFfigs'));
end
if ~exist(fullfile(resDir,'PTmats'))
mkdir(fullfile(resDir,'PTmats'));
end
if ~exist(fullfile(resDir,'Fotos'))
mkdir(fullfile(resDir,'Fotos'));
end
catch
cd(wCodeDir)
end
clear scan
if exist('resDir','var')&&~isempty(resDir)
fhconsole= gcf;
set(fhconsole,'Name',strcat('EASYconsole- ',char(resDir)))
else
set(fhconsole,'Name','EASYconsole -Exp. Analysis NOT selected.')
end
end
%% CALLBACKS %% %% CALLBACKS %%
% function Parameters_Callback(~, ~, ~)
% global wCodeDir
% cd(wCodeDir)
% function CFparameters_Callback(~, ~, ~)
% global wCodeDir
% cd(wCodeDir)
% function RunCF_Callback(~, ~, ~)
% global wCodeDir
% cd(wCodeDir)
% try
% CcurveFitStartup
% catch ME
% cd(wCodeDir)
% end
%
% callback for the 'Run' in the dropdown menu % callback for the 'Run' in the dropdown menu
function run_Callback(~, ~, ~) function run_Callback(~, ~, ~)
global wCodeDir returnHome
try
catch ME
cd(wCodeDir)
end end
end
% function Dbase_Callback(~, ~, ~)
% global wCodeDir
% try
% catch ME
% cd(wCodeDir)
% end
% function runImAnal_Callback(~, ~, ~)
% global wCodeDir
% cd(wCodeDir)
% try
% ImStartup
% catch ME
% cd(wCodeDir)
% EASYconsole
% end
function runPlateMapPintool_Callback(~, ~, ~) function runPlateMapPintool_Callback(~, ~, ~)
global wCodeDir returnHome
cd(wCodeDir) try
try NImapPT
NImapPT catch ME
catch ME returnHome
cd(wCodeDir) EASYconsole
EASYconsole end
end
end end
function NImCFcombo_Callback(~, ~, ~) function NImCFcombo_Callback(~, ~, ~)
global wCodeDir returnHome
cd(wCodeDir) try
try par4Gbl_Main8c
par4Gbl_Main8c catch
catch returnHome
cd(wCodeDir) EASYconsole
EASYconsole end
end
end end
function runPlateImAnal_Callback(~, ~, ~) function runPlateImAnal_Callback(~, ~, ~)
global wCodeDir returnHome
cd(wCodeDir) try
try NImStartupOnly
NImStartupOnly catch ME
catch ME returnHome
cd(wCodeDir) EASYconsole
EASYconsole end
end end
end
% function runCF_Callback(~, ~, ~)
% global wCodeDir
% try
% cd(wCodeDir)
% CcurveFitStartup
% catch ME
% cd(wCodeDir)
% end
function PlateCFit_Callback(~, ~, ~) function PlateCFit_Callback(~, ~, ~)
global wCodeDir global ExpOutmat
global ExpOutmat returnHome
try try
cd(wCodeDir) NCstart
NCstart catch ME
catch ME returnHome
cd(wCodeDir) end
end
end end
% function Gen_CF_GenORF_Callback(~, ~, ~)
% global wCodeDir
% try
% DgenCFoutWnum
% catch ME
% cd(wCodeDir)
% EASYconsole
% end
% function ImParams_Callback(~, ~, ~)
% global wCodeDir
% try
% catch ME
% cd(wCodeDir)
% EASYconsole
% end
%*************************
% function createPTmap_Callback(~, ~, ~)
% global wCodeDir
% try
% cd(wCodeDir)
% ImapPT()
% catch ME
% cd(wCodeDir)
% end
%*************************
function GenPrintouts_Callback(~, ~, ~) function GenPrintouts_Callback(~, ~, ~)
end end
%
% function Gen_YXmaster_Callback(~, ~, ~)
% global wCodeDir
% try
% Dgen_YXmasterFile
% catch ME
% cd(wCodeDir)
% EASYconsole
% end
% function Gen_CurveFitOut_Callback(~, ~, ~)
% global wCodeDir
% try
% DgenLegCFout
% catch ME
% cd(wCodeDir)
% EASYconsole
% end
% function Gen_CF_withNums_Callback(~, ~, ~)
% global wCodeDir
% try
% DgenCFoutWnum
% catch ME
% cd(wCodeDir)
% EASYconsole
% end
% function Gen_CF_withNumsOrfsGenes_Callback(~, ~, ~)
% global wCodeDir
% try
% DgenCFoutWnumOrfgene
% catch ME
% cd(wCodeDir)
% EASYconsole
% end
% function Gen_CF_withNumsOrfsGenesPerts_Callback(~, ~, ~)
% global wCodeDir
% try
% DgenCFoutWnumOrfgenePertsDev
% catch ME
% cd(wCodeDir)
% EASYconsole
% end
% function zx_Callback(~, ~, ~)
function uploadExcelMP2DB_Callback(~, ~, ~) function uploadExcelMP2DB_Callback(~, ~, ~)
end end
% function uploadYXmaster2DB_Callback(~, ~, ~)
%
% function Gen_CF4DB_Callback(~, ~, ~)
%
%
% function Gen_CF4DB_Extras4Review_Callback(~, ~, ~)
%
%
% function uploadCF2DB_Callback(~, ~, ~)
% --------------------------------------------------------------------
function runDMPexcel_Callback(~, ~, ~) function runDMPexcel_Callback(~, ~, ~)
global wCodeDir global ExpPath
global ExpPath try
try DMPexcel2mat_2024winLinix %DMPexcel2mat_2023winLinix
DMPexcel2mat_2024winLinix %DMPexcel2mat_2023winLinix catch ME
catch ME returnHome
cd(wCodeDir) EASYconsole
EASYconsole end
end
end end
% --------------------------------------------------------------------
function runResults_DBcombo_Callback(~, ~, ~) function runResults_DBcombo_Callback(~, ~, ~)
global wCodeDir
try try
DgenResults240430 %similar but semicolons removed to restore so cmdLine display info. DgenResults240430 %similar but semicolons removed to restore so cmdLine display info.
%Dgen241010qhtcp %par4global -convert 1x1cell of 384cells to be like previous 1x384 cells CFparameter %Dgen241010qhtcp %par4global -convert 1x1cell of 384cells to be like previous 1x384 cells CFparameter
catch ME catch ME
disp('Error in DgenResults240430') disp('Error in DgenResults240430')
cd(wCodeDir) returnHome
EASYconsole EASYconsole
end
end end
end
% --------------------------------------------------------------------
function Tools_Callback(~, ~, ~) function Tools_Callback(~, ~, ~)
end end
% --------------------------------------------------------------------
function runOverlayPlots_Callback(~, ~, ~) function runOverlayPlots_Callback(~, ~, ~)
global wCodeDir returnHome
cd(wCodeDir) try
try DoverlayPlots2
DoverlayPlots2 returnHome
cd(wCodeDir) EASYconsole
EASYconsole catch ME
catch ME returnHome
cd(wCodeDir) EASYconsole
EASYconsole end
end
end end
% --------------------------------------------------------------------
function runFotoStrip_Callback(~, ~, ~) function runFotoStrip_Callback(~, ~, ~)
global wCodeDir returnHome
cd(wCodeDir) try
try F_NImStartup_CentCir
F_NImStartup_CentCir returnHome
cd(wCodeDir) EASYconsole
EASYconsole catch ME
catch ME returnHome
cd(wCodeDir) EASYconsole
EASYconsole end
end
end end
% --------------------------------------------------------------------
function runDisplayFig_Callback(~, ~, ~) function runDisplayFig_Callback(~, ~, ~)
global wCodeDir returnHome
cd(wCodeDir) try
try UfigDisplay
UfigDisplay catch ME
catch ME returnHome
cd(wCodeDir) EASYconsole
EASYconsole end
end
end end
% --------------------------------------------------------------------
function runViewParameters_Callback(~, ~, ~) function runViewParameters_Callback(~, ~, ~)
global wCodeDir returnHome
cd(wCodeDir)
try
catch ME
cd(wCodeDir)
EASYconsole
end
end
% --------------------------------------------------------------------
function QkviewN_Callback(~, ~, ~)
global wCodeDir
cd(wCodeDir)
try
try try
cd fullfile(ExpPath) catch ME
catch returnHome
if ispc cd c:\ EASYconsole
else end
cd (fullfile('~'));
end
end
QkviewImages
catch ME
cd(wCodeDir)
EASYconsole
end
end end
% --------------------------------------------------------------------
function CFdisplay_Callback(~, ~, ~) function QkviewN_Callback(~, ~, ~)
global wCodeDir returnHome
cd(wCodeDir) try
try try
NCsingleDisplay cd(fullfile(ExpPath))
cd(wCodeDir) catch
EASYconsole if ispc
catch ME cd('C:\')
cd(wCodeDir) else
EASYconsole cd(fullfile('~'));
end
end
QkviewImages
catch ME
returnHome
EASYconsole
end
end end
function CFdisplay_Callback(~, ~, ~)
returnHome
try
NCsingleDisplay
returnHome
EASYconsole
catch ME
returnHome
EASYconsole
end
end end