-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathaedes_maptool.m
More file actions
479 lines (426 loc) · 14.7 KB
/
aedes_maptool.m
File metadata and controls
479 lines (426 loc) · 14.7 KB
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
function aedes_maptool()
% AEDES_MAPTOOL - A GUI for calculating various parameter maps
%
%
% Synopsis:
%
% Description:
%
% Examples:
%
% See also:
%
% This function is a part of Aedes - A graphical tool for analyzing
% medical images
%
% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
%
% Department of Physics, Department of Neurobiology
% University of Kuopio, FINLAND
%
% This program may be used under the terms of the GNU General Public
% License version 2.0 as published by the Free Software Foundation
% and appearing in the file LICENSE.TXT included in the packaging of
% this program.
%
% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
% Public variables
H = [];
Dat = [];
% Draw GUI
H = l_DrawGUI();
%%%%%%%%%%%%%%%%%%%%%%%
%% Draw GUI
%%%%%%%%%%%%%%%%%%%%%%%
function H=l_DrawGUI()
% Get screensize
scrsz = get(0,'screensize');
fig_w = 650;
fig_h = 580;
fig_pos = [scrsz(3)/2-fig_w/2 scrsz(4)/2-fig_h/2 ...
fig_w fig_h];
%% Load default font and colors
% DefaultColor=get(0,'DefaultUicontrolBackgroundcolor');
GD=aedes_gui_defaults;
% GD.col.frame = DefaultColor;
% Main figure --------------------------
H.FIG = figure('units','pixels',...
'position',fig_pos,...
'NumberTitle','off',...
'Name','Aedes Map Tool',...
'Menubar','none',...
'toolbar','none',...
'color',GD.col.mainfig, ...
'doublebuffer','on',...
'Handlevisibility','off');
% UiToolbar ----------------------
try
tmp=load('aedes_cdata.mat');
catch
error('Could not open aedes_cdata.mat. Aborting...')
end
Dat.cdata = tmp.cdata;
hUiToolbar = uitoolbar('parent',H.FIG);
H.UITOOLBAR_OPEN = uipushtool('parent',hUiToolbar,...
'cdata',Dat.cdata.open2,...
'tooltip','Open options file',...
'clickedcallback','');
H.UITOOLBAR_SAVE = uipushtool('parent',hUiToolbar,...
'cdata',Dat.cdata.save2_small,...
'tooltip','Save options',...
'clickedcallback','');
%% OPTIONS %%%%%%%%%%%%%%%%%%%%%%%
% Options uipanel ----------------------
H.OPTIONS_UIPANEL = uipanel('parent',H.FIG,...
'units','pixels',...
'position',[5 40 fig_w-10 300],...
'BackGroundColor',GD.col.frame,...
'title','Options',...
'fontweight','bold');
tmp = get(H.OPTIONS_UIPANEL,'position');
H.OUTDIR_UIPANEL = uipanel('parent',H.OPTIONS_UIPANEL,...
'units','pixels',...
'position',[5 5 tmp(3)-10 80],...
'BackGroundColor',GD.col.frame);
tmp = get(H.OUTDIR_UIPANEL,'position');
% Output directory editbox ---------------
% Get default output folder from preferences
try
DefaultOutputFolder = getpref('Aedes','MapToolDefaultOutputFolder');
catch
if isunix
DefaultOutputFolder = getenv('HOME');
else
DefaultOutputFolder = getenv('USERPROFILE');
end
end
H.OUTDIR_EDIT = uicontrol('parent',H.OUTDIR_UIPANEL,...
'style','edit',...
'units','pixels',...
'position',[5 5 tmp(3)-60 22],...
'backgroundcolor',GD.col.edit,...
'enable','off',...
'horizontalalign','left',...
'string',DefaultOutputFolder);
tmp = get(H.OUTDIR_EDIT,'position');
% Output directory browse btn ------------
H.OUTDIR_BROWSE = uicontrol('parent',H.OUTDIR_UIPANEL,...
'style','pushbutton',...
'units','pixels',...
'position',[tmp(1)+tmp(3)+3 tmp(2) 47 tmp(4)],...
'string','...',...
'enable','off');
tmp = get(H.OUTDIR_EDIT,'position');
% Input dir as output dir
H.OUTDIR_RADIO1 = uicontrol('parent',H.OUTDIR_UIPANEL,...
'units','pixels',...
'position',[tmp(1) tmp(2)+tmp(4)+3 350 tmp(4)],...
'style','radio',...
'value',0,...
'String','Use custom folder',...
'BackGroundColor',GD.col.frame,...
'callback',{@l_SelectOutputDir,'custom'});
tmp = get(H.OUTDIR_RADIO1,'position');
H.OUTDIR_RADIO2 = uicontrol('parent',H.OUTDIR_UIPANEL,...
'units','pixels',...
'position',[tmp(1) tmp(2)+tmp(4)+3 tmp(3) tmp(4)],...
'style','radio',...
'value',1,...
'String','Use data input folder as output folder',...
'BackGroundColor',GD.col.frame,...
'callback',{@l_SelectOutputDir,'input'});
% Maptype and fit values uipanel ------------------
tmp = get(H.OUTDIR_UIPANEL,'position');
panel_w = 215;
panel_h = 190;
H.MAPTYPE_UIPANEL = uipanel('parent',H.OPTIONS_UIPANEL,...
'units','pixels',...
'position',[5 tmp(2)+tmp(4)+5 panel_w panel_h],...
'backgroundcolor',GD.col.frame);
tmp = get(H.MAPTYPE_UIPANEL,'position');
% Maptype popup --------------------------
H.MAPTYPE_TX = uicontrol('parent',H.MAPTYPE_UIPANEL,...
'units','pixels',...
'position',[5 tmp(4)-10-15 70 15],...
'style','text',...
'String','Map type',...
'backgroundcolor',GD.col.frame,...
'horizontalalign','left');
tmp = get(H.MAPTYPE_TX,'position');
maptypes = l_GetMapTypes;
H.MAPTYPE_POPUP = uicontrol('parent',H.MAPTYPE_UIPANEL,...
'units','pixels',...
'position',[tmp(1) tmp(2)-20-3 200 20],...
'style','popup',...
'string',maptypes);
tmp = get(H.MAPTYPE_TX,'position');
% Fit values edit and popup -------------------
H.FITVALS_TX = uicontrol('parent',H.MAPTYPE_UIPANEL,...
'units','pixels',...
'position',[tmp(1) tmp(2)-15-40 tmp(3) 15],...
'style','text',...
'String','Fit values',...
'backgroundcolor',GD.col.frame,...
'horizontalalign','left');
tmp = get(H.FITVALS_TX,'position');
H.FITVALS_EDIT = uicontrol('parent',H.MAPTYPE_UIPANEL,...
'units','pixels',...
'position',[tmp(1) tmp(2)-22-3 200 22],...
'style','edit',...
'String','',...
'backgroundcolor',GD.col.edit,...
'horizontalalign','left');
tmp = get(H.FITVALS_EDIT,'position');
% % Fit value multiplication
% H.FITVALS_MULTI = uicontrol('parent',H.MAPTYPE_UIPANEL,...
% 'units','pixels',...
% 'position',[tmp(1) tmp(2)-22-2 tmp(3) 22],...
% 'style','popup',...
% 'String',{'Multiplication: 1',...
% 'Multiplication: 1000',...
% 'Multiplication: 100',...
% 'Multiplication: 10',...
% 'Multiplication: 0.1',...
% 'Multiplication: 0.01',...
% 'Multiplication: 0.001',...
% 'Multiplication: custom'});
% tmp = get(H.FITVALS_MULTI,'position');
% Use procpar field --------------------------
H.FITVALS_USE_PROCPAR = uicontrol('parent',H.MAPTYPE_UIPANEL,...
'units','pixels',...
'position',[tmp(1) tmp(2)-22-2 tmp(3) 22],...
'style','popup',...
'tooltip',sprintf('Select the procpar field\n that contains the fit values'),...
'String',{'Use procpar field...'},...
'horizontalalign','left');
tmp = get(H.FITVALS_USE_PROCPAR,'position');
H.FITVALS_USE_PROCPAR_SAVE = uicontrol('parent',H.MAPTYPE_UIPANEL,...
'units','pixels',...
'position',[tmp(1) tmp(2)-20-2 tmp(3) 20],...
'style','checkbox',...
'tooltip',sprintf('Use this procpar field as\n default for this map type'),...
'String','Use as default for this map type',...
'horizontalalign','left',...
'backgroundcolor',GD.col.frame,...
'fontsize',8);
%% Output file name and mask file controls
tmp=get(H.MAPTYPE_UIPANEL,'position');
H.OUTPUTFILE_UIPANEL = uipanel('parent',H.OPTIONS_UIPANEL,...
'units','pixels',...
'position',[tmp(1)+tmp(3)+5 tmp(2) 270 tmp(4)],...
'backgroundcolor',GD.col.frame);
tmp=get(H.OUTPUTFILE_UIPANEL,'position');
% Output file name text and edit
H.OUTPUTFILE_TX = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
'units','pixels',...
'position',[5 tmp(4)-15-10 120 15],...
'style','text',...
'String','Output File Name',...
'backgroundcolor',GD.col.frame,...
'horizontalalign','left');
tmp = get(H.OUTPUTFILE_TX,'position');
outputfile_tooltip = ...
sprintf(['The following special formatting can be\n',...
'used in this dialog:\n',...
'%%m = map type identifier (t2map, t1rmap, etc.)\n',...
'%%f = file name from input folder (e.g. MyData.fid -> %%f = MyData)\n',...
' \n',...
'Note that numbering and file extension are handled automatically.']);
H.OUTPUTFILE_EDIT = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
'units','pixels',...
'position',[tmp(1) tmp(2)-22-3 250 22],...
'style','edit',...
'String','%m_%f',...
'backgroundcolor',GD.col.edit,...
'horizontalalign','left',...
'tooltip',outputfile_tooltip);
tmp = get(H.OUTPUTFILE_EDIT,'position');
% Overwrite without warning checkbox
H.OUTPUTFILE_OVERWRITE = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
'units','pixels',...
'position',[tmp(1) tmp(2)-20-2 tmp(3) 20],...
'style','checkbox',...
'value',0,...
'String','Overwrite without warning',...
'backgroundcolor',GD.col.frame,...
'horizontalalign','left');
tmp = get(H.OUTPUTFILE_OVERWRITE,'position');
% Fit type text
H.FITTYPE_TX = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
'units','pixels',...
'position',[5 tmp(2)-15-20 120 15],...
'style','text',...
'String','Fit type',...
'backgroundcolor',GD.col.frame,...
'horizontalalign','left');
tmp = get(H.FITTYPE_TX,'position');
% Linearized or non-linear fit
H.LINEARFIT_RADIO = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
'units','pixels',...
'position',[tmp(1) tmp(2)-22-3 200 22],...
'style','radio',...
'value',1,...
'string','Linearized fit',...
'backgroundcolor',GD.col.frame);
tmp = get(H.LINEARFIT_RADIO,'position');
H.NONLINEARFIT_RADIO = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
'units','pixels',...
'position',[tmp(1) tmp(2)-22-3 tmp(3) 22],...
'style','radio',...
'value',0,...
'string','Non-linear fit',...
'backgroundcolor',GD.col.frame);
tmp = get(H.NONLINEARFIT_RADIO,'position');
% % Initial values -------------------------------
% H.INITIALVAL_TX = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
% 'units','pixels',...
% 'position',[35 tmp(2)-15-3 90 15],...
% 'style','text',...
% 'String','Initial values',...
% 'backgroundcolor',GD.col.frame,...
% 'horizontalalign','left');
% tmp = get(H.INITIALVAL_TX,'position');
%
% H.INITIALVAL_POPUP = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
% 'units','pixels',...
% 'position',[tmp(1)+tmp(3) tmp(2)-2 70 22],...
% 'style','popup',...
% 'string',{'Auto','Custom'},...
% 'enable','off');
% tmp = get(H.INITIALVAL_POPUP,'position');
% H.INITIALVAL_EDIT = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
% 'units','pixels',...
% 'position',[tmp(1)+tmp(3) tmp(2) 60 22],...
% 'style','edit',...
% 'String','',...
% 'backgroundcolor',GD.col.edit,...
% 'horizontalalign','left',...
% 'enable','off');
% % Mask File ---------------------------------
% H.MASKFILE_TX = uicontrol('parent',H.MASK_UIPANEL,...
% 'units','pixels',...
% 'position',[tmp(1) tmp(2)-15-20 tmp(3) 15],...
% 'style','text',...
% 'String','Mask File',...
% 'backgroundcolor','r',...GD.col.frame,...
% 'horizontalalign','left');
% tmp = get(H.MASKFILE_TX,'position');
% H.MASKFILE_EDIT = uicontrol('parent',H.MASK_UIPANEL,...
% 'units','pixels',...
% 'position',[tmp(1) tmp(2)-22 tmp(3) 22],...
% 'style','edit',...
% 'String','',...
% 'backgroundcolor',GD.col.edit,...
% 'horizontalalign','left');
% Add options to selected files -------------
tmp = get(H.OUTPUTFILE_UIPANEL,'position');
btn_h = 30;
btn_w = 130;
H.ADD_OPT_TO_SEL = uicontrol('parent',H.OPTIONS_UIPANEL,...
'units','pixels',...
'position',[tmp(1)+tmp(3)+5 tmp(2)+tmp(4)-btn_h btn_w btn_h],...
'style','pushbutton',...
'string','Add to selected',...
'tooltip','Add options to selected files');
tmp = get(H.ADD_OPT_TO_SEL,'position');
H.ADD_OPT_TO_ALL = uicontrol('parent',H.OPTIONS_UIPANEL,...
'units','pixels',...
'position',[tmp(1) tmp(2)-btn_h-3 tmp(3) tmp(4)],...
'style','pushbutton',...
'string','Add to all',...
'tooltip','Add options to all files');
%% FILES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Files uipanel ---------------------
tmp = get(H.OPTIONS_UIPANEL,'position');
H.FILES_UIPANEL = uipanel('parent',H.FIG,...
'units','pixels',...
'position',[tmp(1) tmp(2)+tmp(4)+5 fig_w-10 220],...
'BackGroundColor',GD.col.frame,...
'title','Data Files',...
'fontweight','bold');
tmp = get(H.FILES_UIPANEL,'position');
% Quit button --------------------------
btn_h = 30;
btn_w = 90;
H.QUIT_BTN = uicontrol('parent',H.FIG,...
'units','pixels',...
'position',[fig_w-btn_w-5 5 btn_w btn_h],...
'style','pushbutton',...
'string','Quit');
tmp = get(H.QUIT_BTN,'position');
% Fit maps btn-------------------------
H.FIT_MAPS_BTN = uicontrol('parent',H.FIG,...
'units','pixels',...
'position',[tmp(1)-tmp(3)-3 tmp(2) tmp(3) tmp(4)],...
'style','pushbutton',...
'string','Fit Maps');
% Files listbox -------------------------
tmp = get(H.FILES_UIPANEL,'position');
H.FILES_LBOX = uicontrol('parent',H.FILES_UIPANEL,...
'style','listbox',...
'string',{'*/home/tjniskan/MyMapData/070907/MapFromARat.fid/fid',...
'*/home/tjniskan/MyMapData/070907/MapFromARat.fid/fid',...
'*/home/tjniskan/MyMapData/090907/MapFromARat.fid/fid',...
'*/home/tjniskan/MyMapData/100907/MapFromARat.fid/fid',...
'*/home/tjniskan/MyMapData/120907/MapFromARat.fid/fid',...
'/home/tjniskan/MyMapData/150907/MapFromARat.fid/fid',...
'/home/tjniskan/MyMapData/180907/MapFromARat.fid/fid',...
'/home/tjniskan/MyMapData/230907/MapFromARat.fid/fid',...
'/home/tjniskan/MyMapData/011007/MapFromARat.fid/fid',...
'/home/tjniskan/MyMapData/051007/MapFromARat.fid/fid',...
'/home/tjniskan/MyMapData/131007/MapFromARat.fid/fid'},...
'units','pixel',...
'position',[5 5 tmp(3)-10 tmp(4)-70],...
'backgroundcolor',GD.col.listbox,...
'Max',3,'Min',1);
tmp = get(H.FILES_LBOX,'position');
% Add files btn --------------------------
H.FILES_ADD = uicontrol('parent',H.FILES_UIPANEL,...
'style','pushbutton',...
'units','pixels',...
'position',[5 tmp(2)+tmp(4)+3 40 40],...
'tooltip','Add files to list',...
'cdata',Dat.cdata.add);
tmp = get(H.FILES_ADD,'position');
% Remove selected ------------------------
H.FILES_REMSEL = uicontrol('parent',H.FILES_UIPANEL,...
'style','pushbutton',...
'units','pixels',...
'position',[tmp(1)+tmp(3)+3 tmp(2) tmp(3) tmp(4)],...
'tooltip','Remove selected files from list',...
'cdata',Dat.cdata.delete);
tmp = get(H.FILES_REMSEL,'position');
% Remove all -----------------------------
H.FILES_REMALL = uicontrol('parent',H.FILES_UIPANEL,...
'style','pushbutton',...
'units','pixels',...
'position',[tmp(1)+tmp(3)+3 tmp(2) tmp(3) tmp(4)],...
'tooltip','Remove all files from list',...
'cdata',Dat.cdata.deleteall);
tmp = get(H.FILES_REMALL,'position');
end % function l_DrawGUI()
%%%%%%%%%%%%%%%%%%%%%
%% Get Map Types
%%%%%%%%%%%%%%%%%%%%%
function maptypes = l_GetMapTypes()
maptypes = {'T2','T1','T2 rho','T1 rho','ADC',...
'Perfusion','B1'};
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Callback for output folder selection radiobuttons
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function l_SelectOutputDir(h,evd,opt)
if strcmpi(opt,'custom')
set(H.OUTDIR_EDIT,'enable','on')
set(H.OUTDIR_BROWSE,'enable','on')
set(H.OUTDIR_RADIO1,'value',1)
set(H.OUTDIR_RADIO2,'value',0)
elseif strcmpi(opt,'input')
set(H.OUTDIR_EDIT,'enable','off')
set(H.OUTDIR_BROWSE,'enable','off')
set(H.OUTDIR_RADIO1,'value',0)
set(H.OUTDIR_RADIO2,'value',1)
end
end
end % aedes_maptool()