From d69ac75fa0a318f5f09bd05af3cdf7ee7b320c44 Mon Sep 17 00:00:00 2001 From: Bryan Roessler Date: Wed, 31 Jul 2024 14:23:14 -0400 Subject: [PATCH] Pause EZview work for now --- workflow/.old/apps/matlab/ExpFrontend.m | 212 ++++++++++++++++++ workflow/apps/matlab/ezview/EZexpSel.m | 10 +- .../apps/matlab/ezview/EZinterAgingDev0.m | 7 +- workflow/apps/matlab/ezview/EZmultiDayGui.m | 2 +- workflow/apps/matlab/ezview/EZmultiExLoad.m | 2 +- workflow/apps/matlab/ezview/EZvInitLoad.m | 17 +- workflow/apps/matlab/ezview/EZviewGui.m | 9 +- 7 files changed, 232 insertions(+), 27 deletions(-) create mode 100644 workflow/.old/apps/matlab/ExpFrontend.m diff --git a/workflow/.old/apps/matlab/ExpFrontend.m b/workflow/.old/apps/matlab/ExpFrontend.m new file mode 100644 index 00000000..76e2513b --- /dev/null +++ b/workflow/.old/apps/matlab/ExpFrontend.m @@ -0,0 +1,212 @@ +% FrontEnd utility to copy source result sheet into Exp_ folders of +% StudiesQHTCP/StudyName/Exp1(2,3,4). This allow the automation of path +% capture to the StudiesDataArchieve.txt study log. +% Select, copy and Capture Study Exp_ details to study log + +%Exp meta data collection + +% Set path variables +wCodeDir=pwd; +Wstudy=fullfile('../', wCodeDir); +studyDate=datetime('now'); + +%Load results file meta data into workspace +try + ExpLabel= strcat('Exp',wCodeDir(end)) + questdlg('\fontsize{20} Select the !!Results File','File Selection','OK', struct('Default','OK','Interpreter','tex')); + [resFile,resPath]= uigetfile('*.txt') + copyfile((fullfile(resPath,resFile)),fullfile(wCodeDir)) + resDate= char(regexp(resFile, '(\d\d\_\d\d\d\d)|( \d\d\_\d\d\d\d|\d\d\d\d\d\d)','match')) + cd .. + + if ispc + lastSep=max(strfind(Wstudy,'\')) + studyName=Wstudy((lastSep+1):end) + else + lastSep=max(strfind(Wstudy,'/')) + studyName=Wstudy((lastSep+1):end) + end + + % Build the study info array + S.sDate(1)= {studyDate}; + S.sName(1)= {studyName} + S.sPath(1)= {Wstudy} + S.ELabel(1)= {ExpLabel} + S.EresDate(1)= {resDate} + S.EresFile(1)= {resFile} + S.EresPath(1)= {resPath} + + cd .. + + fid = fopen('StudiesDataArchive.txt','a'); + fprintf(fid,'StudyDate\tStudyName\tStudyPath\tExpNum\tExpDate\tExpPath\tResultFile\n'); + fprintf(fid, '%s\t %s\t %s\t %s\t %s\t %s\t %s \n',S.sDate{1},S.sName{1},S.sPath{1},S.ELabel{1},S.EresDate{1},S.EresPath{1},S.EresFile{1}); + fclose(fid); + fclose('all'); + +catch + cd(wCodeDir) + disp('Error: Unable to Execute ExpFrontend.m') +end + +cd(wCodeDir) + +%************************************************************************************* +%************************************************************************************* +%##################################################################################### +%Improved storage ammenable for database use +%FrontEnd utility to copy source result sheet into Exp_ folders of +%StudiesQHTCP/StudyName/Exp1(2,3,4). This allow the automation of path +%capture to the StudiesDataArchieve.txt study log. +%Select, copy and Capture Study Exp_ details to study log +studyDateNow= studyDate %preserve the 'Now' date +nowNumFNm= strcat((int2str(now)),'.mat') % from previous section incase the /StudyName doesn't have a standard date +%capture the /StudiesQHTCP directory for storing log data +cd ../.. +logPath= pwd %is /.../Exp_ +cd(wCodeDir) +%Try to load an existing data set from previous Frontend calls +try %end ~ln121 + load(fullfile(logPath,'.studyLog.mat')) %load(fullfile('../../','studyLog.mat')) +catch %If no studyLog.mat found [Initial First Entry] + ExpLabel= strcat('Exp',wCodeDir(end)) + resDate= char(regexp(resFile, '(\d\d\_\d\d\d\d)|( \d\d\_\d\d\d\d|\d\d\d\d\d\d)','match')) + cd .. %move up to current study folder from ../Exp_ folder; + %Study meta data collection + Wstudy= pwd %Capture the specific current Study directory + try %try to extract study date from folder name + studyDate= char(regexp(Wstudy, '(\d\d\_\d\d\d\d)|( \d\d\_\d\d\d\d|\d\d\d\d\d\d)| \d\d\d\d\d\d)','match')) + S.sDate(1)= {studyDate}; + catch %if unsuccessful, accept the current date and convert to a 6 char string + studyDate= yyyymmdd(studyDateNow); + studyDate= (int2str(studyDate)) + studyDate= studyDate(3:8) + end + %Capture StudyName + if ispc + lastSep=max(strfind(Wstudy,'\')) + studyName= Wstudy((lastSep+1):end) + else + lastSep=max(strfind(Wstudy,'/')) + studyName= Wstudy((lastSep+1):end) + + end + %Put current First data entry into Structure of Save to StudyLog.mat file + S.sDate(1)= {studyDate}; + S.sName(1)= {studyName} + S.sPath(1)= {Wstudy} + S.ELabel(1)= {ExpLabel} + S.EresDate(1)= {resDate} + S.EresFile(1)= {resFile} + S.EresPath(1)= {resPath} + + cd(wCodeDir) + +logFiletxt= fullfile(logPath,'StudiesDataArchive4DB.txt') %relative .txt path +%Initialize the StudiesDataArchive.txt file with the First row of meta data + +%Print to a .txt spreadsheet the first set of data in the logFiletxt file +fid = fopen(logFiletxt,'w'); +fprintf(fid,'StudyDate\tStudyName\tStudyPath\tExpNum\tExpDate\tExpPath\tResultFile\n'); +fprintf(fid, '%s\t %s\t %s\t %s\t %s\t %s\t %s \n',studyDate,studyName,Wstudy,ExpLabel,resDate,resPath,resFile); +fclose(fid); +%Save the first entry meta data into a permanent .mat files for future recall +save(fullfile(logPath,'studyLog4DB.mat'), 'S') +save(fullfile(logPath,'.studyLog.mat'), 'S') +save(fullfile(logPath,'.nowNumFNm.mat'), 'S') + + + +end %end for try for the First entry only +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +%++++++++END of FIRST ENTRY startup section++++++++++++++++++++++++++++++++ +%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + + +%Begin routine for all Entries After the Initial data entry**************** +ExpLabel= strcat('Exp',wCodeDir(end)) +resDate= char(regexp(resFile, '(\d\d\_\d\d\d\d)|( \d\d\_\d\d\d\d|\d\d\d\d\d\d)','match')) %Capture date from !!Results file + +cd .. %Move to the current study folder + +%Capture study meta dat +Wstudy= pwd % Capture the path to the current study + + %Attempt to extract study date from folder name and convert to a + %searchable numeric date + studyDate= char(regexp(Wstudy, '(\d\d\_\d\d\d\d)|( \d\d\_\d\d\d\d|\d\d\d\d\d\d)| \d\d\d\d\d\d)','match')) + if ~isempty(studyDate) %If no date in folder name use current date and convert to 6char string + S.sDate(1)= {studyDate}; + if isequal((str2num(studyDate(3))),'_') %Remove '_' so that date is a number for easy DB search + studyDate= strcat(studyDate(1:2),studyDate(4:6)) + end + else + studyDate= yyyymmdd(studyDateNow); + studyDate= (int2str(studyDate)) + studyDate= studyDate(3:8) + end + +if ispc + lastSep=max(strfind(Wstudy,'\')) + studyName= Wstudy((lastSep+1):end) +else + lastSep=max(strfind(Wstudy,'/')) + studyName= Wstudy((lastSep+1):end) +end + +%Put meta data into a structure for storage (studyLog.mat) and future +%compare operations +lastRow= length(S.sPath) + +%Compare these just obtained paths with those stored in the studyLog.mat +%file and add a new row if the study or results sheet meta data is new or different +cd .. %Move the the /QHTPCstudies folder +logtxt= 'StudiesDataArchive4DB.txt' +logFiletxt= fullfile(logPath,logtxt) % +try + matched=0; + for n= 1:(lastRow) + if strcmp(Wstudy,S.sPath(n)) && strcmp(resPath, S.EresPath(n)) && strcmp(ExpLabel, S.ELabel(n)) + matched= 1; + break + end + end + + +%Update the StudiesDataArchive.txt file with a new row of meta data +if matched== 0 %if no match for this entry then add a line to the text archive file + fid = fopen(logFiletxt,'w'); + S.sDate(lastRow+1)= {studyDate}; + S.sName(lastRow+1)= {studyName}; + S.sPath(lastRow+1)= {Wstudy}; + S.ELabel(lastRow+1)= {ExpLabel}; + S.EresDate(lastRow+1)= {resDate}; + S.EresFile(lastRow+1)= {resFile}; + S.EresPath(lastRow+1)= {resPath}; + for n= 1:(lastRow +1) + %Print to a .txt spreadsheet and Save update to .mat files + if n==1 + fprintf(fid,'StudyDate\tStudyName\tStudyPath\tExpNum\tExpDate\tExpPath\tResultFile\n'); + end + fprintf(fid, '%s\t %s\t %s\t %s\t %s\t %s\t %s \n',S.sDate{n},S.sName{n},S.sPath{n},S.ELabel{n},S.EresDate{n},S.EresPath{n},S.EresFile{n}); + end + + fclose(fid); %close DBase amenable study log file after data update + + save((fullfile(logPath,'studyLog4DB.mat')), 'S') % path for studyLog.mat + save((fullfile(logPath,'.studyLog.mat')), 'S') %path backup studyLogBU.mat + save((fullfile(logPath,strcat('.',nowNumFNm))), 'S') +end +fclose('all'); + +catch + cd(wCodeDir) %Return to the location of the frontend.m code (/studyName/Exp_) + fclose('all'); + clear S %clear data structure variable 'S.' +end + +cd(wCodeDir) %Return to the location of the frontend.m code (/studyName/Exp_) +clear all %clear workspace variables + + diff --git a/workflow/apps/matlab/ezview/EZexpSel.m b/workflow/apps/matlab/ezview/EZexpSel.m index 216f8ecb..652a9bcf 100755 --- a/workflow/apps/matlab/ezview/EZexpSel.m +++ b/workflow/apps/matlab/ezview/EZexpSel.m @@ -2,7 +2,7 @@ global Expaa global Expbb global expType -global usrExpJobsDir +global scansDir global zonePB w=pwd; @@ -90,7 +90,7 @@ if expType==1 % Return without execution if user cancels or doesn't select a .mat file try - if openExpfile==0 || scansDir==0 + if matFile==0 || scansDir==0 return end catch @@ -100,14 +100,11 @@ if expType==1 orfLstSel=get(handles.GeneOrfTog,'value') end - Exp(expN).Dexp(1).srtGnLst={('CheckMP/MPDMfile')}; Exp(expN).Dexp(1).srtOrfLst={('CheckMP/MPDMfile')}; set(handles.listboxGnOrf,'value',1) %Fix accomodation for bug in App Designer .. .wlapp converter 230906 set(handles.listboxGnOrf,'string',cellstr([{'Failed To Load'}; {' '}])); - - ExpOutmat=fullfile(scansDir,openExpfile); - load(ExpOutmat); + load(matFile); cd(scansDir) cd ..; resDir=pwd; @@ -137,7 +134,6 @@ if expType==1 load(fullfile(resDir,'Fotos','BGatTpts')) load(fullfile(resDir,'PTmats','NImParameters')) %Backup for cond. sothat failure to load is recovered back prev. ExpJob data - %test in temp Exp(expN).Dexp(1).temp.DM=DM; Exp(expN).Dexp(1).temp.MP=MP; diff --git a/workflow/apps/matlab/ezview/EZinterAgingDev0.m b/workflow/apps/matlab/ezview/EZinterAgingDev0.m index ec469cbb..e4b1fdff 100755 --- a/workflow/apps/matlab/ezview/EZinterAgingDev0.m +++ b/workflow/apps/matlab/ezview/EZinterAgingDev0.m @@ -1,12 +1,13 @@ %single gene L based interaction shift display function EZinterAgingDev0 global Exp + global matFile - [openExpfile,scansDir]=uigetfile('.mat','Open Experiment folder and data storage .mat file name','MultiSelect','on'); + [matFile,scansDir]=uigetfile('.mat','Open Experiment folder and data storage .mat file name','MultiSelect','on'); AgMPDM=load(fullfile(scansDir,'MasterPlateFiles','MPDMmat.mat')); - for i=1:size(openExpfile,2) - ExpOutmat{i}=fullfile(scansDir,openExpfile{i}); + for i=1:size(matFile,2) + ExpOutmat{i}=fullfile(scansDir,matFile{i}); EScan{i}=load(ExpOutmat{1}); end diff --git a/workflow/apps/matlab/ezview/EZmultiDayGui.m b/workflow/apps/matlab/ezview/EZmultiDayGui.m index 598b763d..0b4465a2 100755 --- a/workflow/apps/matlab/ezview/EZmultiDayGui.m +++ b/workflow/apps/matlab/ezview/EZmultiDayGui.m @@ -5,7 +5,7 @@ function EZmultiDayGui global exDlst global exFolder global expType - global usrExpJobsDir + global scansDir xPos=0.05; btnWid=0.10; diff --git a/workflow/apps/matlab/ezview/EZmultiExLoad.m b/workflow/apps/matlab/ezview/EZmultiExLoad.m index 587018d6..f7fdabb1 100755 --- a/workflow/apps/matlab/ezview/EZmultiExLoad.m +++ b/workflow/apps/matlab/ezview/EZmultiExLoad.m @@ -28,7 +28,7 @@ for n=1:Exp(expN).DexpLength % size(matFile,2) set(handles.listboxGnOrf,'value',1) %Fix accomodation for bug in App Designer .. .wlapp converter 230918 set(handles.listboxGnOrf,'string',cellstr([{'Failed To Load'}; {' '}])); % try - ExpOutmat=matFile(n) %fullfile(scansDir,openExpfile); + ExpOutmat=matFile(n) load(char(ExpOutmat)); %cd(scansDir) %cd ..; diff --git a/workflow/apps/matlab/ezview/EZvInitLoad.m b/workflow/apps/matlab/ezview/EZvInitLoad.m index 1af2c073..4a8bf215 100755 --- a/workflow/apps/matlab/ezview/EZvInitLoad.m +++ b/workflow/apps/matlab/ezview/EZvInitLoad.m @@ -1,9 +1,10 @@ -%EZvInitLoad +% EZvInitLoad global Exp global Expaa global Expbb global userPars -global usrExpJobsDir +global scansDir +global matFile global zonePB global mpdmFile global ghandles @@ -147,7 +148,7 @@ try % 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') + [matFile,scansDir]=uigetfile('.mat','Open Experiment folder and data storage .mat file name','MultiSelect','off') load (fullfile(Exp(1).Dexp(1).ExpFoldr,'MasterPlateFiles','MPDMmat.mat')) for i=1:numExps Exp(i).Dexp(1).DM=DM; @@ -804,13 +805,9 @@ catch ME %Outer loop try around entire code subroutine Exp(1).Dexp(1).srtOrfLst=cellstr([{'Failed To Load'}; {' '}]); Exp(2).Dexp(1).srtOrfLst=cellstr([{'Failed To Load'}; {' '}]); Exp(3).Dexp(1).srtOrfLst=cellstr([{'Failed To Load'}; {' '}]); - %[openExpfile,scansDir] - if ~contains(openExpfile,'.mat') - cd(scansDir) - cd '..' - ExpPath=pwd; - cd(w) - ExpOutImFile=fullfile(scansDir,openExpfile); + + if ~contains(matFile,'.mat') + ExpOutImFile=fullfile(matFile); EZvImagesOnly end end diff --git a/workflow/apps/matlab/ezview/EZviewGui.m b/workflow/apps/matlab/ezview/EZviewGui.m index 4808392e..5dd662d5 100755 --- a/workflow/apps/matlab/ezview/EZviewGui.m +++ b/workflow/apps/matlab/ezview/EZviewGui.m @@ -1892,14 +1892,13 @@ function HMapRange_Callback(hObject, eventdata, handles) % flip=upper(answer(2)); end -function SetExpJobsFolder_Callback(hObject, eventdata, handles) +function setScansDir_Callback(hObject, eventdata, handles) % hObject handle to SetExpJobsFolder (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA - if ~exist('usrExpJobsDir','var') - selpath=uigetdir('default','Set /ExpJobs Folder') - usrExpJobsDir=selpath; - end + % if ~exist('scansDir','var') + scansDir=uigetdir('default','Set Project Scans Folder') + % end end % Executes on button press in zonePB1.