0001 function out=DIVA_SoundMap(varargin);
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 out=[];
0025 global DIVA_SoundMap_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}),
0032 initfile='';
0033 else,
0034 initfile=[SessionFolder,'Session_',varargin{indexargin+1},filesep,mfilename,'.mat'];
0035 end
0036 if isempty(initfile) | isempty(dir(initfile)),
0037 disp([mfilename, ' : Defining new session...']);
0038
0039 DIVA_SoundMap_data.params=struct(...
0040 'delayToMotorCortex',.005);
0041
0042
0043 else,
0044 data=load(initfile,'-mat');
0045 DIVA_SoundMap_data.params=data.params;
0046 end
0047
0048 DIVA_SoundMap_data.params.delayToSomatosensoryCortex=...
0049 DIVA_SoundMap_data.params.delayToMotorCortex+...
0050 DIVA('MotorCortex','delayToVocalTract')+...
0051 DIVA('VocalTract','delayToSensoryChannel')+0*...
0052 DIVA('SensoryChannel','delayToSensory')+...
0053 DIVA('Sensory','delayToSomatosensoryCortex');
0054
0055 DIVA_SoundMap_data.params.delayToAuditoryCortex=...
0056 DIVA_SoundMap_data.params.delayToMotorCortex+...
0057 DIVA('MotorCortex','delayToVocalTract')+...
0058 DIVA('VocalTract','delayToSoundChannel')+0*...
0059 DIVA('SoundChannel','delayToCochlea')+...
0060 DIVA('Cochlea','delayToAuditoryCortex');
0061
0062
0063
0064
0065 out={'target'};
0066
0067
0068 case 'save',
0069 SessionFolder=strcat(DIVA('SessionFolder'),filesep);
0070 if nargin<indexargin+1,
0071 initfile=[SessionFolder,'Session_','default',filesep,mfilename,'.mat'];
0072 else,
0073 initfile=[SessionFolder,'Session_',varargin{indexargin+1},filesep,mfilename,'.mat'];
0074 end
0075 params=DIVA_SoundMap_data.params;
0076 save(initfile,'params');
0077
0078 case 'exit',
0079 clear DIVA_SoundMap_data;
0080
0081
0082
0083 case 'disp',
0084 disp(DIVA_SoundMap_data.params);
0085 out=fieldnames(DIVA_SoundMap_data.params);
0086
0087
0088
0089 case 'target',
0090
0091 targetindex=varargin{indexargin+1};
0092 DIVA('MotorCortex','target',targetindex,...
0093 DIVA_SoundMap_data.params.delayToMotorCortex);
0094 DIVA('SomatosensoryCortex','target',targetindex,...
0095 DIVA_SoundMap_data.params.delayToSomatosensoryCortex);
0096 DIVA('AuditoryCortex','target',targetindex,...
0097 DIVA_SoundMap_data.params.delayToAuditoryCortex);
0098 if ~nargout,
0099 DIVA('ModelStatePlot','SoundMap','target');
0100 end
0101
0102
0103
0104 otherwise,
0105 if isfield(DIVA_SoundMap_data.params,varargin{indexargin}),
0106 if indexargin==nargin,
0107 out=DIVA_SoundMap_data.params.(varargin{indexargin});
0108 else,
0109 DIVA_SoundMap_data.params.(varargin{indexargin})=varargin{indexargin+1};
0110 end
0111 else,
0112 warning('DIVA_SoundMap: wrong argument');
0113 end
0114 end
0115 end
0116