Dear SPM users,
we would like to convert float datatype images to int16 using SPM8. I tried
Vo = V;
Vo.fname = Po;Vo.dt = [spm_type('int16') spm_platform('bigend')];
Yo = zeros(V.dim(1:3));
for i=1:V.dim(3),
Yo(:,:,i) = spm_slice_vol(V,spm_matrix([0 0 i]),V.dim(1:2),0);
end;
spm_write_vol(Vo,Yo);
but this does not work properly. For example, grey matter probability maps
appear to be more or less binary after conversion. I would very much
appreciate your help.
With very best wishes,
Ralph.
On Mon, 24 Jul 2000 10:40:29 +0100 (BST), John Ashburner
<[log in to unmask]> wrote:
>| Is there any reason to prefer using floating point images over signed 16-bit
>| images (int16)? The latter take half the disk space. (I'm wondering about
>| the dynamic range of typical MRI images used in functional brain mapping,
>| and the effect of the datatype on roundoff error. Typically, it appears
>| that either floating point or int16 is good enough, given the size of signal
>| changes and the fact that we're interested in such signal changes in gray
>| matter, where the signal is well away from 0.)
>
>Floating point images are prefered when the dynamic range of the images
>is not known beforehand. Integer datatypes need a scalefactor, whereas
>floating point images assume a scalefactor of one. In order to save
>memory, the images are written a plane at a time, rather than the whole
>volume at once. This can not be done for integer datatype images, as
>the scalefactors can not be derived until all the processing is complete.
>
>|
>| Also, if I convert analyze-format floating point images to int16 before
>| using spm, should I follow the following rough algorithm?
>|
>| max = max of the abs values in the floating point image
>| SCALE = max/2^15 (put this in the .hdr file, as well as TYPE=4)
>| int16 image = (round) (fp image/scale)
>
>The above procedure should work (although I would use a scale of
>max/(2^15-1)). However, the easiest way of converting to a different
>datatype is probably something like:
>
>VI = spm_vol(spm_get(1,'*.img'));
>VO = VI;
>VO.fname = '16_bit_version.img';
>VO.dim(4) = spm_type('int16');
>dat = zeros(VO.dim(1:3));
>for i=1:VI.dim(3),
> dat(:,:,i) = spm_slice_vol(VI,spm_matrix([0 0 i]),VI.dim(1:2),0);
>end;
>spm_write_vol(VO,dat);
>clear dat
>
>All the best,
>-John
>
>
>
>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
|