0001 function m = pr_expand(img, nvoxels, outvol)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 if nargin < 2
0015 error('Need two input args');
0016 end
0017 if nargin < 3
0018 outvol = [];
0019 end
0020 if ischar(img)
0021 img = spm_vol(img);
0022 end
0023 if ~isstruct(img) & isempty(outvol)
0024 m = zeros(size(img));
0025 elseif isempty(outvol)
0026 error('Need output volume information');
0027 else
0028 if ischar(outvol)
0029 q = outvol;
0030 outvol = img;
0031 outvol.fname = q;
0032 outvol.descrip = sprintf('Expanded image (%g,%g,%g)',nvoxels);
0033 if isfield(img,'descrip'),
0034 outvol.descrip = sprintf('%s - expanded (%g,%g,%g)',img.descrip, s);
0035 end;
0036 end
0037 m = spm_create_image(outvol);
0038 end
0039
0040 nvoxels = nvoxels(:);
0041 if length(nvoxels) == 1
0042 nvoxels = ones(3,1)*nvoxels;
0043 end
0044
0045 for i = 1:3
0046 f{i} = ones(nvoxels(i)*2+1,1);
0047 end
0048
0049 spm_conv_vol(img,m,f{:},-nvoxels);