load neuromag mri-fiffile. [USAGE] [voxel, mri_trans_info] = neuromag_load_mri_info(<fiffile>); [IN] fiffile : neuromag MRI fiffile. [OUT] voxel : Voxel data in MRI fiffile. [X x Y x Z uint8] mri_trans_info .trans_head2mri : [4 x 4 double] : transformation matrix (HEAD ==> MRI(usually DICOM)) .trans_head2vox : [4 x 4 double] : transformation matrix (HEAD ==> Voxel) .trans_vox2mri : [4 x 4 double] : transformation matrix (VOXEL ==> MRI(usually DICOM)) rH : position in Head coordinate rM : position in MRI coordinate rV : position in Voxel coordinate [rM 1] = [rH 1] * trans_head2mri; [rM 1] = [rV 1] * trans_vox2mri; [rV 1] = [rH 1] * trans_head2vox; Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [voxel, mri_trans_info] = neuromag_load_mri_info(fiffile) 0002 % load neuromag mri-fiffile. 0003 % [USAGE] 0004 % [voxel, mri_trans_info] = neuromag_load_mri_info(<fiffile>); 0005 % [IN] 0006 % fiffile : neuromag MRI fiffile. 0007 % [OUT] 0008 % voxel : Voxel data in MRI fiffile. [X x Y x Z uint8] 0009 % mri_trans_info 0010 % .trans_head2mri : [4 x 4 double] 0011 % : transformation matrix (HEAD ==> MRI(usually DICOM)) 0012 % .trans_head2vox : [4 x 4 double] 0013 % : transformation matrix (HEAD ==> Voxel) 0014 % .trans_vox2mri : [4 x 4 double] 0015 % : transformation matrix (VOXEL ==> MRI(usually DICOM)) 0016 % 0017 % rH : position in Head coordinate 0018 % rM : position in MRI coordinate 0019 % rV : position in Voxel coordinate 0020 % 0021 % [rM 1] = [rH 1] * trans_head2mri; 0022 % [rM 1] = [rV 1] * trans_vox2mri; 0023 % [rV 1] = [rH 1] * trans_head2vox; 0024 % 0025 % Copyright (C) 2011, ATR All Rights Reserved. 0026 % License : New BSD License(see VBMEG_LICENSE.txt) 0027 0028 % 0029 % --- Previous check 0030 % 0031 if ~exist('fiffile', 'var') || exist(fiffile, 'file') ~= 2 0032 error('invalid fiffile was specified.'); 0033 end 0034 0035 % 0036 % --- Get MRI Data 0037 % 0038 hdr = fiff_read_mri(fiffile); 0039 voxel_t = cat(3, hdr.slices.data); 0040 voxel = permute(voxel_t, [2 1 3]); 0041 0042 trans_vox2mri = hdr.voxel_trans.trans; 0043 trans_head2mri = hdr.trans.trans; 0044 0045 0046 % [rM 1] = [rH 1] * trans_head2mri'; 0047 % [rM 1] = [rV 1] * trans_vox2mri'; 0048 % [rV 1] = [rM 1] / trans_vox2mri'; 0049 % [rV 1] = [rH 1] * trans_head2vox; 0050 % trans_head2vox = trans_head2mri' / trans_vox2mri'; 0051 0052 mri_trans_info = struct; 0053 mri_trans_info.trans_head2mri = trans_head2mri'; 0054 mri_trans_info.trans_head2vox = trans_head2mri' / trans_vox2mri'; 0055 mri_trans_info.trans_vox2mri = trans_vox2mri';