=====  VBMEG ꡼Ρ

С0.50a_0
CVSversion_0_5_0_a_0

=====  CVS

CVSROOT
  :pserver:username@lobule2:/home/cnb/rhayashi/cvs_repository/vbmeg_genesis


====== С(0.41)νѹ

1.VBѹ
2.եɲ
3.Ǿǥ˴ؤѹ
4.ǾǥκɸѴν 
5.GUIѹ
6.job_current_trλѹ
7.¾ѹ

============ 1.VBѹ

ˡΤޤȤ (job_vb)  ver 0.5

١饤ưٿѹ
bayes_parm.forward_model = 'focal' λ
    ١饤ư٤ꤹglobal_region = focal_region Ȥ
    VBˤglobal_region̵Τǡfocal_regionȤ

bayes_parm.forward_model = 'focal+global' λ
    global_region  focal_region 
    global_region  focal_region δĤ򤱤

bayes_parm.remove_crossed_area = ON ǰʾѹ¹
  bayes_parm.remove_crossed_area = OFF ǡư

ʾѹ򤹤뤿ˡvb_leadfield_preparation
  vb_focal_leadfield_preparationvb_global_leadfield_preparationʬ

ʾѹбơvbmeg_current_reconstruct ⽤

ʬѥ᥿μư
bayes_parm.a0_act = [] λ
  a0_act Bayes Wiener (vbmeg_multi_fmri)Ǽưꤹ褦ˤ

a0_act ͤꤵ줿ϡƱ

1ƥåס
  fMRIѥη ƻ Bayes Wiener ǵ

2ƥåס
  1ƥåפǷ׻ήʬȤѤVB

ʣfMRIѥǽ
  ʣfMRIѥνŤ͹碌ήʬɽνŤߤ
  alpha = v0 + sum_n a0(n) * fMRI(n)^2
  Ȥơ١饤ư v0 ϸꤷơa0(n) 
  ƻǤνŤߤϰۤʤ

եȤVBMEG
  ܺ٤̤˵

ؿ cortex_normal_variance BVǥǤζ˵ˡʬ׻

VBι§ν

ǽVB§ȤȾ˹®§Ȥ褦ѹ

bayes_parm.Npre_train : ǽVB§Ȥ
bayes_parm.Ntrain     : 

ƴؿμѹ

job_vb
% Wiener estimation for hyper-prior parameter 'a0_act'
% Set  'global area' = 'focal area' in 'focal' model
% Remove focal area from global area

vb_set_vb_parm
% VB estimation parameteres 'vb_parm' are set based on 'bayes_parm'
% Input arguments are modified

set_multiple_prior
% Set (multiple) fMRI activity pattern(s) for Bayes Wiener estimate

set_vb_prior
% Set prior hyperparameter using fMRI activity pattern  or Wiener estimate

vbmeg_multi_fmri
% Bayesian Wiener estimation for MEG. 
% Current variance is represented by mixture of fMRI patterns
% Weight coefficient for each fMRI pattern is estimated

vbmeg_ard_estimate2
% VB-update equation is used for iteration <= Npre_train
% Soft normal constraint is implemented

vb_baseline_variance_acquisition
% vbmeg_multi_fmri is used for baseline estimation


============ 2.եɲ

եλȤ ver 0.5 ( For advanced user)

եѥ꡼ɥեɤκ

ˡʿѷ׻ե饰 average mode for normal direction
basis_parm.normal_mode
    = NORMAL_ADJACENT_MEAN = 0 : ˡʿ(׻ˡ)
    = NORMAL_NEIGHBOR_MEAN = 1 : BVǾǥ˵ˡʿ

եVBꤹ뤿ˤϡʲǥ꡼ɥեɤ
basis_parm.Basis_mode  = CURRENT_3D % Ωˡ3
basis_parm.normal_mode = NORMAL_NEIGHBOR_MEAN

եȤVBMEG

եե饰 : bayes_parm.soft_mode

ϡ (ˡ : Default)
bayes_parm.soft_mode = 0;  
bayes_parm.variance_orientation = OFF;  

ե
bayes_parm.soft_mode = 1;
bayes_parm.variance_orientation = ON;  

եȤϸ§ȤǾǥѤ
  ץɸǾǥȤäƤʤ

եΥ꡼ɥեå

bayes_parm.soft_mode = 1 λGUI å
basis_parm.Basis_mode = 3  basis_parm.normal_mode = 1  å
[Norient, normal_mode] = load_basis_info(basisfile);

եʬѥ᥿
̤פ路ʤϤѤƻ

