0001 function Z = test_vb_calc_current(proj_root,test_parm)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 vb_disp('--- Start: test_vb_calc_current');
0034 resultdir = './vbmeg_result/';
0035
0036
0037
0038
0039
0040 filterfile ...
0041 = [resultdir 'sbj_test_UR_' test_parm.cortex '_' test_parm.data '_' ...
0042 test_parm.method '_' test_parm.prior '_' test_parm.tempwin ...
0043 '.vbfilt.mat'];
0044
0045
0046
0047
0048
0049 curr_parm.overlap_mode = 0;
0050 curr_parm.ix_area = [];
0051 curr_parm.trial_average = false;
0052 curr_parm.ix_trial = 1;
0053 curr_parm.tsubsmpl = [];
0054
0055
0056
0057
0058
0059 load(filterfile,'VBfilt','bayes_parm')
0060
0061
0062
0063
0064
0065 [Z,W,Jinfo] = vb_calc_current(proj_root,VBfilt,bayes_parm,curr_parm);
0066 ix_act = Jinfo.ix_act;
0067 ix_act_ex = Jinfo.ix_act_ex;
0068 Ztmp = Z(:,551:650,:);
0069
0070
0071
0072
0073
0074 VBfilt2 = VBfilt;
0075 bexp{1} = vb_load_meg_data(bayes_parm.megfile{1});
0076 vb_struct2vars(bayes_parm,{'twin_meg','Tperiod','Tnext'});
0077 bexp{1} = bexp{1}(:,twin_meg(1):twin_meg(2),:);
0078 VBfilt2.Ntrial(1) = size(bexp{1},3);
0079 VBfilt2.Tsample = twin_meg(2)-twin_meg(1)+1;
0080 VBfilt2.Twindow = vb_calc_timewindow(VBfilt2.Tsample,Tperiod,Tnext);
0081 Z2 = vb_calc_current(proj_root,VBfilt2,bexp,curr_parm);
0082 d = sqrt(sum(sum((Z-Z2).^2))/sum(sum(Z.^2)));
0083 vb_disp_nonl(['Difference with ''bexp'' usage: ' sprintf('%1.3f\n',d)]);
0084
0085
0086
0087
0088
0089 brainfile ...
0090 = [proj_root resultdir 'sbj_test_' test_parm.cortex '.brain.mat'];
0091 [V,F,xx,inf_C] = vb_load_cortex(brainfile,'Inflate');
0092
0093 J = zeros(size(V,1),1);
0094 J(ix_act_ex) = sqrt(sum((W*Ztmp).*(W*Ztmp),2));
0095 vb_disp(['Cortical model vertices: ' num2str(size(V,1))]);
0096 vb_disp(['J-current vertices : ' num2str(length(ix_act_ex))]);
0097 vb_disp(['Z-current vertices : ' num2str(length(ix_act))]);
0098 vb_disp(['Sample time points : ' num2str(size(Z,2))]);
0099
0100
0101
0102
0103
0104 figure;
0105 subplot(3,2,[1 2]);
0106 plot(Z');
0107
0108
0109
0110
0111
0112 subplot(3,2,3);
0113 plot_parm = vb_set_plot_parm;
0114 plot_parm.LRflag = 'L';
0115 vb_plot_cortex(plot_parm,V,F,inf_C,J);
0116 view([-90 0]);
0117 axis equal;
0118 axis off;
0119 axis tight;
0120
0121 subplot(3,2,4);
0122 plot_parm = vb_set_plot_parm;
0123 plot_parm.LRflag = 'R';
0124 vb_plot_cortex(plot_parm,V,F,inf_C,J);
0125 view([90 0]);
0126 axis equal;
0127 axis off;
0128 axis tight;
0129
0130 subplot(3,2,5);
0131 plot_parm = vb_set_plot_parm;
0132 plot_parm.LRflag = 'L';
0133 vb_plot_cortex(plot_parm,V,F,inf_C,J);
0134 view([90 0]);
0135 axis equal;
0136 axis off;
0137 axis tight;
0138
0139 subplot(3,2,6);
0140 plot_parm = vb_set_plot_parm;
0141 plot_parm.LRflag = 'R';
0142 vb_plot_cortex(plot_parm,V,F,inf_C,J);
0143 view([-90 0]);
0144 axis equal;
0145 axis off;
0146 axis tight;
0147
0148 vb_disp('--- End : test_vb_calc_current');
0149
0150 return;