Skip to content

Commit e407c8d

Browse files
committed
Fixed plotting scripts to match new data structure
1 parent df6ca99 commit e407c8d

21 files changed

+137
-73
lines changed

.DS_Store

0 Bytes
Binary file not shown.

calculate_power.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ function calculate_power(varargin)
137137
eval([method ' = PowerRes;']); % creates a variable named after the method
138138

139139
save(file_name, method, '-append');
140-
141-
fprintf('Finished power calculation for file %s \n', file_name);
142140

143141
end
142+
143+
fprintf('Finished power calculation for file %s \n', file_name);
144144

145145
end
146146

config_files/setparams.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@
2828
% Author: Fabricio Cravo | Date: March 2025
2929

3030
% Datasets - Commented for easy use
31-
Params.data_dir = './data/s_abcd_fc_rosenblatt.mat';
31+
% Params.data_dir = './data/s_abcd_fc_rosenblatt.mat';
3232
% Params.data_dir = './data/s_hcp_fc_noble_tasks.mat';
33-
% Params.data_dir = './data/s_hcp_act_noble_1.mat';
33+
Params.data_dir = './data/s_hcp_act_noble_1.mat';
34+
Params.output = NaN;
3435

3536
% Save specifications - if NaN output becomes dataset file name
3637
Params.save_directory = './power_calculator_results/';
3738
Params.gt_data_dir = './power_calculator_results/ground_truth/';
3839

39-
Params.output = 'abcd_100_reps';
40+
4041

4142
% Options - full_file, compact_file;
4243
Params.subsample_file_type = 'compact_file';

data_fit_scripts/fit_power_curve.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
% Default Weibull function
88
% default_func = @(params, x) 100*(1 - exp(-(x./params(1)).^params(2)));
9-
default_func = @(params, x) 100 ./ (1 + (params(1) ./ x).^params(2));
9+
default_func = @(params, x) params(3) ./ (1 + (params(1) ./ x).^params(2));
1010

1111
addParameter(p, 'fit_function', default_func, @(x) isa(x, 'function_handle'));
12-
addParameter(p, 'lower_bounds', [1, 0.1], @isnumeric); % Allow custom initial params
13-
addParameter(p, 'upper_bounds', [100000, 5], @isnumeric); % Allow custom initial params
12+
addParameter(p, 'lower_bounds', [1, 0.1, 0], @isnumeric); % Allow custom initial params
13+
addParameter(p, 'upper_bounds', [100000, 5, 100], @isnumeric); % Allow custom initial params
1414

1515
parse(p, varargin{:});
1616

@@ -24,9 +24,10 @@
2424
% b: start with exponential shape (b=1)
2525
a_init = median(results_x);
2626
b_init = 1;
27+
c_init = 50;
2728

2829
% Initial guess: [scale, shape]
29-
initial_params = [a_init, b_init];
30+
initial_params = [a_init, b_init, c_init];
3031

3132
% Define cost function (sum of squared residuals)
3233
cost_func = @(params) sum((results_y - power_func(params, results_x)).^2);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function edge_groups = get_edge_groups_from_meta_data(meta_data)
2+
3+
if isfield(meta_data, 'edge_groups')
4+
edge_groups = meta_data.edge_groups;
5+
return;
6+
end
7+
8+
if isfield(meta_data, 'rep_parameters')
9+
edge_groups = meta_data.rep_parameters.edge_groups;
10+
return;
11+
end
12+
13+
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function mask = get_mask_from_meta_data(meta_data)
2+
3+
if isfield(meta_data, 'mask')
4+
mask = meta_data.mask;
5+
return;
6+
end
7+
8+
if isfield(meta_data, 'rep_parameters')
9+
mask = meta_data.rep_parameters.mask;
10+
return
11+
end
12+
13+
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function study_name = get_study_name_from_meta_data(meta_data)
2+
3+
if isfield(meta_data, 'study_name')
4+
study_name = meta_data.study_name;
5+
return;
6+
end
7+
8+
if isfield(meta_data, 'rep_parameters')
9+
study_name = meta_data.rep_parameters.test_name;
10+
return;
11+
end
12+
13+
end

plot_scripts/.DS_Store

2 KB
Binary file not shown.

