This function is used to register cortical area data. [syntax] vb_add_area(areafile,area_new,MRI_ID,flag) [input] areafile : Cortical area file (.area.mat). area_new : Area information struct to be registered. area_new.Iextract: Set of vertex indices of the new data. area_new.key : ID of the new data. MRI_ID : <optional> If 'areafile' does not exist, this MRI ID is assigned to the actfile created in this function. If this variable is not set, MRI_ID will be set to '0000000' as a tentative identifier. flag : <obsolete> If OFF, confirmation dialog will be suppressed. [note] If cortical area file, specified by 'areafile' parameter, does not exist, the file will be created automatically. [example] >> areafile = './TY/data/TY.area.mat'; >> Area.key = 'tmp'; >> Area.Iextract = [1:I]'; % I is the number of vertices >> vb_add_area(areafile,Area); [history] 2005-01-07 Taku Yoshioka 2010-05-26 Taku Yoshioka Message display changed Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function vb_add_area(areafile,AreaNew,MRI_ID,flag) 0002 % This function is used to register cortical area data. 0003 % 0004 % [syntax] 0005 % vb_add_area(areafile,area_new,MRI_ID,flag) 0006 % 0007 % [input] 0008 % areafile : Cortical area file (.area.mat). 0009 % area_new : Area information struct to be registered. 0010 % area_new.Iextract: Set of vertex indices of the new data. 0011 % area_new.key : ID of the new data. 0012 % MRI_ID : <optional> If 'areafile' does not exist, this MRI ID is 0013 % assigned to the actfile created in this function. If this 0014 % variable is not set, MRI_ID will be set to '0000000' as a 0015 % tentative identifier. 0016 % flag : <obsolete> If OFF, confirmation dialog will be suppressed. 0017 % 0018 % [note] 0019 % If cortical area file, specified by 'areafile' parameter, does not 0020 % exist, the file will be created automatically. 0021 % 0022 % [example] 0023 % >> areafile = './TY/data/TY.area.mat'; 0024 % >> Area.key = 'tmp'; 0025 % >> Area.Iextract = [1:I]'; % I is the number of vertices 0026 % >> vb_add_area(areafile,Area); 0027 % 0028 % [history] 0029 % 2005-01-07 Taku Yoshioka 0030 % 2010-05-26 Taku Yoshioka 0031 % Message display changed 0032 % 0033 % Copyright (C) 2011, ATR All Rights Reserved. 0034 % License : New BSD License(see VBMEG_LICENSE.txt) 0035 0036 % 0037 % Verbose level setting 0038 % 0039 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0040 global vbmeg_inst 0041 verbose_const = vb_define_verbose; 0042 0043 if isempty(vbmeg_inst) | ~isfield(vbmeg_inst,'verbose_level'), 0044 verbose_level = verbose_const.VERBOSE_LEVEL_NOTICE; 0045 else 0046 verbose_level = vbmeg_inst.verbose_level; 0047 end 0048 0049 % 0050 % If given areafile is exist or not? 0051 % 0052 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0053 if exist(areafile) == 2 0054 load(areafile); 0055 % Old version support 0056 if ~exist('MRI_ID'), 0057 MRI_ID = '0000000'; 0058 vb_disp(['Area file ''' areafile ''' is a old version, ' ... 0059 'in which variable ''MRI_ID'' is not saved. A tentative ' ... 0060 'ID ''0000000'' was automatically assigned to the area ' ... 0061 'file. '],verbose_const.VERBOSE_LEVEL_INFO); 0062 end 0063 else 0064 if nargin <= 2, MRI_ID = '0000000'; end; 0065 vb_disp('New area file was created. '); 0066 Area = cell(0,1); 0067 end 0068 0069 % 0070 % Identifier duplicatioin check 0071 % 0072 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0073 inc_size = 1; 0074 for i = 1:length(Area) 0075 if strcmp(AreaNew.key,Area{i}.key) 0076 inc_size = 0; 0077 if verbose_level>=verbose_const.VERBOSE_LEVEL_NOTICE, 0078 msg = ['Area ID ''' AreaNew.key ''' is already used. ' ... 0079 'Overwrite ?']; 0080 str = questdlg(msg,'Area registration','Yes','Cancel', ... 0081 'Cancel'); 0082 if strcmp(str,'Yes') 0083 Area{i} = AreaNew; 0084 h = msgbox(['Area ID ''' AreaNew.key ''' was overwritten.']); 0085 uiwait(h); 0086 end 0087 else 0088 vb_disp(['Area ID ''' AreaNew.key ''' is used, ' ... 0089 'so it is overwritten with new data. '], ... 0090 verbose_const.VERBOSE_LEVEL_WARNING); 0091 Area{i} = AreaNew; 0092 end 0093 end 0094 end 0095 0096 % 0097 % Add new area information and save the area file 0098 % 0099 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0100 tmp = cell(length(Area)+inc_size,1); 0101 for i = 1:length(Area) 0102 tmp{i} = Area{i}; 0103 end 0104 0105 if inc_size 0106 tmp{length(Area)+1} = AreaNew; 0107 Area = tmp; 0108 end 0109 0110 vb_fsave(areafile,'Area','MRI_ID');