Dear Stephen,
You are right - the char being used internally is a signed char and
not an unsigned one. I would normally not recommend doing the
internal calculations in fslmaths with "char" as it is so easy to cause
under/overflows, regardless of whether it is signed or unsigned.
We will update the documentation to make it clear that "-dt char"
is using a signed 8-bit integer.
All the best,
Mark
On 25 Aug 2010, at 04:28, Stephen Towler wrote:
> Hi FSLers,
>
> Is this expected behavior? "fslmaths -dt char $mask -bin -odt char"
> outputs intensity of 0 instead of expected 1 when non-zero input
> values are between 127 and 255 inclusive. Behavior not manifest when
> fslmaths -dt is float, so maybe the char in "fslmaths -dt char" is a
> signed 8-bit integer but the char in "fslmaths -odt char" is an
> unsigned 8-bit integer? Spent a few hours rechecking my script's
> logic and syntax before I discovered this behavior, distilled into
> this snippet below (just paste to bash commandline as-is):
>
> for charMaskValue in 255 254 200 130 129 128 127 126 125 124 100 050
> 001; do \
> fslmaths -dt char ${FSLDIR}/data/standard/
> MNI152_T1_1mm_brain_mask.nii.gz -mul ${charMaskValue} ~/temp/
> charMNImask-foreground${charMaskValue} -odt char; \
> fslmaths -dt char ~/temp/charMNImask-foreground${charMaskValue} -bin
> ~/temp/charMNImask-foreground${charMaskValue}-bin -odt char; \
> echo "charMNImask-foreground${charMaskValue} intensity min and max:
> `fslstats ~/temp/charMNImask-foreground${charMaskValue} -R`"; \
> echo "charMNImask-foreground${charMaskValue}-bin intensity min and
> max: `fslstats ~/temp/charMNImask-foreground${charMaskValue}-bin -
> R`"; \
> echo ""; \
> done
>
>
> My output below. Notice that only mask values less than 127 are
> correctly binarized to 1:
>
>
> charMNImask-foreground255 intensity min and max: 0.000000 255.000000
> charMNImask-foreground255-bin intensity min and max: 0.000000 0.000000
>
> charMNImask-foreground254 intensity min and max: 0.000000 254.000000
> charMNImask-foreground254-bin intensity min and max: 0.000000 0.000000
>
> charMNImask-foreground200 intensity min and max: 0.000000 200.000000
> charMNImask-foreground200-bin intensity min and max: 0.000000 0.000000
>
> charMNImask-foreground130 intensity min and max: 0.000000 130.000000
> charMNImask-foreground130-bin intensity min and max: 0.000000 0.000000
>
> charMNImask-foreground129 intensity min and max: 0.000000 129.000000
> charMNImask-foreground129-bin intensity min and max: 0.000000 0.000000
>
> charMNImask-foreground128 intensity min and max: 0.000000 128.000000
> charMNImask-foreground128-bin intensity min and max: 0.000000 0.000000
>
> charMNImask-foreground127 intensity min and max: 0.000000 127.000000
> charMNImask-foreground127-bin intensity min and max: 0.000000 0.000000
>
> charMNImask-foreground126 intensity min and max: 0.000000 126.000000
> charMNImask-foreground126-bin intensity min and max: 0.000000 1.000000
>
> charMNImask-foreground125 intensity min and max: 0.000000 125.000000
> charMNImask-foreground125-bin intensity min and max: 0.000000 1.000000
>
> charMNImask-foreground124 intensity min and max: 0.000000 124.000000
> charMNImask-foreground124-bin intensity min and max: 0.000000 1.000000
>
> charMNImask-foreground100 intensity min and max: 0.000000 100.000000
> charMNImask-foreground100-bin intensity min and max: 0.000000 1.000000
>
> charMNImask-foreground050 intensity min and max: 0.000000 50.000000
> charMNImask-foreground050-bin intensity min and max: 0.000000 1.000000
>
> charMNImask-foreground001 intensity min and max: 0.000000 1.000000
> charMNImask-foreground001-bin intensity min and max: 0.000000 1.000000
>
>
> Only tested on two machines, both using precompiled FSL binaries:
>
> $ uname -a
> Darwin stowler-mbp.local 10.4.0 Darwin Kernel Version 10.4.0: Fri
> Apr 23 18:28:53 PDT 2010; root:xnu-1504.7.4~1/RELEASE_I386 i386 i386
> $ cat $FSLDIR/etc/fslversion
> 4.1.5
>
> $ uname -a
> Linux b0.phhp.ufl.edu 2.6.32.16-150.fc12.x86_64 #1 SMP Sat Jul 24
> 05:19:12 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux
> $ cat $FSLDIR/etc/fslversion
> 4.1.5
>
>
> Thanks!
> Stephen
|