% tangential variance coefficient
bayes_parm.tan_var = 1 (Default)
% tangential variance max
bayes_parm.var_max = 1/sqrt(2) (Default)
% ˡʬ  1 Ȥ
% ʬ = sin( tan_var * ʿˡγʿ) <= var_max


============ 3.Ǿǥ˴ؤѹ

 job_brain, job_leadfield ν  ver 0.5

job_brainǤνɲ

֥쥤ܥ㡼(Freesurfer)ǾǥγĺǺǤᤤ
  Ǿǥɸᡢbrain_fileѿɲ

normal_stat = original_normal_statics(proj_root,brain_parm);

% normal_stat.neighbor_org : original BV brain neighbor index list
% normal_stat.normal_org   : original BV brain normal vector

٤򣱡ˤǾǥ
  Ƕ˵֤ʿѵΥ5mm ĺ8000
  job_reduced_cortex(proj_root,brain_parm)

ǾǥΥե̾
   brain_file  = [ xxx.brain.mat ]
  ٥ǥ   = [ xxx_reduce.brain.mat ]
  area_file, act_file Ʊ

job_inflate
brain_file Фinflate ǥκ
ǾǥФinflate ǥκԤ

ɲåѥ᥿

% BVǾǥγ˺ǤᤤĺõκȾ
% Max radius for BV surface neighbor
brain_parm.R_normal = 0.004; % Default 4mm
% Reduce ratio for reduced brain
brain_parm.reduce_brain = 1/3;  % Default = 1/3;

꡼ɥեɷ׻ˡɲ

MEG꡼ɥեɤĴ´ؿŸǷ׻
EEG꡼ɥեɤǥǷ׻
EEG꡼ɥեɤBEMǷ׻

ɲåѥ᥿

basis_parm˰ʲΥѥ᥿ɲä̾ξ礳ꤷʤƤ
ץǥǥեȤΤʤ


BEMMEGĴ´ؿ׻λ
% basis_parm.Recalc     : Recalculation force flag    (Default OFF)
    = ON λϡե MEGinfo.SPHinfo  Omega ¸ߤƤ
      Ʒ׻

MEGĴ´ؿ׻λ
% basis_parm.func_order : Order of spherical harmonics function (Default 35)

EEG
% basis_parm.sigma      : Conductivity of each region
% basis_parm.radius     : Relative radius of sphere
basis_parm.sigma = [ 1.0  0.0125  1.0 ]; (Default)
basis_parm.radius = [ 0.87  0.92   1.0 ];(Default)

¸Ǿǥؤˡɲ

¸ brainfile ˡɲäǾǥؿ

job_normal_stat(proj_root,brain_parm)

ΰ(areakey)ưپ(actkey) ǾǥѤѴ

 ΰ(areakey)ưپ(actkey) ǾǥѤѴؿ
% acttivity map is transformed to act map in the reduced brain model
act_to_reduce_brain(actfile, areafile, actkey)
act_to_reduce_brain(actfile, areafile, actkey, reducekey,reduced_actfile)

% Area index is transformed to area index in the reduced brain model
area_to_reduce_brain(areafile, areakey)
area_to_reduce_brain(areafile, areakey, reducekey,reduced_areafile)


============ 4.Ǿǥ˴ؤѹ

ǾǥκɸѴν ver 0.5

ޤBrainVoyagerSPMɸؤѴŤγḶ󤬺äɤ
Ȥ˹ԤäƤʲΤ褦˥ܥɸmmºɸȤѴ礬
ĤäΤǡ

Τᡢver 0.4 ˷׻Ǿǥ ver 0.5 ʹߤ˷׻Ǿǥ
ɸϾۤʤäƤ롣

ǡ˴ؤ

ver 0.4 ˷׻Ǿǥ ver 0.5 ǻȤ
Ǿǥ1(*.brain.mat, *.act.mat, *.area.mat, *.basis.mat, *.meg.mat)
äƤϡ򤽤Τޤ޻Ȥäjob_vb, job_current Ԥ롣

ver 0.5 Ǻǽ餫ǾǥľƲϤ(侩)


ver 0.4 Ǻä*.brain.matб*.act.mat, *.area.mat 
ver 0.5 Ǻä*.brain.matб*.act.mat, *.area.mat ϰۤʤΤǡ
*.brain.matľ顢*.act.mat, *.area.matľʤФʤ

% ---- make_brain_data2 (ver 0.5) ---
Brain Voyager coordinate(V)  Right-hand SPM coordinate(Vspm) 
ľѴؿ bvoyger_spm_right ä
V θ[255/2. 255/2. 255/2]  Vspm θ[ 0, 0, 0]碌

  Vspm = bvoyger_spm_right(V,2)
    Vspm(:,1) = 255/2 - V(:,3); 
    Vspm(:,2) = 255/2 - V(:,1); 
    Vspm(:,3) = 255/2 - V(:,2); 

