forked from NIFTI-Imaging/nifti_clib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imcp
63 lines (59 loc) · 2.22 KB
/
imcp
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
#!/bin/sh
# imcp - copy image files
#
# Stephen Smith and Mark Jenkinson, FMRIB Image Analysis Group
#
#
# The imcp file was originally part of FSL - FMRIB's Software Library
# http://www.fmrib.ox.ac.uk/fsl
# imcp has now been placed in the public domain.
#
#
# Developed at FMRIB (Oxford Centre for Functional Magnetic Resonance
# Imaging of the Brain), Department of Clinical Neurology, Oxford
# University, Oxford, UK
#
#
if [ $# -lt 1 ] ; then
echo "Usage: $0 <file1> <file2>"
echo "Usage: $0 <file1> <file2> ... <fileN> <directory>"
echo " Copies images from file1 to file2 (including all extensions)"
echo " NB: filenames can be basenames or include an extension"
exit 1;
fi
if [ $# -eq 2 -a ! -d $2 ] ; then
f1=`${FSLDIR}/bin/remove_ext $1`;
f2=`${FSLDIR}/bin/remove_ext $2`;
# do the copies
if [ -f ${f1}.hdr ] ; then /bin/cp ${f1}.hdr ${f2}.hdr ; fi
if [ -f ${f1}.hdr.gz ] ; then /bin/cp ${f1}.hdr.gz ${f2}.hdr.gz ; fi
if [ -f ${f1}.img ] ; then /bin/cp ${f1}.img ${f2}.img ; fi
if [ -f ${f1}.img.gz ] ; then /bin/cp ${f1}.img.gz ${f2}.img.gz ; fi
if [ -f ${f1}.nii ] ; then /bin/cp ${f1}.nii ${f2}.nii ; fi
if [ -f ${f1}.nii.gz ] ; then /bin/cp ${f1}.nii.gz ${f2}.nii.gz ; fi
if [ -f ${f1}.mnc ] ; then /bin/cp ${f1}.mnc ${f2}.mnc ; fi
if [ -f ${f1}.mnc.gz ] ; then /bin/cp ${f1}.mnc.gz ${f2}.mnc.gz ; fi
fi
if [ $# -gt 2 -o -d $2 ] ; then
for nm in $@ ; do
dir=$nm;
done
if [ ! -d $dir ] ; then
echo "When using multiple arguments, last name must be a directory"
exit 1;
fi
# remove directory from list of files
flist="echo $@ | sed s/$dir \*\$//";
for fn in $flist ; do
f1=`${FSLDIR}/bin/remove_ext $fn`;
# do the copies
if [ -f ${f1}.hdr ] ; then /bin/cp ${f1}.hdr ${dir} ; fi
if [ -f ${f1}.hdr.gz ] ; then /bin/cp ${f1}.hdr.gz ${dir} ; fi
if [ -f ${f1}.img ] ; then /bin/cp ${f1}.img ${dir} ; fi
if [ -f ${f1}.img.gz ] ; then /bin/cp ${f1}.img.gz ${dir} ; fi
if [ -f ${f1}.nii ] ; then /bin/cp ${f1}.nii ${dir} ; fi
if [ -f ${f1}.nii.gz ] ; then /bin/cp ${f1}.nii.gz ${dir} ; fi
if [ -f ${f1}.mnc ] ; then /bin/cp ${f1}.mnc ${dir} ; fi
if [ -f ${f1}.mnc.gz ] ; then /bin/cp ${f1}.mnc.gz ${dir} ; fi
done
fi