]> Creatis software - clitk.git/blobdiff - vv/scripts/create_mhd_4D.sh
Delete widget first, the image data after
[clitk.git] / vv / scripts / create_mhd_4D.sh
index 8eac7828fc0799d3e4940104e4a95a6f25c61d2e..238e26aa9b4e68f649fc13af46003d098ced77c3 100755 (executable)
@@ -1,16 +1,22 @@
 #!/bin/sh
 
-###############################################
-# create_mhd_4D        argument : repertoire #
-###############################################
+
+#####################################################################
+# create_mhd_4D        argument : repertoire nom_fichier_de_sortie #
+#####################################################################
 if [ $# -lt 1 ]
 then
-    echo "Usage: create_mhd_4D directory"
+    echo "Usage: create_mhd_4D.sh directory output_file_name(without path)"
     exit 1
 fi
 
 cd $1
-nbph=`ls -l *0.mhd | wc -l`
+nbph=`find . -iname "*0.mhd" | wc -l`
+if [ $nbph = 0 ]
+then
+    echo "Error: no phase found"
+    exit 1
+fi
 orig=`ls -1 *0.mhd | head -n 1`
 
 cat $orig | sed "s/NDims = .*/NDims = 4/
@@ -20,7 +26,7 @@ cat $orig | sed "s/NDims = .*/NDims = 4/
                 s/AnatomicalOrientation = .*/AnatomicalOrientation = ????/
                 /ElementSpacing/ s/.*/& 1/
                 /DimSize/ s/.*/& $nbph/
-                s/ElementDataFile = .*/ElementDataFile = LIST/" > CT_4D.mhd
+                s/ElementDataFile = .*/ElementDataFile = LIST/" > $2
 
-ls -1 *0.raw >> CT_4D.mhd
+ls -1 *0.raw >> $2
 cd ..