% ---- make_brain_data ( before ver 0.5) ---
ޤǤΥץǤϡʲΤ褦2ʳκɸѴԤäƤ

Vox  = bvoyger_to_vox(V)    
Vspm = vox_to_spm_right(Vox)

ϰʲκɸѴб
    Vspm(:,1) = 255/2 - V(:,3) + 1  ;
    Vspm(:,2) = 255/2 - V(:,1) - 1/2;
    Vspm(:,3) = 255/2 - V(:,2) - 1/2;

ʤľܸƱΤ碌Τ0.5-1.0mm Ƥ롣

<>
Vox = bvoyger_to_vox(V)
    Vox(:,1) = V(:,1) + 1; 
    Vox(:,2) = V(:,2) + 1; 
    Vox(:,3) = 256 - V(:,3) - fix( (256 - Vdim(1)*Vsize(1))/2 );

Vspm = vox_to_spm_right(Vox)
    Vspm(:,1) =   Vox(:,3) - Vdim(1)*Vsize(1)*0.5;
              = - V(:,3)   + 255/2 + 1
    Vspm(:,2) = - Vox(:,1) + Vdim(2)*Vsize(2)*0.5;
              = - V(:,1)   + Vdim(2)*Vsize(2)/2 
              = - V(:,1)   + 255/2 - 1/2
    Vspm(:,3) = - Vox(:,2) + Vdim(3)*Vsize(3)*0.5;
              = - V(:,2)   + Vdim(3)*Vsize(3)/2
              = - V(:,2)   + 255/2 - 1/2

============ 5.GUIѹ

1.GUIΥ꥽򥹥ץȴƤΤfigureեѹ
  (GUIAdvancedѥ᡼GUIб̤λ֤)
2.GUIѹ
  1.ʲΥѥ᡼ɲäб(ƥѥ᡼ˤĤƤϡ1.VBѹפ򻲾)
     bayes_parm.Npre_train
               .soft_mode
               .tan_var
               .var_max
               .removed_cross_area
  2.ʲΥѥ᡼ѹб
     bayes_parm.a0_act(ѥ᡼autoΥåܥåɽ
                       auto˥åäƤȤϡa0_act=[]Ȥjob_vbƤ)

  3.ǥեͤμ, template/set_bayes_parm.m褦ѹ
  4.ѹ
    (a)ǥFoward modelnoise estimation modelʤ빽ѹ
    (b)act keyʣǤ褦ѹ
  5.ΥǥTimeWindowե뤫ɤ߹ळȤǤʤԶ

3.GUIѹ
  - Leadfield׻GUI
    Bem modeBASIS_MEG_HARMONICSɲä
    Normal modeɲä
4.project_mgrѥ᡼κѵǽɲ
  - project_mgrɽƤ롢¹ԥѥ᡼ΣĤ򥯥å
    å򲡲ȡ˥塼ɽ졢launch application򤹤ȡ
    򤷤ѥ᡼ä֤GUI(Ȥ)ư뵡ǽɲä

============ 6.job_current_trλѹ

  job_current_trλѹ

˥ȥ饤ή׻褦ѹ
  parm.trial_average = OFF
  ȥ饤ʿήΤߤ׻ job_current Ȥ
jactdir β˥ȥ饤ήե뤬¸
currfile ˤϥȥ饤ʿήȥȥ饤ή˴ؤ¸
job_current  trial_average = OFF Ǽ¹Ԥ
  ȥ饤ήҤȤĤ currfile ¸

job_current_tr(proj_root,parm)

--- Input parameters
 - parm.resultfile : Estimated result by job_vb
   .bayes.mat file.
 - parm.currfile   : Average current is saved.
                     Infomation of current file are also saved.
                     current of each trials are saved into 'jactdir' directory
   .curr.mat file 
 - parm.jactdir : output directory of current files for each trial
                  relative path from proj_root
                  do not include '/' or '\' in the end of string
                  If 'jactdir' is not given,  jactdir = 'temp'
--- Optional  (default)
 - parm.areafile ([])  --> focal window
   .area.mat file.
 - parm.area_key ([])
   ID of interested area.
 - parm.tsubsmpl ([]) --> whole time points
   Time points where currents are calculated. For example,
   if tsubsmpl = [1:5:100], currents are calculated at only every 5 sample
   point.
--- Variables saved in output file (.curr.mat)

 - Jact
 - Jbck
 - ix_act
 - ix_bck
 - Lact
 - Lbck
 - Varact
 - bayes_parm
 - vb_parm

============ 7.¾ѹ

