vb_job_dipole --- Input megfile Nopt : 最適化最大繰り返し回数 mode : Minimization mode =0 : fminsearch =1 : fminunc Vinit : initial dipole position (Ndipole x 3) --- Output Vopt : ダイポールの位置座標 (Ndipole x 3) err : 正規化誤差 iter : iteration number Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 % vb_job_dipole 0002 % --- Input 0003 % megfile 0004 % Nopt : 最適化最大繰り返し回数 0005 % mode : Minimization mode 0006 % =0 : fminsearch 0007 % =1 : fminunc 0008 % Vinit : initial dipole position (Ndipole x 3) 0009 % --- Output 0010 % Vopt : ダイポールの位置座標 (Ndipole x 3) 0011 % err : 正規化誤差 0012 % iter : iteration number 0013 % 0014 % Copyright (C) 2011, ATR All Rights Reserved. 0015 % License : New BSD License(see VBMEG_LICENSE.txt) 0016 0017 megfile =''; 0018 Nopt = 1000; 0019 mode = 1; 0020 0021 % set time window & trial number to estimate 0022 trial_id = [1:2]; 0023 t_begin = 1; 0024 t_end = 100; 0025 0026 Vinit = [0 0 0]; 0027 0028 % Error function name for dipole search 0029 %errfunc = 'vb_dipole_error'; % for external current (Biot-Savart Eq.) 0030 errfunc = 'vb_dipole_error_sarvas';% for cortical current (Sarvas Eq.) 0031 0032 % Load sensor info 0033 [pick,Qpick,Wsensor,V0] = vb_load_sensor(meg_file); 0034 0035 % Change center of coordinate 0036 pick = [pick(:,1)-V0(1), pick(:,2)-V0(2), pick(:,3)-V0(3)]; 0037 0038 % Load MEG data 0039 bexp = vb_load_meg_data(megfile); 0040 0041 bexp = bexp(:, t_begin:t_end, trial_id); 0042 [N, T, M] = size(bexp); 0043 0044 bexp = reshape(bexp, [N , T*M]); 0045 0046 % dipole search 0047 [Vopt, err, iter] = ... 0048 vb_dipole_search(Vinit(:), bexp, pick, Qpick, Wsensor, Nopt, mode, errfunc); 0049 0050 % Right-hand SPM (m) coordinate 0051 Vopt = [ V(:,1)+V0(1), Vopt(:,2)+V0(2), Vopt(:,3)+V0(3)];