This practical shows how to use bc for general real
number calculations (particularly divisions) and how
fslstats and fslmaths can rescale and
convert images. The content is more advanced and hence optional for
those new to scripting.
- Floating point division using
bc
To do general floating point division, you must add scale=val; For example
  var=`echo "scale=5; 5.4 / 1.9" | bc`
The scale part specifies the numbers of decimal places in the output.
Also note that the double quotes are necessary to stop the semicolon
terminating the echo command.
- Scaling and converting image intensities
The max and min intensity values for a given image can be found using fslstats .
Separate and store these values by piping the output into awk (see theory slide)
Given these values work out the
scaling factor and offset required to force the intensity range to be
within 0 to 255 (using bc ).
Apply the scaling and offset
using fslmaths and then (in another call) convert the
datatype to 8bit by using:
  fslmaths input output -odt char
Look here to find the cheat.
|
|