Х
1.job/job_inflate.m
  ǥ쥯ȥѥԶ礬ꡢʥѥ᡼Ǽ¹ԤƤ
  check_inflate_modelǥ顼λƤޤХ
2.job/job_preprocess_meg3.m
  ؿsave_divisionˤäХ
3.job/job_current_tr.m, job_current.m
  - ϥѥ᡼Υå˴ؤХ
  - Tstart˴ؤХ

ؿɲ

1.vbmeg/common/utility/kl_distance.m
  kl_disntaceؿɲ

  KL-distance of X and Y
  KL = kl_distance(X,Y)
  X and Y are normalized before calculation 
  Zero value component is replaced by eps

2.common/loadfunc/load_basis_info.m
  Basisեɤ߹ߴؿɲ

  [Norient, normal_mode] = load_basis_info(basisfile);
  [Norient, normal_mode, bem_mode] = load_basis_info(basisfile);
  --- Input
  basisfile : leadfileld basis file name
  --- Output
  Norient     : number of independent current orientation 
  normal_mode : normal average mode
  basis_parm  : leadfield calculation parameters

3.common/loadfunc/is_inflate_cortex.m
  ե졼ȥǡbrainե¸ߤ뤫åؿɲ
  result = is_inflate_cortex(brainfile)
 
  -- Input 
  brainfile   : Brain file name
  --- Output
    result = SUCCESS;
    result = FAILURE;

4.BrainVoyagerˡ󤬤뤫ɤåؿɲ
  common/loadfunc/is_normal_statics.m 

  Check existence of original BV brain normal information
   result = is_normal_statics(brainfile)
  --- Output
    result = SUCCESS;
    result = FAILURE;

5.Atlas label뤿δؿɲ
  tool_box/atlas2vb/get_atlas_area_label.m

  Get area index corresponding to atlas map in the given area
 
  [ix_list, ix_name] = get_atlas_label(ix_area,atlasfile,atlas_id)
  --- Input
  ix_area : Vertex index for given area
  atlasfile : File name of subject atlas file (*.atlas.mat)
  atlas_id  : Atlas name ('aal', 'brodmann')
  --- Output
  ix_list : set of area index corresponding to atlas region
  ix_name : name of atlas region corresponding to 'ix_list'

6.ΰ(areakey)ưپ(actkey) ǾǥѤѴؿ
  % acttivity map is transformed to act map in the reduced brain model
  act_to_reduce_brain(actfile, areafile, actkey)
  act_to_reduce_brain(actfile, areafile, actkey, reducekey,reduced_actfile)

  % Area index is transformed to area index in the reduced brain model
  area_to_reduce_brain(areafile, areakey)
  area_to_reduce_brain(areafile, areakey, reducekey,reduced_areafile)

7.¸ brainfile ˡɲäǾǥؿ
  job/job_normal_stat.m

  job_normal_stat(proj_root,brain_parm)

8.common/utility/matlab_version.m
  MATLABΥСԤؿɲá

  Usage: [major, minor, revision, build] = matlab_version;
  [OUT]
      major : MATLAB major version
      minor : MATLAB minor version
      revision : MATLAB revision
      build : MATLAB build number

9.template/
  ʲΥեɲá
  set_current_parm_test.m, set_current_parm.m (job_currentѥѥ᡼ե)
  set_bayes_default_parameters.m

ѹ
1.MATLABΥСåƼ¹ԤƤսν
  MATLABΥСMATLABȤ߹ߴؿversion('-release')
    ؿmatlab_versionѤ褦ѹ
    MATLABֵѤ꡼ֹλͤ礭ѹ줿ᡣ
  ե롧vb_save, vb_fsave, dilation_3d.m erosion_3d.m test_morfology.m
                create_gui.m, proj_run.m, 
2.common/utility/err_array.m
  ɤʼǤӤǤ褦ˤ
3.common/container/add_area.m, add_act.m
  ǡ¸saveؿǤϤʤvb_fsaveؿѤ褦ѹ.
4.plotfunc/check_model/
  ؿɬפʥǡϤʤäϡʲ
  åɽƥ꥿󤹤褦ѹ
    check_sphere_slice.m
        There is no analize file: *****
        Check of sphere model is skipped
    check_brain_modelm
        There is no analize file: *****
        Check of MRI and brain model is skipped
    check_fmri.m
        There is no inflate data: *****
        Plot of fMRI on inflate brain model is skipped
5.common/loadfunc/load_normal_statics.m
  brainե'normal_stat'̵֤ǡؿƤФ줿ȤΥ顼åɲ
6.vbmeg.m
  СGUI˴ؤ뵭Ҥ
  Сɽǽɲá񼰡vbmeg('-version');

