1
+ %%
2
+ % LiveCellMiner.
3
+ % Copyright (C) 2020 D. Moreno-Andres, A. Bhattacharyya, W. Antonin, J. Stegmaier
4
+ %
5
+ % Licensed under the Apache License, Version 2.0 (the "License");
6
+ % you may not use this file except in compliance with the License.
7
+ % You may obtain a copy of the Liceense at
8
+ %
9
+ % http://www.apache.org/licenses/LICENSE-2.0
10
+ %
11
+ % Unless required by applicable law or agreed to in writing, software
12
+ % distributed under the License is distributed on an "AS IS" BASIS,
13
+ % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ % See the License for the specific language governing permissions and
15
+ % limitations under the License.
16
+ %
17
+ % Please refer to the documentation for more information about the software
18
+ % as well as for installation instructions.
19
+ %
20
+ % If you use this application for your work, please cite the repository and one
21
+ % of the following publications:
22
+ %
23
+ % TBA
24
+ %
25
+ %%
26
+
27
+
28
+ %% get the selected single features
29
+ selectedFeatures = parameter .gui .merkmale_und_klassen .ind_em ;
30
+ selectedOutputVariable = parameter .gui .merkmale_und_klassen .ausgangsgroesse ;
31
+
32
+ %% find the manual synchronization index
33
+ synchronizationIndex = callback_livecellminer_find_time_series(var_bez , ' manualSynchronization' );
34
+
35
+ %% get stage transitions
36
+ if (synchronizationIndex > 0 )
37
+ confirmedTrack = squeeze(d_orgs(ind_auswahl , 1 , synchronizationIndex )) > 0 ;
38
+ else
39
+ confirmedTrack = ones(size(ind_auswahl ));
40
+ end
41
+
42
+ %% retrieve the parameters and convert them to numbers
43
+ significanceLevel = 3 ;
44
+
45
+ disp([' Computing Median Absolute Deviation (MAD) using a threshold of ' num2str(significanceLevel ) ' *MAD for hits.' ]);
46
+
47
+ %% perform selected test to all selected features independently for each of the output variables
48
+ for f= selectedFeatures
49
+
50
+ %% get the selected output classes
51
+ selectedOutputClasses = unique(code(ind_auswahl ));
52
+ numOutputClasses = length(selectedOutputClasses );
53
+
54
+
55
+ %% open result files for writing
56
+ outputFileName = [' MADTest_' kill_lz(dorgbez(f ,: )) ' _TestResult.csv' ];
57
+ fileHandle = fopen([parameter .projekt .pfad filesep outputFileName ], ' wb' );
58
+
59
+ %% write the specifiers
60
+ fprintf(fileHandle , ' Feature Name; Median; MAD\n ' );
61
+
62
+ %% compute the global median
63
+ currentValues = d_org(ind_auswahl(confirmedTrack ), f );
64
+ currentValues(isinf(currentValues ) | isnan(currentValues )) = [];
65
+ globalMedian = median(currentValues );
66
+ medianValues = zeros(numOutputClasses , 1 );
67
+ medianDeviations = zeros(numOutputClasses , 1 );
68
+
69
+ %% compute absolute median deviation
70
+ for i= 1 : numOutputClasses
71
+
72
+ %% get the current output classes
73
+ currentClass = selectedOutputClasses(i );
74
+
75
+ %% find indices matching the feature and output classes
76
+ selectedIndices = intersect(ind_auswahl , find(code_alle(ind_auswahl , selectedOutputVariable ) == currentClass & confirmedTrack ));
77
+ outputVariableName = zgf_y_bez(selectedOutputVariable , currentClass ).name;
78
+
79
+ %% get the feature values
80
+ currentFeatureValues = d_org(selectedIndices , f );
81
+ currentFeatureValues(isinf(currentFeatureValues ) | isnan(currentFeatureValues )) = [];
82
+
83
+ medianValues(i ) = median(currentFeatureValues );
84
+ medianDeviations(i ) = abs(medianValues(i ) - globalMedian );
85
+ end
86
+
87
+ MADValue = mean(medianDeviations );
88
+ MADThreshold = globalMedian + 3 * MADValue ;
89
+
90
+ fprintf(fileHandle , ' Global Median; %f ; %f\n ' , globalMedian , MADValue );
91
+
92
+ showHistogram = false ; showViolinPlots = true ; callback_livecellminer_show_combined_boxplots(parameter , d_org , d_orgs , dorgbez , var_bez , ind_auswahl , bez_code , code_alle , zgf_y_bez , showHistogram , showViolinPlots );
93
+
94
+ fh = gcf ; hold on ;
95
+ plot([0 , numOutputClasses + 1 ], [globalMedian , globalMedian ], ' --k' , ' LineWidth' , 2 );
96
+ plot([0 , numOutputClasses + 1 ], [globalMedian + significanceLevel * MADValue , globalMedian + 3 * MADValue ], ' -.k' , ' LineWidth' , 2 );
97
+ plot([0 , numOutputClasses + 1 ], [globalMedian - significanceLevel * MADValue , globalMedian - 3 * MADValue ], ' -.k' , ' LineWidth' , 2 );
98
+
99
+ currentYLim = get(gca , ' YLim' );
100
+ textOffset = (currentYLim(2 ) - currentYLim(1 )) / 60 ;
101
+ text(0.01 , globalMedian + textOffset , ' Global Median' );
102
+ text(0.01 , globalMedian + 3 * MADValue + textOffset , sprintf(' Global Median + %i *MAD' , significanceLevel ));
103
+ text(0.01 , globalMedian - 3 * MADValue - textOffset , sprintf(' Global Median - %i *MAD' , significanceLevel ));
104
+
105
+ %% compute absolute median deviation
106
+ for i= 1 : numOutputClasses
107
+
108
+ %% get the current output classes
109
+ currentClass = selectedOutputClasses(i );
110
+
111
+ %% find indices matching the feature and output classes
112
+ outputVariableName = zgf_y_bez(selectedOutputVariable , currentClass ).name;
113
+
114
+ %% get the feature values
115
+ currentMAD = (medianValues(i ) - globalMedian ) / MADValue ;
116
+
117
+ %% print the current feature name
118
+ fprintf(fileHandle , ' %s ;%f ;%f ;\n ' , outputVariableName , medianValues(i ), currentMAD );
119
+ end
120
+
121
+ %% close the file handles
122
+ fclose(fileHandle );
123
+ end
0 commit comments