DIVA_Template DIVA module template Explanation of what this module does DIVA_Template('init' [,SessionName]); Initializes the module DIVA_Template('save' [,SessionName] ); Saves state DIVA_Template('exit'); Exits the module (without saving) DIVA_Template(PropertyName [,PropertyValue] ) Reads and writes internal model properties DIVA_Template(ChannelName1,ChannelValue1,... ChannelName2,ChannelValue2,...); Executes module process(es)
0001 function out=DIVA_Template(varargin); 0002 % DIVA_Template DIVA module template 0003 % 0004 % Explanation of what this module does 0005 % 0006 % DIVA_Template('init' [,SessionName]); Initializes the module 0007 % DIVA_Template('save' [,SessionName] ); Saves state 0008 % DIVA_Template('exit'); Exits the module (without saving) 0009 % DIVA_Template(PropertyName [,PropertyValue] ) Reads and writes internal model properties 0010 % 0011 % DIVA_Template(ChannelName1,ChannelValue1,... 0012 % ChannelName2,ChannelValue2,...); Executes module process(es) 0013 % 0014 0015 % Dependencies: 0016 % 0017 0018 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0019 % This is a template for any new DIVA module. 0020 % CHANGE any occurrence of 'DIVA_Template' to 'DIVA_ModuleName' everywhere in this 0021 % file (including the file name) 0022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0023 0024 out=[]; 0025 global DIVA_Template_data 0026 0027 for indexargin=1:2:nargin, 0028 switch(varargin{indexargin}), 0029 case 'init', 0030 SessionFolder=strcat(DIVA('SessionFolder'),filesep); 0031 if nargin<indexargin+1 | isempty(varargin{indexargin+1}), initfile=''; 0032 else, initfile=[SessionFolder,'Session_',varargin{indexargin+1},filesep,mfilename,'.mat']; end 0033 if isempty(initfile) | isempty(dir(initfile)), 0034 disp([mfilename, ' : Defining new session...']); 0035 % INITIALIZES INTERNAL MODULE PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0036 DIVA_Template_data.params=struct(...); 0037 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0038 0039 else, 0040 data=load(initfile,'-mat'); 0041 DIVA_Template_data.params=data.params; 0042 end 0043 % INITIALIZES OTHER (TEMPORAL) PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0044 DIVA_Template_data.params.current=struct(...); 0045 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0046 0047 % LIST OF MODULE CHANNELS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0048 out={}; 0049 %out={'ChannelName1','ChannelName2',...}; 0050 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0051 0052 case 'save', 0053 SessionFolder=strcat(DIVA('SessionFolder'),filesep); 0054 if nargin<indexargin+1, initfile=[SessionFolder,'Session_','default',filesep,mfilename,'.mat']; 0055 else, initfile=[SessionFolder,'Session_',varargin{indexargin+1},filesep,mfilename,'.mat']; end 0056 params=DIVA_Template_data.params; 0057 save(initfile,'params'); 0058 0059 case 'exit', 0060 clear DIVA_Template_data; 0061 % CODE FOR CLEARING MEMORY OR THE LIKE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0062 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0063 0064 case 'disp', 0065 disp(DIVA_Template_data.params); 0066 out=fieldnames(DIVA_Microphone_data.params); 0067 0068 % CODE IMPLEMENTING THIS MODULE PROCESS(ES) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0069 % Note: use DIVA(ModuleName,ChannelName,data,delay) to comunicate with other DIVA modules 0070 case 'ChannelName1', 0071 case 'ChannelName2', 0072 ... 0073 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0074 0075 otherwise, 0076 if isfield(DIVA_Template_data.params,varargin{indexargin}), 0077 if indexargin==nargin, out=DIVA_Template_data.params.(varargin{indexargin}); 0078 else, DIVA_Template_data.params.(varargin{indexargin})=varargin{indexargin+1}; end 0079 else, warning('DIVA_Template: wrong argument'); end 0080 end 0081 end