 b = load('CAT.dat');

% b=load('LIFECLEF2014_BIRDAMAZON_XC_WAV_RN9224.wav_T4_Q20_J40.dat');


carre = reshape(b(:,1:68*floor(length(b)/68)),68,68,floor(length(b)/68));              
crossF = std(carre(2:end,:,:),0,1)./mean(carre(2:end,:,:),1) ;
crossT = std(carre(2:end,:,:),0,2)./mean(carre(2:end,:,:),2) ;

mF = median(squeeze(crossF));                           
mT = median(squeeze(crossT));     
length(mF)
Cf=(std(std(carre(2:end,:,:)))./mean(mean(squeeze(carre(2:end,:,:)))));
E=squeeze(std(sum(carre(2:end,:,:))))';
length(Cf)                      
R =(1./E).*(1./squeeze(Cf)').*  mF ./ mT ;

R( median(squeeze(carre(1,:,:)))<0) =inf;                                           

[ v iq ]= sort(R);                                      
iq(1:2)

set(gcf,'PaperUnits','inches','PaperPosition',[0 0 50 50])

for i = 1:64 ; subplot(16,16,i) ; imagesc(squeeze(carre(2:end,:,iq(i)))); title([num2str(std(squeeze(carre(2:end,:,iq(i))))/mean(squeeze(carre(2:end,:,iq(i))))) ,num2str(median(squeeze(carre(1,:,iq(i))))) ,' ' , num2str(iq(i))]) ; end ; 
eval(['print best' num2str(i) '.png -dpng -r100 ']);

hist(diff(iq),1:1:1000)
print -dpng histdiff.png 

