BIC-MNI / minc-tools

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

nii2mnc doesn't seem to handle scl_slope and scl_inter properly #110

Open gdevenyi opened 3 years ago

gdevenyi commented 3 years ago

nii2mnc seems to have issues handling the voxel storage/scaling features of nifti.

I have a file with scl_slope = 0.000219166, scl_inter = 0

If I re-generate the NIFTI using ANTs ConvertImage, which strips the scaling and encodes directly in the voxel values:

> ConvertImage 3 file_with_scaling.nii.gz file_without_scaling.nii.gz

I can see that the resulting MINC files are different

> mincstats file_with_scaling.mnc
*** mincstats - reported min (3.59153) doesn't equal header (0.000876664)
*** mincstats - reported max (7.18109) doesn't equal header (7.1812)
File:              file_with_scaling.mnc
Mask file:         (null)
Total voxels:      8711680
# voxels:          8711680
% of total:        100
Volume (mm3):      4001.943345
Min:               3.591529182
Max:               7.181086052
Sum:               32807197.61
Sum^2:             124161604.9
Mean:              3.765886443
Variance:          0.07041399787
Stddev:            0.2653563601
CoM_voxel(y,z,x):  102.1101118 82.5984099 127.4448086
CoM_real(x,y,z):   -2.192321458 -1.239079736 -2.827323455

Histogram:         (null)
Total voxels:      8711680
# voxels:          8711680
% of total:        100
Median:            3.63232449
Majority:          3.617962337
BiModalT:          3.984158603
PctT [  0%]:       0.002671744039
Entropy :          6.322473846
> mincstats file_without_scaling.mnc
File:              file_without_scaling.mnc
Mask file:         (null)
Total voxels:      8711680
# voxels:          8711680
% of total:        100
Volume (mm3):      4001.94323
Min:               0.0008766643004
Max:               7.181195736
Sum:               3046036.55
Sum^2:             3519566.35
Mean:              0.3496497289
Variance:          0.2817505648
Stddev:            0.5308018131
CoM_voxel(y,z,x):  104.3723066 84.62019458 126.3109265
CoM_real(x,y,z):   -2.035618383 -1.095800832 -2.699890566

Histogram:         (null)
Total voxels:      8711680
# voxels:          8711680
% of total:        100
Median:            0.08524575843
Majority:          0.05652413711
BiModalT:          0.7889166824
PctT [  0%]:       0.002671744068
Entropy :          7.319477426

Comparing the two MINC files, min(file_without_scaling.mnc) = 0.000219166*min(file_with_scaling.mnc)

Considering the max values are the same, I'm guessing the issue is with how the minimum value is calculated. Will investigate further.