Home > bioelectromagnetism > avw_metric.m

avw_metric

PURPOSE ^

AVW_METRIC - Convert image location from CRS to meters

SYNOPSIS ^

function [XYZm] = avw_metric(hdr,XYZimg)

DESCRIPTION ^

 AVW_METRIC - Convert image location from CRS to meters

 Useage:  XYZm = avw_metric(hdr,XYZimg)

 hdr    - avw.hdr from avw_hdr_read
 XYZimg - Nx3 matrix of image coordinates
 XYZm   - Nx3 matrix of image meter coordinates (not mm)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [XYZm] = avw_metric(hdr,XYZimg)
0002 
0003 % AVW_METRIC - Convert image location from CRS to meters
0004 %
0005 % Useage:  XYZm = avw_metric(hdr,XYZimg)
0006 %
0007 % hdr    - avw.hdr from avw_hdr_read
0008 % XYZimg - Nx3 matrix of image coordinates
0009 % XYZm   - Nx3 matrix of image meter coordinates (not mm)
0010 %
0011 
0012 % $Revision: 1.1 $ $Date: 2004/11/12 01:30:25 $
0013 
0014 % Licence:  GNU GPL, no express or implied warranties
0015 % History:  06/2002, Darren.Weber@flinders.edu.au
0016 %
0017 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0018 
0019 if isempty(XYZimg), error('XYZimg is empty'); end;
0020 if isempty(hdr),    error('hdr is empty'); end;
0021 
0022 if size(XYZimg,2) ~= 3,
0023     msg = sprintf('AVW_METRIC: XYZimg must be Nx3 matrix\n');
0024     error(msg);
0025 end
0026 
0027 XYZpixdim = double(hdr.dime.pixdim(2:4));
0028 
0029 if findstr(hdr.dime.vox_units,'mm'),
0030     fprintf('AVW_METRIC: voxel units: mm\n');
0031     XYZpixdim = XYZpixdim ./ 1000;
0032 end
0033 if findstr(hdr.dime.vox_units,'cm'),
0034     fprintf('AVW_METRIC: voxel units: cm\n');
0035     XYZpixdim = XYZpixdim ./ 100;
0036 end
0037 
0038 XYZpixdim = repmat(XYZpixdim,size(XYZimg,1),1);
0039 
0040 
0041 XYZm = XYZimg .* XYZpixdim;
0042 
0043 return

Generated on Mon 15-Aug-2005 15:36:19 by m2html © 2003