Mercurial > hg > map
comparison userProgramsTim/map_iih_onto_log.m @ 38:c2204b18f4a2 tip
End nov big change
author | Ray Meddis <rmeddis@essex.ac.uk> |
---|---|
date | Mon, 28 Nov 2011 13:34:28 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
37:771a643d5c29 | 38:c2204b18f4a2 |
---|---|
1 function [mappediih,centerfreqs] = map_iih_onto_log(iih,numchannels,sfreq) | |
2 | |
3 %function to map an IPIH from the interval axis onto the frequency axis | |
4 %with no overlap and mean firing rate. | |
5 % | |
6 % Tim Juergens, September 2011 | |
7 % | |
8 % input: iih: IPIH with dimensions interval (1) and time step (2) | |
9 % the first dimension translates to time using the actual | |
10 % sampling frequency | |
11 % numchannels: number of desired channels | |
12 % sfreq: sampling frequency | |
13 % output: mappediih: IPIH with dimensions frequency channel (1) and time | |
14 % step (2) | |
15 % centerfreqs: center frequencies of the channels of mappediih | |
16 | |
17 ctr_intervals = [1/sfreq:1/sfreq:size(iih,1)/sfreq]; | |
18 lowestBF=1/ctr_intervals(end); | |
19 highestBF=10000; | |
20 | |
21 borderfreqs = logspace(log10(lowestBF),log10(highestBF),numchannels+1); | |
22 | |
23 for iCounter = 1:numchannels | |
24 centerfreqs(iCounter)=(borderfreqs(iCounter)+borderfreqs(iCounter+1))/2; | |
25 end | |
26 | |
27 for iCounter = 1:length(borderfreqs) %find the indices that correspond to the borderfrequencies of the BF filters | |
28 [tmp,channelbordersIPIindex(iCounter)]=min(abs(borderfreqs(iCounter)-1./ctr_intervals)); | |
29 end | |
30 | |
31 for iCounter = 1:length(centerfreqs) | |
32 %mapping with one interval sample overlap | |
33 mappediih(iCounter,:) = mean(iih(channelbordersIPIindex(end-iCounter+1):channelbordersIPIindex(end-iCounter),:)); | |
34 end | |
35 | |
36 | |
37 | |
38 % OPTIONAL PLOTTING | |
39 figure | |
40 YTickIdx = 1:floor(numel(centerfreqs)/6):numel(centerfreqs); | |
41 YTickIdxRev = numel(centerfreqs)+1-YTickIdx; | |
42 if ~isempty(gca) | |
43 axes(gca); %#ok<MAXES> | |
44 imagesc(mappediih); | |
45 set(gca, 'YTick', YTickIdx); | |
46 set(gca, 'YTickLabel', num2str( centerfreqs(YTickIdxRev)', '%0.0f' )); | |
47 ylabel('cf in Hz') | |
48 end |