Home > marsbar > @mardo > full_vol.m

full_vol

PURPOSE ^

returns vol with full path, from vols, or image names

SYNOPSIS ^

function V = full_vol(D, imgs)

DESCRIPTION ^

 returns vol with full path, from vols, or image names
 FORMAT V = full_vol(D, imgs)

 Input 
 D           - mardo design object
 imgs        - image names or vol structs
 
 Output
 V           - vol structs with full path names
 
 If the filename for the image does not exist, the routine returns an
 empty vol struct - which has the filename set, but all other fields are
 empty

 $Id$

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function V = full_vol(D, imgs)
0002 % returns vol with full path, from vols, or image names
0003 % FORMAT V = full_vol(D, imgs)
0004 %
0005 % Input
0006 % D           - mardo design object
0007 % imgs        - image names or vol structs
0008 %
0009 % Output
0010 % V           - vol structs with full path names
0011 %
0012 % If the filename for the image does not exist, the routine returns an
0013 % empty vol struct - which has the filename set, but all other fields are
0014 % empty
0015 %
0016 % $Id$
0017 
0018 if nargin < 2
0019   error('Need image information');
0020 end
0021 
0022 Swd = swd(D);
0023 if isempty(Swd)
0024   error('Need directory of design; it is missing');
0025 end
0026 
0027 def_struct = mars_vol_utils('def_vol');
0028 
0029 if isempty(imgs)
0030   V = def_struct; 
0031   return
0032 end
0033 
0034 if iscell(imgs)
0035   imgs = char(imgs);
0036 end
0037 if isstruct(imgs) % vol struct, check for absolute path name
0038   V = imgs;
0039   nimgs = prod(size(imgs));
0040   for i = 1:nimgs
0041     fname = V(i).fname;
0042     if ~mars_utils('isabspath', fname);
0043       fname = fullfile(Swd, fname);
0044     end
0045     V(i).fname = fname;
0046   end
0047 elseif ischar(imgs)
0048   for i = 1:size(imgs, 1)
0049     fname = deblank(imgs(i,:));
0050     if ~mars_utils('isabspath', fname)
0051       fname = fullfile(Swd, fname);
0052     end
0053     if exist(fname, 'file')
0054       V(i) = spm_vol(fname);
0055     else
0056       V(i).fname = fname;
0057     end
0058   end  
0059 else
0060   error('Odd input format for images');
0061 end
0062 

Generated on Wed 11-May-2022 16:26:09 by m2html © 2003-2019