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 / testBM.m @ 33:161913b595ae

History | View | Annotate | Download (5.06 KB)

1 29:b51bf546ca3f rmeddis
function testBM (BMlocations, paramsName,...
2
    relativeFrequencies, AN_spikesOrProbability, paramChanges)
3
% testBM generates input output functions for DRNL model for any number
4
% of locations.
5
% Computations are bast on a single channel model (channelBFs=BF)
6
% peak displacement (peakAmp) is measured.
7
%  if DRNLParams.useMOC is chosen, the full model is run (slow)
8
%  otherwise only DRNL is computed.
9
% Tuning curves are generated based on a range of frequencies reletove to
10
% the BF of the location.
11
%
12
13
global    DRNLParams
14
15
if nargin<5
16
    paramChanges=[];
17
end
18
19
if nargin<4
20
    AN_spikesOrProbability='probability';
21
end
22
23
savePath=path;
24
addpath (['..' filesep 'utilities'],['..' filesep 'MAP'])
25
26
levels=-10:10:90;   nLevels=length(levels);
27
% levels= 50;   nLevels=length(levels);
28
29
% refBMdisplacement is the displacement of the BM at threshold
30
% 1 nm disp at  threshold (9 kHz, Ruggero)
31
% ? adjust for frequency
32
refBMdisplacement= 1e-8; % adjusted for 10 nm at 1 kHz
33
34
toneDuration=.200;
35
rampDuration=0.01;
36
silenceDuration=0.01;
37
38
sampleRate=30000;
39
40
dbstop if error
41
figure(3), clf
42
set(gcf,'position',[280   350   327   326])
43
set(gcf,'name','DRNL - BM')
44
pause(0.1)
45
46
finalSummary=[];
47
nBFs=length(BMlocations);
48
BFno=0; plotCount=0;
49
for BF=BMlocations
50
    BFno=BFno+1;
51
    plotCount=plotCount+nBFs;
52
    stimulusFrequencies=BF* relativeFrequencies;
53
    nFrequencies=length(stimulusFrequencies);
54
55
    peakAmpBM=zeros(nLevels,nFrequencies);
56
    peakAmpBMdB=NaN(nLevels,nFrequencies);
57
    peakEfferent=NaN(nLevels,nFrequencies);
58
    peakAREfferent=NaN(nLevels,nFrequencies);
59
60
61
    levelNo=0;
62
    for leveldB=levels
63
        disp(['level= ' num2str(leveldB)])
64
        levelNo=levelNo+1;
65
66
        freqNo=0;
67
        for frequency=stimulusFrequencies
68
            freqNo=freqNo+1;
69
70
            % Generate stimuli
71
            globalStimParams.FS=sampleRate;
72
            globalStimParams.overallDuration=...
73
                toneDuration+silenceDuration;  % s
74
            stim.phases='sin';
75
            stim.type='tone';
76
            stim.toneDuration=toneDuration;
77
            stim.frequencies=frequency;
78
            stim.amplitudesdB=leveldB;
79
            stim.beginSilence=silenceDuration;
80
            stim.rampOnDur=rampDuration;
81
            % no offset ramp
82
            stim.rampOffDur=rampDuration;
83
            doPlot=0;
84
            inputSignal=stimulusCreate(globalStimParams, stim, doPlot);
85
            inputSignal=inputSignal(:,1)';
86
87
            %% run the model
88
            MAPparamsName=paramsName;
89
90
            global DRNLoutput MOCattenuation ARattenuation
91
            MAP1_14(inputSignal, sampleRate, BF, ...
92
                MAPparamsName, AN_spikesOrProbability, paramChanges);
93
94
            DRNLresponse=DRNLoutput;
95
            peakAmp=max(max(...
96
                DRNLresponse(:, end-round(length(DRNLresponse)/2):end)));
97
            peakAmpBM(levelNo,freqNo)=peakAmp;
98
            peakAmpBMdB(levelNo,freqNo)=...
99
                20*log10(peakAmp/refBMdisplacement);
100
            peakEfferent(levelNo,freqNo)=min(min(MOCattenuation));
101
            peakAREfferent(levelNo,freqNo)=min(min(ARattenuation));
102
103
        end  % tone frequency
104
    end  % level
105
106
    %% analyses results and plot
107 33:161913b595ae rmeddis
if length(relativeFrequencies)>2
108
    maxRows=3;
109
else
110
    maxRows=2;
111
end
112 29:b51bf546ca3f rmeddis
113
    % BM I/O plot (top panel)
114
    figure(3)
115 33:161913b595ae rmeddis
    subplot(maxRows,nBFs,BFno), cla
116 29:b51bf546ca3f rmeddis
    plot(levels,peakAmpBMdB, 'linewidth',2)
117
    hold on, plot(levels, repmat(refBMdisplacement,1,length(levels)))
118
    hold off
119
    title(['BF=' num2str(BF,'%5.0f') ' - ' paramsName])
120
    xlabel('level')
121
    %     set(gca,'xtick',levels),  grid on
122
    if length(levels)>1,xlim([min(levels) max(levels)]), end
123
    ylabel(['dB re:' num2str(refBMdisplacement,'%6.1e') 'm'])
124
    ylim([-20 50])
125
    set(gca,'ytick',[-10 0 10 20 40])
126
    grid on
127
    %     legend({num2str(stimulusFrequencies')}, 'location', 'EastOutside')
128
    UTIL_printTabTable([levels' peakAmpBMdB], ...
129
        num2str([0 stimulusFrequencies]','%5.0f'), '%5.0f')
130
    finalSummary=[finalSummary peakAmpBMdB];
131
132
    % Tuning curve
133
    if length(relativeFrequencies)>2
134 33:161913b595ae rmeddis
        figure(3), subplot(maxRows,nBFs, 2*nBFs+BFno)
135 29:b51bf546ca3f rmeddis
        %         contour(stimulusFrequencies,levels,peakAmpBM,...
136
        %             [refBMdisplacement refBMdisplacement],'r')
137
        contour(stimulusFrequencies,levels,peakAmpBM,...
138
            refBMdisplacement.*[1 5 10 50 100])
139
        title(['tuning curve at ' num2str(refBMdisplacement) 'm']);
140
        ylabel('level (dB) at reference')
141
        xlim([100 10000])
142
        grid on
143
        hold on
144
        set(gca,'xscale','log')
145
    end
146
147
148
    % MOC contribution
149
    figure(3)
150 33:161913b595ae rmeddis
    subplot(maxRows,nBFs,nBFs+BFno), cla
151 29:b51bf546ca3f rmeddis
    plot(levels,20*log10(peakEfferent), 'linewidth',2)
152
    ylabel('MOC (dB attenuation)'), xlabel('level')
153
    title(['peak MOC: model= ' AN_spikesOrProbability])
154
    grid on
155
    if length(levels)>1, xlim([min(levels) max(levels)]), end
156
157
    % AR contribution
158
    hold on
159
    plot(levels,20*log10(peakAREfferent), 'r')
160
    hold off
161
162
end % best frequency
163
164
UTIL_showStructureSummary(DRNLParams, 'DRNLParams', 10)
165
166
    UTIL_printTabTable([levels' finalSummary], ...
167
        num2str([0 stimulusFrequencies]','%5.0f'), '%5.0f')
168
169
path(savePath);