BIC-MNI / minc-tools

Basic minc-tools from former minc repository
Other
29 stars 25 forks source link

mincreshape modifies image-min when changing type #119

Open bbbxyz opened 2 years ago

bbbxyz commented 2 years ago

Hello,

I've encountered some odd behaviour with mincreshape:

# Create a phantom with 0's and 1's
$ make_phantom phantom.mnc
# Set its range to 5-10 and fill 
$ mincreshape -fillvalue 5 -valid_range 5 10 -image_range 5 10 phantom.mnc phantom_5_10.mnc 

This works as expected and creates a volume filled with 5's with an image-min of 5

# Change the type to any integer type (byte here)
$ mincreshape -byte phantom_5_10.mnc phantom_byte.mnc
# image-min is now zero and volume is now filled with zeros
$ mincstats -min -max phantom_byte.mnc 
*** mincstats - reported max (0) doesn't equal header (10)
Min:               0
Max:               0
$ mincinfo -varvalue image-min phantom_byte.mnc 
0
0
[...]
0

Is this expected?

vfonov commented 2 years ago

make_phantom phantom.mnc - makes a volume with values between 0 and 1 mincreshape -fillvalue 5 -valid_range 5 10 -image_range 5 10 phantom.mnc phantom_5_10.mnc creates a volume filled with NaN's , because all values are outside of image range. mincreshape -byte phantom_5_10.mnc phantom_byte.mnc tries to convert NaN values to bytes, replaces them with 0 (pixfillvalue)