giuseppe pagnoni Wrote:
-------------------------------------------------------
> I have noticed that when copying NIFTI data (from
> a Philips scanner) with 3dcopy, an automatic
> conversion from INT16 to FLOAT32 seems to be
> taking place [...]
> But why is that
> happening? Is there a way to keep the original
> format? If the data are originally INT16, it
> seems to me that you waste a lot of disk space and
> computing time by doubling the size of the data
> right away.
In my understanding int16 was used in AFNI in the old days, when disk space was expensive. Nowadays disk space is quite cheap, so it's not too much of an issue.
When using int16, data is stored together with a min value p and max value q; each value v is then stored as an int16 i with v=p + s*i, where s=(q-p)/(2^16-1) is the step size. When having a few outliers (extreme values) q-p is large so the step size s is large too. This reduces the resolution for the rest of the data (which is usually the data of interest). In addition, every processing step usually involves some averaging of existing values that have to be converted back to an int16, which again impoverishes the data (even if during computations the data is stored internally as float32).
Float32 does not have this disadvantage as it holds an exponent, allowing for a large range of data and yet good numerical precision.
Therefore float32 is currently considered as the preferred option by most.
Also note that you can enable compression which reduces file sizes considerably, and this compression works transparently in the AFNI programs. One way is to specify an extension for the output file (e.g. -prefix output.nii.gz to store in nifti and gzip the output). Another approach is to set the environmental variable AFNI_COMPRESSOR to BZIP2 or GZIP so that AFNI compresses the data automatically.