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

pr_wvmask

PURPOSE ^

returns wavelet eqivalent mask for given voxel mask

SYNOPSIS ^

function wtobj = pr_wvmask(voxmask, params, options)

DESCRIPTION ^

 returns wavelet eqivalent mask for given voxel mask
 FORMAT wtobj = pr_wvmask(voxmask, params, options)

 Inputs
 voxmask     - voxel mask image name / vol struct
 params      - struct with wavelet and other parameters
               Fields:
                 scales     - wavelet scales
                 wavelet    - phiw_wavelet object
                 maskthresh - threshold for mask
               and any other options that may be useful for the
               phiw_wvimg object (see phiw_wvimg constructor)
 options     - any other options for creation of phiw_wvimg object
 
 Outputs
 wtobj       - phiw_wvimg object with transformed mask
 
 $Id: pr_wvmask.m,v 1.5 2005/06/18 17:53:56 matthewbrett Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function wtobj = pr_wvmask(voxmask, params, options)
0002 % returns wavelet eqivalent mask for given voxel mask
0003 % FORMAT wtobj = pr_wvmask(voxmask, params, options)
0004 %
0005 % Inputs
0006 % voxmask     - voxel mask image name / vol struct
0007 % params      - struct with wavelet and other parameters
0008 %               Fields:
0009 %                 scales     - wavelet scales
0010 %                 wavelet    - phiw_wavelet object
0011 %                 maskthresh - threshold for mask
0012 %               and any other options that may be useful for the
0013 %               phiw_wvimg object (see phiw_wvimg constructor)
0014 % options     - any other options for creation of phiw_wvimg object
0015 %
0016 % Outputs
0017 % wtobj       - phiw_wvimg object with transformed mask
0018 %
0019 % $Id: pr_wvmask.m,v 1.5 2005/06/18 17:53:56 matthewbrett Exp $
0020   
0021 if nargin < 1
0022   voxmask = spm_get(1,'img','Voxel mask');
0023 end
0024 if nargin < 2
0025   params = [];
0026 end
0027 if nargin < 3
0028   options = [];
0029 end
0030 
0031 params = mars_struct('ffillmerge', params, options);
0032 
0033 def_struct = struct('scales',1, ...
0034             'wavelet',phiw_wavelet, ...
0035             'maskthresh', 0.05, ...
0036             'datatype','uint8');
0037 
0038 params = mars_struct('ffillmerge', def_struct, params);
0039 
0040 if ischar(voxmask),voxmask=spm_vol(voxmask);end
0041 
0042 % get unity wavelet
0043 wv1 = unitywavelet(params.wavelet);
0044 
0045 % wt voxel mask
0046 wtobj = phiw_wvimg(voxmask, ...
0047            params, ...
0048            wv1, ...
0049            params.scales);
0050 
0051 % levels, quadrants
0052 img_dims = size(wtobj.img);
0053 [tmp qs nquads] = levels(wv1, img_dims, params.scales);
0054 
0055 % expand by width of wavelet for all 3 dimensions
0056 for d = 1:length(img_dims)
0057   ex(d) = width(params.wavelet, img_dims(d));
0058 end
0059 
0060 % cycle over blocks to do smoothing
0061 for l = 1:params.scales+1
0062   if l > params.scales
0063     % at top level -> only one quadrant
0064     nquads = 2;
0065   end
0066   dims = phiw_lims('dims', qs{l}{1});
0067   for q = 1:nquads-1
0068     dblk = reshape(wtobj(l,q),dims);
0069     wtobj(l,q) = pr_expand(dblk,ex);
0070   end
0071 end
0072 
0073 % rebinarize
0074 wtobj.img(wtobj.img>params.maskthresh) = 1;

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