Home > functions > job > vb_job_brain_model_std2sbj.m

vb_job_brain_model_std2sbj

PURPOSE ^

Make subject cortical surface from standard brain model

SYNOPSIS ^

function [V,F,xx] = vb_job_brain_model_std2sbj(proj_root,brain_parm)

DESCRIPTION ^

 Make subject cortical surface from standard brain model
   by using spatial normalization file made by SPM

    vb_job_brain_model_std2sbj(proj_root,brain_parm)
 --- Input 
 proj_root  : root directory for output data file

 brain_parm : parameter structure
 - Input file (absolute path)
 brain_parm.std_brain   : Standard brain file
 brain_parm.spm_normalization_file : Spatial normalization file (SPM *sn.mat)
 brain_parm.analyze_file: MRI T1 image file (Analyze/NIFTI)

 - Output file (relative path from proj_root)
 brain_parm.brain_file  : brain_file 
 brain_parm.area_file   : area_file  
 brain_parm.act_file    : act_file   

 ---- Output (also saved in the subject brain_file)
 V      : Cortical vertex point cordinate (SPM_Right_m) 
 F      : Patch index structure
 xx     : Normal vector to cortical surface 
 ---- Saved variable in the brain_file
 xxA       : area for vertex

 xxF{i}    : Next-neighbor index for the vertex-i
 xxD{i}    : Distance between next-neighbor and the vertex-i
 xxT{n}    : vertex index for n-th triangle
 nextIX{i} : Neighbor index list for the vertex-i
 nextDD{i} : Distance from the vertex-i

 Vinfo     : Vertex dimension structure

 M. Sato 2009-12-2

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function    [V,F,xx] = vb_job_brain_model_std2sbj(proj_root,brain_parm)
0002 % Make subject cortical surface from standard brain model
0003 %   by using spatial normalization file made by SPM
0004 %
0005 %    vb_job_brain_model_std2sbj(proj_root,brain_parm)
0006 % --- Input
0007 % proj_root  : root directory for output data file
0008 %
0009 % brain_parm : parameter structure
0010 % - Input file (absolute path)
0011 % brain_parm.std_brain   : Standard brain file
0012 % brain_parm.spm_normalization_file : Spatial normalization file (SPM *sn.mat)
0013 % brain_parm.analyze_file: MRI T1 image file (Analyze/NIFTI)
0014 %
0015 % - Output file (relative path from proj_root)
0016 % brain_parm.brain_file  : brain_file
0017 % brain_parm.area_file   : area_file
0018 % brain_parm.act_file    : act_file
0019 %
0020 % ---- Output (also saved in the subject brain_file)
0021 % V      : Cortical vertex point cordinate (SPM_Right_m)
0022 % F      : Patch index structure
0023 % xx     : Normal vector to cortical surface
0024 % ---- Saved variable in the brain_file
0025 % xxA       : area for vertex
0026 %
0027 % xxF{i}    : Next-neighbor index for the vertex-i
0028 % xxD{i}    : Distance between next-neighbor and the vertex-i
0029 % xxT{n}    : vertex index for n-th triangle
0030 % nextIX{i} : Neighbor index list for the vertex-i
0031 % nextDD{i} : Distance from the vertex-i
0032 %
0033 % Vinfo     : Vertex dimension structure
0034 %
0035 % M. Sato 2009-12-2
0036 %
0037 % Copyright (C) 2011, ATR All Rights Reserved.
0038 % License : New BSD License(see VBMEG_LICENSE.txt)
0039 
0040 DEBUG_MODE=0;
0041 
0042 proj_root = vb_rm_trailing_slash(proj_root);
0043 
0044 std_brain    = brain_parm.std_brain;
0045 snfile       = brain_parm.spm_normalization_file;
0046 analyze_file = brain_parm.analyze_file;
0047 
0048 % Output file path
0049 brain_file = [proj_root filesep brain_parm.brain_file];
0050 area_file  = [proj_root filesep brain_parm.area_file ];
0051 act_file   = [proj_root filesep brain_parm.act_file  ];
0052 
0053 % ID for MRI image data
0054 [udir, fname] = fileparts(analyze_file);
0055 MRI_ID = fname;
0056 
0057 [V,F,xx,Vinfo,Vindx] = vb_get_cortex_surf_from_std(std_brain,snfile);
0058 
0059 %%%% DEBUG %%%%
0060 if DEBUG_MODE==2, return; end;
0061 
0062 %
0063 % --- Search next-point index and distance
0064 %
0065 fprintf('--- Search next-point index and distance ');
0066 
0067 [xxD, xxF, xxT] = vb_next_distance( [F.F3L ; F.F3R], V ); % unit : m
0068 
0069 %
0070 % --- Calculate area assigned to the vertex
0071 %
0072 
0073 [xxA] = vb_calc_patch_area(V, F.F3, xxT);
0074 
0075 fprintf(['--- Save brain model \n']);
0076 fprintf('     filename = %s\n', brain_file );
0077 
0078 % load Standard brain coordinate
0079 Vmni = vb_load_cortex(std_brain);
0080 Vmni = Vmni(Vindx,:);
0081 % mni2tal : MNI to Talairach coordinate transformation
0082 Vtal = mni2tal(Vmni);
0083 
0084 % load Standard brain Inflate model
0085 [Vinflate,Ft,xxt,inf_C]= vb_load_cortex(std_brain, 'Inflate');
0086 Vinflate = Vinflate(Vindx,:);
0087 inf_C = inf_C(Vindx,:);
0088 
0089 vb_save([brain_file], 'F','V','xx','xxF','xxD','xxA',...
0090      'Vmni','Vtal','Vinflate','inf_C','Vinfo','MRI_ID');
0091 
0092 % Copy atlas-area file
0093 EXT_brain = '.brain.mat';
0094 std_id    = std_brain(1:findstr(std_brain,EXT_brain)-1);
0095 
0096 std_act_aal  = [std_id  '_aal.act.mat'];
0097 std_act_brd  = [std_id  '_brodmann.act.mat'];
0098 std_area_aal  = [std_id  '_aal.area.mat'];
0099 std_area_brd  = [std_id  '_brodmann.area.mat'];
0100 
0101 brain_id  = brain_file(1:findstr(brain_file,EXT_brain)-1);
0102 
0103 save_act_aal  = [brain_id  '_aal.act.mat'];
0104 save_act_brd  = [brain_id  '_brodmann.act.mat'];
0105 save_area_aal  = [brain_id  '_aal.area.mat'];
0106 save_area_brd  = [brain_id  '_brodmann.area.mat'];
0107 
0108 if exist(std_act_aal,'file'), copyfile(std_act_aal,save_act_aal);end;
0109 if exist(std_act_brd,'file'), copyfile(std_act_brd,save_act_brd);end;
0110 if exist(std_area_aal,'file'), copyfile(std_area_aal,save_area_aal);end;
0111 if exist(std_area_brd,'file'), copyfile(std_area_brd,save_area_brd);end;
0112 
0113 % total number of vertex
0114 Ndipole = Vinfo.Ndipole;
0115 Vindx   = 1:Ndipole;
0116 
0117 % Make activity map file
0118 act_new.key     = 'Uniform';
0119 act_new.xxP     = ones(Ndipole,1);
0120 act_new.comment = 'artificial data';
0121 
0122 vb_add_act([act_file], act_new, MRI_ID, OFF);
0123 
0124 % Make Area file
0125 AreaNew.key      = 'Cortex';
0126 AreaNew.Iextract = [1:Ndipole]'; 
0127 
0128 vb_add_area([area_file], AreaNew, MRI_ID, OFF);
0129 
0130 if DEBUG_MODE==1, 
0131     figure;
0132     hist(xxA*1e6, 0:0.25:10);
0133     xlim([0 10])
0134     title('Histgram of patch area')
0135     xlabel('Area')
0136     return; 
0137 end;
0138 %
0139 % Search neighbor points along cortex sheet
0140 %
0141 
0142 if isfield(brain_parm,'R_max'),
0143     Rmax    = brain_parm.R_max; 
0144 else
0145     Rmax    = 18e-3; 
0146 end
0147 if isfield(brain_parm,'R_max'),
0148     Display = brain_parm.display;
0149 else
0150     Display = 200;
0151 end
0152 
0153 [nextIX , nextDD] = vb_find_neighbor_all(Rmax, xxF, xxD, Vindx, Display);
0154 
0155 vb_save([brain_file],'nextIX','nextDD');
0156 
0157 
0158 % Check brain model by 3D & MRI image
0159 vb_check_brain_model(proj_root,brain_parm);
0160 
0161 figure;
0162 hist(vb_cell_merge(xxD)*1000,100);
0163 title('Histgram of Vertex distance [mm]')
0164 
0165 proj_file_save(brain_parm);
0166 
0167 return
0168 
0169 function    proj_file_save(brain_parm)
0170 % project_file save
0171 proj_file = get_project_filename;
0172 
0173 if isempty(proj_file)
0174     return;
0175 end
0176 
0177 project_file_mgr('load', proj_file);
0178 project_file_mgr('add', 'brain_parm', brain_parm);
0179 
0180 return

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005