rmeddis@38
|
1 function [pooledIPIdata,ctr] = poolIPI_across_channels(IPIhisttime,IPIhistweight)
|
rmeddis@38
|
2
|
rmeddis@38
|
3 %function that pools IPIdata across all channels in order to plot the data
|
rmeddis@38
|
4 %as in Secker-Walker JASA 1990 Fig. 6
|
rmeddis@38
|
5
|
rmeddis@38
|
6 %plots IPI-Histograms in a matrix display as in Secker-Walker JASA 1990
|
rmeddis@38
|
7 %Fig. 4
|
rmeddis@38
|
8 %
|
rmeddis@38
|
9 % Tim Jürgens, February 2011
|
rmeddis@38
|
10 %
|
rmeddis@38
|
11 % input: IPIhisttime: matrix containing the interval times found in the
|
rmeddis@38
|
12 % analysis
|
rmeddis@38
|
13 % first dimension: frequency channel
|
rmeddis@38
|
14 % second dimension: time step (hop position)
|
rmeddis@38
|
15 % third dimension: interval dimension (max 3)
|
rmeddis@38
|
16 % IPIhistweight: matrix containing the interval weights found in the
|
rmeddis@38
|
17 % analysis, same dimensions as IPIhisttime
|
rmeddis@38
|
18 % output: pooledIPIdata: matrix containing the pooled and weighted IPI
|
rmeddis@38
|
19 % histograms as a function of time (hop position)
|
rmeddis@38
|
20 % first dimension: time step (hop position)
|
rmeddis@38
|
21 % second dimension: IPI intervals
|
rmeddis@38
|
22 % ctr: center values of classes of IPI intervals
|
rmeddis@38
|
23 % ATTENTION: depending on the amplitude of the signals the value
|
rmeddis@38
|
24 % 'verticalshift' might have to be adjusted in order to see structures in
|
rmeddis@38
|
25 % the plot
|
rmeddis@38
|
26
|
rmeddis@38
|
27 verticalshift = 3000; %0.008;%vertical shift of single time series in z-coordinate units
|
rmeddis@38
|
28 ctr = [0:0.02:5].*1e-3; %classes (center-values) of 20 microsec width
|
rmeddis@38
|
29
|
rmeddis@38
|
30 %preallocation of variables
|
rmeddis@38
|
31 pooledIPIdata = zeros(size(IPIhisttime,2),length(ctr));
|
rmeddis@38
|
32 smoothed_pooledIPI = zeros(size(IPIhisttime,2),length(ctr)-5);
|
rmeddis@38
|
33
|
rmeddis@38
|
34 for iCounter = 1:size(IPIhisttime,2) %one for time spacing
|
rmeddis@38
|
35 %cannot use matlabs hist function because weighting must be applied
|
rmeddis@38
|
36
|
rmeddis@38
|
37 tmpIPIhisttime = squeeze(IPIhisttime(:,iCounter,:));
|
rmeddis@38
|
38 tmpIPIhistweight = squeeze(IPIhistweight(:,iCounter,:));
|
rmeddis@38
|
39 tmpIPIhisttime = tmpIPIhisttime(:);
|
rmeddis@38
|
40 tmpIPIhistweight = tmpIPIhistweight(:);
|
rmeddis@38
|
41 for jCounter = 1:length(tmpIPIhisttime)
|
rmeddis@38
|
42 %look which class
|
rmeddis@38
|
43 [tmp1,classindex] = min(abs(tmpIPIhisttime(jCounter)-ctr));
|
rmeddis@38
|
44 pooledIPIdata(iCounter,classindex) = pooledIPIdata(iCounter,classindex)+tmpIPIhistweight(jCounter);
|
rmeddis@38
|
45 end
|
rmeddis@38
|
46
|
rmeddis@38
|
47 end
|
rmeddis@38
|
48
|
rmeddis@38
|
49 %smooth data using a 5-point hamming window
|
rmeddis@38
|
50 hamm_window = hamming(5);
|
rmeddis@38
|
51 for iCounter = 1:size(pooledIPIdata,1)
|
rmeddis@38
|
52 for jCounter = 3:length(ctr)-2 %start with 3 and end with 2 samples
|
rmeddis@38
|
53 %less the length of ctr in order not to get in conflict with the length of
|
rmeddis@38
|
54 %the hamm_window
|
rmeddis@38
|
55 smoothed_pooledIPI(iCounter,jCounter-2) = ...
|
rmeddis@38
|
56 pooledIPIdata(iCounter,(jCounter-2):(jCounter+2))*hamm_window./sum(hamm_window);
|
rmeddis@38
|
57 end
|
rmeddis@38
|
58 end
|
rmeddis@38
|
59 smoothed_ctr = ctr(3:end-2);
|
rmeddis@38
|
60
|
rmeddis@38
|
61
|
rmeddis@38
|
62 figure;
|
rmeddis@38
|
63
|
rmeddis@38
|
64 Tickvector = [];
|
rmeddis@38
|
65 TickLabels = [];
|
rmeddis@38
|
66 for iCounter = 1:size(IPIhisttime,2)
|
rmeddis@38
|
67 hold on;
|
rmeddis@38
|
68 verticalposition = verticalshift*(iCounter-1);
|
rmeddis@38
|
69 %multiply by 1000 to set abscissa to ms units
|
rmeddis@38
|
70 plot(1000.*smoothed_ctr, ...
|
rmeddis@38
|
71 smoothed_pooledIPI(iCounter,:)+verticalposition, ...
|
rmeddis@38
|
72 'k','LineWidth',2);
|
rmeddis@38
|
73 if mod(iCounter,5) == 1 %set best frequency as a label every 10 channels
|
rmeddis@38
|
74 Tickvector = [Tickvector verticalposition];
|
rmeddis@38
|
75 TickLabels = [TickLabels; (iCounter-1)*3]; %time spacing is every 3ms
|
rmeddis@38
|
76 end
|
rmeddis@38
|
77 end
|
rmeddis@38
|
78 set(gca,'yTick',Tickvector,'yTickLabel',num2str(TickLabels,'%4.0f'));
|
rmeddis@38
|
79 ylabel('Stimulus Time (ms)');
|
rmeddis@38
|
80 xlabel('Interval (ms)');
|
rmeddis@38
|
81 xlim([min(1000*ctr) max(1000*ctr)]);
|
rmeddis@38
|
82 ylim([-verticalshift verticalposition+3*verticalshift]);
|
rmeddis@38
|
83 box on;
|