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