/usr/bin/mincview is in minc-tools 2.3.00+dfsg-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | #! /bin/bash
#
# Script for viewing a minc file.
# uses display from ImageMagick to display the images.
PGM_CODE="P5"
PPM_CODE="P6"
# Check arguments
if [ $# -lt "1" ] || \
[ $# -gt "2" ] || \
[ "$1" = "-help" ] || \
[ "$1" = "-h" ]
then
cat <<END
Usage: $0 <infile.mnc> [<slice number>]
Images are displayed with the patients left on the left side
of the screen.
END
exit -1
fi
infile="$1"
# Create temporary directory
tmpdir="/tmp/mincview-$$"
# cleanup nicely
trap "rm -rf $tmpdir" 0 1 2 3 13 15
mkdir -p $tmpdir
# Get dimension names
dims=( $(mincinfo -vardims image $infile ) )
echo " + Dimensions: ${dims[*]}"
# Check for vector dimension
pnm_code=$PGM_CODE
if [ "${dims[${#dims[*]} - 1]}" = "vector_dimension" ]
then
ndims=$(( ${#dims[*]} - 1 ))
nvec=$(mincinfo $infile -dimlength $dims[$#dims])
start_suffix=",0"
if [ $nvec != 3 ]
then
count_suffix=",1"
else
count_suffix=",3"
pnm_code=$PPM_CODE
fi
else
ndims="${#dims[*]}"
start_suffix=""
count_suffix=""
fi
echo " + ndims: $ndims"
if [ $ndims -gt 3 ]
then
nprefix=$(( $ndims - 3 ))
start_prefix=$(awk 'BEGIN{for (i=0;i<$nprefix;i++) print "0,"}' < /dev/null)
count_prefix=$(awk 'BEGIN{for (i=0;i<$nprefix;i++) print "1,"}' < /dev/null)
elif [ $ndims -lt "2" ]
then
echo "No image found in file $infile"
exit -1
else
start_prefix=""
count_prefix=""
fi
# Get number of slices and image dimensions
ind1=$(( $ndims - 3 ))
ind2=$(( $ndims - 2 ))
ind3=$(( $ndims - 1 ))
if [ $ind1 -gt "-1" ]
then
nslices=$(mincinfo $infile -dimlength ${dims[$ind1]})
else
nslices=1
fi
# figure out which slices to get
allslices=$(seq 0 $(($nslices - 1)))
slices_to_get=${2:-"$allslices"}
if [ "$slices_to_get" = "$2" ]
then
if [ "$slices_to_get" -ge "$nslices" ] || [ "$slices_to_get" -lt "0" ]
then
echo ""
echo "$0: Slice number $slices_to_get out of range (0-$nslices)"
echo ""
exit -1
fi
fi
# Check for inverting images to get standard orientation
imgsize=( $(mincinfo -dimlength ${dims[$ind2]} -dimlength ${dims[$ind3]} $infile) )
echo " + imgsize: ${imgsize[0]}x${imgsize[1]}"
echo " + nslices $nslices"
# Loop through slices, if needed
echo -n "Loading slices"
for slice in $slices_to_get
do
echo -n "."
if [ $ndims -gt 2 ]
then
start="${start_prefix}$slice,0,0${start_suffix}"
count="${count_prefix}1,${imgsize[0]},${imgsize[1]}${count_suffix}"
else
start="0,0$start_suffix"
count="${imgsize[0]},${imgsize[1]}$count_suffix"
fi
output_file=$(printf "$tmpdir/slice-%04d.pgm" $slice)
echo "$pnm_code" > $output_file
echo "${imgsize[1]} ${imgsize[0]}" >> $output_file
echo "255" >> $output_file
mincextract -byte \
-start $start \
-count $count \
-positive_direction \
$infile >> $output_file
slice=$(($slice + 1))
done
echo "Done"
cat <<END
--------------------------------------------------------------
Images are now being displayed with display from ImageMagick.
Use <space> to advance to the next image
The image number is displayed in the title of the window
--------------------------------------------------------------
END
# Display the images
display -monitor -geometry 512x512 -flip $tmpdir/slice-*.pgm
|