Commit 265dbfa4 authored by Sam Harrison's avatar Sam Harrison
Browse files

Include optimal value in plots

This is not always max is best (e.g. the NAF2 plots), so we now explicitly plot
the optimal value too.
parent f326b88e
......@@ -43,10 +43,11 @@ signs = diag(sign( cP(gt_inds,inf_inds) + cA(gt_inds,inf_inds) ));
%--------------------------------------------------------------------------
% Spatial accuracy - cosine similarity between subject maps
scores.P.data = NaN(params.S, params.N);
scores.P.name = 'Spatial maps';
scores.P.metric = 'Cosine similarity';
scores.P.range = [-1.0, 1.0];
scores.P.data = NaN(params.S, params.N);
scores.P.name = 'Spatial maps';
scores.P.metric = 'Cosine similarity';
scores.P.optimal = 1.0;
scores.P.range = [-1.0, 1.0];
for s = 1:params.S
% Just the scores between the two
cP = cosine_sim(P{s}, inf_P{s});
......@@ -58,10 +59,11 @@ end
%--------------------------------------------------------------------------
% Spatial accuracy - cross subject correlations
scores.P_xs.data = NaN(params.V, params.N);
scores.P_xs.name = 'Spatial maps (cross subject)';
scores.P_xs.metric = 'Correlation';
scores.P_xs.range = [-1.0, 1.0];
scores.P_xs.data = NaN(params.V, params.N);
scores.P_xs.name = 'Spatial maps (cross subject)';
scores.P_xs.metric = 'Correlation';
scores.P_xs.optimal = 1.0;
scores.P_xs.range = [-1.0, 1.0];
for n = 1:params.N
Pn = NaN(params.V, params.S);
inf_Pn = NaN(params.V, params.S);
......@@ -87,10 +89,11 @@ end
% Repeat for the temporal accuracy
% Take correlation between true and inferred time courses
scores.A.data = NaN(sum(params.R), params.N);
scores.A.name = 'Timecourses';
scores.A.metric = 'Correlation';
scores.A.range = [-1.0, 1.0];
scores.A.data = NaN(sum(params.R), params.N);
scores.A.name = 'Timecourses';
scores.A.metric = 'Correlation';
scores.A.optimal = 1.0;
scores.A.range = [-1.0, 1.0];
sr = 1;
for s = 1:params.S
for r = 1:params.R(s)
......@@ -125,15 +128,17 @@ end
% ** IGNORED ** Can't really disambiguate this from spatial scale
%scores.aA.data = diag(corr(aA, inf_aA));
% Return scores in order of GT components so comparable across methods
%scores.aA.data = scores.aA.data(gt_inds);
%scores.aA.name = 'Amplitudes';
%scores.aA.metric = 'Correlation';
%scores.aA.range = [-1.0, 1.0];
%scores.aA.data = scores.aA.data(gt_inds);
%scores.aA.name = 'Amplitudes';
%scores.aA.metric = 'Correlation';
%scores.aA.optimal = 1.0;
%scores.aA.range = [-1.0, 1.0];
% Each element, across amplitudes (i.e. behavioural prediction)
scores.aA_xs.data = diag(corr(aA', inf_aA'));
scores.aA_xs.name = 'Amplitudes (cross subject)';
scores.aA_xs.metric = 'Correlation';
scores.aA_xs.range = [-1.0, 1.0];
scores.aA_xs.data = diag(corr(aA', inf_aA'));
scores.aA_xs.name = 'Amplitudes (cross subject)';
scores.aA_xs.metric = 'Correlation';
scores.aA_xs.optimal = 1.0;
scores.aA_xs.range = [-1.0, 1.0];
%figure; imagesc(aA, max(aA(:))*[-1 1]); colorbar();
%figure; imagesc(inf_aA, max(inf_aA(:))*[-1 1]); colorbar();
......@@ -161,10 +166,11 @@ end
% Save the cosine similarity between unwrapped netmats
% Cosine sim as zero is meaningful for netmats
scores.cP.data = diag(cosine_sim(cPz, inf_cPz)); % Each subject, across elements
scores.cP.name = 'Spatial map interactions';
scores.cP.metric = 'Cosine similarity';
scores.cP.range = [-1.0, 1.0];
scores.cP.data = diag(cosine_sim(cPz, inf_cPz)); % Each subject, across elements
scores.cP.name = 'Spatial map interactions';
scores.cP.metric = 'Cosine similarity';
scores.cP.optimal = 1.0;
scores.cP.range = [-1.0, 1.0];
%figure; imagesc(cPz); colorbar
%figure; imagesc(inf_cPz); colorbar
%figure; imagesc(cosine_sim(cPz, inf_cPz), [-1, 1]); colorbar
......@@ -201,15 +207,17 @@ end
% Save the correlations over netmat elements
% Each subject, across elements (i.e. are netmats similar)
% Cosine sim as zero is meaningful for netmats
scores.pcA.data = diag(cosine_sim(pcAz, inf_pcAz));
scores.pcA.name = 'Netmats';
scores.pcA.metric = 'Cosine similarity';
scores.pcA.range = [-1.0, 1.0];
scores.pcA.data = diag(cosine_sim(pcAz, inf_pcAz));
scores.pcA.name = 'Netmats';
scores.pcA.metric = 'Cosine similarity';
scores.pcA.optimal = 1.0;
scores.pcA.range = [-1.0, 1.0];
% Each element, across subjects (i.e. behavioural prediction)
scores.pcA_xs.data = diag(corr(pcAz', inf_pcAz'));
scores.pcA_xs.name = 'Netmats (cross subject)';
scores.pcA_xs.metric = 'Correlation';
scores.pcA_xs.range = [-1.0, 1.0];
scores.pcA_xs.data = diag(corr(pcAz', inf_pcAz'));
scores.pcA_xs.name = 'Netmats (cross subject)';
scores.pcA_xs.metric = 'Correlation';
scores.pca_xs.optimal = 1.0;
scores.pcA_xs.range = [-1.0, 1.0];
%figure; imagesc(pcAz); colorbar
%figure; imagesc(inf_pcAz); colorbar
......@@ -229,15 +237,17 @@ inf_cPz = repelem(inf_cPz, 1, params.R);
% Cosine sim as zero is meaningful for netmats
scores.cP_pcA.data ...
= diag(cosine_sim(inf_cPz, inf_pcAz)) - diag(cosine_sim(cPz, pcAz));
scores.cP_pcA.name = 'Spatial-temporal netmat interactions';
scores.cP_pcA.metric = 'Cosine similarity (difference from GT)';
scores.cP_pcA.range = [-2.0, 2.0];
scores.cP_pcA.name = 'Spatial-temporal netmat interactions';
scores.cP_pcA.metric = 'Cosine similarity (difference from GT)';
scores.cP_pcA.optimal = 0.0;
scores.cP_pcA.range = [-2.0, 2.0];
% Each element, across subjects (i.e. behavioural prediction)
scores.cP_pcA_xs.data ...
= diag(corr(inf_cPz', inf_pcAz')) - diag(corr(cPz', pcAz'));
scores.cP_pcA_xs.name = 'Spatial-temporal netmat interactions (cross subject)';
scores.cP_pcA_xs.metric = 'Correlation (difference from GT)';
scores.cP_pcA_xs.range = [-2.0, 2.0];
scores.cP_pcA_xs.name = 'Spatial-temporal netmat interactions (cross subject)';
scores.cP_pcA_xs.metric = 'Correlation (difference from GT)';
scores.cP_pcA_xs.optimal = 0.0;
scores.cP_pcA_xs.range = [-2.0, 2.0];
%figure(); plot(cPz(:), pcAz(:), '.')
%figure(); plot(inf_cPz(:), inf_pcAz(:), '.')
......
......@@ -44,8 +44,9 @@ for test = tests'
results = combineResults(scores, params, test);
% Plot marginals
plotDistributions(results.methods, results.data, visibility);
ylim(results.range + 0.025 * diff(results.range) * [-1; 1]);
plotDistributions( ...
results.methods, results.data, results.optimal, results.range, ...
visibility);
ylabel(results.metric);
title(results.name);
if saveFigures
......@@ -57,7 +58,9 @@ for test = tests'
end
% And all data
plotAllVals(results.methods, results.data, results.range, visibility);
plotAllVals( ...
results.methods, results.data, results.optimal, results.range, ...
visibility);
ylabel(results.metric);
title(results.name);
if saveFigures
......@@ -157,9 +160,10 @@ results = struct();
%Extract the methods that have been tested
results.methods = fieldnames(scores);
results.name = {};
results.metric = {};
results.range = [];
results.name = {};
results.metric = {};
results.optimal = [];
results.range = [];
%Loop over methods, extracting scores where appropriate
n = 1;
......@@ -173,9 +177,10 @@ while n <= numel(results.methods)
% Concatenate data by adding a new last dimension
results.data{n} = cat(3, method_scores.data);
% Record metadata
results.name = union(results.name, {method_scores.name});
results.metric = union(results.metric, {method_scores.metric});
results.range = union(results.range, [method_scores.range]);
results.name = union(results.name, {method_scores.name});
results.metric = union(results.metric, {method_scores.metric});
results.optimal = union(results.optimal, [method_scores.optimal]);
results.range = union(results.range, [method_scores.range]);
%Move on to the next method
n = n + 1;
else
......@@ -198,6 +203,10 @@ if numel(results.metric) ~= 1
else
results.metric = results.metric{1};
end
if numel(results.optimal) ~= 1
results.optimal
error('Inconsistent/missing optimums!')
end
if numel(results.range) ~= 2
results.name
error('Inconsistent/missing ranges!')
......@@ -209,7 +218,7 @@ end
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [ ] = plotDistributions( methods, results, visibility )
function [ ] = plotDistributions( methods, results, optimal, lims, visibility )
%Given a set of methods and results, shows the marginal distributions
%Find max number of data points recorded for any method
......@@ -225,7 +234,8 @@ for n = 1:numel(methods)
end
%Plot results with appropriate labels
figure('Visible', visibility); box on;
figure('Visible', visibility); box on; hold on;
plot([0.5, numel(methods) + 0.5], [optimal, optimal], 'Color', [0.2, 0.8, 0.2]);
%h = boxplot(boxmat, 'labels', methods);%, 'labelorientation', 'inline');
%Change line thicknesses
%for ih=1:6
......@@ -235,6 +245,9 @@ h = violinplot(boxmat, methods, ...
'ShowData', false, 'ViolinAlpha', 0.75, 'BoxColor', [0.1, 0.1, 0.1]);
xtickangle(45);
%Set lims
ylim(lims + 0.025 * diff(lims) * [-1; 1]);
end
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
......@@ -273,7 +286,7 @@ end
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [ ] = plotAllVals( methods, results, lims, visibility )
function [ ] = plotAllVals( methods, results, optimal, lims, visibility )
%Plots all the results, rather than combining into a single box plot
methodSpacing = 1/2; repeatSpacing = 1/4;
......@@ -314,8 +327,11 @@ for n = 1:numel(methods)
end
% Plot optimal
plot([0, xEnd], [optimal, optimal], 'Color', [0.2, 0.8, 0.2]);
%Set lims
xlim([0 xEnd]); ylim(lims)
xlim([0 xEnd]); ylim(lims + 0.025 * diff(lims) * [-1; 1]);
%Add labels
xticks(labelTicks);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment