0001 function [B, Model, nGact, nGall, nGGall, Cov, bsnorm, ix_act, ix_bck, ...
0002 vb_parm, Wact, Wbck, ix_act_ex, ix_bck_ex] ...
0003 = vb_load_result_z(proj_root, resultfile, ix_area)
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 if ~isempty(proj_root)
0025 resultfile = fullfile(proj_root, resultfile);
0026 end
0027
0028 load(resultfile, 'bayes_parm','Model','Cov','vb_parm');
0029
0030 if ~isempty(proj_root);
0031 bayes_parm_abs = vb_parm_absolute_path(proj_root, bayes_parm);
0032 else
0033 bayes_parm_abs = bayes_parm;
0034 end
0035
0036 if isfield(bayes_parm_abs,'remove_crossed_area'),
0037 remove_crossed_area = bayes_parm_abs.remove_crossed_area;
0038 else
0039 remove_crossed_area = OFF;
0040 end
0041
0042
0043 [B] = vb_megdata_preparation(bayes_parm_abs);
0044
0045
0046
0047 [nGall, bsnorm, ix_global, ix_global_ex, Wbck, Lbck] = ...
0048 vb_global_leadfield_preparation(bayes_parm_abs);
0049 [nGact, ix_focal, ix_focal_ex, Wact, Lact] = ...
0050 vb_focal_leadfield_preparation(bayes_parm_abs, bsnorm);
0051
0052 if remove_crossed_area == ON,
0053
0054 switch bayes_parm_abs.forward_model
0055 case 'focal+global',
0056 [nGall, bstmp, ix_global, ix_global_ex, Wbck, Lbck] = ...
0057 vb_global_leadfield_preparation(bayes_parm_abs, bsnorm, ON );
0058 case 'focal',
0059 ix_global = [];
0060 ix_global_ex = [];
0061 end
0062 end
0063
0064
0065
0066
0067 A_inv = sum(Model.a , 2);
0068 Nvact = vb_parm.Nvact;
0069 Nact = length(A_inv);
0070 L = Nact/Nvact;
0071 Lact = vb_parm.Norient;
0072
0073 if bayes_parm_abs.variance_orientation == ON
0074 A_inv = reshape(A_inv, [Nvact L]);
0075 A_inv = sum( A_inv ,2);
0076 end
0077
0078
0079 ix_act_nz = find( A_inv > 0 );
0080 ix_focal_nz = ix_focal(ix_act_nz);
0081
0082
0083 if isempty(ix_area),
0084 ix_area = ix_focal;
0085
0086 end
0087
0088
0089 [j_tmp, ix_area_nz] = vb_index2indexsub(ix_area, ix_focal_nz);
0090
0091
0092
0093
0094
0095
0096
0097
0098 [j_act, ix_act] = vb_index2indexsub(ix_area_nz, ix_focal);
0099
0100
0101 if remove_crossed_area == OFF
0102
0103 [k_bck, ix_bck] = vb_index2indexsub(ix_area_nz, ix_global);
0104 else
0105 [k_bck, ix_bck] = vb_index2indexsub(ix_area, ix_global);
0106 end
0107
0108
0109
0110
0111 Nvact_area = length(ix_act);
0112 Njact_area = Nvact_area * Lact;
0113
0114
0115 Lbck = vb_parm.Norient_all;
0116 Nvall = length(ix_global);
0117 Nvall_area = length(ix_bck);
0118 Njall_area = Nvall_area* Lbck ;
0119
0120
0121 a_inv = Model.a;
0122 Nwin = size(a_inv,2);
0123
0124 if bayes_parm_abs.variance_orientation == ON
0125 jj_act = repmat(j_act(:), [1 L]) ...
0126 + repmat((0:(L-1))*Nvact, [Nvact_area 1]);
0127 else
0128 jj_act = j_act;
0129 end
0130
0131 Model.a = a_inv(jj_act(:),:);
0132
0133 vb_parm.Njact_area = Njact_area;
0134 vb_parm.Njall_area = Njall_area;
0135
0136 Nsession = vb_parm.Nsession;
0137
0138
0139 jj_act = repmat(j_act(:), [1 Lact]) ...
0140 + repmat((0:(Lact-1))*Nvact, [Nvact_area 1]);
0141 kk_bck = repmat(k_bck(:), [1 Lbck]) ...
0142 + repmat((0:(Lbck-1))*Nvall, [Nvall_area 1]);
0143
0144 for n = 1 : Nsession
0145 G = nGact{n};
0146 Gb = nGall{n};
0147
0148 nGact{n} = G(:, jj_act(:));
0149 nGall{n} = Gb(:, kk_bck(:));
0150 nGGall{n} = Gb * Gb';
0151 end
0152
0153
0154 Wact = Wact(:,j_act);
0155 Wbck = Wbck(:,k_bck);
0156
0157 j_act_ex = find( sum(Wact,2) > 0);
0158 k_bck_ex = find( sum(Wbck,2) > 0);
0159
0160
0161
0162
0163 ix_act_ex = ix_focal_ex(j_act_ex);
0164 ix_bck_ex = ix_global_ex(k_bck_ex);
0165
0166 Wact = Wact(j_act_ex,:);
0167 Wbck = Wbck(k_bck_ex,:);
0168
0169 fprintf('# of active vertex = %d\n', Nvact_area)
0170 fprintf('# of active current = %d\n', Njact_area)
0171
0172 fprintf('# of background vertex = %d\n', Nvall_area)
0173 fprintf('# of background current = %d\n', Njall_area)
0174
0175 fprintf('# of extended active vertex = %d\n', length(ix_act_ex))
0176 fprintf('# of extended background vertex = %d\n', length(ix_bck_ex))
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191