plot_scripts/average_heat_map_gen.m

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
function average_array = average_heat_map_gen(method, n_subs, directory, varargin)
1+
function [average_array, c_above_80] = ...
2+
average_heat_map_gen(method, n_subs, directory, varargin)
23
%
34
% For the paper: Shitf - down to select for paste
4-
% - average_heat_map_gen('Parametric_FDR',40,'/Users/f.cravogomes/Desktop/Pc_Res_Updated/power_calculation/hcp_fc')
5-
% - average_heat_map_gen('Constrained_cpp_FWER',40,'/Users/f.cravogomes/Desktop/Pc_Res_Updated/power_calculation/abcd_fc_test2')
6-
5+
% - average_heat_map_gen('Constrained_FDR',80,'/Users/f.cravogomes/Desktop/Pc_Res_Updated/SHOCK Paper Results/power_calculation/hcp_fc')
6+
% - average_heat_map_gen('Size_cpp',500,'/Users/f.cravogomes/Desktop/Pc_Res_Updated/SHOCK Paper Results/power_calculation/abcd_100_sex/')
7+
78
% Create parser object
89
p = inputParser;
910

@@ -45,23 +46,28 @@
4546
end
4647

4748
data = load(fullfile(files(i_f).folder, files(i_f).name));
48-
49-
if data.meta_data.subject_number ~= n_subs
49+
50+
if get_sub_number_from_meta_data(data.meta_data) ~= n_subs
5051
continue
5152
end
52-
53+
5354
data_acrs_tasks{end + 1} = data.(method).tpr;
5455
end
5556

5657
% Calculate average accross tasks
5758
data_acrs_tasks = cat(3, data_acrs_tasks{:});
5859
average_array = mean(data_acrs_tasks, 3);
60+
61+
c_above_80 = sum(average_array > 80, 'all');
5962

6063
% Get unflattening function based on experiment mask
61-
unflat_matrix_fun = unflatten_matrix(data.meta_data.rep_parameters.mask);
64+
mask = get_mask_from_meta_data(data.meta_data);
65+
unflat_matrix_fun = unflatten_matrix(mask);
6266

6367
% Unflat
64-
if ~strcmp(data.(method).meta_data.level, 'network')
68+
if ~strcmp( ...
69+
get_stats_level_from_method_data(method, data.(method), data.meta_data), ...
70+
'network')
6571

6672
try
6773
power_data = unflat_matrix_fun(average_array);
@@ -89,8 +95,9 @@
8995
end
9096

9197
end
92-
93-
edge_groups_line = data.meta_data.rep_parameters.edge_groups(1, :);
98+
99+
edge_groups = get_edge_groups_from_meta_data(data.meta_data);
100+
edge_groups_line = edge_groups(1, :);
94101

95102

96103
previous_number = edge_groups_line(1);
@@ -114,21 +121,43 @@
114121
end
115122

116123
end
117-
118-
% Assuming your 2D matrix is called 'data'
119-
figure;
124+
125+
% Figure config
126+
figure('Position', [100, 100, 800, 700]);
127+
120128
imagesc(power_data);
121-
colorbar;
122-
title(heatmap_title);
123-
xlabel(x_label);
124-
ylabel(y_label);
129+
130+
c = colorbar;
131+
c.FontSize = 12;
132+
c.FontWeight = 'bold';
133+
c.Label.String = 'Power (%)';
134+
c.Label.FontSize = 14;
135+
c.Label.FontWeight = 'bold';
136+
137+
title(heatmap_title, 'FontSize', 16, 'FontWeight', 'bold');
138+
139+
xlabel(x_label, 'FontSize', 14, 'FontWeight', 'bold');
140+
ylabel(y_label, 'FontSize', 14, 'FontWeight', 'bold');
141+
142+
set(gca, 'FontSize', 11, 'FontWeight', 'normal');
143+
144+
set(gca, 'LineWidth', 1.5);
145+
146+
set(gca, 'Layer', 'top');
147+
set(gca, 'GridLineStyle', '-');
148+
set(gca, 'GridColor', [0.5, 0.5, 0.5]);
149+
set(gca, 'GridAlpha', 0.1);
150+
grid on;
125151

126152
add_network_lines_from_starts(network_boundaries);
127153

128154
heat_map_color = custom_colors('sci_blu');
129-
130-
% Convert to 0-1 range
131155
colormap(heat_map_color);
156+
157+
axis square;
158+
159+
set(gca, 'TickDir', 'out');
160+
set(gca, 'Box', 'on');
132161

133162
end
134163

plot_scripts/generate_latex_table_from_cell.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
parse(p, varargin{:});
2020

2121
decimal_places = p.Results.format_numbers;
22-
22+
2323
if size(cell_data, 2) ~= numel(headers)
2424
error('Header data must be provided with correct number of headers')
2525
end

0 commit comments

Comments
 (0)