Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make_phantom - Signed byte volumes created with wrong voxel range #26

Open
bbbxyz opened this issue Mar 29, 2020 · 1 comment
Open

make_phantom - Signed byte volumes created with wrong voxel range #26

bbbxyz opened this issue Mar 29, 2020 · 1 comment

Comments

@bbbxyz
Copy link

bbbxyz commented Mar 29, 2020

$ make_phantom -signed -byte -clobber test.mnc && mincheader test.mnc 
hdf5 test {
dimensions:
        xspace = 128 ;
        yspace = 128 ;
        zspace = 128 ;
variables:
        byte image(xspace, yspace, zspace) ;
                image:version = "MINC Version    1.0" ;
                image:vartype = "group________" ;
                image:valid_range = 0., 255. ;
                image:varid = "MINC standard variable" ;
                image:complete = "true_" ;
                image:dimorder = "xspace,yspace,zspace" ;
                image:signtype = "signed__" ;
[...]

Note the valid_range being 0 to 255 which doesn't work for signed bytes. The range should be -128 to 127 right?
Using mincstats on the same volume gives me :

mincstats test.mnc
*** mincstats - reported max (0) doesn't equal header (1)
File:              test.mnc
Mask file:         (null)
Total voxels:      2097152
# voxels:          2076816
% of total:        99.03030396
Volume (mm3):      16614528
Min:               0
Max:               0
Sum:               0
Sum^2:             0
Mean:              0
Variance:          0
Stddev:            0
CoM_voxel(x,y,z):  0 0 0
CoM_real(x,y,z):   0 0 0

Histogram:         (null)
Total voxels:      2097152
# voxels:          2076816
% of total:        99.03030396
Median:            0.0005000000119
Majority:          0.0002500000119
BiModalT:          0.5002499819
PctT [  0%]:       0.0002500000119
Entropy :          0
@gdevenyi
Copy link
Contributor

gdevenyi commented Apr 9, 2020

There are indeed a few places where the value range is hard-coded and isn't adapted properly for changing the output type:
https://github.com/BIC-MNI/mni_autoreg/blob/develop/make_phantom/make_phantom.c#L278-L281

It looks like you could fix this with:
-voxel_range -128 127

I'll need to dig into http://www.bic.mni.mcgill.ca/~david/volume_io/volume_io.html to figure out how to programmaticly set the voxel range properly given the default voxel range for a given voxel type.

> make_phantom -voxel_range -128 127 -signed -byte -clobber test.mnc && mincheader test.mnc 
hdf5 test {
dimensions:
        xspace = 128 ;
        yspace = 128 ;
        zspace = 128 ;
variables:
        byte image(xspace, yspace, zspace) ;
                image:version = "MINC Version    1.0" ;
                image:vartype = "group________" ;
                image:valid_range = -128., 127. ;
                image:varid = "MINC standard variable" ;
                image:complete = "true_" ;
                image:dimorder = "xspace,yspace,zspace" ;
                image:signtype = "signed__" ;
        double image-min ;
                image-min:version = "MINC Version    1.0" ;
                image-min:vartype = "var_attribute" ;
                image-min:varid = "MINC standard variable" ;
        double image-max ;
                image-max:version = "MINC Version    1.0" ;
                image-max:vartype = "var_attribute" ;
                image-max:varid = "MINC standard variable" ;
        double xspace ;
                xspace:version = "MINC Version    1.0" ;
                xspace:vartype = "dimension____" ;
                xspace:start = 0. ;
                xspace:spacing = "regular__" ;
                xspace:alignment = "centre" ;
                xspace:comments = "X increases from patient left to right" ;
                xspace:units = "mm" ;
                xspace:varid = "MINC standard variable" ;
                xspace:length = 128 ;
                xspace:step = 2. ;
        double yspace ;
                yspace:version = "MINC Version    1.0" ;
                yspace:vartype = "dimension____" ;
                yspace:start = 0. ;
                yspace:spacing = "regular__" ;
                yspace:alignment = "centre" ;
                yspace:comments = "Y increases from patient posterior to anterior" ;
                yspace:units = "mm" ;
                yspace:varid = "MINC standard variable" ;
                yspace:length = 128 ;
                yspace:step = 2. ;
        double zspace ;
                zspace:version = "MINC Version    1.0" ;
                zspace:vartype = "dimension____" ;
                zspace:start = 0. ;
                zspace:spacing = "regular__" ;
                zspace:alignment = "centre" ;
                zspace:comments = "Z increases from patient inferior to superior" ;
                zspace:units = "mm" ;
                zspace:varid = "MINC standard variable" ;
                zspace:length = 128 ;
                zspace:step = 2. ;

// global attributes:
                :ident = "gdevenyi:monster:2020.04.09.13.15.11:5337:1" ;
                :minc_version = "2.4.05" ;
                :history = "Thu Apr  9 13:15:11 2020>>> make_phantom -voxel_range -128 127 -signed -byte -clobber test.mnc\n",
                        "(mni_autoreg 0.99.70)\n",
                        "" ;
data:

 image-min = 0 ;

 image-max = 1 ;

 xspace = 0 ;

 yspace = 0 ;

 zspace = 0 ;
}
13:15:12 [gdevenyi@monster:/tmp] [base] $ mincstats test.mnc 
File:              test.mnc
Mask file:         (null)
Total voxels:      2097152
# voxels:          2097152
% of total:        100
Volume (mm3):      16777216
Min:               0
Max:               1
Sum:               20336
Sum^2:             20336
Mean:              0.009696960449
Variance:          0.009602933986
Stddev:            0.097994561
CoM_voxel(x,y,z):  64 64 64.5
CoM_real(x,y,z):   128 128 129

Histogram:         (null)
Total voxels:      2097152
# voxels:          2097152
% of total:        100
Median:            0.0004975757599
Majority:          0.00025
BiModalT:          0.00025
PctT [  0%]:       0.00025
Entropy :          0.07877741944


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants