Home > SurfStat > SurfStatWriteVol.m

SurfStatWriteVol

PURPOSE ^

wtites volumetric data to files in MINC, ANALYZE, NIFTI or AFNI format.

SYNOPSIS ^

function SurfStatWriteVol( filenames, data, vol );

DESCRIPTION ^

wtites volumetric data to files in MINC, ANALYZE, NIFTI or AFNI format. 

 Usage: SurfStatWriteVol( filenames, data, vol );

 filenames  = single file name with extension .mnc, .img, .nii or .brik as 
              above (3D if k=1, 4D if k>1), or cell array of k 3D files. 
 data       = k x v matrix of data, v=#vertices.
 vol.lat    = nx x ny x nz array, 1=in, 0=out, clamped to the mask.
 vol.vox    = 1 x 3 vector of voxel sizes in mm of the clamped mask.
 vol.origin = position in mm of the first voxel of the clamped mask.
 vol.parent = header info from SurfStatReadVol1.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function SurfStatWriteVol( filenames, data, vol );
0002 
0003 %wtites volumetric data to files in MINC, ANALYZE, NIFTI or AFNI format.
0004 %
0005 % Usage: SurfStatWriteVol( filenames, data, vol );
0006 %
0007 % filenames  = single file name with extension .mnc, .img, .nii or .brik as
0008 %              above (3D if k=1, 4D if k>1), or cell array of k 3D files.
0009 % data       = k x v matrix of data, v=#vertices.
0010 % vol.lat    = nx x ny x nz array, 1=in, 0=out, clamped to the mask.
0011 % vol.vox    = 1 x 3 vector of voxel sizes in mm of the clamped mask.
0012 % vol.origin = position in mm of the first voxel of the clamped mask.
0013 % vol.parent = header info from SurfStatReadVol1.
0014 
0015 n=size(vol.lat);
0016 m=zeros(n);
0017 if ~isfield(vol,'parent_file')
0018     d=vol.parent;
0019 end
0020 d.data=zeros(d.dim(1:3));
0021 step=round(vol.vox./d.vox);
0022 s=round((vol.origin-d.origin)./d.vox)+1;
0023 [k,v]=size(data);
0024 for i=1:k
0025     m(vol.lat)=data(i,:);
0026     d.data(s(1)+(0:n(1)-1)*step(1),s(2)+(0:n(2)-1)*step(2),...
0027         s(3)+(0:n(3)-1)*step(3))=m;
0028     if isstr(filenames)
0029         d.file_name=filenames;
0030         SurfStatWriteVol1(d,1:d.dim(3),i);
0031     else
0032         d.file_name=filenames{i};
0033         SurfStatWriteVol1(d,1:d.dim(3),1);
0034     end
0035 end
0036 
0037 return
0038 end
0039 
0040 
0041 
0042 
0043 
0044

Generated on Fri 26-Sep-2008 14:05:29 by m2html © 2003