-
Notifications
You must be signed in to change notification settings - Fork 0
/
MUSim_make_csv.m
95 lines (77 loc) · 3.64 KB
/
MUSim_make_csv.m
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
%Read simulation results in csv files
%
%Author: Eric Fields
%Version Date: 21 June 2019
main_dir = MUSim_main_dir();
%% Familywise measures
%Run Python script creating Familywise measure csvs
%Add location of Python script to Python path
py_addpath(main_dir);
%Run script
py.MUSim_make_csv.main();
%% Elementwise measurse
results_mats = get_files(fullfile(main_dir, 'results'), 'simulation_results.mat');
components = {'namesP300_reduced', 'P300'; ...
'NonCon_N400_reduced', 'N400'; ...
'simulated_focal_effect', 'P1'};
for i = 1:length(results_mats)
mat_file = results_mats{i};
%Get effect and time window
effect_name = components{cellfun(@(x) contains(mat_file, x), components(:,1)), 2};
[s_idx, e_idx] = regexp(mat_file, '_\d*-\d*_');
time_wind = mat_file((s_idx+1):(e_idx-1));
%Load simulation results
load(fullfile(main_dir, 'results', mat_file));
methods = fieldnames(simulation_results);
methods = methods(9:end);
%Elementwise Power
ew_power = table('Size', [1e4, length(methods)-1], ...
'VariableTypes', repmat({'doublenan'}, [1, length(methods)-1]), ...
'VariableNames', methods(2:end));
for m = 2:length(methods)
method = methods{m};
ew_power{:, methods{m}} = simulation_results.(method).ew_power;
output_file = fullfile(main_dir, 'results', sprintf('MUSim_Power_EW_power_%s_%s.csv', effect_name, time_wind));
writetable(ew_power, output_file);
end
%Elementwise FDR
ew_FDR = table('Size', [1e4, length(methods)-1], ...
'VariableTypes', repmat({'doublenan'}, [1, length(methods)-1]), ...
'VariableNames', methods(2:end));
for m = 2:length(methods)
method = methods{m};
ew_FDR{:, methods{m}} = simulation_results.(method).ew_FDR;
output_file = fullfile(main_dir, 'results', sprintf('MUSim_Power_EW_FDR_%s_%s.csv', effect_name, time_wind));
writetable(ew_FDR, output_file);
end
%Elementwise Type I
ew_TypeI = table('Size', [1e4, length(methods)-1], ...
'VariableTypes', repmat({'doublenan'}, [1, length(methods)-1]), ...
'VariableNames', methods(2:end));
for m = 2:length(methods)
method = methods{m};
ew_TypeI{:, methods{m}} = simulation_results.(method).ew_TypeI;
output_file = fullfile(main_dir, 'results', sprintf('MUSim_Power_EW_TypeI_%s_%s.csv', effect_name, time_wind));
writetable(ew_TypeI, output_file);
end
%Onset
onset = table('Size', [1e4, length(methods)-1], ...
'VariableTypes', repmat({'doublenan'}, [1, length(methods)-1]), ...
'VariableNames', methods(2:end));
for m = 2:length(methods)
method = methods{m};
onset{:, methods{m}} = simulation_results.(method).onset;
output_file = fullfile(main_dir, 'results', sprintf('MUSim_Power_EW_onset_%s_%s.csv', effect_name, time_wind));
writetable(onset, output_file);
end
%Offset
offset = table('Size', [1e4, length(methods)-1], ...
'VariableTypes', repmat({'doublenan'}, [1, length(methods)-1]), ...
'VariableNames', methods(2:end));
for m = 2:length(methods)
method = methods{m};
offset{:, methods{m}} = simulation_results.(method).offset;
output_file = fullfile(main_dir, 'results', sprintf('MUSim_Power_EW_offset_%s_%s.csv', effect_name, time_wind));
writetable(offset, output_file);
end
end