


Make smooth cortex from standard brain mask
[V,F,xx,brain_parm] = vb_job_brain_std2sbj(proj_root,brain_parm)
--- Input
proj_root : root directory for data file
brain_parm : parameter structure
- Input file
brain_parm.subj_mask : Subject brain mask file
brain_parm.analyze_file: analyze_file
- Output file
brain_parm.brain_file : brain_file
brain_parm.area_file : area_file
brain_parm.act_file : act_file
- Parameter
brain_parm.Nvertex = 3000; number of cortical vertex
brain_parm.Radius = [2 -2]; morphological smoothing
brain_parm.gray_val : threshold value for gray matter
if it is empty, only brain mask is used
if is is given, voxel with larger intensity than 'gray_val' is selected
---- Output (also saved in the 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 2007/7/05
Copyright (C) 2011, ATR All Rights Reserved.
License : New BSD License(see VBMEG_LICENSE.txt)


0001 function [V,F,xx,brain_parm] = vb_job_brain_std2sbj(proj_root,brain_parm) 0002 % Make smooth cortex from standard brain mask 0003 % [V,F,xx,brain_parm] = vb_job_brain_std2sbj(proj_root,brain_parm) 0004 % --- Input 0005 % proj_root : root directory for data file 0006 % brain_parm : parameter structure 0007 % - Input file 0008 % brain_parm.subj_mask : Subject brain mask file 0009 % brain_parm.analyze_file: analyze_file 0010 % - Output file 0011 % brain_parm.brain_file : brain_file 0012 % brain_parm.area_file : area_file 0013 % brain_parm.act_file : act_file 0014 % - Parameter 0015 % brain_parm.Nvertex = 3000; number of cortical vertex 0016 % brain_parm.Radius = [2 -2]; morphological smoothing 0017 % brain_parm.gray_val : threshold value for gray matter 0018 % if it is empty, only brain mask is used 0019 % if is is given, voxel with larger intensity than 'gray_val' is selected 0020 % 0021 % ---- Output (also saved in the brain_file) 0022 % V : Cortical vertex point cordinate (SPM_Right_m) 0023 % F : Patch index structure 0024 % xx : Normal vector to cortical surface 0025 % ---- Saved variable in the brain_file 0026 % xxA : area for vertex 0027 % 0028 % xxF{i} : Next-neighbor index for the vertex-i 0029 % xxD{i} : Distance between next-neighbor and the vertex-i 0030 % xxT{n} : vertex index for n-th triangle 0031 % nextIX{i} : Neighbor index list for the vertex-i 0032 % nextDD{i} : Distance from the vertex-i 0033 % 0034 % Vinfo : Vertex dimension structure 0035 % 0036 % M. Sato 2007/7/05 0037 % 0038 % Copyright (C) 2011, ATR All Rights Reserved. 0039 % License : New BSD License(see VBMEG_LICENSE.txt) 0040 0041 DEBUG_MODE=0; 0042 0043 proj_root = vb_rm_trailing_slash(proj_root); 0044 subj_mask = [proj_root filesep brain_parm.subj_mask]; 0045 analyze_file = brain_parm.analyze_file; 0046 0047 % Output file path 0048 brain_file = [proj_root filesep brain_parm.brain_file]; 0049 area_file = [proj_root filesep brain_parm.area_file ]; 0050 act_file = [proj_root filesep brain_parm.act_file ]; 0051 0052 [V, F, xx, Xcenter] = vb_make_smooth_cortex_surf(subj_mask,analyze_file,brain_parm); 0053 0054 msg = {'Cortical surface is plotted'; 'Is this OK ?'}; 0055 str = questdlg(msg,'Check result','Yes', 'No','Yes'); 0056 if strcmp(str,'No'), return; end; 0057 0058 %%%% DEBUG %%%% 0059 if DEBUG_MODE==2, return; end; 0060 0061 % ID for MRI image data 0062 [udir, fname] = fileparts(analyze_file); 0063 MRI_ID = fname; 0064 0065 [V,F,xx,Vinfo] = vb_get_cortex_info(V, F, xx, Xcenter); 0066 0067 % 0068 % --- Search next-point index and distance 0069 % 0070 tic; 0071 fprintf('--- Search next-point index and distance '); 0072 0073 [xxD, xxF, xxT] = vb_next_distance( [F.F3L ; F.F3R], V ); % unit : m 0074 0075 fprintf('%f[sec]\n',toc); 0076 0077 % 0078 % --- Calculate area assigned to the vertex 0079 % 0080 tic 0081 0082 [xxA] = vb_calc_patch_area(V, F.F3, xxT); 0083 0084 fprintf('%f[sec]\n',toc); 0085 0086 fprintf(['--- Save brain model \n']); 0087 fprintf(' filename = %s\n', brain_file ); 0088 0089 vb_save([brain_file], 'F','V','xx','xxF','xxD','xxA',... 0090 'Vinfo','MRI_ID'); 0091 0092 % total number of vertex 0093 Ndipole = Vinfo.Ndipole; 0094 Vindx = 1:Ndipole; 0095 0096 % Make activity map file 0097 act_new.key = 'Uniform'; 0098 act_new.xxP = ones(Ndipole,1); 0099 act_new.comment = 'artificial data'; 0100 0101 vb_add_act([act_file], act_new, MRI_ID, OFF); 0102 0103 % Make Area file 0104 AreaNew.key = 'Cortex'; 0105 AreaNew.Iextract = [1:Ndipole]'; 0106 0107 vb_add_area([area_file], AreaNew, MRI_ID, OFF); 0108 0109 if DEBUG_MODE==1, 0110 figure; 0111 hist(xxA*1e6, 0:0.25:10); 0112 xlim([0 10]) 0113 title('Histgram of patch area') 0114 xlabel('Area') 0115 return; 0116 end; 0117 % 0118 % Search neighbor points along cortex sheet 0119 % 0120 0121 if isfield(brain_parm,'R_max'), 0122 Rmax = brain_parm.R_max; 0123 else 0124 Rmax = 18e-3; 0125 end 0126 if isfield(brain_parm,'R_max'), 0127 Display = brain_parm.display; 0128 else 0129 Display = 200; 0130 end 0131 0132 [nextIX , nextDD] = vb_find_neighbor_all(Rmax, xxF, xxD, Vindx, Display); 0133 0134 vb_save([brain_file],'nextIX','nextDD'); 0135 0136 0137 % Check brain model by 3D & MRI image 0138 vb_check_brain_model(proj_root,brain_parm); 0139 0140 figure; 0141 hist(vb_cell_merge(xxD)*1000,100); 0142 title('Histgram of Vertex distance [mm]') 0143 0144 proj_file_save(brain_parm); 0145 0146 return 0147 0148 function proj_file_save(brain_parm) 0149 % project_file save 0150 proj_file = get_project_filename; 0151 0152 if isempty(proj_file) 0153 return; 0154 end 0155 0156 project_file_mgr('load', proj_file); 0157 project_file_mgr('add', 'brain_parm', brain_parm); 0158 0159 return