48 lines
1.5 KiB
Matlab
48 lines
1.5 KiB
Matlab
function[] = statistics(exp)
|
|
%
|
|
% Calculate pairwise TFCE statistics between aggregates
|
|
% based on permutation
|
|
%
|
|
%
|
|
|
|
for a = 1:length(exp.aggregates)
|
|
|
|
for b = setdiff(1:length(exp.aggregates), a)
|
|
|
|
%% retreive matrices for aggregates of comparison
|
|
[traces_a time_a] = exp.get_aggregate_data(a);
|
|
[traces_b time_b] = exp.get_aggregate_data(b);
|
|
|
|
%% TODO: Check time_a == time_b !
|
|
|
|
traces = [traces_a ; traces_b];
|
|
labels = [repmat(1, 1:size(traces_a,2)) repmat(2, 1:size(traces_b,2))];
|
|
|
|
%% calculate true difference:
|
|
|
|
true_signal = nanmean(traces_a) - nanmean(traces_b);
|
|
|
|
%% perform permutations
|
|
nperm = exp.settings.Statistics.NumberOfPermutations;
|
|
P = nan(size(traces_1,1), nperm);
|
|
|
|
for i = 1:nperm
|
|
|
|
labels_permuted = labels(randperm(length(labels)));
|
|
a_perm = find(labels_permuted==1); b_perm = find(labels_permuted==2);
|
|
|
|
P(:,i) = nanmean(traces(a_perm,:)) - nanmean(traces(b_perm,:));
|
|
end
|
|
hmin = 0; hmax = max(max(P));
|
|
|
|
%% perform TFCE
|
|
T = TFCEobj('D', P, 'hmax', hmax);
|
|
T.TFCECalc;
|
|
|
|
%% store results
|
|
exp.aggregates.statistics.TFCE(a,b).results.pvalues = T.Pvalues;
|
|
%% threshold FWE comparison
|
|
exp.aggregates.statistics.TFCE(a,b).results.pvalues = T.Pvalues;
|
|
end
|
|
end
|