Commit ac562901 authored by Kevin Bronik's avatar Kevin Bronik

Upload New File

parent 899f0550
#!/bin/bash
# Copyright (C) 2019 UCL
#
# Developed at Department of Medical Physics and Biomedical Engineering
# University, UCL, UK
#
#
# This software/script calculates all the following important performance metrics:
# Dice Similarity Index(SI)
# Sensitivity
# Precision
# Specificity
# Jaccardindex
# Conformity
# HausdorffDistance
# Overlapcoefficient
# Tanimotocoefficient
# Matthewscorrelationcoefficient
# Accuracy
# Voxel-level false discovery rate(FDR)
# Voxel-level false negative ratio(FNR)
# Cluster-level FDR
# Cluster-level FNR
# Detection error rate(DER)
# utline error rate(OER)
# Mean Total Area(MTA)
# Volume of segmentation
# Volume of manual mask
# if [ $# -lt 1 ] ; then
# echo "Usage: `basename $0` <lesionmask> <threshold> <manualmask> <foldershortname> <modelname> <distancefunction> <factor> <symmetry> <saveoutput>"
# echo " "
# echo "For example:
# bash RunMe.sh *lesionmask*.nii.gz 0.5 *manualmask*.nii.gz testing modeldatatrain euclidean mean symmetric 1.0 2.0 1"
# echo " "
# echo "The script calculates measures of overlap between the lesion mask generated by any algorithm and the manual mask and lesion volumes of both"
# echo " "
# echo "Threshold = probability threshold that will be applied to output before calculation of the overlap measures"
# echo " "
# echo "Saveoutput = if set to 0 it will output the measures' names and values on the screen with the following format:"
# echo "
# # Dice Similarity Index(SI)
# # Sensitivity
# # Precision
# # Specificity
# # Jaccardindex
# # Conformity
# # HausdorffDistance
# # Overlapcoefficient
# # Tanimotocoefficient
# # Matthewscorrelationcoefficient
# # Accuracy
# # Voxel-level false discovery rate(FDR)
# # Voxel-level false negative ratio(FNR)
# # Cluster-level FDR
# # Cluster-level FNR
# # Detection error rate(DER)
# # utline error rate(OER)
# # Mean Total Area(MTA)
# # Volume of segmentation
# # Volume of manual mask"
# echo " "
# echo "-If Saveoutput set to 1 it will save only the values (in the same order) in a .txt filethe output file will be saved in the same folder of the lesion mask with the name Overlap_and_Volumes_<lesionmask>_<threshold>.txt"
# exit 1
# fi
# lesionmask=$1
# threshold=$2
# manualmask=$3
# foldershortname=$4
# modelname=$5
# distancefunction=$6
# factor=$7
# symmetry=$8
# saveoutput=$9
# PRIVATE=`zenity --forms --title="Create user" --text="Add new user" --add-entry="First Name" --add-entry="Last Name" --add-entry="Username"| awk '{ print $1 $2 $3 }'`
# value=$(zenity --entry --title "Window title" --entry-text "${array[@]}" --text "Insert your choice.")
# --width 100 --height 100
# --on-top \
# --center \
help () {
yad --on-top --center --title="Look4 Help" --image="help.jpg" --button=gtk-quit:0
}
export -f help
startgui() {
PRIVATE=`yad --width 100 --height 100 --on-top --center --title="Performance Analysis" --text="<span foreground='blue'><b>Please fill in the required field*:</b></span>" \
--image="MedicalPhysics_CIMIC_UCL_logo.jpg" \
--form --date-format="%-d %B %Y" \
--field="Lesion Mask*" \
--field="Threshold*" \
--field="Manual Mask*" \
--field="Folder Short Name*" \
--field="Model Name*" \
--field="Weight" \
--field="P_norm" \
--field="Distance Function":CB \
--field="Factor":CB \
--field="Symmetry":CB \
--field="Saveoutput":CB \
--field="Date":DT \
--button=gtk-help:'bash -c help' \
--button=gtk-quit:1 \
--button=Ok:0 \
"" "" "" "" "" "1.0" "2.0" 'euclidean!minkowski!cityblock!cosine!hamming!seuclidean!sqeuclidean!correlation!jaccard!chebyshev!canberra!braycurtis!mahalanobis!yule!matching!dice!kulsinski!rogerstanimoto!russellrao!sokalmichener!sokalsneath!wminkowski' 'mean!direct' 'symmetric!nonsymmetric' 'yes!no' "Click calendar icon"`
}
startgui
# PRIVATE=`zenity --forms --title="Performance Analysis" --text="Please fill in the required field"\
# --add-entry="Lesion Mask" --add-entry="Threshold"\
# --add-entry="Manual Mask" --add-entry="Folder Short Name" --add-entry="Model Name"\
# --add-entry="Distance Function"\
# --add-entry="Factor" --add-entry="Symmetry" --add-entry="saveoutput"`
lesionmask=$(echo $PRIVATE | cut -d '|' -f 1)
threshold=$(echo $PRIVATE | cut -d '|' -f 2)
manualmask=$(echo $PRIVATE | cut -d '|' -f 3)
foldershortname=$(echo $PRIVATE | cut -d '|' -f 4)
modelname=$(echo $PRIVATE | cut -d '|' -f 5)
weight=$(echo $PRIVATE | cut -d '|' -f 6)
p_norm=$(echo $PRIVATE | cut -d '|' -f 7)
distancefunction=$(echo $PRIVATE | cut -d '|' -f 8)
factor=$(echo $PRIVATE | cut -d '|' -f 9)
symmetry=$(echo $PRIVATE | cut -d '|' -f 10)
sp=$(echo $PRIVATE | cut -d '|' -f 11)
dt=$(echo $PRIVATE | cut -d '|' -f 12)
if [ "$sp" == "yes" ] ; then
saveoutput=1
else
saveoutput=0
fi
if [ -z "$lesionmask" ] || [ -z "$threshold" ] || [ -z "$manualmask" ] || [ -z "$foldershortname" ] || [ -z "$modelname" ] ; then
clear
echo "Please try again and fill in all the required fields correctly"
echo "For example:
[-]field[Lesion Mask*], if the lesion mask file's name is *lesionmask*.nii.gz, you only need to fill in lesionmask
[-]field[Threshold*], fill in a numerical number
[-]field[Manual Mask*], if the manual mask file's name is *manualmask*.nii.gz, you only need to fill in manualmask
[-]field[Folder Short Name*], if the testing folders' name is *testing*, you only need to fill in testing
[-]field[Model Name*], fill in the Model Name that has been used for training data
"
exit
else
continue
fi
echo "lesionmask" $lesionmask
echo "threshold" $threshold
echo "manualmask" $manualmask
echo "foldershortname" $foldershortname
echo "modelname" $modelname
echo "distancefunction" $distancefunction
echo "weight" $weight
echo "p_norm" $p_norm
echo "factor" $factor
echo "symmetry" $symmetry
echo "saveoutput" $saveoutput
for f in $(find *${foldershortname}* -type d);
do
echo "Preprocessing on the folder: "$f
# mv ${file/_flair3D.nii.gz}* /home/kbronik/Desktop/STARTINGNEWTEST/ms-smart/${file/_flair3D.nii.gz}_training
cp universal_HD.py $f
cp performanceanalysis $f
cp $f/${modelname}/* $f
rm -rf $f/tmp
rm -rf $f/${modelname}
done
echo -e "Date:" ${dt} >> final_result.txt
echo -e "Dice Similarity Index(SI)[1] \nSensitivity[2] \nPrecision[3] \nSpecificity[4] \nJaccardindex[5] \nConformity[6] \n${factor}${symmetry}HausdorffDistance[7] \nOverlapcoefficient[8] \nTanimotocoefficient[9] \nMatthewscorrelationcoefficient[10] \nAccuracy[11] \nVoxel-level false discovery rate(FDR)[12] \nVoxel-level false negative ratio(FNR)[13] \nCluster-level FDR[14] \nCluster-level FNR[15] \nDetection error rate(DER)[16] \nOutline error rate(OER)[17] \nMean Total Area(MTA)[18] \nVolume of segmentation[19] \nVolume of manual mask[20]" >> final_result.txt
echo -e "[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]" >> final_result.txt
clear
for folder in $(find *${foldershortname}* -type d);
do
echo "Calculation of performance metrics will be processed on the folder: "$folder
if [[ ! $folder ]] ; then
clear
echo $folder 'is not there, aborting.'
exit
fi
bash $folder/performanceanalysis $folder/*${lesionmask}* ${threshold} $folder/*${manualmask}* ${distancefunction} ${factor} ${symmetry} ${weight} ${p_norm} ${saveoutput}
# mv $file /home/kbronik/Desktop/STARTINGNEWTEST/olddata/$file
rm -rf $folder/tmp
rm -rf $folder/${modelname}
done
echo "All calculation of performance metrics finished and completed"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment