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