comparison toolboxes/bioakustik_tools/visualisation/dataspecgram.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function [h,out] = dataspecgram(wavin, varargin)
2 %[h,spec] = dataspecgram(data,'sr',fs,'fftlen',2048,'stepw',1024,'winsize',2048,'min_fkhz',0.5,'max_fkhz',15,'nolog',0,'clip',0,'logadd',0);
3
4
5 [sr,fftlen, stepw,winsize,min_fkhz,max_fkhz,nolog,clip,logadd,fontsize,cutoff,colormode,unused]=process_options(varargin,...
6 'sr',44800,'fftlen',2048,'stepw',1024,'winsize',2048,'min_fkhz',0.5,'max_fkhz',15,...
7 'nolog',0,'clip',0,'logadd',0,'fontsize',8,'cutoff',0,'colormode','jet');
8 out= specgram(wavin,fftlen,sr,winsize,winsize-stepw);
9
10 wavlens=round(length(wavin)/sr*100)/100;
11
12 firstindex= max(round(fftlen/(sr)*min_fkhz*1000),1);
13 lastindex= min(round(fftlen/(sr)*max_fkhz*1000),fftlen/2);
14
15 out=out(firstindex:lastindex,:);
16 if nolog
17 out=abs(out);
18 out=sqrt(abs(out));
19 out=out./max(max(out));
20 else
21 out=log(0.000000001+logadd+abs(out));
22 out=out./max(max(abs(out)));
23 out=out+1;
24 end
25
26 %cut off small values
27 if cutoff
28 for i=1:size(out,2)
29 out((out(:,i)<cutoff),i)=0;
30 end
31 end
32
33
34
35 if clip > 0
36 h=image([0 wavlens],[min_fkhz max_fkhz],out*100*clip);
37 else
38 h=imagesc([0 wavlens],[min_fkhz max_fkhz],out);
39 end
40
41 switch colormode
42 case 'inv'
43 color= 'w';
44 bgcolor= 'k';
45 colormap(hot);
46 case 'bw'
47 color= 'black';
48 colormap(1-grey);
49 bgcolor= 'w';
50 case 'jet'
51 color= 'black';
52 colormap(jet);
53 bgcolor= 'w';
54 end
55
56 set(gca,'FontSize',fontsize,'xcolor',color);
57 set(gca,'FontSize',fontsize,'ycolor',color);
58
59 h=get(0,'CurrentFigure');
60 axis xy;
61 set(gcf, 'color', bgcolor);
62 set(gcf, 'InvertHardCopy', 'off');
63
64 xlabel('Time[s]','FontSize',fontsize,'Color',color)
65 ylabel('Frequency[kHz]','FontSize',fontsize,'Color',color)