0001 function out=DIVA_SensoryChannel(varargin);
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 out=[];
0021 global DIVA_SensoryChannel_data
0022
0023 indexargin=1;
0024 switch(varargin{indexargin}),
0025 case 'init',
0026 SessionFolder=strcat(DIVA('SessionFolder'),filesep);
0027 if nargin<indexargin+1 | isempty(varargin{indexargin+1}),
0028 initfile='';
0029 else,
0030 initfile=[SessionFolder,'Session_',varargin{indexargin+1},filesep,mfilename,'.mat'];
0031 end
0032 if isempty(initfile) || isempty(dir(initfile)),
0033 disp([mfilename, ' : Defining new session...']);
0034
0035 DIVA_SensoryChannel_data.params=struct(...
0036 'delayToSensory',.0);
0037
0038
0039 else,
0040 data=load(initfile,'-mat');
0041 DIVA_SensoryChannel_data.params=data.params;
0042 end
0043
0044 DIVA_SensoryChannel_data.params.current=struct(...
0045 'configuration',[],...
0046 'delay',[]);
0047
0048
0049
0050 out={};
0051
0052
0053 case 'save',
0054 SessionFolder=strcat(DIVA('SessionFolder'),filesep);
0055 if nargin<indexargin+1,
0056 initfile=[SessionFolder,'Session_','default',filesep,mfilename,'.mat'];
0057 else,
0058 initfile=[SessionFolder,'Session_',varargin{indexargin+1},filesep,mfilename,'.mat'];
0059 end
0060 params=DIVA_SensoryChannel_data.params;
0061 save(initfile,'params');
0062
0063 case 'exit',
0064 clear DIVA_SensoryChannel_data;
0065
0066
0067
0068 case 'disp',
0069 disp(DIVA_SensoryChannel_data.params);
0070 out=fieldnames(DIVA_SensoryChannel_data.params);
0071
0072
0073
0074 case 'configuration',
0075 DIVA_SensoryChannel_data.current.configuration = varargin{indexargin+1};
0076 if nargin<indexargin+2 | isempty(varargin{indexargin+2}),
0077 DIVA_SensoryChannel_data.current.delay = 0;
0078 else,
0079 DIVA_SensoryChannel_data.current.delay = varargin{indexargin+2};
0080 end
0081 DIVA_SensoryChannel_data.current.delay = ...
0082 DIVA_SensoryChannel_data.current.delay + ...
0083 DIVA_SensoryChannel_data.params.delayToSensory;
0084
0085 if ~nargout,
0086 DIVA('Sensory','configuration',...
0087 DIVA_SensoryChannel_data.current.configuration,...
0088 DIVA_SensoryChannel_data.current.delay);
0089 else,
0090 out={DIVA_SensoryChannel_data.current.configuration};
0091 end
0092
0093
0094
0095 otherwise,
0096 if isfield(DIVA_SensoryChannel_data.params,varargin{indexargin}),
0097 if indexargin==nargin,
0098 out=DIVA_SensoryChannel_data.params.(varargin{indexargin});
0099 else,
0100 DIVA_SensoryChannel_data.params.(varargin{indexargin})=varargin{indexargin+1};
0101 end
0102 else,
0103 warning('DIVA_SensoryChannel: wrong argument');
0104 end
0105 end