Debian Codegraph @

fsliolib/imcp

raw
1 #!/bin/sh
2
3 # imcp - copy image files
4 #
5 # Stephen Smith and Mark Jenkinson, FMRIB Image Analysis Group
6 #
7 #
8 # The imcp file was originally part of FSL - FMRIB's Software Library
9 # http://www.fmrib.ox.ac.uk/fsl
10 # imcp has now been placed in the public domain.
11 #
12 #
13 # Developed at FMRIB (Oxford Centre for Functional Magnetic Resonance
14 # Imaging of the Brain), Department of Clinical Neurology, Oxford
15 # University, Oxford, UK
16 #
17 #
18
19 if [ $# -lt 1 ] ; then
20 echo "Usage: $0 <file1> <file2>"
21 echo "Usage: $0 <file1> <file2> ... <fileN> <directory>"
22 echo " Copies images from file1 to file2 (including all extensions)"
23 echo " NB: filenames can be basenames or include an extension"
24 exit 1;
25 fi
26
27 if [ $# -eq 2 -a ! -d $2 ] ; then
28 f1=`${FSLDIR}/bin/remove_ext $1`;
29 f2=`${FSLDIR}/bin/remove_ext $2`;
30 # do the copies
31 if [ -f ${f1}.hdr ] ; then /bin/cp ${f1}.hdr ${f2}.hdr ; fi
32 if [ -f ${f1}.hdr.gz ] ; then /bin/cp ${f1}.hdr.gz ${f2}.hdr.gz ; fi
33 if [ -f ${f1}.img ] ; then /bin/cp ${f1}.img ${f2}.img ; fi
34 if [ -f ${f1}.img.gz ] ; then /bin/cp ${f1}.img.gz ${f2}.img.gz ; fi
35 if [ -f ${f1}.nii ] ; then /bin/cp ${f1}.nii ${f2}.nii ; fi
36 if [ -f ${f1}.nii.gz ] ; then /bin/cp ${f1}.nii.gz ${f2}.nii.gz ; fi
37 if [ -f ${f1}.mnc ] ; then /bin/cp ${f1}.mnc ${f2}.mnc ; fi
38 if [ -f ${f1}.mnc.gz ] ; then /bin/cp ${f1}.mnc.gz ${f2}.mnc.gz ; fi
39 fi
40
41 if [ $# -gt 2 -o -d $2 ] ; then
42 for nm in $@ ; do
43 dir=$nm;
44 done
45 if [ ! -d $dir ] ; then
46 echo "When using multiple arguments, last name must be a directory"
47 exit 1;
48 fi
49 # remove directory from list of files
50 flist="echo $@ | sed s/$dir \*\$//";
51 for fn in $flist ; do
52 f1=`${FSLDIR}/bin/remove_ext $fn`;
53 # do the copies
54 if [ -f ${f1}.hdr ] ; then /bin/cp ${f1}.hdr ${dir} ; fi
55 if [ -f ${f1}.hdr.gz ] ; then /bin/cp ${f1}.hdr.gz ${dir} ; fi
56 if [ -f ${f1}.img ] ; then /bin/cp ${f1}.img ${dir} ; fi
57 if [ -f ${f1}.img.gz ] ; then /bin/cp ${f1}.img.gz ${dir} ; fi
58 if [ -f ${f1}.nii ] ; then /bin/cp ${f1}.nii ${dir} ; fi
59 if [ -f ${f1}.nii.gz ] ; then /bin/cp ${f1}.nii.gz ${dir} ; fi
60 if [ -f ${f1}.mnc ] ; then /bin/cp ${f1}.mnc ${dir} ; fi
61 if [ -f ${f1}.mnc.gz ] ; then /bin/cp ${f1}.mnc.gz ${dir} ; fi
62 done
63 fi