returns (pseudo) vol struct for 3d matrix FORMAT vol = pr_matrix2vol(mat3d,mat) Inputs mat3d - 3D matrix mat - optional 4x4 voxel -> world transformation Outputs vol - kind of SPM vol struct with matrix data added $Id: pr_matrix2vol.m,v 1.1 2005/04/20 15:05:00 matthewbrett Exp $
0001 function vol = pr_matrix2vol(mat3d, mat) 0002 % returns (pseudo) vol struct for 3d matrix 0003 % FORMAT vol = pr_matrix2vol(mat3d,mat) 0004 % 0005 % Inputs 0006 % mat3d - 3D matrix 0007 % mat - optional 4x4 voxel -> world transformation 0008 % 0009 % Outputs 0010 % vol - kind of SPM vol struct with matrix data added 0011 % 0012 % $Id: pr_matrix2vol.m,v 1.1 2005/04/20 15:05:00 matthewbrett Exp $ 0013 0014 if nargin < 1 0015 error('Need matrix to add to vol'); 0016 end 0017 if nargin < 2 0018 mat = []; 0019 end 0020 if isempty(mat) 0021 mat = spm_matrix([]); 0022 end 0023 vol = []; 0024 if ~isempty(mat3d) 0025 vol.imgdata = mat3d; 0026 vol.mat = mat; 0027 vol.dim = size(mat3d); 0028 end