Skip to content

Commit d44e50e

Browse files
committed
Fixes for HBN data to be compatible
1 parent 8c3fd24 commit d44e50e

11 files changed

+55
-24
lines changed

.DS_Store

0 Bytes
Binary file not shown.

parfor_stat_tools/pf_repetition_loop.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
end
8181

8282
% Skip method if no submethods need computation
83-
if ~any(struct2array(submethods_struct))
83+
if ~any(cell2mat(struct2cell(submethods_struct)))
8484
continue;
8585
end
8686

power_calculator_tools/atlas_data_set_map.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ case startsWith(data_set_choice, 'test') && endsWith(data_set_choice, 'act')
5858
atlas_file = NaN;
5959

6060
otherwise
61-
error('No atlas file found for dataset: %s', data_set_choice);
61+
% Default to shen atlas now
62+
atlas_file = './atlas_storage/map268_subnetwork.mat';
63+
% error('No atlas file found for dataset: %s', data_set_choice);
6264
end
6365
end
6466
end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function subset_cell = cap_t2_test_subs_when_data_limited(RP)
2+
3+
subset_cell = {};
4+
for i = 1:numel(RP.list_of_nsubset)
5+
n = RP.list_of_nsubset{i};
6+
7+
if n >= RP.n_subs_1 || n >= (RP.n_subs - RP.n_subs_1)
8+
fprintf(['Subset size %d exceeds minority group (%d vs %d). ' ...
9+
'Removing from analysis.\n'], ...
10+
n, RP.n_subs_1, RP.n_subs - RP.n_subs_1);
11+
else
12+
subset_cell{end+1} = n;
13+
end
14+
end
15+
16+
end

power_calculator_tools/draw_repetition_ids.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
ids = [ids; ids + RP.n_subs]';
5858

5959
case 't2'
60-
60+
6161
ids_1 = randperm(RP.n_subs_1, RP.n_subs_subset);
6262
ids_2 = randperm(RP.n_subs - RP.n_subs_1, RP.n_subs_subset) + RP.n_subs_1;
6363

power_calculator_tools/extract_atlas_related_parameters.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
trilmask_net = NaN;
4444
edge_groups = [];
4545
n_networks = 0;
46-
46+
4747
% Only apply atlas to the network-based stats
4848
if ~isnan(RP.atlas_file)
4949

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function [index_cond_1, index_cond_2] = get_index_matching_score(TestData_score, test_score_set)
2+
3+
% Type cast to str to handle weird datatypes
4+
score_str = string(TestData_score);
5+
set_str = string(test_score_set);
6+
7+
% Find indexes matching the condition
8+
index_cond_1 = score_str == set_str(1);
9+
index_cond_2 = score_str == set_str(2);
10+
11+
end

power_calculator_tools/infer_test_from_data.m

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,17 @@
5555

5656
test_type_origin = 'score_cond';
5757
% if two unique entries in score -> t (paired) or t2
58-
59-
% Are the subids always in outcomes? For the hpc one, we have
60-
% NaN and it is likely a t2 test
61-
index_cond_1 = strcmp(TestData.score, test_score_set{1});
62-
index_cond_2 = strcmp(TestData.score, test_score_set{2});
58+
59+
[index_cond_1, index_cond_2] = get_index_matching_score(TestData.score, ...
60+
test_score_set);
6361

6462
sub_ids_cond1 = BrainData.(TestData.reference_condition).sub_ids(index_cond_1);
6563
sub_ids_cond2 = BrainData.(TestData.reference_condition).sub_ids(index_cond_2);
6664

6765
%% TODO: Divided by the two - focus on group sizes
6866
n_equal = numel(intersect(sort(sub_ids_cond1), sort(sub_ids_cond2)));
6967
n_unique = numel(setxor(sub_ids_cond1, sub_ids_cond2));
70-
68+
7169
if n_equal >= n_unique
7270
test_type = 't';
7371
else

power_calculator_tools/rep_cal_function.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function rep_cal_function(Params)
106106
% However, only the r test type will use this test
107107
switch test_type_origin
108108

109-
% Here: RP.test_name, RP.n_subs_1, RP.n_subs_2, RP.n_subs
109+
% Here: RP.test_name, RP.n_subs_1, RP.n_subs_2, RP.n_subs
110110
case 'score_cond'
111111
[X, Y , RP] = subs_data_from_score_condition(RP, OutcomeData.(t), BrainData, t);
112112

@@ -117,6 +117,10 @@ function rep_cal_function(Params)
117117
error('Test type origin not found')
118118

119119
end
120+
121+
if strcmp(RP.test_type, 't2')
122+
RP.list_of_nsubset = cap_t2_test_subs_when_data_limited(RP);
123+
end
120124

121125
% Sets ground truth parameters for gt calculation
122126
% Future note, avoid this, for clarity, make sure each function returns exactly

power_calculator_tools/subs_data_from_score_condition.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@
4343
case 't2'
4444

4545
ref_cond = TestData.reference_condition;
46-
47-
index_cond_1 = strcmp(TestData.score, test_score_set{1});
48-
index_cond_2 = strcmp(TestData.score, test_score_set{2});
4946

47+
[index_cond_1, index_cond_2] = get_index_matching_score(TestData.score, ...
48+
test_score_set);
49+
5050
% I call c1 one rest and c2 task for consitency - even though
5151
% they might not be task and rest
5252
RP.sub_ids_rest = TestData.sub_ids(index_cond_1);

0 commit comments

Comments
 (0)