Home > phiwave > @phido > private > pr_expand.m

pr_expand

PURPOSE ^

expand (probably binary) image by 'nvoxels' no of voxels

SYNOPSIS ^

function m = pr_expand(img, nvoxels, outvol)

DESCRIPTION ^

 expand (probably binary) image by 'nvoxels' no of voxels

 Inputs
 img            - matrix, or image name, or vol struct
 nvoxels        - number of voxels to expand by
 outvol         - output image name or vol struct to write

 Outputs
 m              - matrix, or vol struct output

 $Id: pr_expand.m,v 1.2 2005/06/05 04:42:22 matthewbrett Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function m = pr_expand(img, nvoxels, outvol)
0002 % expand (probably binary) image by 'nvoxels' no of voxels
0003 %
0004 % Inputs
0005 % img            - matrix, or image name, or vol struct
0006 % nvoxels        - number of voxels to expand by
0007 % outvol         - output image name or vol struct to write
0008 %
0009 % Outputs
0010 % m              - matrix, or vol struct output
0011 %
0012 % $Id: pr_expand.m,v 1.2 2005/06/05 04:42:22 matthewbrett Exp $
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);

Generated on Wed 06-Jul-2005 18:07:21 by m2html © 2003