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;
easyPath=which(mfilename);
[easyDir,easyFileName]=fileparts(easyPath);
easyDir=fullfile(easyDir)
easyDir=fullfile(easyDir);
[parentDir, ~]=fileparts(easyDir);
userName=system('whoami');
now=datetime('now');
todayDateStr=datestr(now, 'yyyymmdd');
disp(strcat('This script name: ', easyFileName))
@@ -45,7 +47,7 @@ function varargout = EASYconsole(varargin)
easySuffix=get_env('EASY_SUFFIX');
else
[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
% Reimplementing here for stand-alone mode
% While the easySuffix directory exists, increment by one and try again
@@ -57,13 +59,13 @@ function varargout = EASYconsole(varargin)
end
end
% Might as well check this too
if userName ~= userNameScans
disp('WARNING: userName does not match userNameScans');
if userName ~= scansUserName
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");
end
% For happiness
if datestr(now, 'yyyymmdd') == date
disp("Early bird gets the worm")
if todayDateStr == scansDate
disp("Early bird gets the worm");
end
end
@@ -88,7 +90,7 @@ function varargout = EASYconsole(varargin)
easyResultsDir=fullfile(get_env('EASY_RESULTS_DIR'));
disp(strcat('Using project prefix: ', easyResultsDir, ' from environment variable EASY_RESULTS_DIR'))
else
easyResultsDirName=strcat('Results_',datestr(now, 'yyyymmdd'),'_',easySuffix);
easyResultsDirName=strcat('Results_',todayDateStr,'_',easySuffix);
easyResultsDir=fullfile(scansDir,easyResultsDirName);
scansDir=fullfile(parent_dir,'ExpJobs') % relative to easy script dir
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'));
% 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);
% ExpOutmat=fullfile(matDir,strcat(datestr(now,29),newExpfile));
% ExpPath=fullfile(newExppath);
@@ -165,7 +167,7 @@ function EASYconsole_OpeningFcn(hObject, ~, handles, varargin)
fhconsole=gcf;
% 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)
set(fhconsole,'Name',strcat('EASYconsole- ',char(easyResultsDir)));
@@ -215,13 +217,13 @@ function NewExpDat_Callback(~, ~, ~)
SWnewExp=1;
inputFileName=strrep(inputFile,'.mat','');
easyResultsDirName=strcat('Results_',datestr(now,'yyyymmdd'),'_',userName,'_',inputFileName);
easyResultsDirName=strcat('Results_',todayDateStr,'_',userName,'_',inputFileName);
% Set paths
scansDir=fullfile(inputPath);
easyResultsDir=fullfile(scansDir,easyResultsDirName);
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*****
nlist=dir(fullfile(scansDir,'*'));