/usr/bin/mincview is in minc-tools 2.1.00-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 | #! /bin/csh -f
# Script for viewing a minc file.
# Requires a pnm file viewer such as xv or display from ImageMagick,
# as wells as the filter invert_raw_image.
#
# Displays images with patient left on left side of the screen.
# Constants
set VIEWER = "display" # Any pnm display program that handles a list of files
set VIEWER_OPTIONS = "-geometry 512x512"
set PGM_CODE = "P5"
set PPM_CODE = "P6"
set usage = "Usage: $0 <filename.mnc> [<slice number>]"
set exit_status = 0
# Check arguments
if (($#argv < 1) || ($#argv > 2) || ("$1" == "-help") || ("$1" == "-h")) then
echo "$usage"
exit -1
endif
set filename = "$1"
set slice = `awk "BEGIN{print $2+0}" < /dev/null`
@ slice_specified = ( $#argv >= 2 )
# Create temporary directory
if (! $?TMPDIR) then
if (-d /var/tmp) then
set TMPDIR = /var/tmp
else if (-d /usr/tmp) then
set TMPDIR = /usr/tmp
else
set TMPDIR = /tmp
endif
endif
if (! -d $TMPDIR) then
echo "Working directory $TMPDIR does not exist."
exit 1
endif
set workingdir = $TMPDIR
set workingparent = $workingdir/mincview-$$
set childdir = $filename:t
set workingdir = $workingparent/$childdir
onintr cleanup
mkdir $workingparent
mkdir $workingdir
# Expand the file if needed
set newfilename = $filename:t
set newfilename = $workingdir/temp_$newfilename:r
set filename = `mincexpand $filename $newfilename -name_only`
# Get dimension names
set dims = `mincinfo $filename -vardims image`
# Check for vector dimension
set pnm_code = $PGM_CODE
set bytes_per_pixel = 1
if ("$dims[$#dims]" == "vector_dimension") then
@ ndims = $#dims - 1
set nvec = `mincinfo $filename -dimlength $dims[$#dims]`
set start_suffix = ",0"
if ($nvec != 3) then
set count_suffix = ",1"
else
set count_suffix = ",3"
set pnm_code = $PPM_CODE
set bytes_per_pixel = 3
endif
else
set ndims = $#dims
set start_suffix = ""
set count_suffix = ""
endif
if ($ndims > 3) then
@ nprefix = $ndims - 3
set start_prefix = \
"`awk 'BEGIN{for (i=0;i<$nprefix;i++) print "'"'"0,"'"'"}' < /dev/null`"
set count_prefix = \
"`awk 'BEGIN{for (i=0;i<$nprefix;i++) print "'"'"1,"'"'"}' < /dev/null`"
else if ($ndims < 2) then
echo "No image found in file $filename"
set exit_status = -1
goto cleanup
else
set start_prefix = ""
set count_prefix = ""
endif
# Get number of slices and image dimensions
@ ind1 = $ndims - 2
@ ind2 = $ndims - 1
@ ind3 = $ndims
if ($ind1 > 0) then
set nslices = `mincinfo $filename -dimlength $dims[$ind1]`
else
set nslices = 1
endif
set imgsize = `mincinfo $filename -dimlength $dims[$ind2] -dimlength $dims[$ind3]`
if ($slice_specified) then
if (($slice >= $nslices) || ($slice < 0)) then
echo "Slice number out of range"
set exit_status = -1
goto cleanup
endif
@ nslices = $slice + 1
endif
# Check for inverting images to get standard orientation
set rows = -$imgsize[1]
set cols = $imgsize[2]
# Loop through slices, if needed
echo -n Loading slices
while ($slice < $nslices)
echo -n .
if ($ndims > 2) then
set start = "$start_prefix $slice,0,0 $start_suffix"
set count = "$count_prefix 1,$imgsize[1],$imgsize[2] $count_suffix"
else
set start = "0,0 $start_suffix"
set count = "$imgsize[1],$imgsize[2] $count_suffix"
endif
set output_file = $workingdir/$slice
echo "$pnm_code" >! $output_file
echo "$imgsize[2] $imgsize[1]" >> $output_file
echo "255" >> $output_file
mincextract $filename -byte -start "$start" -count "$count" \
-positive_direction |\
invert_raw_image $cols $rows $bytes_per_pixel >> $output_file
@ slice++
end
echo Done
# Remove the temporary file
rm -f $newfilename
# Display the images
cd $workingparent
$VIEWER $VIEWER_OPTIONS $childdir/{?,??,???,????}
cleanup:
cd /
rm -rf $workingparent
exit $exit_status
|