forked from gamorosino/bl_app_dbb_DisSeg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
gamorosino
committed
Dec 17, 2021
1 parent
c79fc6b
commit 3cf4ddc
Showing
6 changed files
with
127 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/" | ||
computed=${1} | ||
groud_truth=${2} | ||
output=$3 | ||
if [ $# -lt 1 ]; then | ||
echo $0: "usage: "$( basename $0 )" <segmentation1.ext> <segmentation2.ext> [<output>]" | ||
return 1; | ||
fi | ||
|
||
|
||
|
||
|
||
|
||
if ! ( [ -z "${computed}" ] || [ "${computed}" == "null" ] || [ -z "${groud_truth}" ] || [ "${groud_truth}" == "null" ] ); then | ||
|
||
echo "computed: "${computed} | ||
echo "groud_truth: "${groud_truth} | ||
|
||
inputidr=$( dirname ${computed} ) | ||
|
||
[ -z ${output} ] && { output=${inputidr}"/dice_score.txt" ; } | ||
|
||
|
||
python ${SCRIPT_DIR}/dice_score.py ${computed} ${groud_truth} ${output} | ||
|
||
|
||
|
||
|
||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
#! /bin/bash | ||
tag_list=( ACC PFM MCDs HD ) | ||
#pub_id=$1 | ||
output_dir=./'DBB_test' | ||
mkdir -p ${output_dir} | ||
for tag in ${tag_list[@]}; do | ||
bl bids download --pub "61b8b6b57ebe1c6fd7f048f2" --tag EMEDEA-PED --tag ${tag} #--output ./DBB_test | ||
mkdir -p ${output_dir}'/'${tag} | ||
bl bids download --pub "61b8b6b57ebe1c6fd7f048f2" --tag EMEDEA-PED --tag ${tag} --output ${output_dir}'/'${tag} | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#! /bin/bash | ||
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>]" | ||
exit -1; | ||
fi | ||
|
||
echo "t1: "${t1} | ||
echo "mask: "${mask} | ||
input_dir=$( dirname ${t1} ) | ||
[ -z ${outputdir} ] && { outputdir=${input_dir}"/segmentation" ; } | ||
echo "outputdir: "${outputdir} | ||
|
||
mkdir -p ${outputdir} | ||
output=${outputdir}'/segmentation.nii.gz' | ||
proc_dir=${input_dir}"/proc/" | ||
mkdir -p ${proc_dir} | ||
reference=${SCRIPT_DIR}'/data/IMAGE_0426.nii.gz' | ||
|
||
t1_hm=${proc_dir}'/t1_hm.nii.gz' | ||
ImageMath 3 ${t1_hm} HistogramMatch ${t1} ${reference} | ||
|
||
chkcp_dir=${SCRIPT_DIR} | ||
|
||
python ${SCRIPT_DIR}/predict.py ${t1_hm} ${output} ${chkcp_dir} --mask ${mask} | ||
|
||
cp ${SCRIPT_DIR}'/data/label.json' ${outputdir} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#! /bin/bash | ||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/" | ||
testset_dir=$1 | ||
output_dir=$2 | ||
if [ $# -lt 1 ]; then | ||
echo $0: "usage: "$( basename $0 )" <test_set_dir> [<output_dir>]" | ||
return 1; | ||
fi | ||
predict_script=${SCRIPT_DIR}/"main_local.sh" | ||
disce_score_script=${SCRIPT_DIR}/"dice_score_local.sh" | ||
[ -z ${output_dir} ] && { output_dir=${testset_dir}'/bids/derivatives/bl_app_dbb_DisSeg/' ; } | ||
mkdir -p ${output_dir} | ||
for i in $( ls ${testset_dir}/* -d ); do | ||
b_name_i=$( basename ${i} ) | ||
[ "${b_name_i}" == "bids" ] && { continue; } | ||
[ -d ${i} ] || { continue; } | ||
echo ${i} | ||
t1_i=$( ls ${i}'/dt-neuro-anat-t1w.id-'*/'t1.nii.gz' ) | ||
mask_i=$( ls ${i}'/dt-neuro-mask.id-'*/'mask.nii.gz' ) | ||
parc_i=$( ls ${i}'/dt-neuro-parcellation-volume.id-'*/'parc.nii.gz' ) | ||
echo 't1': ${t1_i} | ||
echo 'mask': ${mask_i} | ||
echo 'parc': ${parc_i} | ||
output_dir_i=${output_dir}'/'$( basename ${i} )'/' | ||
echo ${output_dir_i} | ||
mkdir -p ${output_dir_i} | ||
bash ${predict_script} ${t1_i} ${mask_i} ${output_dir_i}'/' | ||
output_seg=${output_dir_i}'/segmentation.nii.gz' | ||
dice_score=${output_dir_i}'/dice_score.txt' | ||
bash ${disce_score_script} ${output_seg} ${parc_i} ${dice_score} | ||
cat ${dice_score} | ||
done | ||
|
||
csv_file=${output_dir}'/dice_score.csv' | ||
|
||
echo "Subject_Id CSF GM WM DGM Brainstem Cerebellum" | ||
|
||
echo "Subject_Id CSF GM WM DGM Brainstem Cerebellum" > ${csv_file} | ||
|
||
for i in $( ls ${output_dir}/* -d ); do | ||
|
||
echo $( basename ${i} ) $( cat ${i}'/dice_score.txt' ) | ||
echo $( basename ${i} ) $( cat ${i}'/dice_score.txt' ) >> ${csv_file} | ||
|
||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#! /bin/bash | ||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/" | ||
project_id='60a14ca503bcad0ad27cada9' | ||
outputdir=$1 | ||
download_dir=./'DBB_test' | ||
bash ${SCRIPT_DIR}/download_testset.sh | ||
mkdir -p ${outputdir} | ||
tag_list=( ACC PFM MCDs HD ) | ||
for tag in ${tag_list[@]}; do | ||
bash ${SCRIPT_DIR}/predict_testset_local.sh ${download_dir}'/'${tag}'/'proj-${project_id} ${outputdir}'/'${tag} | ||
done |