Get transform matrix from voxcel to RAS mm coordinate [Trans] = get_coord_trans_mat(fname) Trans : transform matrix from voxcel to RAS mm coordinate [x y z 1] = [i j k 1] * Trans Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [Trans] = get_coord_trans_mat(fname) 0002 % Get transform matrix from voxcel to RAS mm coordinate 0003 % [Trans] = get_coord_trans_mat(fname) 0004 % Trans : transform matrix from voxcel to RAS mm coordinate 0005 % [x y z 1] = [i j k 1] * Trans 0006 % 0007 % Copyright (C) 2011, ATR All Rights Reserved. 0008 % License : New BSD License(see VBMEG_LICENSE.txt) 0009 0010 [hdr, filetype] = load_nii_hdr(fname); 0011 0012 nii.hdr = hdr; 0013 nii.filetype = filetype; 0014 0015 % get rotation and translation 0016 [orient, R, T] = get_orient_info(nii); 0017 % [x ; y ; z] = R * [i ; j ; k] + T 0018 % [x y z] = [i j k] * R' + T' 0019 % [x y z 1] = [i j k 1] * Trans 0020 0021 Trans = [R' zeros(3,1); T' 1];