Home > vbmeg > functions > tool_box > dmri_processor > functions > dmri_vbmeg_vertex_select.m

dmri_vbmeg_vertex_select

PURPOSE ^

Choose verticies of VBMEG brain model by specifing num_vertex.

SYNOPSIS ^

function dmri_vbmeg_vertex_select(brain_file, fs_info_file, num_vertex, parcel_file)

DESCRIPTION ^

 Choose verticies of VBMEG brain model by specifing num_vertex.

 [Usage]
    dmri_vbmeg_vertex_select(brain_file, fs_info_file, num_vertex, parcel_file);

 [Input]
      brain_file : VBMEG BRAIN-MAT file(.brain.mat)
    fs_info_file : Freesurfer information file.
      num_vertex : The number of verticies.
     parcel_file : Parcel file.

 [Output]
    none

 [Example]
    

 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:

SOURCE CODE ^

0001 function dmri_vbmeg_vertex_select(brain_file, fs_info_file, num_vertex, parcel_file)
0002 % Choose verticies of VBMEG brain model by specifing num_vertex.
0003 %
0004 % [Usage]
0005 %    dmri_vbmeg_vertex_select(brain_file, fs_info_file, num_vertex, parcel_file);
0006 %
0007 % [Input]
0008 %      brain_file : VBMEG BRAIN-MAT file(.brain.mat)
0009 %    fs_info_file : Freesurfer information file.
0010 %      num_vertex : The number of verticies.
0011 %     parcel_file : Parcel file.
0012 %
0013 % [Output]
0014 %    none
0015 %
0016 % [Example]
0017 %
0018 %
0019 % Copyright (C) 2011, ATR All Rights Reserved.
0020 % License : New BSD License(see VBMEG_LICENSE.txt)
0021 
0022 %
0023 % --- Previous check
0024 %
0025 if nargin ~= 4
0026     error('Please check input arguments');
0027 end
0028 if exist(brain_file, 'file') ~= 2
0029     error('brain_file not found.');
0030 end
0031 if exist(fs_info_file, 'file') ~= 2
0032     error('fs_info_file not found.');
0033 end
0034 if num_vertex <= 0
0035     error('Invalid num_vertex was specified.');
0036 end
0037 if ~ischar(parcel_file)
0038     error('parcel_file is not a filename.');
0039 end
0040 
0041 %
0042 % --- Main Procedure
0043 %
0044 load(brain_file, 'brain_parm', 'Vinfo');
0045 if ~isfield(Vinfo, 'cortexL')
0046     warning('Specified BRAIN-MAT(.brain.mat) is created by VBMEG 1.0. The number of parcels will be different between subjects.');
0047     dmri_vbmeg_vertex_select_old(brain_file, fs_info_file, num_vertex, parcel_file);
0048     return;
0049 end
0050 
0051 % Reference standard brain
0052 [std_parm, std_brain_dir] = vb_set_icbm152(brain_parm.Nvertex);
0053 std_brain_file = fullfile(std_brain_dir, std_parm.brain_file);
0054 if exist(std_brain_file, 'file') ~= 2
0055     % error case
0056     fprintf('To make parcellation information about this brain model, \n');
0057     fprintf('it needs to create a custom resolution standard brain model, please type as below.\n');
0058     fprintf('==========\n');
0059     fprintf('[parm, proj_root] = vb_set_icbm152(%d);\n', brain_parm.Nvertex);
0060     fprintf('vb_job_brain_std(proj_root, parm);\n');
0061     fprintf('==========\n');
0062     fprintf('Then re-run the operation.\n');
0063     return;
0064 end
0065 
0066 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0067 % Select vertices on standard brain
0068 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0069 disp(['Select ' num2str(num_vertex) ' vertices on standard brain.']);
0070 
0071 % Select specified number of verticies on the standard brain file.
0072 s = load(std_brain_file, 'Vmni', 'Vinfo');
0073 s_cortex_ix = [s.Vinfo.cortexL; s.Vinfo.cortexR];
0074 reduce_ratio = num_vertex/length(s_cortex_ix);
0075 vbmeg_area_ix = vb_reduce_cortex(std_brain_file, s_cortex_ix, reduce_ratio);
0076 
0077 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0078 % Check and save if selected verticies are subcortex.
0079 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0080 p = struct;
0081 [tmp1, tmp2, p.Vinfo] = vb_load_cortex_info(brain_file, 'subj');
0082 p_cortex_ix = [p.Vinfo.cortexL; p.Vinfo.cortexR];
0083 sub_cortex_ix = setdiff(vbmeg_area_ix, p_cortex_ix);
0084 
0085 vb_fsave(parcel_file, 'vbmeg_area_ix', 'sub_cortex_ix');
0086 disp(['Saved:' parcel_file]);

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005