#! /bin/csh -f # # stem2fmt # # Finds the format/extension given the stem. # # Looks for a disk file called stem.fmt, where fmt is: # mgh, mgz, bhdr, or img (in that order), and returns fmt # # Original Author: Doug Greve # CVS Revision Info: # $Author: greve $ # $Date: 2007/06/18 02:22:49 $ # $Revision: 1.3 $ # # 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: stem2fmt stem" echo " Looks for stem.fmt where fmt is mgh mgz nii nii.gz bhdr img," echo " then returns fmt. See also stem2fname." exit 1; endif set stem = $argv[1]; foreach fmt (mgh mgz nii nii.gz bhdr img) set testfile = $stem.$fmt if(-e $testfile) then echo $fmt exit 0; endif end echo "ERROR: could not determine format for $stem" exit 1; ##########################################