+ list_suffix=""
+ list_phase_file_prefix=`find $1 -maxdepth 1 -iname "${prefix}[0-9]*.mhd"`
+ for phase_file_prefix in $list_phase_file_prefix
+ do
+ if grep -q "NDims = 4" $phase_file_prefix 2> /dev/null
+ then
+ #echo $phase_file_prefix is 4D
+ continue;
+ fi;
+ phase_file_prefix_name=`basename $phase_file_prefix .mhd`
+# if [[ ! -z `echo "$phase_file_prefix_name" | grep "__[0-9]"` ]]
+# then
+# suffix="NONE"
+# else
+# if [[ ! -z `echo "$phase_file_prefix_name" | grep "[0-9]-.*\]"` ]]
+# then
+# suffix=`echo $phase_file_prefix_name | sed "s/.*[0-9]-//;s/_\.mhd//;s/\.mhd//"`
+# else
+# suffix="NONE"
+# fi
+# fi
+#
+
+ # suffix: grep sequence of numbers followed by sequence of characters and remove sequence of numbers
+ # suffix=`echo $phase_file_prefix_name | grep -o "\([[:digit:]\.\_\-]\+\)\([[:alpha:][:punct:]]*$\)" | sed 's/\([[:digit:]\.\_\-]\+\)\([[:alpha:][:punct:]]*$\)/\2/'`
+ suffix=`echo $phase_file_prefix_name | grep -o "\([\.\_\-]*\)\([[:digit:]]\+\)\([[:alpha:][:punct:]]*$\)"`
+ if ! echo $suffix | grep -qo "^\-\+"; then
+ suffix=`echo $suffix | sed 's/\([\.\_\-]*\)\([[:digit:]]\+\)\([[:alpha:][:punct:]]*$\)/\3/'`
+ fi
+ suffix=`echo $suffix | sed 's/[\.\_\-]\+$//'`
+ if [[ -z $suffix ]]
+ then
+ suffix="NONE"
+ fi
+
+ # register new suffix if not yet done
+ if [[ -z `echo "$list_suffix" | grep -w -- "$suffix"` ]]
+ then
+ list_suffix="$list_suffix $suffix"
+ fi
+ done