From 54f375face51e10009f6d4d9791e297dfb562b91 Mon Sep 17 00:00:00 2001 From: Bryan Roessler Date: Wed, 31 Jul 2024 22:37:23 -0400 Subject: [PATCH] Reorganize EASY module --- workflow/apps/matlab/easy/EASYconsole.m | 2 +- workflow/qhtcp-workflow | 61 ++++++++++++------------- 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/workflow/apps/matlab/easy/EASYconsole.m b/workflow/apps/matlab/easy/EASYconsole.m index 486b05a1..7cade239 100644 --- a/workflow/apps/matlab/easy/EASYconsole.m +++ b/workflow/apps/matlab/easy/EASYconsole.m @@ -273,7 +273,7 @@ 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')); [inputFile,inputPath]=uiputfile('.mat'); inputFileName=strrep(inputFile,'.mat',''); - easyResultsDirName=strcat('Results_',todayStr,'_',userName,'_',inputFileName); + % easyResultsDirName=strcat('Results_',todayStr,'_',userName,'_',inputFileName); % Set paths scansDir=fullfile(inputPath); diff --git a/workflow/qhtcp-workflow b/workflow/qhtcp-workflow index 7c0befc6..2d2d802d 100755 --- a/workflow/qhtcp-workflow +++ b/workflow/qhtcp-workflow @@ -588,43 +588,42 @@ easy() { EOF declare -gx EASY_DIR="$APPS_DIR/matlab/easy" + declare -gx EASY_RESULTS_DIR="$EASY_OUT_DIR/$PROJECT_PREFIX" script="$EASY_DIR/EASYconsole.m" - # Copy templates - - # Add EASY directory to the Matlab path - # If this does not work we can try changing the -sd argument and if that fails then pushing/popping - debug "Adding EASY directory to the Matlab path" - hash matlab &>/dev/null && - matlab -nodisplay -nosplash -nodesktop -nojvm -batch "addpath('$EASY_DIR')" + # Prompt user for suffix + echo "Default EASY results directory: $EASY_RESULTS_DIR" + read -r -p "Enter a custom suffix and/or hit enter to use the default (no suffix): " EASY_SUFFIX + [[ -n $EASY_SUFFIX ]] && EASY_RESULTS_DIR+="_$EASY_SUFFIX" + + # Backup and create EASY results dirs + [[ -d $EASY_RESULTS_DIR ]] && backup "$EASY_RESULTS_DIR" + [[ -d $EASY_RESULTS_DIR ]] || mkdir -p "$EASY_RESULTS_DIR" + + # Make EASY dirs + dirs=('PrintResults' 'CFfigs' 'Fotos') + for d in "${dirs[@]}"; do + if [[ ! -d $EASY_RESULTS_DIR/$d ]]; then + debug "mkdir $EASY_RESULTS_DIR/$d" + mkdir "$EASY_RESULTS_DIR/$d" + fi + done + + # Copy Templates + declare -gx DRUG_MEDIA_FILE="$EASY_RESULTS_DIR/DrugMedia_$PROJECT.xls" + declare -gx MASTER_PLATE_FILE="$EASY_RESULTS_DIR/MasterPlate_$PROJECT.xls" + rsync -a "$EASY_DIR"/{figs,PTmats} "$EASY_RESULTS_DIR" # Ask the user to launch EASYconsole.m in MATLAB # MATLAB doesn't support passing args to scripts se we have to use ENV VARS instead - # These are proably already set in our scope but be explicit just in case so we don't have to export? # TODO will need to play with the -sd startup option to see what works (well) # Skip this step altogether in auto mode since it requires graphical interaction if ! ((YES)) && ask "Start EASY in MATLAB? This requires a GUI."; then - # export PROJECT_SCANS_DIR PROJECT_DATE PROJECT_USER PROJECT - # export EASY_DIR EASY_NAME EASY_SUFFIX EASY_RESULTS_DIR - # export MASTER_PLATE_FILE DRUG_MEDIA_FILE - - declare -gx DRUG_MEDIA_FILE="$EASY_RESULTS_DIR/DrugMedia_$PROJECT.xls" - declare -gx MASTER_PLATE_FILE="$EASY_RESULTS_DIR/MasterPlate_$PROJECT.xls" - - # Make EASY dirs - debug "mkdir -p $EASY_RESULTS_DIR" - mkdir -p "$EASY_RESULTS_DIR" - dirs=('PrintResults' 'CFfigs' 'Fotos') - for d in "${dirs[@]}"; do - if [[ ! -d $EASY_RESULTS_DIR/$d ]]; then - debug "mkdir $EASY_RESULTS_DIR/$d" - mkdir "$EASY_RESULTS_DIR/$d" - fi - done - - # Copy templates - rsync -a "$EASY_DIR"/{figs,PTmats} "$EASY_RESULTS_DIR" - + # Add EASY directory to the Matlab path + # If this does not work we can try changing the -sd argument and if that fails then pushing/popping + debug "Adding EASY directory to the Matlab path" + hash matlab &>/dev/null && + matlab -nodisplay -nosplash -nodesktop -nojvm -batch "addpath('$EASY_DIR')" # Launch matlab # matlab -nosplash -sd "$PROJECT_SCANS_DIR" -r "run $script" matlab -nosplash -r "run $script" @@ -637,7 +636,7 @@ module ezview # @description TODO WIP ezview() { debug "Running: ${FUNCNAME[0]}" - + declare -gx EZVIEW_DIR="$APPS_DIR/matlab/ezview" script="$EZVIEW_DIR/EZviewGui.m" @@ -1577,7 +1576,7 @@ main() { declare -gx QHTCP_TEMPLATE_DIR="$TEMPLATES_DIR/qhtcp" declare -gx STUDY_TEMPLATE_DIR="$TEMPLATES_DIR/exp" declare -gx STUDY_INFO_FILE="$QHTCP_PROJECT_DIR/StudyInfo.csv" - declare -gx EASY_RESULTS_DIR="$QHTCP_PROJECT_DIR/easy" + declare -gx EASY_OUT_DIR="$QHTCP_PROJECT_DIR/easy" if ((DEBUG)); then declare -p SCANS_DIR OUT_DIR TEMPLATES_DIR APPS_DIR \ PROJECTS PROJECT \