-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjpa_getAllResults.m
More file actions
132 lines (129 loc) · 4.83 KB
/
jpa_getAllResults.m
File metadata and controls
132 lines (129 loc) · 4.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
function new_all_sig_results = jpa_getAllResults(pathToAllSigRes,current_sig_results)
% Function that combines a existing Results-File with a new Results-file.
% Results that already exists in old Results-File will be overwritten.
% Results that does exist in old Results-File and not in current_sig_results
% will not be deleted and will be written in output. So no Information will
% be lost.
%
% Syntax:
% new_all_sig_results =
% jpa_getAllResults(pathToAllSigRes,current_sig_results)
%
% Inputs:
% pathToAllSigRes - Path to old sig_results file
% current_sig_results - Struct which contains new results
% .type - Name of statistical Analysis
% .name - Name of statistical Test-directory
% .con - Name of Contrast
% .ClusterFWE - Struct containing thresholded results of Cluster
% Familywise-error-correction
% .ClusterFDR - Struct containing thresholded results of Cluster
% False Detection Rate
% .PeakFWE - Struct containing thresholded results of PeakCoord
% Familywise-error-correction
% .PeakFDR - Struct containing thresholded results of PeakCoord
% False Detection Rate
%
% Outputs:
% new_all_sig_results - Struct containing Information from old file
% which are not in current_sig_results and all Information in
% current_sig_results
%
% Example:
% jpa_getAllResults('C:\all_sig_res.mat',current_sig_results)
% where current_sig_results
% .type = 'ttest'
% .name = 'ttest'
% .con = 'con_0001'
% .ClusterFWE = []
% .ClusterFDR = []
% .PeakFWE = []
% .PeakFDR = []
%
% Other m-files required: none
% Subfunctions: none
% MAT-files required: none
%
% See also:
% Author: Jan Albrecht
% Work address:
% email: jan-philipp.albrecht@charite.de, j.p.albrecht@fu-berlin.de
% Website:
% Sep 2015; Last revision: 29-Sep-2015
%------------- BEGIN CODE --------------
% test for existance of all_sig_results.mat
if exist(pathToAllSigRes,'file')
% load file
all_sig_results = load(pathToAllSigRes);
% get name of loaded file
fieldname = fieldnames(all_sig_results);
all_sig_results = all_sig_results.(fieldname{1,1});
% check if all_sig_res is empty
if ~isempty(all_sig_results)
% check if current_sig_results is empty
if ~isempty(current_sig_results)
% dermine size of loaded .mat
[l,b] = size(all_sig_results);
% determine size of current_sig_results
[l,d] = size(current_sig_results);
else % case empty:
% new_all_sig_results has to be all_sig_results because
% current_sig_results is empty
new_all_sig_results = all_sig_results;
return;
end
else % case empty:
% new_all_sig_results has to be current_sig_results because
% all_sig_results is empty
new_all_sig_results = current_sig_results;
return;
end
% Initialize index for new output
inx = 0;
% initialize logical vector(s)
currResFound = false(d,1);
found = false;
% loop through all_sig_results rows
for i=1:1:b
% loop through current results rows
for j=1:1:d
% compare name and contrast-Name of all_sig_results and
% current_sig_results
if strcmp(all_sig_results(i).name , current_sig_results(j).name) ...
&& strcmp(all_sig_results(i).con , current_sig_results(j).con)
% case: both equal
% in output will be written the new results in
% current_sig_results
inx = inx + 1;
new_all_sig_results(inx) = current_sig_results(j);
% set logical vector at position to true;
currResFound(j,1) = true;
% set found to true so the (old) name and contrast in
% all_sig_results will not be written
found = true;
break;
end
end
% check if test with contrast was found in current_sig_results
if ~found
% case: not
% write old results in new results because it has not been
% renewed e.g. is not in current_sig_results
inx = inx + 1;
new_all_sig_results(inx) = all_sig_results(i);
end
% initialize logical for next result
found = false;
end
% write rest of current_sig_results in output
current_sig_results = current_sig_results(~currResFound);
[l,c] = size(current_sig_results);
for i=1:1:c
inx = inx + 1;
new_all_sig_results(inx) = current_sig_results(i);
end
else % case: no old result file exists
new_all_sig_results = current_sig_results;
end
end
%------------- END CODE --------------