Skip to content

Commit

Permalink
BUG: Fix ShellCheck issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanjohnson-lab authored and Ivan-E-Johnson committed Mar 4, 2024
1 parent 735ac80 commit 3722e33
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions example_run_brain_mask_tool_docker.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
#!/bin/bash
CURRENT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) # Get the directory of the script

# Get the directory of the script
CURRENT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

# Default values
DEFAULT_INPUT_DIR="${CURRENT_DIR}/example_tool/example_data/CAIPIRINHA_SPACE_Neuro_Head_Examples"
DEFAULT_OUTPUT_DIR="${CURRENT_DIR}/example_tool/example_output"
DEFAULT_STUDY_ID="12345"

# Use provided arguments if they exist, otherwise use default values
INPUT_DIR=${1:-$DEFAULT_INPUT_DIR}
OUTPUT_DIR=${2:-$DEFAULT_OUTPUT_DIR}
STUDY_ID=${3:-$DEFAULT_STUDY_ID}
INPUT_DIR=${1:-"${DEFAULT_INPUT_DIR}"}
OUTPUT_DIR=${2:-"${DEFAULT_OUTPUT_DIR}"}
STUDY_ID=${3:-"${DEFAULT_STUDY_ID}"}

if [ ! -d "$INPUT_DIR" ]; then
echo "Input directory does not exist: $INPUT_DIR"
# Check if input directory exists
if [ ! -d "${INPUT_DIR}" ]; then
echo "Input directory does not exist: ${INPUT_DIR}"
exit 1
fi
if [ ! -d "$OUTPUT_DIR" ]; then
echo "Output directory does not exist: $OUTPUT_DIR"
echo "Creating output directory: $OUTPUT_DIR"
mkdir -p "$OUTPUT_DIR"
fi

# Check if output directory exists, if not create it
if [ ! -d "${OUTPUT_DIR}" ]; then
echo "Output directory does not exist: ${OUTPUT_DIR}"
echo "Creating output directory: ${OUTPUT_DIR}"
mkdir -p "${OUTPUT_DIR}"
fi

# Run the docker command
docker run --rm \
-v "$INPUT_DIR":/input \
-v "$OUTPUT_DIR":/output \
brainmasktool:v0.1\
-v "${INPUT_DIR}":/input \
-v "${OUTPUT_DIR}":/output \
brainmasktool:v0.1 \
-s /input \
-o /output\
-i "$STUDY_ID"
-o /output \
-i "${STUDY_ID}"

0 comments on commit 3722e33

Please sign in to comment.