annotate toolboxes/MIRtoolbox1.3.2/MIRToolbox/@mirkeysom/mirkeysom.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function varargout = mirkeysom(orig,varargin)
wolffd@0 2 % ks = mirkeysom(x) projects a chromagram on a self-organizing map.
wolffd@0 3 % Creates a pseudocolor map showing the projection of chromagram onto a
wolffd@0 4 % self-organizing map trained with the Krumhansl-Kessler profiles (modified
wolffd@0 5 % for chromagrams). Colors correspond to Pearson correlation values.
wolffd@0 6 % References:
wolffd@0 7 % Toiviainen, P. & Krumhansl, C. L. (2003). Measuring and modeling
wolffd@0 8 % real-time responses to music: the dynamics of tonality induction.
wolffd@0 9 % Perception, 32(6), 741-766.
wolffd@0 10 % Krumhansl, C. L., & Toiviainen, P. (2001) Tonal cognition.
wolffd@0 11 % In R. J. Zatorre & I. Peretz (Eds.), The Biological Foundations of Music.
wolffd@0 12 % Annals of the New York Academy of Sciences.
wolffd@0 13
wolffd@0 14 % filename.key = 'File';
wolffd@0 15 % filename.type = 'String';
wolffd@0 16 % filename.default = 0;
wolffd@0 17 % option.filename = filename;
wolffd@0 18
wolffd@0 19 specif.option = struct;
wolffd@0 20 specif.defaultframelength = 1;
wolffd@0 21 specif.defaultframehop = .5;
wolffd@0 22
wolffd@0 23 varargout = mirfunction(@mirkeysom,orig,varargin,nargout,specif,@init,@main);
wolffd@0 24
wolffd@0 25
wolffd@0 26 function [c type] = init(orig,option)
wolffd@0 27 c = mirchromagram(orig,'Normal');
wolffd@0 28 type = 'mirkeysom';
wolffd@0 29
wolffd@0 30
wolffd@0 31 function s = main(c,option,postoption)
wolffd@0 32 if iscell(c)
wolffd@0 33 c = c{1};
wolffd@0 34 end
wolffd@0 35 load keysomaudiodata;
wolffd@0 36 m = get(c,'Magnitude');
wolffd@0 37 disp('Projecting the chromagram to a self-organizing map...')
wolffd@0 38 z = cell(1,length(m));
wolffd@0 39 p = cell(1,length(m));
wolffd@0 40 for i = 1:length(m)
wolffd@0 41 mi = m{i};
wolffd@0 42 if not(iscell(mi))
wolffd@0 43 mi = {mi};
wolffd@0 44 end
wolffd@0 45 zi = cell(1,length(mi));
wolffd@0 46 pi = cell(1,length(mi));
wolffd@0 47 for j = 1:length(mi)
wolffd@0 48 mj = mi{j};
wolffd@0 49 zj = zeros(24,size(mj,2),size(mj,3),36);
wolffd@0 50 pi{j} = zeros(24,size(mj,2),size(mj,3),36);
wolffd@0 51 for k = 1:size(mj,2)
wolffd@0 52 for l = 1:size(mj,3)
wolffd@0 53 for kk=1:36
wolffd@0 54 for ll=1:24
wolffd@0 55 tmp = corrcoef([mj(:,k,l) somw(:,kk,ll)]);
wolffd@0 56 zj(ll,k,l,kk) = tmp(1,2);
wolffd@0 57 end
wolffd@0 58 end
wolffd@0 59 end
wolffd@0 60 end
wolffd@0 61 zi{j} = zj;
wolffd@0 62 end
wolffd@0 63 z{i} = zi;
wolffd@0 64 p{i} = pi;
wolffd@0 65 end
wolffd@0 66 s = class(struct,'mirkeysom',mirdata(c));
wolffd@0 67 s = purgedata(s);
wolffd@0 68 s = set(s,'Title','Key SOM','Abs','','Ord','','Weight',z,'Pos',p);
wolffd@0 69 %if option.filename
wolffd@0 70 % mov = display(s,option.filename);
wolffd@0 71 %else
wolffd@0 72 % mov = display(s);
wolffd@0 73 %end
wolffd@0 74 %s = {s,mov};