| 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|