rmeddis@38: function [pooledIPIdata,ctr] = poolIPI_across_channels(IPIhisttime,IPIhistweight) rmeddis@38: rmeddis@38: %function that pools IPIdata across all channels in order to plot the data rmeddis@38: %as in Secker-Walker JASA 1990 Fig. 6 rmeddis@38: rmeddis@38: %plots IPI-Histograms in a matrix display as in Secker-Walker JASA 1990 rmeddis@38: %Fig. 4 rmeddis@38: % rmeddis@38: % Tim Jürgens, February 2011 rmeddis@38: % rmeddis@38: % input: IPIhisttime: matrix containing the interval times found in the rmeddis@38: % analysis rmeddis@38: % first dimension: frequency channel rmeddis@38: % second dimension: time step (hop position) rmeddis@38: % third dimension: interval dimension (max 3) rmeddis@38: % IPIhistweight: matrix containing the interval weights found in the rmeddis@38: % analysis, same dimensions as IPIhisttime rmeddis@38: % output: pooledIPIdata: matrix containing the pooled and weighted IPI rmeddis@38: % histograms as a function of time (hop position) rmeddis@38: % first dimension: time step (hop position) rmeddis@38: % second dimension: IPI intervals rmeddis@38: % ctr: center values of classes of IPI intervals rmeddis@38: % ATTENTION: depending on the amplitude of the signals the value rmeddis@38: % 'verticalshift' might have to be adjusted in order to see structures in rmeddis@38: % the plot rmeddis@38: rmeddis@38: verticalshift = 3000; %0.008;%vertical shift of single time series in z-coordinate units rmeddis@38: ctr = [0:0.02:5].*1e-3; %classes (center-values) of 20 microsec width rmeddis@38: rmeddis@38: %preallocation of variables rmeddis@38: pooledIPIdata = zeros(size(IPIhisttime,2),length(ctr)); rmeddis@38: smoothed_pooledIPI = zeros(size(IPIhisttime,2),length(ctr)-5); rmeddis@38: rmeddis@38: for iCounter = 1:size(IPIhisttime,2) %one for time spacing rmeddis@38: %cannot use matlabs hist function because weighting must be applied rmeddis@38: rmeddis@38: tmpIPIhisttime = squeeze(IPIhisttime(:,iCounter,:)); rmeddis@38: tmpIPIhistweight = squeeze(IPIhistweight(:,iCounter,:)); rmeddis@38: tmpIPIhisttime = tmpIPIhisttime(:); rmeddis@38: tmpIPIhistweight = tmpIPIhistweight(:); rmeddis@38: for jCounter = 1:length(tmpIPIhisttime) rmeddis@38: %look which class rmeddis@38: [tmp1,classindex] = min(abs(tmpIPIhisttime(jCounter)-ctr)); rmeddis@38: pooledIPIdata(iCounter,classindex) = pooledIPIdata(iCounter,classindex)+tmpIPIhistweight(jCounter); rmeddis@38: end rmeddis@38: rmeddis@38: end rmeddis@38: rmeddis@38: %smooth data using a 5-point hamming window rmeddis@38: hamm_window = hamming(5); rmeddis@38: for iCounter = 1:size(pooledIPIdata,1) rmeddis@38: for jCounter = 3:length(ctr)-2 %start with 3 and end with 2 samples rmeddis@38: %less the length of ctr in order not to get in conflict with the length of rmeddis@38: %the hamm_window rmeddis@38: smoothed_pooledIPI(iCounter,jCounter-2) = ... rmeddis@38: pooledIPIdata(iCounter,(jCounter-2):(jCounter+2))*hamm_window./sum(hamm_window); rmeddis@38: end rmeddis@38: end rmeddis@38: smoothed_ctr = ctr(3:end-2); rmeddis@38: rmeddis@38: rmeddis@38: figure; rmeddis@38: rmeddis@38: Tickvector = []; rmeddis@38: TickLabels = []; rmeddis@38: for iCounter = 1:size(IPIhisttime,2) rmeddis@38: hold on; rmeddis@38: verticalposition = verticalshift*(iCounter-1); rmeddis@38: %multiply by 1000 to set abscissa to ms units rmeddis@38: plot(1000.*smoothed_ctr, ... rmeddis@38: smoothed_pooledIPI(iCounter,:)+verticalposition, ... rmeddis@38: 'k','LineWidth',2); rmeddis@38: if mod(iCounter,5) == 1 %set best frequency as a label every 10 channels rmeddis@38: Tickvector = [Tickvector verticalposition]; rmeddis@38: TickLabels = [TickLabels; (iCounter-1)*3]; %time spacing is every 3ms rmeddis@38: end rmeddis@38: end rmeddis@38: set(gca,'yTick',Tickvector,'yTickLabel',num2str(TickLabels,'%4.0f')); rmeddis@38: ylabel('Stimulus Time (ms)'); rmeddis@38: xlabel('Interval (ms)'); rmeddis@38: xlim([min(1000*ctr) max(1000*ctr)]); rmeddis@38: ylim([-verticalshift verticalposition+3*verticalshift]); rmeddis@38: box on;