3 ###############################################################################
5 # FILE: create_mhd_pattern.sh
6 # AUTHOR: RĂ´mulo Pinho 05/08/2011
8 # Similar to create_mhd_4D.sh, but receives a pattern as input.
11 # create_mhd_pattern.sh "<path>/all_my_phases_start_like_this_"
13 ###############################################################################
17 cat $orig | sed "s/NDims = .*/NDims = 4/
18 s/TransformMatrix = .*/TransformMatrix = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1/
20 /CenterOfRotation/ s/.*/& 0/
21 s/AnatomicalOrientation = .*/AnatomicalOrientation = ????/
22 /ElementSpacing/ s/.*/& 1/
23 /DimSize/ s/.*/& $nbph/
24 s/ElementDataFile = .*/ElementDataFile = LIST/" > "$dirname/$file_name_4D"
29 echo "$phase" >> "$dirname/$file_name_4D"
33 #################################################
34 # create_mhd_4D argument : repertoire #
35 #################################################
38 echo "Usage: $0 PREFIX [SUFFIX]"
47 list_phase_file=`ls -1 $dirname/$prefix*[0-9]*$suffix.mhd`
48 for ph in $list_phase_file
50 if [ -e `echo $ph | sed 's/mhd/raw/'` ]
57 nb_phase_file=`ls -1 $dirname/$prefix*[0-9]*$suffix.mhd | wc -l`
58 if [ $nb_phase_file = 0 ]
60 echo "Error: no phase found"
64 orig=`echo $list_phase_file | cut -f 1 -d ' '`
65 listph=`echo $listph | sed 's:\.mhd:\.raw:g'`
67 file_name_4D=`echo "${prefix}4D${suffix}.mhd"`
70 echo "$dirname/$file_name_4D"