% analyze_laterality.m
%
% Analyze surface laterality for look_at_moriarty data
%-------------------------------------------------------------------------
%
% version history
% 27062018 Rogier   Created
%
% copyright
% Rogier B. Mars, University of Oxford, 2018
%-------------------------------------------------------------------------

% Load data
data = readimgfile('../look_at_moriarty_results/chimp_LR_take4b_allsubjects_50ICs_ICAtracts.dtseries.nii');
dataflipped = [data(20253:end,:); data(1:20252,:)];

% Create corrcoef
corrmatrix = zeros(50,50);
for i = 1:50
        corrmatrix(i,:) = corr(data(:,i),dataflipped,'type','Pearson');
end

% Plot results
figure;
myimagesc(corrmatrix,'imgTitle','Cortical symmetry','xAxisLabel','Flipped independent components','yAxisLabel','Independent Components');
hcb=colorbar; title(hcb,'Pearson r'); set(gcf,'color','w'); line([1 50],[1 50]);

% Get average max corr of group
c{1} = [20 34]; % cst
c{2} = [28 46 49 8 5 25 2 26 48 37 19 4]; % limbic
c{3} = [1 30 12 16 11 13 7 36 33 35 43 18 22 45 6 10]; % tempocc
c{4} = [3 9 14 15 17 21 23 24 27 29 31 32 38 39 40 41 42 44 47 50]; % parfront
for cc = 1:length(c)
    c_elements = [];
    for i = c{cc}
        c_elements = [c_elements max(corrmatrix(i,:))];
    end
    c_avg(cc) = mean(c_elements); clear c_elements;
end
