Home > utility > feReplaceImageValues.m

feReplaceImageValues

PURPOSE ^

Takes a 3/4D image (img, like a dwi data file) and

SYNOPSIS ^

function img = feReplaceImageValues(img,vals,coords,indexes)

DESCRIPTION ^

 Takes a 3/4D image (img, like a dwi data file) and 
 replaces the values of the image at the coordinates (coords)
 with the values in vals.
 
   img  = feReplaceImageValues(img,vals,coords,indexes) 

 img:     img volume.
 vals:    A list of N values that will be placed into the img volume
 coords:  Nx3 matrix of coordinates in the volume.

 indexes is a subset of the 4th dimension of img if img is a 4D file. For
 example it helsp addressing the diffusion directions and not the b0
 images in the data set. Default is 1:size(img,4).

 Copyright (2013-2014), Franco Pestilli, Stanford University, pestillifranco@gmail.com.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function img = feReplaceImageValues(img,vals,coords,indexes)
0002 % Takes a 3/4D image (img, like a dwi data file) and
0003 % replaces the values of the image at the coordinates (coords)
0004 % with the values in vals.
0005 %
0006 %   img  = feReplaceImageValues(img,vals,coords,indexes)
0007 %
0008 % img:     img volume.
0009 % vals:    A list of N values that will be placed into the img volume
0010 % coords:  Nx3 matrix of coordinates in the volume.
0011 %
0012 % indexes is a subset of the 4th dimension of img if img is a 4D file. For
0013 % example it helsp addressing the diffusion directions and not the b0
0014 % images in the data set. Default is 1:size(img,4).
0015 %
0016 % Copyright (2013-2014), Franco Pestilli, Stanford University, pestillifranco@gmail.com.
0017 
0018 % If index is not passed, then copy the data into all of the slots in the
0019 % 4th dimension
0020 if notDefined('indexes'),   indexes = 1:size(img,4); end
0021 if ~( length(indexes) <= size(img,4) )
0022   error('Image and vals do not have the same size.')
0023 end
0024 
0025 if ~( size(vals,2) == size(coords,1) )
0026   error('Vals and coords do not have the same size.')
0027 end
0028 
0029 if ~( length(indexes) == size(vals,1) )
0030   error('Image and vals do not have the same size.')
0031 end
0032 
0033 for ic = 1:size(coords,1)
0034   img(coords(ic,1),coords(ic,2),coords(ic,3),indexes)   = vals(:,ic);
0035 end
0036 
0037 end

Generated on Wed 16-Jul-2014 19:56:13 by m2html © 2005