forked from bramzandbelt/slice_display
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsd_config_settings.m
192 lines (150 loc) · 7.25 KB
/
sd_config_settings.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
function settings = sd_config_settings(todo, varargin)
% SD_CONFIG_SETTINGS Initializes empty settings variable or fills one with defaults
%
% DESCRIPTION
% This function initializes or completes the settings variable that is used
% by the sd_display function to visualize NIfTI images.
%
% SYNTAX
% settings = sd_config_settings('init')
% settings = sd_config_settings('fill-defaults',settings)
%
% EXAMPLES
% Initialize an empty settings variable:
% settings = SD_CONFIG_SETTINGS('init');
%
% Fill an existing settings variable with defaults:
% settings = SD_CONFIG_SETTINGS('fill-defaults',settings);
%
% .........................................................................
% Bram Zandbelt ([email protected]), Radboud University
% Make sure required toolboxes are on path
assert(~isempty(spm('Dir')),'<a href="http://www.fil.ion.ucl.ac.uk/spm/">SPM</a> cannot be found; make sure it is on MATLAB''s search path.')
assert(exist('panel.m','file') > 0,'<a href="https://www.mathworks.com/matlabcentral/fileexchange/20003-panel">Panel</a> cannot be found; make sure it is on MATLAB''s search path')
switch lower(todo)
case 'init'
m = struct('figure', [], ...
'panel', [], ...
'slice', [], ...
'colorbar', []);
wh = struct('figure', [], ...
'map_panel', [], ...
'legend_panel', [], ...
'slice', [], ...
'colorbar', []);
constraints = struct('slice', [], ...
'colorbar', []);
n = struct('slice', [], ...
'slice_row', [], ...
'slice_column', [], ...
'colorbar', []);
fig_specs = struct('title', '', ...
'margin',m, ...
'width', wh, ...
'height', wh, ...
'width_constraints', constraints, ...
'height_constraints', constraints, ...
'height_width_ratio', constraints, ...
'n', n, ...
'i', struct('colorbar',[]));
slice = struct('orientation','', ...
'disp_slices', [], ...
'show_labels',[], ...
'show_orientation',[], ...
'transform',[], ...
'xmm', [], ...
'ymm', [], ...
'zmm', [], ...
'x', [], ...
'y', [], ...
'vdims', [], ...
'pandims', []);
paper = struct('type','', ...
'orientation', '');
settings = struct('slice',slice, ...
'fig_specs',fig_specs, ...
'paper',paper);
case 'fill-defaults'
settings = varargin{1};
% settings.slice
% =================================================================
if isempty(settings.slice.orientation)
settings.slice.orientation = 'axial';
end
if isempty(settings.slice.disp_slices)
settings.slice.disp_slices = -20:4:40;
end
if isempty(settings.slice.show_labels)
settings.slice.show_labels = true;
end
if isempty(settings.slice.show_orientation)
settings.slice.show_orientation = true;
end
% settings.fig_specs
% =================================================================
% settings.fig_specs.margin
% -----------------------------------------------------------------
if isempty(settings.fig_specs.margin.figure)
if isempty(settings.fig_specs.title)
settings.fig_specs.margin.figure = [15 15 5 5];
else
settings.fig_specs.margin.figure = [15 15 5 20];
end
end
if isempty(settings.fig_specs.margin.panel)
settings.fig_specs.margin.panel = [5 5 2 2];
end
if isempty(settings.fig_specs.margin.slice)
settings.fig_specs.margin.slice = [0 0 0 0];
end
if isempty(settings.fig_specs.margin.colorbar)
settings.fig_specs.margin.colorbar = [5 5 2 2];
end
% settings.fig_specs.width
% -----------------------------------------------------------------
if isempty(settings.fig_specs.width.figure)
settings.fig_specs.width.figure = 180;
end
if isempty(settings.fig_specs.width.map_panel)
settings.fig_specs.width.map_panel = settings.fig_specs.width.figure - ...
settings.fig_specs.margin.figure(1) - ...
settings.fig_specs.margin.figure(3);
end
if isempty(settings.fig_specs.width.legend_panel)
settings.fig_specs.width.legend_panel = settings.fig_specs.width.figure - ...
settings.fig_specs.margin.figure(1) - ...
settings.fig_specs.margin.figure(3);
end
% settings.fig_specs.height
% -----------------------------------------------------------------
if isempty(settings.fig_specs.height.colorbar)
end
% settings.fig_specs.width_constraints
% -----------------------------------------------------------------
if isempty(settings.fig_specs.width_constraints.slice)
settings.fig_specs.width_constraints.slice = [10,40];
end
if isempty(settings.fig_specs.width_constraints.colorbar)
settings.fig_specs.width_constraints.colorbar = [20,100];
end
% settings.fig_specs.height_constraints
% -----------------------------------------------------------------
if isempty(settings.fig_specs.height_constraints.colorbar)
settings.fig_specs.height_constraints.colorbar = [5,10];
end
% settings.fig_specs.n
% -----------------------------------------------------------------
if isempty(settings.fig_specs.n.slice)
settings.fig_specs.n.slice = numel(settings.slice.disp_slices);
end
% settings.paper
% =================================================================
if isempty(settings.paper.type)
settings.paper.type = 'A4';
end
if isempty(settings.paper.orientation)
settings.paper.orientation = 'portrait';
end
otherwise
error('First element must be ''init'' or ''fill-defaults''. Type ''help sd_config_settings''.')
end