Browse code

starting som prediction fine-tuned class-performance visualisation

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@112 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on21/01/2009 16:34:25
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,43 @@
1
+function inds = som_sub2ind(msize,Subs)
2
+
3
+%SOM_SUB2IND Linear index from map grid subscripts.
4
+%
5
+% ind = som_sub2ind(msize,Subs)
6
+%
7
+%  ind = som_sub2ind([10 15],[4 5]);
8
+%  ind = som_sub2ind(sMap,[4 5]);
9
+%  ind = som_sub2ind(sMap.msize,[4 5]);
10
+%  inds = som_sub2ind([10 15],[4 5; 3 2; 1 10]);
11
+%
12
+%  Input and output arguments: 
13
+%   msize  (struct) map or topology struct
14
+%          (vector) size 1 x m, specifies the map grid size
15
+%   Subs   (matrix) size n x m, the subscripts of n vectors
16
+%
17
+%   inds   (vector) size n x 1, corresponding linear indeces
18
+%
19
+% See also SOM_IND2SUB.
20
+
21
+% Contributed to SOM Toolbox vs2, February 2nd, 2000 by Juha Vesanto
22
+% http://www.cis.hut.fi/projects/somtoolbox/
23
+
24
+% juuso 300798
25
+
26
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27
+
28
+if isstruct(msize), 
29
+  if strcmp(msize.type,'som_map'), msize = msize.topol.msize; 
30
+  elseif strcmp(msize.type,'som_topol'), msize = msize.msize;
31
+  else error('Invalid first argument.'); end
32
+end
33
+
34
+% check off-limits
35
+[n d] = size(Subs);
36
+offl = find(Subs < 1 | Subs > msize(ones(n,1),1:d)); 
37
+Subs(offl) = NaN;
38
+
39
+% indexes
40
+k = [1 cumprod(msize(1:end-1))]';
41
+inds = 1 + (Subs-1)*k;
42
+
43
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%