To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

The primary repository for this project is hosted at git://github.com/rmeddis/MAP.git .
This repository is a read-only copy which is updated automatically every hour.

Statistics Download as Zip
| Branch: | Revision:

root / testPrograms / test_MAP1_14.m @ 15:35af36fe0a35

History | View | Annotate | Download (4.51 KB)

1
function test_MAP1_14
2
% test_MAP1_14 is a general purpose test routine that can be adjusted to
3
% test a number of different applications of MAP1_14
4
%
5
% A range of options are supplied in the early part of the program
6
%
7
% One use of the function is to create demonstrations; filenames <demoxx>
8
%  to illustrate particular features
9
%
10
% #1
11
% Identify the file (in 'MAPparamsName') containing the model parameters
12
% 
13
% #2
14
% Identify the kind of model required (in 'AN_spikesOrProbability').
15
%  A full brainstem model (spikes) can be computed or a shorter model
16
%  (probability) that computes only so far as the auditory nerve
17
%
18
% #3
19
% Choose between a tone signal or file input (in 'signalType')
20
%
21
% #4
22
% Set the signal rms level (in leveldBSPL)
23
%
24
% #5
25
% Indentify the channels in terms of their best frequencies in the vector
26
%  BFlist.
27
%
28
% Last minute changes to the parameters fetched earlier can be made using
29
%  the cell array of strings 'paramChanges'.
30
%  Each string must have the same format as the corresponding line in the
31
%  file identified in 'MAPparamsName'
32
%
33
% When the demonstration is satisfactory, freeze it by renaming it <demoxx>
34

    
35

    
36
%%  #1 parameter file name
37
MAPparamsName='Normal';
38

    
39

    
40
%% #2 probability (fast) or spikes (slow) representation
41
AN_spikesOrProbability='spikes';
42
% or
43
% AN_spikesOrProbability='probability';
44

    
45

    
46
%% #3 pure tone, harmonic sequence or speech file input
47
signalType= 'tones';
48
duration=0.100;                 % seconds
49
% duration=0.020;                 % seconds
50
sampleRate= 64000;
51
% toneFrequency= 250:250:8000;    % harmonic sequence (Hz)
52
toneFrequency= 2000;            % or a pure tone (Hz8
53

    
54
rampDuration=.005;              % seconds
55

    
56
% or
57
% signalType= 'file';
58
% fileName='twister_44kHz';
59
% fileName='new-da-44khz';
60

    
61

    
62
%% #4 rms level
63
% signal details
64
leveldBSPL= 90;                  % dB SPL
65

    
66

    
67
%% #5 number of channels in the model
68
%   21-channel model (log spacing)
69
numChannels=21;
70
lowestBF=250; 	highestBF= 8000; 
71
BFlist=round(logspace(log10(lowestBF), log10(highestBF), numChannels));
72

    
73
%   or specify your own channel BFs
74
BFlist=toneFrequency;
75

    
76

    
77
%% #6 change model parameters
78
paramChanges=[];
79

    
80
% or
81
% Parameter changes can be used to change one or more model parameters
82
%  *after* the MAPparams file has been read
83
% This example declares only one fiber type with a calcium clearance time
84
% constant of 80e-6 s (HSR fiber) when the probability option is selected.
85
        paramChanges={'AN_IHCsynapseParams.ANspeedUpFactor=5;', ...
86
            'IHCpreSynapseParams.tauCa=86e-6;'};
87

    
88
%% delare showMap options
89
showMapOptions=[];  % use defaults
90

    
91
% or (example: show everything including an smoothed SACF output
92
    showMapOptions.showModelParameters=0;
93
    showMapOptions.showModelOutput=1;
94
    showMapOptions.printFiringRates=1;
95
    showMapOptions.showACF=0;
96
    showMapOptions.showEfferent=1;
97

    
98
%% Generate stimuli
99

    
100
dbstop if error
101
restorePath=path;
102
addpath (['..' filesep 'MAP'],    ['..' filesep 'wavFileStore'])
103
switch signalType
104
    case 'tones'
105
        inputSignal=createMultiTone(sampleRate, toneFrequency, ...
106
            leveldBSPL, duration, rampDuration);
107
        
108
    case 'file'
109
        [inputSignal sampleRate]=wavread(fileName);       
110
        inputSignal(:,1);
111
        targetRMS=20e-6*10^(leveldBSPL/20);
112
        rms=(mean(inputSignal.^2))^0.5;
113
        amp=targetRMS/rms;
114
        inputSignal=inputSignal*amp;
115
end
116

    
117

    
118
%% run the model
119
tic
120

    
121
fprintf('\n')
122
disp(['Signal duration= ' num2str(length(inputSignal)/sampleRate)])
123
disp([num2str(numChannels) ' channel model'])
124
disp('Computing ...')
125

    
126
restorePath=path;
127
addpath (['..' filesep 'MAP'])
128

    
129
MAP1_14(inputSignal, sampleRate, BFlist, ...
130
    MAPparamsName, AN_spikesOrProbability, paramChanges);
131
path(restorePath)
132
toc
133

    
134
% the model run is now complete. Now display the results
135
showMAP(showMapOptions)
136
for i=1:length(paramChanges)
137
disp(paramChanges{i})
138
end
139

    
140
toc
141
path(restorePath)
142

    
143

    
144
function inputSignal=createMultiTone(sampleRate, toneFrequency, ...
145
    leveldBSPL, duration, rampDuration)
146
% Create pure tone stimulus
147
dt=1/sampleRate; % seconds
148
time=dt: dt: duration;
149
inputSignal=sum(sin(2*pi*toneFrequency'*time), 1);
150
amp=10^(leveldBSPL/20)*28e-6;   % converts to Pascals (peak)
151
inputSignal=amp*inputSignal;
152

    
153
% apply ramps
154
% catch rampTime error
155
if rampDuration>0.5*duration, rampDuration=duration/2; end
156
rampTime=dt:dt:rampDuration;
157
ramp=[0.5*(1+cos(2*pi*rampTime/(2*rampDuration)+pi)) ...
158
    ones(1,length(time)-length(rampTime))];
159
inputSignal=inputSignal.*ramp;
160
ramp=fliplr(ramp);
161
inputSignal=inputSignal.*ramp;
162

    
163
% add 10 ms silence
164
silence= zeros(1,round(0.03/dt));
165
inputSignal= [silence inputSignal silence];
166