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