Skip to content
Snippets Groups Projects
Commit 9d821e93 authored by Cowboy's avatar Cowboy
Browse files

Fix fslcreatehd unit tests

parent ab80717c
No related branches found
No related tags found
No related merge requests found
......@@ -8,13 +8,11 @@ function neq() {
n2=$2
result=`echo "$n1 == $n2" | bc`
if [[ "$result" == "0" ]]; then
echo "$n1 != $n2"
if [[ "$result" == "0" ]]; then
echo "$n1 != $n2"
return 0;
fi
# echo "$n1 == $n2"
return 1;
}
......@@ -32,42 +30,67 @@ function fslcreatehd_test() {
originx=$1; shift
originy=$1; shift
originz=$1; shift
dtype=$1; shift
fname=$1; shift
# echo "$originx * $pixdim1"
originx=`echo "$originx * $pixdim1" | bc`
originy=`echo "$originy * $pixdim2" | bc`
originz=`echo "$originz * $pixdim3" | bc`
got_dim0=` fslhd 3d | egrep "^dim0" | tr -s '\t' | cut -f 2`
got_dim1=` fslhd 3d | egrep "^dim1" | tr -s '\t' | cut -f 2`
got_dim2=` fslhd 3d | egrep "^dim2" | tr -s '\t' | cut -f 2`
got_dim3=` fslhd 3d | egrep "^dim3" | tr -s '\t' | cut -f 2`
got_dim4=` fslhd 3d | egrep "^dim4" | tr -s '\t' | cut -f 2`
got_pixdim1=`fslhd 3d | egrep "^pixdim1" | tr -s '\t' | cut -f 2`
got_pixdim2=`fslhd 3d | egrep "^pixdim2" | tr -s '\t' | cut -f 2`
got_pixdim3=`fslhd 3d | egrep "^pixdim3" | tr -s '\t' | cut -f 2`
got_pixdim4=`fslhd 3d | egrep "^pixdim4" | tr -s '\t' | cut -f 2`
got_originx=`fslhd 3d | egrep "^sto_xyz:1" | cut -d ' ' -f 4`
got_originy=`fslhd 3d | egrep "^sto_xyz:2" | cut -d ' ' -f 4`
got_originz=`fslhd 3d | egrep "^sto_xyz:3" | cut -d ' ' -f 4`
if neq $dim0 $got_dim0; then return 1; fi
if neq $dim1 $got_dim1; then return 1; fi
if neq $dim2 $got_dim2; then return 1; fi
if neq $dim3 $got_dim3; then return 1; fi
if neq $dim4 $got_dim4; then return 1; fi
if neq $pixdim1 $got_pixdim1; then return 1; fi
if neq $pixdim2 $got_pixdim2; then return 1; fi
if neq $pixdim3 $got_pixdim3; then return 1; fi
if neq $pixdim4 $got_pixdim4; then return 1; fi
if neq $originx $got_originx; then return 1; fi
if neq $originy $got_originy; then return 1; fi
if neq $originz $got_originz; then return 1; fi
args="$dim0 $dim1 $dim2 $dim3 $pixdim1 $pixdim2 $pixdim3 $pixdim4 $originx $originy $originz $dtype $fname"
originx=`echo "($dim1 * $pixdim1) - (( $originx + 1) * $pixdim1)" | bc`
originy=`echo "-$originy * $pixdim2" | bc`
originz=`echo "-$originz * $pixdim3" | bc`
got_dim0=` fslhd $fname | egrep "^dim0" | tr -s '\t' | cut -f 2`
got_dim1=` fslhd $fname | egrep "^dim1" | tr -s '\t' | cut -f 2`
got_dim2=` fslhd $fname | egrep "^dim2" | tr -s '\t' | cut -f 2`
got_dim3=` fslhd $fname | egrep "^dim3" | tr -s '\t' | cut -f 2`
got_dim4=` fslhd $fname | egrep "^dim4" | tr -s '\t' | cut -f 2`
got_pixdim1=`fslhd $fname | egrep "^pixdim1" | tr -s '\t' | cut -f 2`
got_pixdim2=`fslhd $fname | egrep "^pixdim2" | tr -s '\t' | cut -f 2`
got_pixdim3=`fslhd $fname | egrep "^pixdim3" | tr -s '\t' | cut -f 2`
got_pixdim4=`fslhd $fname | egrep "^pixdim4" | tr -s '\t' | cut -f 2`
got_dtype=` fslhd $fname | egrep "^datatype" | tr -s '\t' | cut -f 2`
got_originx=`fslhd $fname | egrep "^sto_xyz:1" | cut -d ' ' -f 4`
got_originy=`fslhd $fname | egrep "^sto_xyz:2" | cut -d ' ' -f 4`
got_originz=`fslhd $fname | egrep "^sto_xyz:3" | cut -d ' ' -f 4`
if neq $dim0 $got_dim0; then echo $args; return 1; fi
if neq $dim1 $got_dim1; then echo $args; return 1; fi
if neq $dim2 $got_dim2; then echo $args; return 1; fi
if neq $dim3 $got_dim3; then echo $args; return 1; fi
if neq $dim4 $got_dim4; then echo $args; return 1; fi
if neq $pixdim1 $got_pixdim1; then echo $args; return 1; fi
if neq $pixdim2 $got_pixdim2; then echo $args; return 1; fi
if neq $pixdim3 $got_pixdim3; then echo $args; return 1; fi
if neq $pixdim4 $got_pixdim4; then echo $args; return 1; fi
if neq $dtype $got_dtype; then echo $args; return 1; fi
if neq $originx $got_originx; then echo $args; return 1; fi
if neq $originy $got_originy; then echo $args; return 1; fi
if neq $originz $got_originz; then echo $args; return 1; fi
return 0
}
fslcreatehd 5 5 5 1 0.5 1.5 1.25 1 1 2 3 2 3d.nii.gz
fslcreatehd_test 3 5 5 5 1 0.5 1.5 1.25 1 1 2 3 2 3d.nii.gz
tests="
5 5 5 1 2 2 2 1 0 0 0 2
5 5 5 1 2 2 2 1 0 0 0 4
5 5 5 1 2 2 2 1 0 0 0 8
5 5 5 1 2 2 2 1 0 0 0 16
5 5 5 1 2 2 2 1 1 2 3 64
5 5 5 1 0.5 1.5 1.25 1 0 0 0 2
5 5 5 1 0.5 1.5 1.25 1.5 0 0 0 2
5 5 5 1 0.5 1.5 1.25 0.5 0 0 0 2
30 30 30 5 5 10 3 5 10 20 10 2
"
echo "$tests" | while IFS= read -r test; do
if [[ $test =~ ^\ *$ ]]; then
continue
fi
rm `imglob -extension fslcreatehd_test_img` &> /dev/null || true
fslcreatehd $test fslcreatehd_test_img
fslcreatehd_test 4 $test fslcreatehd_test_img
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment