annotate reeval/features/extract_features.m @ 2:b1cd83874633

Major structural revision. Modular organization of functionalities
author Francisco Rodriguez Algarra <f.rodriguezalgarra@qmul.ac.uk>
date Wed, 28 Oct 2015 16:15:47 +0000
parents
children
rev   line source
f@2 1 function [features] = extract_features(experiment, N, options)
f@2 2
f@2 3 switch(experiment)
f@2 4
f@2 5 case 'mfcc_740ms'
f@2 6
f@2 7 filters = filter_bank(N, options.filt1_opt);
f@2 8 features = {@(x)(feval(@(x)(...
f@2 9 [x;...
f@2 10 circshift(x, [0 +1]); ...
f@2 11 circshift(x, [0 -1])]),...
f@2 12 format_scat(log_scat(...
f@2 13 spec_freq_average(x, filters, options.sc1_opt)))))};
f@2 14
f@2 15 case {'time_scat_l1', 'time_scat_l2', 'time_scat_l3'}
f@2 16
f@2 17 Wop = wavelet_factory_1d(N, options.filt1_opt, options.sc1_opt);
f@2 18 features = {@(x)(format_scat(log_scat(...
f@2 19 renorm_scat(scat(x, Wop)))))};
f@2 20
f@2 21 case {'time_freq_scat_l2', 'time_freq_scat_l2_adap_q1'}
f@2 22
f@2 23 Wop1 = wavelet_factory_1d(N, options.filt1_opt, options.sc1_opt);
f@2 24 fWop1 = wavelet_factory_1d(...
f@2 25 128, options.ffilt1_opt, options.fsc1_opt);
f@2 26
f@2 27 scatt_fun1 = @(x)(log_scat(renorm_scat(scat(x, Wop1))));
f@2 28 fscatt_fun1 = @(x)(func_output(@scat_freq, 2, scatt_fun1(x), fWop1));
f@2 29 feature_fun1 = @(x)(format_scat(fscatt_fun1(x)));
f@2 30
f@2 31 switch(experiment)
f@2 32
f@2 33 case 'time_freq_scat_l2'
f@2 34
f@2 35 features = {feature_fun1}
f@2 36
f@2 37 case 'time_freq_scat_l2_adap_q1'
f@2 38
f@2 39 Wop2 = wavelet_factory_1d(N, options.filt2_opt, options.sc2_opt);
f@2 40 fWop2 = wavelet_factory_1d(...
f@2 41 32, options.ffilt2_opt, options.fsc2_opt);
f@2 42
f@2 43 scatt_fun2 = @(x)(log_scat(renorm_scat(scat(x, Wop2))));
f@2 44 fscatt_fun2 = @(x)(func_output(@scat_freq, 2, scatt_fun2(x), fWop2));
f@2 45 feature_fun2 = @(x)(format_scat(fscatt_fun2(x)));
f@2 46
f@2 47 features = {feature_fun1, feature_fun2};
f@2 48
f@2 49 end
f@2 50
f@2 51 for k = 1:length(features)
f@2 52 fprintf('testing feature #%d...', k);
f@2 53 tic;
f@2 54 sz = size(features{k}(randn(N, 1)));
f@2 55 aa = toc;
f@2 56 fprintf('Ok (%.2fs) (size [%d, %d])\n', aa, sz(1), sz(2));
f@2 57 end
f@2 58
f@2 59 otherwise
f@2 60 error(['Unknown experiment ', experiment, '. Aborting']);
f@2 61 end
f@2 62
f@2 63 end