-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreproducePaper.m
75 lines (66 loc) · 2.42 KB
/
reproducePaper.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
function reproducePaper(pathToData, whatToReproduce)
% REPRODUCEPAPER Call this function to reproduce all figures from the paper.
%
% SYNTAX:
% reproducePaper /path/to/hdf5/data main
% Reproduce only the main figures.
% reproducePaper /path/to/hdf5/data sm
% Reproduce only the Supplementary figures.
% reproducePaper /path/to/hdf5/data all
% Reproduce all figures.
%
% INPUT:
% pathToData = folder containing all HDF5 files from the data publication
% referenced in the paper.
% whatToReproduce = main|si|all (default: all)
if nargin < 1 || isempty(pathToData) || ~exist(pathToData, 'dir')
fprintf('Please select one of the H5 files from the data publication\n');
fprintf('in the dialog that follows. Alternatively, you can call\n');
fprintf('this function like so:\n\n');
fprintf(' >> reproducePaper %s\n', fullfile('path','to','H5','data'));
fprintf('\nPress [Enter] to continue... ');
input('', 's');
[~, pathName, ~] = uigetfile({'*.h5', 'HDF5 files'}, 'Select first data file');
[pathToData, ~, ~] = fileparts(pathName);
end
if nargin < 2 || isempty(whatToReproduce)
whatToReproduce = 'all';
else
whatToReproduce = lower(whatToReproduce);
switch whatToReproduce
case {'main','sm','all'}
% ok
otherwise
warning('Unknown item "%s"; assuming "all".', whatToReproduce);
whatToReproduce = 'all';
end
end
% Read data.
if ~exist(pathToData, 'dir')
error(['Path not found. Please specify the path to the folder containing ' ...
'the H5 files from the data publication referenced in the paper.']);
end
fprintf('Loading data...\n');
fdc = FdDataCollection();
files = dir(fullfile(pathToData, '*.h5'));
if isempty(files)
error(['No H5 files found. Please specify the path to the folder containing ' ...
'the H5 files from the data publication referenced in the paper.']);
end
for i = 1:length(files)
fprintf('.');
try
fd = importfddata(fullfile(pathToData, files(i).name));
catch err
fprintf('\n!!! Error loading data file %s\n', files(i).name);
disp(getReport(err, 'full'));
fprintf('Please check if you have selected the correct data folder, \n');
fprintf('and if the files have been downloaded correctly.\n');
error('Error loading data file %s', files(i).name);
end
fdc.add(fd);
end
fprintf('\n');
% Make figures.
makeFigures(fdc, ['-' whatToReproduce]);
end