Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions nifti2/nifti_regress_test/cmake_testscripts/c22_copy_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ DATA=$2
OUT_DATA=$(dirname ${DATA}) #Need to write to separate directory
cd ${OUT_DATA}

# gzip output differs across zlib implementations, so compare decompressed content.
nii_cmp() {
if [ "${1##*.}" = "gz" ]; then
rc=0
gzip -dc "$1" > "$1.raw" && gzip -dc "$2" > "$2.raw" && cmp "$1.raw" "$2.raw" || rc=1
rm -f "$1.raw" "$2.raw"
return $rc
fi
cmp "$1" "$2"
}

# note the main input file and prefix for all output files
infile=$DATA/e4.60005.nii.gz
prefix=out.c22
Expand Down Expand Up @@ -42,11 +53,11 @@ ${NT} -copy_image -infile ${prefix}.0.i16.nii.gz \
${NT} -copy_image -infile ${prefix}.1.i64.nii.gz \
-prefix ${prefix}.2.0.i16.nii.gz \
-convert2dtype NIFTI_TYPE_INT16 -convert_verify
if cmp ${prefix}.0.i16.nii.gz ${prefix}.2.0.i16.nii.gz
if nii_cmp ${prefix}.0.i16.nii.gz ${prefix}.2.0.i16.nii.gz
then
echo ""
else
echo "** not a binary match: ${prefix}.0.i16.nii.gz ${prefix}.2.0.i16.nii.gz"
echo "** decompressed content differs: ${prefix}.0.i16.nii.gz ${prefix}.2.0.i16.nii.gz"
exit 1
fi

Expand All @@ -57,10 +68,11 @@ ${NT} -cbl -infile ${prefix}.0.i16.nii.gz \
${NT} -copy_image -infile ${prefix}.1.f32.nii.gz \
-prefix ${prefix}.2.1.i16.nii.gz \
-convert2dtype NIFTI_TYPE_INT16 -convert_fail_choice warn
if cmp ${prefix}.0.i16.nii.gz ${prefix}.2.1.i16.nii.gz
if nii_cmp ${prefix}.0.i16.nii.gz ${prefix}.2.1.i16.nii.gz
then
echo ""
else
echo "** not a binary match: ${prefix}.0.i16.nii.gz ${prefix}.2.1.i16.nii.gz"
echo "** decompressed content differs: ${prefix}.0.i16.nii.gz ${prefix}.2.1.i16.nii.gz"
exit 1
fi

Loading