[c3bd51]: wavelets / plotwavelets.m Maximize Restore History

Download this file

plotwavelets.m    133 lines (115 with data), 4.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
function [C] = plotwavelets(c,info,varargin)
%PLOTWAVELETS Plot wavelet coefficients
% Usage: plotwavelets(c,info,fs)
% plotwavelets(c,info,fs,'dynrange',dynrange,...)
%
% `plowavelets(c,info)` plots the wavelet coefficients *c* using
% additional parameters from struct. `info`. Both parameters are returned
% by any forward transform function in the wavelets directory.
%
% `plowavelets(c,info,fs)` does the same plot assuming a sampling rate of *fs* Hz
% of the original signal.
%
% `plowavelets(c,info,fs,'dynrange',dynrange)` additionally limits the dynamic range.
%
% `C=plowavelets(...)` returns the processed image data used in the
% plotting. Inputting this data directly to `imagesc` or similar functions
% will create the plot. This is usefull for custom post-processing of the
% image data.
%
% `plowavelets` supports optional parameters of |tfplot|. Please see
% the help of |tfplot| for an exhaustive list.
%
% See also: fwt, tfplot
if nargin<2
error('%s: Too few input parameters.',upper(mfilename));
end;
definput.import={'tfplot'};
definput.flags.fwtplottype = {'tfplot','stem'};
definput.keyvals.fs = [];
definput.keyvals.dynrange = [];
[flags,kv]=ltfatarghelper({'fs'},definput,varargin);
if(flags.do_stem)
error('%s: Flag %s not supported yet.',upper(mfilename),flags.fwtplottype);
end
maxSubLen = [];
draw_ticks = 1;
if(strcmpi(info.fname,'fwt'))
%% FWT plot
% Change to the cell format
if(isnumeric(c))
c = wavpack2cell(c,info.Lc,info.dim);
end
maxSubLen = max(info.Lc);
% Only one channel signals can be plotted.
if(size(c{1},2)>1)
error('%s: Multichannel input not supported.',upper(mfilename));
end
subbNo = numel(c);
g = fwtinit(info.fwtstruct,'syn');
aBase = g.a;
filtNo = numel(g.filts);
J = info.J;
a = [aBase(1).^J, reshape(aBase(2:end)*aBase(1).^(J-1:-1:0),1,[])]';
elseif(strcmpi(info.fname,'ufwt'))
% Only one channel signals can be plotted.
if(ndims(c)>2)
error('%s: Multichannel not supported.',upper(mfilename));
end
subbNo = size(c,2);
a = ones(subbNo,1);
g = fwtinit(info.fwtstruct,'syn');
filtNo = numel(g.filts);
J = info.J;
elseif(strcmpi(info.fname,'wfbt'))
% Only one channel signals can be plotted.
if(size(c{1},2)>1)
error('%s: Multichannel input not supported.',upper(mfilename));
end
maxSubLen = max(cellfun(@(cEl) size(cEl,1),c));
a = treeSub(info.wt);
subbNo = numel(c);
draw_ticks = 0;
elseif(strcmpi(info.fname,'uwfbt'))
% Only one channel signals can be plotted.
if(ndims(c)>2)
error('%s: Multichannel not supported.',upper(mfilename));
end
subbNo = size(c,2);
a = ones(subbNo,1);
draw_ticks = 0;
elseif(strcmpi(info.fname,'wpfbt'))
% Only one channel signals can be plotted.
if(size(c{1},2)>1)
error('%s: Multichannel input not supported.',upper(mfilename));
end
maxSubLen = max(cellfun(@(cEl) size(c,1),c));
aCell = nodeSub(nodesBForder(info.wt),info.wt);
a = cell2mat(cellfun(@(aEl) aEl(:)',aCell,'UniformOutput',0));
draw_ticks = 0;
elseif(strcmpi(info.fname,'uwpfbt'))
% Only one channel signals can be plotted.
if(ndims(c)>2)
error('%s: Multichannel not supported.',upper(mfilename));
end
subbNo = size(c,2);
a = ones(subbNo,1);
draw_ticks = 0;
else
error('%s: Unknown function name %s.',upper(mfilename),info.fname);
end
% Use plotfilterbank
C=plotfilterbank(c,a,[],kv.fs,kv.dynrange,flags.plottype,...
flags.log,flags.colorbar,flags.display,'fontsize',kv.fontsize,'clim',kv.clim,'xres',min([maxSubLen,800]));
if(draw_ticks)
% Redo the yticks and ylabel
yTickLabels = cell(1,subbNo);
yTickLabels{1} = sprintf('a%d',J);
Jtmp = ones(filtNo-1,1)*(J:-1:1);
for ii=1:subbNo-1
yTickLabels{ii+1} = sprintf('d%d',Jtmp(ii));
end
ylabel('Subbands','fontsize',kv.fontsize);
set(gca,'ytick',1:subbNo);
set(gca,'ytickLabel',yTickLabels,'fontsize',kv.fontsize);
end