changeset 21:e26be576f241

add figure functions and beta version of getClassInfo
author gregoire lafay <gregoirelafay@sfr.fr>
date Thu, 14 Jan 2016 06:54:31 +0100
parents 3e78af49b119
children 06e845616cae
files nonExposed/analyseBaseLineDev.m nonExposed/coloredSpectrumVisualization.m nonExposed/getClassInfo.m
diffstat 3 files changed, 158 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nonExposed/analyseBaseLineDev.m	Thu Jan 14 06:54:31 2016 +0100
@@ -0,0 +1,67 @@
+load ~/Téléchargements/results.mat
+
+
+val{1}=[10 30 50];
+val{2}=[0 6 12];
+val{3}=[0 1];
+
+for jj=1:length(val{1})
+   indMs(jj,:)=cellfun(@(x) ~isempty(strfind(x,['meanSpace_' num2str(val{1}(jj))])),filenames);
+end
+for jj=1:length(val{2})
+   indEbr(jj,:)=cellfun(@(x) ~isempty(strfind(x,['ebr_' num2str(val{2}(jj))])),filenames);
+end
+for jj=1:length(val{3})
+   indOvlp=cellfun(@(x) ~isempty(strfind(x,'ovlp_1')),filenames);
+end
+
+[~,indBestTresh]=max(max(F,[],1));
+
+figure(1)
+subplot 221
+plot(F(indOvlp & indMs(1,:),indBestTresh),'-*')
+hold on
+plot(F(indOvlp & indMs(2,:),indBestTresh),'-r*')
+plot(F(indOvlp & indMs(3,:),indBestTresh),'-y*')
+hold off
+ylim([0 0.6])
+ylabel('F')
+title('polyphonic')
+set(gca,'xtick',1:3,'xticklabel',val{2},'box','off')
+xlabel('EBR')
+subplot 222
+plot(F(~indOvlp & indMs(1,:),indBestTresh),'-*')
+hold on
+plot(F(~indOvlp & indMs(2,:),indBestTresh),'-r*')
+plot(F(~indOvlp & indMs(3,:),indBestTresh),'-y*')
+hold off
+title('monophonic')
+set(gca,'xtick',1:3,'xticklabel',val{2},'box','off')
+ylim([0 0.6])
+xlabel('EBR')
+ylabel('F')
+
+subplot 223
+plot(Feb(indOvlp & indMs(1,:),indBestTresh),'-*')
+hold on
+plot(Feb(indOvlp & indMs(2,:),indBestTresh),'-r*')
+plot(Feb(indOvlp & indMs(3,:),indBestTresh),'-y*')
+hold off
+ylim([0 0.3])
+ylabel('Feb')
+title('polyphonic')
+set(gca,'xtick',1:3,'xticklabel',val{2},'box','off')
+xlabel('EBR')
+subplot 224
+plot(Feb(~indOvlp & indMs(1,:),indBestTresh),'-*')
+hold on
+plot(Feb(~indOvlp & indMs(2,:),indBestTresh),'-r*')
+plot(Feb(~indOvlp & indMs(3,:),indBestTresh),'-y*')
+hold off
+title('monophonic')
+set(gca,'xtick',1:3,'xticklabel',val{2},'box','off')
+ylim([0 0.3])
+xlabel('EBR')
+ylabel('Feb')
+legend(arrayfun(@(x) ['meanSpace ' num2str(x)],val{1},'UniformOutput',false))
+disp('')
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nonExposed/coloredSpectrumVisualization.m	Thu Jan 14 06:54:31 2016 +0100
@@ -0,0 +1,55 @@
+function [] = coloredSpectrumVisualization(tracks,figNum,settingFigure,figuresOption,fileName,sr)
+
+wStep=1024;
+wSize=wStep*2;
+maxFreqBin=400;
+
+% Producing a colored spectrum visualization
+for i=1:size(tracks,1)
+    spec = log(1+abs(spectrogram(tracks(i,:), hanning(wSize), wStep, wSize)));
+    spec = min(1, spec ./ max(spec(:)));
+    spec = spec(1:maxFreqBin,:);
+    spec = flipud(spec);
+    for colorComp=1:3
+        if (i==1)
+            img(:,:,colorComp) = settingFigure.cmap(i,colorComp)*spec;
+        else
+            img(:,:,colorComp) = img(:,:,colorComp)+settingFigure.cmap(i,colorComp)*spec;
+        end
+    end
+end
+
+
+
+
+img = img/max(img(:));
+
+switch figuresOption
+    case 1
+       f=figure('Visible', 'off');
+    case 2
+       f=figure(figNum);
+end
+
+
+clf;
+imagesc(img);
+xlim([0 size(img,2)])
+ylim([0 maxFreqBin])
+xtick=0:round(settingFigure.sr/wStep*20):size(img,2); % every 20 sec
+ytick=0:50:maxFreqBin; % every 500 Hz
+set(gca,'YTick',0:50:maxFreqBin,'YTicklabel', fliplr(round(ytick*settingFigure.sr/wSize)),'xtick',xtick,'xTicklabel',round(xtick*wStep/settingFigure.sr));
+xlabel('time (sec)')
+ylabel('Frequency (Hz)')
+
+set(f,'PaperUnits','centimeters')
+set(f,'PaperPositionMode','manual')
+set(f,'papersize',[settingFigure.width,settingFigure.height])
+set(f,'paperposition',[0,0,settingFigure.width,settingFigure.height])
+set(findall(f,'-property','FontSize'),'FontSize',settingFigure.FontSize)
+set(findall(f,'-property','FontName'),'FontName','Arial')
+
+print(f,fileName,'-dpng')
+
+end
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nonExposed/getClassInfo.m	Thu Jan 14 06:54:31 2016 +0100
@@ -0,0 +1,36 @@
+clear all
+close all
+
+addpath(genpath('~/projets/simscene'))
+
+inputPath='~/Dropbox/databases/environment/dcase2/dcase2_train_dev/train/sound/event/';
+
+label={'alert','clearthroat','cough','keyboard','doorslam','drawer','keys','knock','laughter','pageturn','phone','speech'};
+
+
+if ~exist(inputPath, 'dir')
+    error(['Could not find local dir ',path,'\n']);
+end
+
+
+for jj=1:length(label)
+    eventInfo(jj).query = label{jj};
+    
+    samples = dir([inputPath '*wav']);
+    samplesInd = find(cellfun('isempty',regexpi({samples.name}, eventInfo(jj).query,'match'))==0);
+    
+    eventInfo(jj).startTimes=[];
+    eventInfo(jj).endTimes=[];
+    eventInfo(jj).names={};
+    
+    for ii=1:length(samplesInd)
+        samplesInfo=audioinfo([inputPath samples(samplesInd(ii)).name]);
+        
+        eventInfo(jj).names{end+1} = samples(samplesInd(ii)).name;
+        eventInfo(jj).startTimes(end+1) = 0;
+        eventInfo(jj).endTimes(end+1) = samplesInfo.TotalSamples/samplesInfo.SampleRate;
+    end
+end
+
+save('data/eventInfo','eventInfo')
+disp('')