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,56 @@
1
+function sD = som_fillnans(sD,sM,bmus)
2
+
3
+% SOM_FILLNANS Replaces NaNs in the data matrix with values from
4
+%              SOM prototypes. 
5
+%
6
+%   sD = som_fillnans(sD,sM, [bmus])
7
+%
8
+%      sD      (struct) data struct
9
+%              (matrix) size dlen x dim
10
+%      sM      (struct) data struct, with .data of size dlen x dim
11
+%              (matrix) size dlen x dim, a matrix from which 
12
+%                       the values are taken from directly
13
+%              (struct) map struct: replacement values are taken from 
14
+%                       sM.codebook(bmus,:)
15
+%      [bmus]  (vector) BMU for each data vector (calculated if not specified)
16
+%
17
+% See also  SOM_MAKE.
18
+
19
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20
+
21
+if isstruct(sD), 
22
+  [dlen dim] = size(sD.data); 
23
+  nans = find(isnan(sD.data)); 
24
+else
25
+  [dlen dim] = size(sD); 
26
+  nans = find(isnan(sD)); 
27
+end
28
+
29
+if nargin<3, 
30
+  bmus = som_bmus(sM,sD);   
31
+end
32
+
33
+if isstruct(sM) & strcmp(sM.type,'som_map'),
34
+  sM = sM.codebook(bmus,:); 
35
+elseif isstruct(sM), 
36
+  sM = sM.data(bmus,:);   
37
+else
38
+  sM = sM(bmus,:);
39
+end
40
+me = mean(sM); 
41
+
42
+if any(size(sM) ~= [dlen dim]), 
43
+  error('Invalid input arguments.')
44
+end
45
+
46
+if isstruct(sD), 
47
+  sD.data(nans) = sM(nans); 
48
+else
49
+  sD(nans) = sM(nans); 
50
+end
51
+  
52
+return; 
53
+
54
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55
+
56
+