[MINC-users] mnc2nii. int vs uint vs float

Thorarin Bjarnason thor4ooo at gmail.com
Thu Sep 7 17:50:37 EDT 2006


Fair enough, providing the case you described is true.

However, when I open the resulting img file (assuming it is raw) using
something like matlab, I have to specify that the binary data is
'int16' in order for the data to look correct when plotted, even
though I specified unsigned short as output for the mnc2nii
conversion. What is happening is that the -ve values are being mapped
to +ve values if I open the file as an uint. When I open the file as
int16, -ve values do exist.

I encourage someone else to try this and see if they reproduce the
trouble I am having. Make sure the mnc input is signed and run mnc2nii
as described below. Perhaps I'm doing something wrong.

On the flip-side. I am now using minctoraw with the flags -unsigned
-short and all is well.

Cheers,

On 9/6/06, Soren Christensen <sorench at gmail.com> wrote:
> Hi Thorain,
>  I think that will depend on the values in your image. If you are within the
> posetive range only of your signed integer datatype then the binary coding
> does not differ from that of unsigned coding in the mentioned range.  This
> will often be the case in images from the scanner. So in other words maybe
> the reason is a limited range of your image?
>
> Best regards
> Soren
>
>
>
> On 9/6/06, Thorarin Bjarnason <thor4ooo at gmail.com> wrote:
> >
> > Hello List,
> >
> > I thought I would start another thread. Even though it is quite
> > possible that my ignorance of data types will soon become apparent.
> > ;-)
> >
> > I am trying to take my mnc files and create raw data consisting of
> > unsigned shorts. When I try to open the resulting raw data as unsigned
> > shorts; they do not look correct. If I open them as signed shorts, all
> > is fine.
> >
> > Perhaps the following workflow will be more clear:
> > ] cp InputFile.mnc InputFile2.mnc
> > ] cp InputFile.mnc InputFile3.mnc
> > ] mnc2nii -signed -short -dual InputFile.mnc
> > <various output>
> > datatype = '4'
> > datatype_name = 'INT16'
> > <various output>
> > ] mnc2nii -unsigned -short -dual InputFile2.mnc
> > <various output>
> > datatype = '512'
> > datatype_name = 'UINT16'
> > <various output>
> > ] mnc2nii -float -dual InputFile3.mnc
> > <various output>
> > datatype = '16'
> > datatype_name = 'FLOAT32'
> > <various output>
> > ] diff InputFile3.img InputFile2.img
> > Binary files InputFile3.img and InputFile2.img differ
> > ] diff InputFile3.img InputFile.img
> > Binary files InputFile3.img and InputFile.img differ
> > ] diff InputFile2.img InputFile.img
> > ]
> >
> > In the case above, 'diff' found no difference between int16 and
> > uint16. Shouldn't there be a difference? Running 'mincheader' on the
> > input files provide a variable (in case it matters):
> > variables:
> >         short image(zspace, yspace, xspace) ;
> >                     image:signtype = "signed__" ;
> >
> > Can anyone reproduce this? Should diff find a difference between int16
> > and uint16? In other words, are my unsigned integers in fact signed
> > when using mnc2nii?
> >
> > Have a nice day,
> >
> > --
> >
> > Thorarin Bjarnason, BEng, MASc
> > www.imaginginformatics.ca
> > _______________________________________________
> > MINC-users at bic.mni.mcgill.ca
> > http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users
> >
> _______________________________________________
> MINC-users at bic.mni.mcgill.ca
> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users
>


-- 

Thorarin Bjarnason, BEng, MASc
www.imaginginformatics.ca


More information about the MINC-users mailing list