
% b=load('LIFECLEF2014_BIRDAMAZON_XC_WAV_RN9224.wav_T4_Q20_J40.dat');
a=dir('/NAS3/SABIOD/public_data/SCATT_BIRD_50mostE_perfile_april2014_RB_HG/');


for I=1:length(a)
I
b = load(['../SCATT_BIRD_50mostE_perfile_april2014_RB_HG/', num2str(I) , '/CAT.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 1 1])
r = 67; % pixels per inch
set(gcf, 'PaperUnits', 'inches', 'PaperPosition', [0 0 67 67]/r);

%for i = 1:150 ; 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 ; 
for i = 1:300 
imagesc(squeeze(carre(2:end,2:end,iq(i))))
set(gca,'position',[0 0 1 1],'units','normalized')
axis off 
%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))]) 
print([num2str(I) , '/classe',num2str(I),  '_best', num2str(i) '_std.png'],'-dpng');
end
LISTE=[];
%for i=1:150
%LISTE=[LISTE;reshape(carre(:,:,iq(i)),1,4624)];
%end
%save(['./' num2str(I) '/carres.dat'],'LISTE','-ascii')
%hist(diff(iq),1:1:1000)
%print([num2str(i), '/histo.png'],'-dpng') 
end
