EASYconsole.m: datestr to datetime

This commit is contained in:
2024-07-26 10:48:14 -04:00
parent b35beb2591
commit 90c832fd0a

View File

@@ -17,9 +17,11 @@ function varargout = EASYconsole(varargin)
startDir=pwd; startDir=pwd;
easyPath=which(mfilename); easyPath=which(mfilename);
[easyDir,easyFileName]=fileparts(easyPath); [easyDir,easyFileName]=fileparts(easyPath);
easyDir=fullfile(easyDir) easyDir=fullfile(easyDir);
[parentDir, ~]=fileparts(easyDir); [parentDir, ~]=fileparts(easyDir);
userName=system('whoami'); userName=system('whoami');
now=datetime('now');
todayDateStr=datestr(now, 'yyyymmdd');
disp(strcat('This script name: ', easyFileName)) disp(strcat('This script name: ', easyFileName))
@@ -45,7 +47,7 @@ function varargout = EASYconsole(varargin)
easySuffix=get_env('EASY_SUFFIX'); easySuffix=get_env('EASY_SUFFIX');
else else
[dirName, ~]=fileparts(scansDir); [dirName, ~]=fileparts(scansDir);
[date, userNameScans, easySuffix]=strsplit(dirName, '_'); [scansDate, scansUserName, easySuffix]=strsplit(dirName, '_');
% The following is handled by the workflow script that calls this module % The following is handled by the workflow script that calls this module
% Reimplementing here for stand-alone mode % Reimplementing here for stand-alone mode
% While the easySuffix directory exists, increment by one and try again % While the easySuffix directory exists, increment by one and try again
@@ -57,13 +59,13 @@ function varargout = EASYconsole(varargin)
end end
end end
% Might as well check this too % Might as well check this too
if userName ~= userNameScans if userName ~= scansUserName
disp('WARNING: userName does not match userNameScans'); disp('WARNING: userName does not match scansUserName');
disp("This usually means that you are attempting to run an EASY analysis on another user's project data scans"); disp("This usually means that you are attempting to run an EASY analysis on another user's project data scans");
end end
% For happiness % For happiness
if datestr(now, 'yyyymmdd') == date if todayDateStr == scansDate
disp("Early bird gets the worm") disp("Early bird gets the worm");
end end
end end
@@ -88,7 +90,7 @@ function varargout = EASYconsole(varargin)
easyResultsDir=fullfile(get_env('EASY_RESULTS_DIR')); easyResultsDir=fullfile(get_env('EASY_RESULTS_DIR'));
disp(strcat('Using project prefix: ', easyResultsDir, ' from environment variable EASY_RESULTS_DIR')) disp(strcat('Using project prefix: ', easyResultsDir, ' from environment variable EASY_RESULTS_DIR'))
else else
easyResultsDirName=strcat('Results_',datestr(now, 'yyyymmdd'),'_',easySuffix); easyResultsDirName=strcat('Results_',todayDateStr,'_',easySuffix);
easyResultsDir=fullfile(scansDir,easyResultsDirName); easyResultsDir=fullfile(scansDir,easyResultsDirName);
scansDir=fullfile(parent_dir,'ExpJobs') % relative to easy script dir scansDir=fullfile(parent_dir,'ExpJobs') % relative to easy script dir
disp(strcat('Using project prefix: ', PROJECT_PREFIX, ' from environment variable PROJECT_PREFIX')) disp(strcat('Using project prefix: ', PROJECT_PREFIX, ' from environment variable PROJECT_PREFIX'))
@@ -104,7 +106,7 @@ function varargout = EASYconsole(varargin)
matFile=fullfile(matDir,strcat(easyResultsDirName,'.mat')); matFile=fullfile(matDir,strcat(easyResultsDirName,'.mat'));
% Play around with making some common variables from our input data % Play around with making some common variables from our input data
% resDirName=fullfile(SCANS_DIR,'Results',strcat(datestr(now, 'yyyymmdd'),'_', PROJECT_SUFFIX); % resDirName=fullfile(SCANS_DIR,'Results',dateStr,'_', PROJECT_SUFFIX);
% resDir=fullfile(SCANS_DIR,resDirName); % resDir=fullfile(SCANS_DIR,resDirName);
% ExpOutmat=fullfile(matDir,strcat(datestr(now,29),newExpfile)); % ExpOutmat=fullfile(matDir,strcat(datestr(now,29),newExpfile));
% ExpPath=fullfile(newExppath); % ExpPath=fullfile(newExppath);
@@ -165,7 +167,7 @@ function EASYconsole_OpeningFcn(hObject, ~, handles, varargin)
fhconsole=gcf; fhconsole=gcf;
% BCR this is set in the global function so I think we're good here % BCR this is set in the global function so I think we're good here
% easyResultsDirName=strcat('Results',datestr(now, 'yyyymmdd'),newExpfilePref); % easyResultsDirName=strcat('Results',todayDateStr,newExpfilePref);
if exist('easyResultsDir','var') && ~isempty(easyResultsDir) if exist('easyResultsDir','var') && ~isempty(easyResultsDir)
set(fhconsole,'Name',strcat('EASYconsole- ',char(easyResultsDir))); set(fhconsole,'Name',strcat('EASYconsole- ',char(easyResultsDir)));
@@ -215,13 +217,13 @@ function NewExpDat_Callback(~, ~, ~)
SWnewExp=1; SWnewExp=1;
inputFileName=strrep(inputFile,'.mat',''); inputFileName=strrep(inputFile,'.mat','');
easyResultsDirName=strcat('Results_',datestr(now,'yyyymmdd'),'_',userName,'_',inputFileName); easyResultsDirName=strcat('Results_',todayDateStr,'_',userName,'_',inputFileName);
% Set paths % Set paths
scansDir=fullfile(inputPath); scansDir=fullfile(inputPath);
easyResultsDir=fullfile(scansDir,easyResultsDirName); easyResultsDir=fullfile(scansDir,easyResultsDirName);
matDir=fullfile(easyResultsDir,'matResults'); matDir=fullfile(easyResultsDir,'matResults');
matFile=fullfile(matDir,strcat(datestr(now,'yyyymmdd'),'_',userName,'_',inputFile)); matFile=fullfile(matDir,strcat(todayDateStr,'_',userName,'_',inputFile));
%***Added for 'parfor global' to preallocate 'scan' structure 20-0123***** %***Added for 'parfor global' to preallocate 'scan' structure 20-0123*****
nlist=dir(fullfile(scansDir,'*')); nlist=dir(fullfile(scansDir,'*'));