#! /bin/csh -f

#
# addmcparams
#
# Computes total displacement from the AFNI motion correction parameter
# file and prints out the old set of parameters with total distplacement 
# as the last column (11th)
#
# Original Author: Doug Greve
# CVS Revision Info:
#    $Author: nicks $
#    $Date: 2007/01/09 22:41:16 $
#    $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
#


if($#argv != 1) then
  echo "USAGE: addmcparams mcdatfile"
  exit 1;
endif

set mcdatfile = $argv[1];

if(! -e $mcdatfile) then
  echo "ERROR:$mcdatfile does not exist"
  exit 1;
endif

cat $mcdatfile | awk '{printf sprintf("%s   %5.3f\n",$0,sqrt($5*$5+$6*$6+$7*$7))}'







exit 0;
######################################
