Home > chronux_0.5 > plots > plotsigdiff.m

plotsigdiff

PURPOSE ^

Function to plot significant differences between two time-frequency arrays X1 and X2

SYNOPSIS ^

function plotsigdiff(X1,X1err,X2,X2err,plt,t,f)

DESCRIPTION ^

 Function to plot significant differences between two time-frequency arrays X1 and X2
 given errors X1err, X2err. 
 Usage: plotsigdiff(X1,X1err,X2,X2err,plt,t,f)

 X1 err and X2err contain upper and lower confidence intervals for X1 and X2
 The plot generated is shows X1-X2 where the difference is significant
 either in dB or on a linear scale.

 Inputs:
 X1: input array t x f. Can also be a function of just the frequency. In this case, row vector
 X1err: lower and upper confidence intervals for X1: lower/upper x t x f
 X2: input array t x f. if vector then as row vector
 X2err: lower and upper condidence intervals for X2: lower/upper x t x f
 plt: 'l' for log, 'n' for no log.
 t: t axis grid for plot. If X1,X2 are vectors, then specify t=1.
 f: f axis grid for plot.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function plotsigdiff(X1,X1err,X2,X2err,plt,t,f)
0002 % Function to plot significant differences between two time-frequency arrays X1 and X2
0003 % given errors X1err, X2err.
0004 % Usage: plotsigdiff(X1,X1err,X2,X2err,plt,t,f)
0005 %
0006 % X1 err and X2err contain upper and lower confidence intervals for X1 and X2
0007 % The plot generated is shows X1-X2 where the difference is significant
0008 % either in dB or on a linear scale.
0009 %
0010 % Inputs:
0011 % X1: input array t x f. Can also be a function of just the frequency. In this case, row vector
0012 % X1err: lower and upper confidence intervals for X1: lower/upper x t x f
0013 % X2: input array t x f. if vector then as row vector
0014 % X2err: lower and upper condidence intervals for X2: lower/upper x t x f
0015 % plt: 'l' for log, 'n' for no log.
0016 % t: t axis grid for plot. If X1,X2 are vectors, then specify t=1.
0017 % f: f axis grid for plot.
0018 if nargin < 7; error('Need all arguments'); end;
0019 [T1,F1]=size(X1); [T2,F2]=size(X2); 
0020 if T1~=T2 || F1~=F2;
0021     error('Arrays are incompatible');
0022 end;
0023 if F1==1 || F2==1;
0024     error('need row vector inputs');
0025 end;
0026 ystr='';
0027 if T1*T2==1,
0028     mask=zeros(1,F1);
0029     indx=find(X1err(1,:)>X2err(2,:) | X2err(1,:)>X1err(2,:));
0030     mask(indx)=1;
0031     if strcmp(plt,'l'); 
0032         X1=10*log10(X1); X2=10*log10(X2); X1err=10*log10(X1err); X2err=10*log10(X2err);
0033         ystr= '  dB';
0034     end;
0035     subplot(311); plot(f,X1,f,X1err(1,:),f,X1err(2,:));
0036     title('Spectrum 1');
0037     xlabel('f')
0038     ylabel(['S1' ystr]);
0039     subplot(312); plot(f,X2,f,X2err(1,:),f,X2err(2,:));
0040     title('Spectrum 2');
0041     xlabel('f')
0042     ylabel(['S2' ystr]);
0043     subplot(313); plot(f,mask.*(X1-X2));
0044     title('Difference where significant');
0045     xlabel('f')
0046     ylabel(['S1-S2' ystr]);
0047 else
0048     mask=zeros(T1,F1);
0049     for n=1:length(t);
0050         for m=1:length(f);
0051            if X1err(1,n,m)>X2err(2,n,m);
0052               mask(n,m)=1;
0053            elseif X2err(1,n,m)>X1err(2,n,m);
0054               mask(n,m)=1;
0055            end;
0056         end;
0057     end;
0058     if strcmp(plt,'l');
0059        X1=10*log10(X1);X2=10*log10(X2); %X1err=10*log10(X1err); X2err=10*log10(X2err);
0060         ystr='  dB';
0061     end;
0062     subplot(311); imagesc(t,f,X1'); axis xy; colorbar;
0063     xlabel('f')
0064     ylabel(['S1' ystr]);
0065     subplot(312); imagesc(t,f,X2'); axis xy; colorbar;
0066     xlabel('f')
0067     ylabel(['S2' ystr]);
0068     subplot(313); imagesc(t,f,(mask.*(X1-X2))'); axis xy; colorbar
0069     xlabel('f')
0070     ylabel(['S1-S2' ystr]);
0071 end

Generated on Tue 16-Aug-2005 21:33:45 by m2html © 2003