hello,
On Wed, 23 Aug 2006 08:55:26 +0100, Steve Smith <[log in to unmask]> wrote:
>> or should i just scale the intensity values "manually", ie,
>> avwmaths++ $inVol -sub $min -div ($max-$min) $outVol -odt float
>
>Indeed - this latter sounds like exactly what you want.
>
>Cheers, Steve.
thanks, steve. if anyone is interested, the code i wrote to
"manually" normalize intensity values to the range
[0,$maxIntensity] is:
inGlobPatt=$1 # ex: '/data/subj1_date_???.hdr'
maxIntensity=1000
pgm=`basename $0 .sh`
for fName in $inGlobPatt; do
fName=`remove_ext $fName`
# get robust min/max for $fName
cmd="avwstats++ $fName -R"
echo $cmd
range=`eval $cmd`
# split range into min and max
min=`echo $range | awk '{split($0, a, " "); print a[1] }'`
max=`echo $range | awk '{split($0, a, " "); print a[2] }'`
# normalize intensity values to [0,$maxIntensity]
scale=`echo "scale=6; $maxIntensity / ( $max - $min )" | bc`
if [ "$scale" = '' ]; then
echo "WARNING $0: Scale calculation failed; Set scale = 1"
scale=1
fi
oVol="/tmp/${pgm}_$$_${ii}"
cmd="avwmaths++ $fName -sub $min -mul $scale $oVol"
echo $cmd
eval $cmd
done
|