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