Home > vbmeg > functions > tool_box > atlas2vb_dir > vb_get_image_info.m

vb_get_image_info

PURPOSE ^

Read image header & get mm coordinate centered at origin

SYNOPSIS ^

function [dim, Trans, XYZmm] = vb_get_image_info(fname)

DESCRIPTION ^

 Read image header & get mm coordinate centered at origin
  [dim, Trans, XYZmm] = vb_get_image_info(fname)
 --- Input
 fname : analyze file name
 --- Output
 dim(1:3) : XYZ-image dimension
 Trans : affine transformation from voxcel coord. to mm-coord at origin
 XYZmm = Trans * [XYZvox ; ones(1,Npoint)];
       : mm coordinate centered at origin

% 2006/11/14 M.Sato

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function    [dim, Trans, XYZmm] = vb_get_image_info(fname)
0002 % Read image header & get mm coordinate centered at origin
0003 %  [dim, Trans, XYZmm] = vb_get_image_info(fname)
0004 % --- Input
0005 % fname : analyze file name
0006 % --- Output
0007 % dim(1:3) : XYZ-image dimension
0008 % Trans : affine transformation from voxcel coord. to mm-coord at origin
0009 % XYZmm = Trans * [XYZvox ; ones(1,Npoint)];
0010 %       : mm coordinate centered at origin
0011 %
0012 %% 2006/11/14 M.Sato
0013 %
0014 % Copyright (C) 2011, ATR All Rights Reserved.
0015 % License : New BSD License(see VBMEG_LICENSE.txt)
0016 
0017 %fprintf('DEBUG\n')
0018 
0019 % Read image-header
0020 [dim, vox, origin] = analyze_hdr_read(fname);
0021 
0022 % origin in voxcel-space -> origin in MNI-mm space
0023 origin = vox(:) .* origin(:);
0024 
0025 Trans  = [vox(1) 0 0 -origin(1) ; ...
0026           0 vox(2) 0 -origin(2) ; ...
0027           0 0 vox(3) -origin(3) ; ...
0028           0 0      0    1     ];
0029 
0030 % XYZmm - 3 x n matrix of XYZ locations
0031 %          mm-coordinates in atlas-template (origin in MNI-space)
0032 [X,Y,Z] = ndgrid(1:dim(1),1:dim(2),1:dim(3));
0033 
0034 XYZmm   = [vox(1)*X(:)' - origin(1); ...
0035            vox(2)*Y(:)' - origin(2); ...
0036            vox(3)*Z(:)' - origin(3)];
0037 
0038 clear X Y Z

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005