change neuromag image orientation to RAS orientation [avw] = change_neuromag_ras(mri_fiffile) --- Input mri_fiffile : MRI fiffile. --- Output avw : Analyze data structure
0001 function avw = change_neuromag_ras(mri_fiffile) 0002 % change neuromag image orientation to RAS orientation 0003 % [avw] = change_neuromag_ras(mri_fiffile) 0004 % --- Input 0005 % mri_fiffile : MRI fiffile. 0006 % --- Output 0007 % avw : Analyze data structure 0008 0009 % orient = get_orient_from_rot(R) 0010 % R : rotation matrix from current axis to RAS coordinate 0011 % --- orient 0012 % orient : axis dim to get RAS coordinate 0013 % = [orient_x orient_y orient_z] 0014 % orient_x : Left to Right axis dim of current image 0015 % orient_y : Posterior to Anterior axis dim of current image 0016 % orient_z : Inferior to Superior axis dim of current image 0017 % 0018 % Left to Right 1 0019 % Posterior to Anterior 2 0020 % Inferior to Superior 3 0021 % Right to Left -1 0022 % Anterior to Posterior -2 0023 % Superior to Inferior -3 0024 % 0025 % Copyright (C) 2011, ATR All Rights Reserved. 0026 % License : New BSD License(see VBMEG_LICENSE.txt) 0027 0028 % load voxel data and transform matrix from mri fiffile. 0029 [voxel, trans_info] = neuromag_load_mri_info(mri_fiffile); 0030 0031 % X_mri = R * X_vox 0032 R = trans_info.trans_vox2mri(1:3,1:3)'; 0033 0034 img = change_img_orient_ras(voxel,R); 0035 0036 dim = size(img); 0037 % get scale factor 0038 vsize = max(abs(R),[],2); 0039 0040 avw.img = img; 0041 avw.hdr = []; 0042 0043 avw.hdr.dime.dim(2:4) = dim; 0044 avw.hdr.dime.pixdim(2:4) = 1000 * vsize';