Home > phiwave > @phiw_wvimg > write_iwtimg.m

write_iwtimg

PURPOSE ^

iwt on wvimg object, save as img

SYNOPSIS ^

function [iwtvol, obj] = write_iwtimg(obj, iwtvol)

DESCRIPTION ^

 iwt on wvimg object, save as img
 FORMAT [iwtvol, obj] = write_iwtimg(obj, iwtvol)
 
 Input
 obj        - wvimg object
 iwtvol     - image name or vol struct to output
 
 Output
 iwtvol     - written vol struct
 obj        - possibly modified wvimg object

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [iwtvol, obj] = write_iwtimg(obj, iwtvol)
0002 % iwt on wvimg object, save as img
0003 % FORMAT [iwtvol, obj] = write_iwtimg(obj, iwtvol)
0004 %
0005 % Input
0006 % obj        - wvimg object
0007 % iwtvol     - image name or vol struct to output
0008 %
0009 % Output
0010 % iwtvol     - written vol struct
0011 % obj        - possibly modified wvimg object
0012 %
0013 % $Id: write_iwtimg.m,v 1.5 2005/06/05 04:42:22 matthewbrett Exp $
0014 
0015 if nargin < 2
0016   iwtvol = [];
0017 end
0018 if isempty(iwtvol)
0019   error('Need output filename or vol struct');
0020 end
0021 if ischar(iwtvol)
0022   iwtvol = struct('fname',iwtvol); 
0023 end
0024 
0025 if ~obj.wtf
0026   error('Object is not wt''ed');
0027 else
0028   obj = doproc(obj);
0029 end
0030 
0031 % fill missing fields in vol struct first from origincal vol struct
0032 iwtvol = mars_struct('fillafromb', iwtvol, obj.ovol);
0033 
0034 % then get any missing defaults from wvol
0035 iwtvol = mars_struct('fillafromb', iwtvol,obj.wvol);
0036 
0037 % do iwt
0038 if obj.options.verbose
0039   fprintf('Inverting transform on %s...\n', obj.wvol.fname);
0040 end
0041 
0042 % set NaN's to zero...
0043 img = obj.img;
0044 img(isnan(img)) = 0;
0045 
0046 % Do inverse transform
0047 img = invert(img, obj.wavelet, obj.scales, obj.oimgi);
0048 
0049 % set up iwtvol
0050 iwtvol.dim(1:3) = size(img);
0051 iwtvol.descrip = obj.descrip;
0052 
0053 % save (might have to do something about complex images here)
0054 iwtvol = spm_write_vol(iwtvol, img);

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