Home > vbmeg > functions > common > container > vb_add_area.m

vb_add_area

PURPOSE ^

This function is used to register cortical area data.

SYNOPSIS ^

function vb_add_area(areafile,AreaNew,MRI_ID,flag)

DESCRIPTION ^

 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    : <optional> = ON  : confirmation dialog will be shown. <default> 
                      = 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
 2015-11-04 rhayashi
  Re-implement flag option.

 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 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    : <optional> = ON  : confirmation dialog will be shown. <default>
0017 %                      = OFF : confirmation dialog will be suppressed.
0018 %
0019 %
0020 % [note]
0021 % If cortical area file, specified by 'areafile' parameter, does not
0022 % exist, the file will be created automatically.
0023 %
0024 % [example]
0025 % >> areafile = './TY/data/TY.area.mat';
0026 % >> Area.key = 'tmp';
0027 % >> Area.Iextract = [1:I]'; % I is the number of vertices
0028 % >> vb_add_area(areafile,Area);
0029 %
0030 % [history]
0031 % 2005-01-07 Taku Yoshioka
0032 % 2010-05-26 Taku Yoshioka
0033 %  Message display changed
0034 % 2015-11-04 rhayashi
0035 %  Re-implement flag option.
0036 %
0037 % Copyright (C) 2011, ATR All Rights Reserved.
0038 % License : New BSD License(see VBMEG_LICENSE.txt)
0039 
0040 %
0041 % Previous check
0042 %
0043 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0044 if ~exist('flag', 'var')
0045     flag = ON;
0046 end
0047 
0048 %
0049 % Verbose level setting
0050 %
0051 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0052 global vbmeg_inst
0053 verbose_const = vb_define_verbose; 
0054 
0055 if isempty(vbmeg_inst) | ~isfield(vbmeg_inst,'verbose_level'), 
0056   verbose_level = verbose_const.VERBOSE_LEVEL_NOTICE;
0057 else
0058   verbose_level = vbmeg_inst.verbose_level;
0059 end
0060 
0061 %
0062 % If given areafile is exist or not?
0063 %
0064 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0065 if exist(areafile) == 2
0066   load(areafile);
0067   % Old version support
0068   if ~exist('MRI_ID'), 
0069     MRI_ID = '0000000';
0070     vb_disp(['Area file ''' areafile ''' is a old version, ' ...
0071              'in which variable ''MRI_ID'' is not saved. A tentative ' ...
0072              'ID ''0000000'' was automatically assigned to the area ' ...
0073              'file. '],verbose_const.VERBOSE_LEVEL_INFO);
0074   end
0075 else
0076   if nargin <= 2, MRI_ID = '0000000'; end;
0077   vb_disp('New area file was created. ');
0078   Area = cell(0,1);
0079 end
0080 
0081 %
0082 % Identifier duplicatioin check
0083 %
0084 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0085 inc_size = 1;
0086 for i = 1:length(Area)
0087   if strcmp(AreaNew.key,Area{i}.key)
0088     inc_size = 0;
0089     if verbose_level>=verbose_const.VERBOSE_LEVEL_NOTICE && flag == ON
0090       msg = ['Area ID ''' AreaNew.key ''' is already used. ' ...
0091          'Overwrite ?'];
0092       str = questdlg(msg,'Area registration','Yes','Cancel', ...
0093              'Cancel');
0094       if strcmp(str,'Yes')
0095         Area{i} = AreaNew;
0096         h = msgbox(['Area ID ''' AreaNew.key ''' was overwritten.']);
0097         uiwait(h);
0098       end
0099     else
0100       vb_disp(['Area ID ''' AreaNew.key ''' is used, ' ...
0101                'so it is overwritten with new data. '], ...
0102                verbose_const.VERBOSE_LEVEL_WARNING); 
0103       Area{i} = AreaNew;
0104     end
0105   end
0106 end
0107 
0108 %
0109 % Add new area information and save the area file
0110 %
0111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0112 tmp = cell(length(Area)+inc_size,1);
0113 for i = 1:length(Area)
0114   tmp{i} = Area{i};
0115 end
0116 
0117 if inc_size
0118   tmp{length(Area)+1} = AreaNew;
0119   Area = tmp;
0120 end
0121 
0122 vb_fsave(areafile,'Area','MRI_ID');

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