Dear all, I am using spm12 for some of my analysis. I create images in subject's native space and firstly want to write them as Nifti images. So I use spm_write_vol. It's strange that the nifti image that I write is not the same as the image that I feed in the function! Can anyone point out the mistake I am making or the solution they have. Here is the code: V = spm_vol(binaryMaskFile);% binaryMaskFile is one of the subject's files, e.g. their mask.nii created after the first level stats % now I change the name of the file V.fname = 'test.nii'; % generate random data data = randn(96,96,72); % save it spm_write_vol(V,data); % read in the written volume and find the difference diffVol = spm_read_vols(spm_vol('test.nii')) - data; max(diffVol(:)) % I get 4.4715 in one example