0001 function [B, Model, nGact, nGall, nGGall, Cov, Wact, Wbck, ...
0002 bsnorm, ix_act, ix_bck, vb_parm] ...
0003 = vb_load_result(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 [nGall, bsnorm, ix_global, ix_global_ex, Wall, Lbck] = ...
0047 vb_global_leadfield_preparation(bayes_parm_abs);
0048 [nGact, ix_focal, ix_focal_ex, Wact, Lact] = ...
0049 vb_focal_leadfield_preparation(bayes_parm_abs, bsnorm);
0050
0051 if remove_crossed_area == ON,
0052
0053 switch bayes_parm_abs.forward_model
0054 case 'focal+global',
0055 [nGall, bstmp, ix_global, ix_global_ex, Wall, Lbck] = ...
0056 vb_global_leadfield_preparation(bayes_parm_abs, bsnorm, ON );
0057 case 'focal',
0058 ix_global_ex = [];
0059 end
0060 end
0061
0062
0063
0064
0065 A_inv = sum(Model.a , 2);
0066 Nvact = vb_parm.Nvact;
0067
0068
0069 if bayes_parm_abs.variance_orientation == ON
0070 A_inv = reshape(A_inv, [Nvact Lact]);
0071 W = sum( Wact * A_inv ,2);
0072 else
0073 W = Wact*A_inv;
0074 end
0075
0076
0077 ix_act_nz = find( W > 0 );
0078 ix_focal_nz = ix_focal_ex(ix_act_nz);
0079
0080
0081 if isempty(ix_area),
0082 ix_area = ix_focal;
0083
0084 end
0085
0086
0087 [j_tmp, ix_area_nz] = vb_index2indexsub(ix_area, ix_focal_nz);
0088
0089
0090
0091
0092
0093
0094
0095
0096 [j_act, ix_act] = vb_index2indexsub(ix_area_nz, ix_focal_ex);
0097
0098
0099 if remove_crossed_area == OFF
0100
0101 [k_bck, ix_bck] = vb_index2indexsub(ix_area_nz, ix_global_ex);
0102 else
0103 [k_bck, ix_bck] = vb_index2indexsub(ix_area, ix_global_ex);
0104 end
0105
0106
0107 Lact = vb_parm.Norient;
0108 Lact_var = vb_parm.Norient_var;
0109 Njact = vb_parm.Njact;
0110 Nvact_area = length(ix_act);
0111 Njact_area = Nvact_area * Lact;
0112
0113
0114 Lbck = vb_parm.Norient_all;
0115 Nvall = length(ix_global);
0116 Nvall_area = length(ix_bck);
0117 Njall_area = Nvall_area* Lbck ;
0118
0119 vb_parm.Njact_area = Njact_area;
0120 vb_parm.Njall_area = Njall_area;
0121
0122 fprintf('# of active current vertex = %d\n', Nvact_area)
0123 fprintf('# of background vertex = %d\n', Nvall_area)
0124
0125 Nsession = vb_parm.Nsession;
0126
0127
0128 for n = 1 : Nsession
0129 nGGall{n} = nGall{n}*nGall{n}';
0130 end
0131
0132
0133 Wact = Wact(j_act,:);
0134 Wbck = Wall(k_bck,:);
0135
0136
0137
0138 for n=1:Nsession
0139 Gb = nGall{n};
0140 Nch = size(Gb,1);
0141
0142 GbW = reshape(Gb, [Nch*Lbck Nvall]) * Wbck';
0143 GbW = reshape(GbW, [Nch Lbck*Nvall_area]);
0144
0145 nGall{n} = GbW;
0146 end
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158 clear Gb;