function nifti2mat(fnms) %nift2mat - copy orientation from SPM5-style NIfTI to SPM99/2-style .mat % store voxel-world mapping from NIfTI headers (as read with spm_get_space % from SPM5) in a .mat file, so that SPM2 or SPM99 should treat the image % orientation/origin/etc in the same way as SPM5. % % BUT CHECK LEFT/RIGHT CONSISTENCY OF THE RESULTS -- ESPECIALLY WITH SPM99 % % Examples: % nifti2mat; % select images with GUI % nifti2mat(filenames); % batch-mode % % See also: % http://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=ind06&L=SPM&P=R594773 if ~exist('fnms', 'var') fnms = spm_select(inf, 'image'); end for f = 1:size(fnms, 1); fnm = deblank(fnms(f, :)); M = spm_get_space(fnm); mat = M; [pth nam] = spm_fileparts(fnm); matfile = fullfile(pth, [nam '.mat']); save(matfile, 'M', 'mat', '-V6'); end