Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
profumo
PFM_Simulations
Commits
5f77760e
Commit
5f77760e
authored
Sep 28, 2019
by
Sam Harrison
Browse files
Automatically save figures to file
parent
930b0b97
Changes
3
Hide whitespace changes
Inline
Side-by-side
RunTests.m
View file @
5f77760e
...
...
@@ -40,6 +40,8 @@ if plotFigures
prettyFigures
();
end
rng
(
'shuffle'
);
%% Set size of problem %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Number of times to repeat simulation / test cycle
...
...
@@ -247,8 +249,6 @@ end
%% Run the tests %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
rng
(
'shuffle'
)
scores
=
struct
();
for
n
=
1
:
params
.
nRepeats
...
...
@@ -377,7 +377,7 @@ for n = 1:params.nRepeats
% = calculateDecompositionAccuracy( ...
% P, icadr_P, A, icadr_A, pcAn, icadr_pcA, params);
catch
warning
(
'MELODIC run failed.'
)
warning
(
'MELODIC run failed.'
)
;
end
%% Run PROFUMO %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
...
...
@@ -413,7 +413,7 @@ for n = 1:params.nRepeats
'scores'
,
...
'params'
,
'atlasParams'
,
'modeParams'
,
...
'options'
,
'atlasOptions'
,
'modeOptions'
,
...
'-v7.3'
)
'-v7.3'
)
;
%% And delete everything we don't need saved %%%%%%%%%%%%%%%%%%%%%%%%%%
if
~
saveData
...
...
@@ -424,17 +424,20 @@ end
%% Plot results %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fprintf
(
'Finished! You can now run e.g.:\n'
);
plotScores
(
scores
,
params
,
baseFileName
,
plotFigures
);
if
plotFigures
input
(
'Press return to continue'
);
close
all
end
fprintf
(
'Finished! Figures have been saved to:\n'
);
fprintf
(
' %s/\n'
,
baseFileName
);
fprintf
(
'To replot the results you can now run e.g.:\n'
);
fprintf
(
'>> initialiseEnvironment();\n'
);
fprintf
(
'>> prettyFigures();\n'
);
fprintf
(
'>> load(
''
%s.mat
''
);\n'
,
baseFileName
);
fprintf
(
'>> plotScores(scores, params);\n'
);
if
plotFigures
plotScores
(
scores
,
params
);
input
(
'Press return to continue'
)
close
all
end
fprintf
(
'\n'
);
%% If run from the command line make sure we quit MATLAB %%%%%%%%%%%%%%%%%%
...
...
Scoring/calculateDecompositionAccuracy.m
View file @
5f77760e
...
...
@@ -143,7 +143,7 @@ scores.pcA.metric = 'Cosine similarity';
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 corrs'
;
scores
.
pcA_xs
.
name
=
'Netmats
(
cross subject corrs
)
'
;
scores
.
pcA_xs
.
metric
=
'Correlation'
;
scores
.
pcA_xs
.
range
=
[
-
1.0
,
1.0
];
...
...
Visualisation/plotScores.m
View file @
5f77760e
function
[
]
=
plotScores
(
scores
,
params
,
save
Figures
)
function
[
]
=
plotScores
(
scores
,
params
,
outputDir
,
plot
Figures
)
%Plots the results from whichever analyses have been run
if
nargin
==
2
saveFigures
=
false
;
if
nargin
<
3
outputDir
=
false
;
end
saveFigures
=
logical
(
outputDir
);
if
saveFigures
figPosLong
=
200
+
[
0
0
1300
200
];
figPosSquare
=
200
+
[
0
0
300
300
];
if
nargin
<
4
plotFigures
=
true
;
end
if
plotFigures
visibility
=
'on'
;
else
visibility
=
'off'
;
end
ticks
=
0
:
0.2
:
1
;
%Where to place ticks for correlations
%--------------------------------------------------------------------------
% Get all the metadata sorted
...
...
@@ -19,27 +23,55 @@ methods = fieldnames(scores)
tests
=
struct2cell
(
structfun
(
@
fieldnames
,
scores
,
'UniformOutput'
,
false
));
tests
=
unique
(
vertcat
(
tests
{:}))
if
saveFigures
mkdir
(
outputDir
);
% [left bottom width height]
figPosLong
=
200
+
[
0
0
1000
200
];
figPosSquare
=
200
+
[
0
0
300
300
];
end
ticks
=
0
:
0.2
:
1
;
%Where to place ticks for correlations
%--------------------------------------------------------------------------
% Plot all the tests
for
test
=
tests
'
test
=
test
{
1
};
results
=
combineResults
(
scores
,
params
,
test
);
plotDistributions
(
results
.
methods
,
results
.
data
);
% Plot marginals
plotDistributions
(
results
.
methods
,
results
.
data
,
visibility
);
ylim
(
results
.
range
+
0.025
*
diff
(
results
.
range
)
*
[
-
1
;
1
]);
ylabel
(
results
.
metric
);
%if saveFigures
% set(gcf, 'Position', figPosLong)
% export_fig('SimData_SpatialMaps', '-pdf', '-transparent')
%end
if
saveFigures
set
(
gcf
(),
'Position'
,
figPosSquare
);
set
(
gcf
(),
'Color'
,
'w'
);
export_fig
(
...
fullfile
(
outputDir
,
strrep
(
results
.
name
,
' '
,
'_'
)),
...
'-pdf'
)
% '-transparent'
end
title
(
results
.
name
);
plotAllVals
(
results
.
methods
,
results
.
data
,
results
.
range
);
% And all data
plotAllVals
(
results
.
methods
,
results
.
data
,
results
.
range
,
visibility
);
ylabel
(
results
.
metric
);
if
saveFigures
set
(
gcf
(),
'Position'
,
figPosLong
);
set
(
gcf
(),
'Color'
,
'w'
);
export_fig
(
...
fullfile
(
outputDir
,
[
strrep
(
results
.
name
,
' '
,
'_'
)
'_all'
]),
...
'-pdf'
)
% '-transparent'
end
title
(
results
.
name
);
end
% Tidy up invisible figures that have been saved
%if ~plotFigures && saveFigures
% close all
%end
%--------------------------------------------------------------------------
if
false
input
(
'Press return to continue'
)
...
...
@@ -105,6 +137,9 @@ for n = 1:length(H)
end
end
end
%--------------------------------------------------------------------------
end
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
...
...
@@ -170,7 +205,7 @@ end
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function
[
]
=
plotDistributions
(
methods
,
results
)
function
[
]
=
plotDistributions
(
methods
,
results
,
visibility
)
%Given a set of methods and results, shows the marginal distributions
%Find max number of data points recorded for any method
...
...
@@ -186,7 +221,7 @@ for n = 1:numel(methods)
end
%Plot results with appropriate labels
figure
();
box
on
;
figure
(
'Visible'
,
visibility
);
box
on
;
%h = boxplot(boxmat, 'labels', methods);%, 'labelorientation', 'inline');
%Change line thicknesses
%for ih=1:6
...
...
@@ -234,12 +269,12 @@ end
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function
[
]
=
plotAllVals
(
methods
,
results
,
lims
)
function
[
]
=
plotAllVals
(
methods
,
results
,
lims
,
visibility
)
%Plots all the results, rather than combining into a single box plot
methodSpacing
=
1
/
2
;
repeatSpacing
=
1
/
4
;
figure
;
hold
on
;
box
on
figure
(
'Visible'
,
visibility
)
;
hold
on
;
box
on
xEnd
=
0
;
labelTicks
=
NaN
(
numel
(
methods
,
1
));
for
n
=
1
:
numel
(
methods
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment