Skip to content

Commit

Permalink
added --no-histmatch option
Browse files Browse the repository at this point in the history
  • Loading branch information
gamorosino committed Oct 6, 2022
1 parent 22dae83 commit 5159b2e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 7 deletions.
29 changes: 25 additions & 4 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,33 @@
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/"
t1=$1
mask=$2
outputdir=$3
no_hm=0
if [ $# -lt 2 ]; then
echo $0: "usage: "$( basename $0 )" <t1.ext> <mask.ext> [<outputdir>]"
echo $0: "usage: "$( basename $0 )" <t1.ext> <mask.ext> [<outputdir>] [--no-histmatch]"
exit -1;
fi
# As long as there is at least one more argument, keep looping
input_3="$3"
while [[ $# -gt 0 ]]; do
key="$3"
case "$key" in
--no-histmatch)
no_hm=1
;;
*)

[ -z ${input_3} ] || { outputdir=${input_3} ; }
;;
esac
# Shift after checking all the cass to get the next option
shift
done

echo "t1: "${t1}
echo "mask: "${mask}
input_dir=$( dirname ${t1} )
[ -z ${outputdir} ] && { outputdir=${input_dir}"/segmentation" ; }
[ -z ${no_hm} ] && { no_hm=0 ; }
echo "outputdir: "${outputdir}

mkdir -p ${outputdir}
Expand All @@ -21,8 +38,12 @@
reference=${SCRIPT_DIR}'/data/IMAGE_0426.nii.gz'

t1_hm=${proc_dir}'/t1_hm.nii.gz'
singularity exec -e docker://brainlife/ants:2.2.0-1bc ImageMath 3 ${t1_hm} HistogramMatch ${t1} ${reference}

if [ ${no_hm} == 0 ]; then
echo "perfroms histogram matching on reference image"
singularity exec -e docker://brainlife/ants:2.2.0-1bc ImageMath 3 ${t1_hm} HistogramMatch ${t1} ${reference}
else
singularity exec -e docker://brainlife/ants:2.2.0-1bc ImageMath 3 ${t1_hm} Normalize ${t1} ${mask} && ImageMath 3 ${t1_hm} m ${t1_hm} 100
fi
chkcp_dir=${SCRIPT_DIR}

singularity exec -e --nv docker://gamorosino/bl_app_dbb_disseg python ${SCRIPT_DIR}/predict.py ${t1_hm} ${output} ${chkcp_dir} --mask ${mask}
Expand Down
28 changes: 25 additions & 3 deletions main_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,27 @@
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/"
t1=$1
mask=$2
outputdir=$3

if [ $# -lt 2 ]; then
echo $0: "usage: "$( basename $0 )" <t1.ext> <mask.ext> [<outputdir>]"
echo $0: "usage: "$( basename $0 )" <t1.ext> <mask.ext> [<outputdir>] [--no-histmatch]"
exit -1;
fi
# As long as there is at least one more argument, keep looping
input_3="$3"
while [[ $# -gt 0 ]]; do
key="$3"
case "$key" in
--no-histmatch)
no_hm=1
;;
*)

[ -z ${input_3} ] || { outputdir=${input_3} ; }
;;
esac
# Shift after checking all the cass to get the next option
shift
done

echo "t1: "${t1}
echo "mask: "${mask}
Expand All @@ -21,7 +37,13 @@
reference=${SCRIPT_DIR}'/data/IMAGE_0426.nii.gz'

t1_hm=${proc_dir}'/t1_hm.nii.gz'
ImageMath 3 ${t1_hm} HistogramMatch ${t1} ${reference}

if [ ${no_hm} == 0 ]; then
echo "perfroms histogram matching on reference image"
ImageMath 3 ${t1_hm} HistogramMatch ${t1} ${reference}
else
ImageMath 3 ${t1_hm} Normalize ${t1} ${mask} && ImageMath 3 ${t1_hm} m ${t1_hm} 100
fi

chkcp_dir=${SCRIPT_DIR}

Expand Down

0 comments on commit 5159b2e

Please sign in to comment.