#!/bin/sh

#
# cor_to_minc
#
# CVS Revision Info:
#    $Author: nicks $
#    $Date: 2007/01/06 00:01:13 $
#    $Revision: 1.2 $
#
# Copyright (C) 2002-2007,
# The General Hospital Corporation (Boston, MA).
# All rights reserved.
#
# Distribution, usage and copying of this software is covered under the
# terms found in the License Agreement file named 'COPYING' found in the
# FreeSurfer source code root directory, and duplicated here:
# https://surfer.nmr.mgh.harvard.edu/fswiki/FreeSurferOpenSourceLicense
#
# General inquiries: freesurfer@nmr.mgh.harvard.edu
# Bug reports: analysis-bugs@nmr.mgh.harvard.edu
#


progname=`basename $0`

usage()
{

	echo "usage: $progname <cor directory> <minc file name>" >&2

	exit 1

} # end usage()

if [ $# -ne 2 ] ; then usage ; fi

if [ ! -d $1 ]
then
	echo "$progname: can't find directory $1" >&2
	exit 1
fi

cat $1/COR-[0-9]* | rawtominc -unsigned -byte -coronal -xstep -1 -ystep -1 -zstep -1 -xdircos 1 0 0 -ydircos 0 -1 0 -zdircos 0 0 1 -xstart 128 -ystart 128 -zstart 128 -mri -range 0 255 -scan_range $2 256 256 256

exit 0

# eof
