Rename easyProjectDir
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
function varargout = EASYconsole(varargin)
|
||||
global easyDir
|
||||
global projectName
|
||||
global projectScansDir
|
||||
global easyResultsDir
|
||||
global easyProjectName
|
||||
@@ -40,23 +41,32 @@ function varargout = EASYconsole(varargin)
|
||||
|
||||
fprintf('This script name: %s\n', easyFileName);
|
||||
|
||||
% Set projectScansDir (project scans directory) intelligently
|
||||
% Allow EASY_DIR env to override hardcoded default EASY directory
|
||||
if ~isempty(getenv('EASY_DIR'))
|
||||
ed=fullfile(getenv('EASY_DIR'));
|
||||
if ~strcmp(easyDir, ed) % sanity check
|
||||
disp("WARNING: EASY_DIR does not match this script's hardcoded EASY location");
|
||||
disp("This is probably OK but this pathway is not well-tested");
|
||||
easyDir=ed;
|
||||
end
|
||||
fprintf('Using EASY script directory: %s from environment variable EASY_DIR\n', easyDir);
|
||||
else
|
||||
fprintf('Using EASY script directory: %s from hardcoded default\n', easyDir);
|
||||
end
|
||||
|
||||
|
||||
% Set projectScansDir intelligently
|
||||
if ~isempty(getenv('PROJECT_SCANS_DIR'))
|
||||
projectScansDir=fullfile(getenv('PROJECT_SCANS_DIR'));
|
||||
if exist(projectScansDir, 'dir')
|
||||
fprintf('Using scans directory: %s from environment variable PROJECT_SCANS_DIR\n', projectScansDir);
|
||||
disp('This usually indicates that we are in module mode');
|
||||
if isempty(getenv('PROJECT'))
|
||||
dirInfo=fileparts(projectScansDir);
|
||||
project=dirInfo.name;
|
||||
end
|
||||
else
|
||||
disp('WARNING: PROJECT_SCANS_DIR does not exist');
|
||||
end
|
||||
elseif ~isempty(getenv('PROJECT')) % for standalone mode
|
||||
% projectScansDir=fullfile(parentDir, '..', '..', 'scans', getenv('PROJECT') 'out', 'easy', getenv('PROJECT'));
|
||||
project=getenv('PROJECT');
|
||||
projectScansDir=fullfile(parentDir, '..', '..', 'scans', project);
|
||||
elseif ~isempty(getenv('PROJECT_NAME')) % for standalone mode
|
||||
projectName=getenv('PROJECT_NAME');
|
||||
projectScansDir=fullfile(parentDir, '..', '..', 'scans', projectName);
|
||||
fprintf('Using project path: %s from environment variable PROJECT\n', projectScansDir);
|
||||
disp('This usually indicates that we are in standalone mode');
|
||||
else
|
||||
@@ -85,18 +95,41 @@ function varargout = EASYconsole(varargin)
|
||||
end
|
||||
whos
|
||||
if ~isempty(matchedDirs)
|
||||
fprintf('Found a non-empty scans directory in our list: %s\n', d);
|
||||
fprintf('Setting projectScansDir to %s\n', char(d));
|
||||
projectScansDir=fullfile(d);
|
||||
fprintf('Using scansDir %s\n', char(d));
|
||||
end
|
||||
fprintf('Scanning inside %s for a project directory\n', d);
|
||||
sortedMatchedDirs=sortrows(matchedDirs);
|
||||
project=sortedMatchedDirs{1}; % select the latest dir (by date prefix)
|
||||
fprintf('Selected latest project directory %s\n', char(project));
|
||||
projectScansDir=fullfile(sortedMatchedDirs{end}); % select the latest dir (by date prefix)
|
||||
fprintf('Using project scans directory: %s\n', char(projectScansDir));
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
% Get the name of the project
|
||||
projectName=basename(projectScansDir);
|
||||
|
||||
% Set the run-specific EASY output directory
|
||||
if ~isempty(getenv('EASY_RESULTS_DIR'))
|
||||
easyResultsDir=fullfile(getenv('EASY_RESULTS_DIR'));
|
||||
fprintf('Using output directory: %s from environment variable EASY_RESULTS_DIR\n', easyResultsDir);
|
||||
else
|
||||
easyProjectName=strcat(todayStr, '_',userName, '_', project);
|
||||
easyResultsDir=fullfile(parentDir, '..', '..', 'out', project, 'easy', easyProjectName);
|
||||
if exist(easyResultsDir, 'dir')
|
||||
fprintf('WARNING: EASY results dir %s already exists\n', easyResultsDir);
|
||||
disp('Files in this directory may be overwritten')
|
||||
fprintf('Using output directory: %s\n', easyResultsDir);
|
||||
end
|
||||
end
|
||||
|
||||
% Get the name of the EASY project
|
||||
if ~isempty(getenv('EASY_PROJECT_NAME'))
|
||||
easyProjectName=getenv('EASY_PROJECT_NAME');
|
||||
else
|
||||
easyProjectName=basename(easyResultsDir);
|
||||
end
|
||||
|
||||
% User sanity check and warning
|
||||
if ~isempty(getenv('PROJECT_USER'))
|
||||
if ~strcmp(getenv('PROJECT_USER'), userName)
|
||||
@@ -104,44 +137,18 @@ function varargout = EASYconsole(varargin)
|
||||
end
|
||||
end
|
||||
|
||||
% Allow module to override hardcoded default EASY directory
|
||||
if ~isempty(getenv('EASY_DIR'))
|
||||
ed=fullfile(getenv('EASY_DIR'));
|
||||
if ~strcmp(easyDir, ed) % sanity check
|
||||
disp("WARNING: EASY_DIR does not match this script's hardcoded EASY location");
|
||||
disp("This is probably OK but this pathway is not well-tested");
|
||||
easyDir=ed;
|
||||
end
|
||||
fprintf('Using EASY script directory: %s from environment variable EASY_DIR\n', easyDir);
|
||||
else
|
||||
fprintf('Using EASY script directory: %s from hardcoded default\n', easyDir);
|
||||
end
|
||||
|
||||
if ~isempty(getenv('EASY_RESULTS_DIR'))
|
||||
easyResultsDir=fullfile(getenv('EASY_RESULTS_DIR'));
|
||||
fprintf('Using output directory: %s from environment variable EASY_RESULTS_DIR\n', easyResultsDir);
|
||||
else
|
||||
easyProjectName=strcat(todayStr,'_',userName,'_', project);
|
||||
easyResultsDir=fullfile(parentDir, '..', '..', 'out', project, 'easy', easyProjectName);
|
||||
if exist(easyResultsDir, 'dir')
|
||||
fprintf('WARNING: EASY results dir %s already exists\n', easyResultsDir);
|
||||
disp('Files in this directory may be overwritten')
|
||||
fprintf('Using output directory: %s\n', easyResultsDir);
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if ~isempty(getenv('MASTER_PLATE_FILE'))
|
||||
masterPlateFile=fullfile(getenv('MASTER_PLATE_FILE'));
|
||||
fprintf('Using drug media file: %s from environment variable MASTER_PLATE_FILE\n', masterPlateFile);
|
||||
else
|
||||
% Try to find MasterPlate_ file on our own
|
||||
mp=fullfile(projectScansDir, strcat('MasterPlate_', project,'.xlsx'));
|
||||
mp=fullfile(easyResultsDir, strcat('MasterPlate_', projectName,'.xlsx'));
|
||||
if exist(mp, 'file')
|
||||
masterPlateFile=mp;
|
||||
fprintf('Using drug media file: %s from internal logic\n', masterPlateFile);
|
||||
fprintf('Using master plate file: %s from internal logic\n', masterPlateFile);
|
||||
else
|
||||
fprintf('WARNING: Have you created a MasterPlate_ file in %s/easy_in/?\n', projectScansDir);
|
||||
fprintf('WARNING: Could not find MasterPlate file: %s\n', mp);
|
||||
fprintf('WARNING: Have you created a MasterPlate_ file in %s', easyResultsDir);
|
||||
end
|
||||
end
|
||||
|
||||
@@ -149,17 +156,17 @@ function varargout = EASYconsole(varargin)
|
||||
drugMediaFile=fullfile(getenv('DRUG_MEDIA_FILE'));
|
||||
fprintf('Using drug media file: %s from environment variable DRUG_MEDIA_FILE\n', drugMediaFile);
|
||||
else
|
||||
dm=fullfile(projectScansDir,'easy_in',strcat('DrugMedia_', project,'.xlsx'));
|
||||
if exist(mp, 'file')
|
||||
dm=fullfile(easyResultsDir, strcat('DrugMedia_', projectName,'.xlsx'));
|
||||
if exist(dm, 'file')
|
||||
drugMediaFile=dm;
|
||||
fprintf('Using drug media file: %s from internal logic\n', drugMediaFile);
|
||||
else
|
||||
fprintf('WARNING: Have you created a DrugMedia_ file in %s/MasterPlateFiles/?\n', projectScansDir);
|
||||
fprintf('WARNING: Have you created a DrugMedia_ file in %s?\n', easyResultsDir);
|
||||
end
|
||||
end
|
||||
|
||||
matDir=fullfile(easyResultsDir);
|
||||
matFile=fullfile(matDir,easyResultsDirName,'.mat');
|
||||
matDir=fullfile(easyResultsDir, 'matResults');
|
||||
matFile=fullfile(matDir,easyProjectName,'.mat');
|
||||
mpdmFile=fullfile(matDir,'MPDM.mat');
|
||||
printResultsDir=fullfile(easyResultsDir,'PrintResults');
|
||||
fotosResultsDir=fullfile(easyResultsDir,'Fotos');
|
||||
@@ -265,7 +272,7 @@ function NewExpDat_Callback(~, ~, ~)
|
||||
global matDir
|
||||
global matFile
|
||||
global easyResultsDir
|
||||
global easyResultsDirName
|
||||
global easyProjectName
|
||||
global fhconsole
|
||||
global scan
|
||||
global userName
|
||||
@@ -276,12 +283,11 @@ function NewExpDat_Callback(~, ~, ~)
|
||||
questdlg('\fontsize{20} NAME the file and NAVIGATE to the directory with the image folders.','File Creation','OK', struct('Default','OK','Interpreter','tex'));
|
||||
[matfile,easyResultsDir]=uiputfile('.mat');
|
||||
inputFileName=strrep(inputFile,'.mat','');
|
||||
% easyResultsDirName=strcat('Results_',todayStr,'_',userName,'_',inputFileName);
|
||||
project=basename(easyResultsDir);
|
||||
|
||||
projectName=basename(easyResultsDir);
|
||||
% Set paths
|
||||
matDir=fullfile(easyResultsDir,'matResults');
|
||||
easyProjectName=strcat(todayStr,'_',userName,'_', project);
|
||||
matFile=fullfile(matDir,strcat(todayStr,'_',userName,'_',inputFile));
|
||||
matFile=fullfile(matDir, projectName, '.mat');
|
||||
|
||||
% Added for 'parfor global' to preallocate 'scan' structure
|
||||
nlist=dir(fullfile(projectScansDir,'*'));
|
||||
@@ -338,19 +344,19 @@ end
|
||||
function LoadDatFile_Callback(~, ~, ~)
|
||||
global matDir
|
||||
global matFile
|
||||
global projectName
|
||||
global easyResultsDir
|
||||
global easyProjectName
|
||||
global easyPath
|
||||
global fhconsole
|
||||
|
||||
try
|
||||
questdlg('Load results .mat from ../out/project/','File Creation','OK', struct('Default','OK','Interpreter','tex'));
|
||||
[inputFile,inputPath]=uigetfile('.mat','Open Experiment folder and data storage .mat file name','MultiSelect','off');
|
||||
matDir=fullfile(inputPath);
|
||||
matFile=fullfile(inputPath,inputFile);
|
||||
[matDir,matFile]=uigetfile('.mat','Open Experiment folder and data storage .mat file name','MultiSelect','off');
|
||||
load(matFile);
|
||||
easyResultsDir=fullfile(matDir,'..');
|
||||
project=basename(easyResultsDir);
|
||||
projectScansDir=fullfile(easyResultsDir, '..', '..', 'scans', project);
|
||||
projectName=basename(easyResultsDir);
|
||||
projectScansDir=fullfile(easyResultsDir, '..', '..', 'scans', projectName);
|
||||
|
||||
% TODO this is pretty hacky and needs something more explicit
|
||||
if isfolder(fullfile(matDir, '..','..','1')) % If Inovation Vrobot Then
|
||||
|
||||
Reference in New Issue
Block a user