4 #################################################################################
5 # create_mhd_3D argument : {image data} raw_image nom_fichier_de_sortie #
6 #################################################################################
9 echo "Usage: create_mhd_3D.sh dimx dimy dimz spcx spcy spcz offx offy offz pixel_type raw_image_file output_file"
10 echo "dim*: dimensions of the image"
11 echo "spc*: pixel spacing along each dimension"
12 echo "off*: offset along each dimension"
13 echo "pixel_type: CHAR, UCHAR, SHORT, USHORT, FLOAT"
14 echo "raw_image_file: image to be referenced by the mhd file created"
15 echo "output_file: mhd to be created"
19 # can point to existing raw files
23 echo "${11} does not exist. Cannot create mhd file."
27 # check if the raw file has the "raw" extension
28 n=`ls ${11} | grep .raw | wc -l`
31 # change extension to raw
32 raw_base=`echo ${11} | cut -d . -f 1`;
33 raw_file=$raw_base".raw";
39 # create file (with some default values...)
40 echo "NDims = 3" > ${12}
41 echo "TransformMatrix = 1 0 0 0 1 0 0 0 1" >> ${12}
42 echo "Offset = " $7 $8 $9 >> ${12}
43 echo "CenterOfRotation = 0 0 0" >> ${12}
44 echo "AnatomicalOrientation = RAI" >> ${12}
45 echo "ElementSpacing = " $4 $5 $6 >> ${12}
46 echo "DimSize = " $1 $2 $3 >> ${12}
47 echo "ElementType = MET_"${10} >> ${12}
48 echo "ElementDataFile = " $raw_file >> ${12}