source: aedes_maptool.m

Last change on this file was 80, checked in by tjniskan, 9 years ago
  • Changed the historical "an2_" prefix to "aedes_" in all files. NOTE:

Any script or function relying to Aedes functions will be broken
because of this. Just do a search/replace from "an2_" to "aedes_" in
your files and all should be well...

  • Changed the name of an2_readtab.m to a more informative

aedes_readphasetable.m

File size: 14.7 KB
Line 
1function aedes_maptool()
2% AEDES_MAPTOOL - A GUI for calculating various parameter maps
3%   
4%
5% Synopsis:
6%
7% Description:
8%
9% Examples:
10%
11% See also:
12%
13
14% This function is a part of Aedes - A graphical tool for analyzing
15% medical images
16%
17% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
18%
19% Department of Physics, Department of Neurobiology
20% University of Kuopio, FINLAND
21%
22% This program may be used under the terms of the GNU General Public
23% License version 2.0 as published by the Free Software Foundation
24% and appearing in the file LICENSE.TXT included in the packaging of
25% this program.
26%
27% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29
30
31% Public variables
32H = [];
33Dat = [];
34
35% Draw GUI
36H = l_DrawGUI();
37
38
39%%%%%%%%%%%%%%%%%%%%%%%
40%% Draw GUI
41%%%%%%%%%%%%%%%%%%%%%%%
42function H=l_DrawGUI()
43
44% Get screensize
45scrsz = get(0,'screensize');
46fig_w = 650;
47fig_h = 580;
48fig_pos = [scrsz(3)/2-fig_w/2 scrsz(4)/2-fig_h/2 ...
49          fig_w fig_h];
50
51%% Load default font and colors
52% DefaultColor=get(0,'DefaultUicontrolBackgroundcolor');
53GD=aedes_gui_defaults;
54% GD.col.frame = DefaultColor;
55
56% Main figure --------------------------
57H.FIG = figure('units','pixels',...
58  'position',fig_pos,...
59  'NumberTitle','off',...
60  'Name','Aedes Map Tool',...
61  'Menubar','none',...
62  'toolbar','none',...
63  'color',GD.col.mainfig, ...
64  'doublebuffer','on',...
65  'Handlevisibility','off');
66
67% UiToolbar ----------------------
68try
69  tmp=load('aedes_cdata.mat');
70catch
71  error('Could not open aedes_cdata.mat. Aborting...')
72end
73Dat.cdata = tmp.cdata;
74hUiToolbar = uitoolbar('parent',H.FIG);
75H.UITOOLBAR_OPEN = uipushtool('parent',hUiToolbar,...
76  'cdata',Dat.cdata.open2,...
77  'tooltip','Open options file',...
78  'clickedcallback','');
79H.UITOOLBAR_SAVE = uipushtool('parent',hUiToolbar,...
80  'cdata',Dat.cdata.save2_small,...
81  'tooltip','Save options',...
82  'clickedcallback','');
83
84
85
86%% OPTIONS %%%%%%%%%%%%%%%%%%%%%%%
87
88% Options uipanel ----------------------
89H.OPTIONS_UIPANEL = uipanel('parent',H.FIG,...
90  'units','pixels',...
91  'position',[5 40 fig_w-10 300],...
92  'BackGroundColor',GD.col.frame,...
93  'title','Options',...
94  'fontweight','bold');
95tmp = get(H.OPTIONS_UIPANEL,'position');
96
97H.OUTDIR_UIPANEL = uipanel('parent',H.OPTIONS_UIPANEL,...
98  'units','pixels',...
99  'position',[5 5 tmp(3)-10 80],...
100  'BackGroundColor',GD.col.frame);
101tmp = get(H.OUTDIR_UIPANEL,'position');
102
103% Output directory editbox ---------------
104
105% Get default output folder from preferences
106try
107  DefaultOutputFolder = getpref('Aedes','MapToolDefaultOutputFolder');
108catch
109  if isunix
110        DefaultOutputFolder = getenv('HOME');
111  else
112        DefaultOutputFolder = getenv('USERPROFILE');
113  end
114end
115H.OUTDIR_EDIT = uicontrol('parent',H.OUTDIR_UIPANEL,...
116  'style','edit',...
117  'units','pixels',...
118  'position',[5 5 tmp(3)-60 22],...
119  'backgroundcolor',GD.col.edit,...
120  'enable','off',...
121  'horizontalalign','left',...
122  'string',DefaultOutputFolder);
123tmp = get(H.OUTDIR_EDIT,'position');
124
125% Output directory browse btn ------------
126H.OUTDIR_BROWSE = uicontrol('parent',H.OUTDIR_UIPANEL,...
127  'style','pushbutton',...
128  'units','pixels',...
129  'position',[tmp(1)+tmp(3)+3 tmp(2) 47 tmp(4)],...
130  'string','...',...
131  'enable','off');
132tmp = get(H.OUTDIR_EDIT,'position');
133
134% Input dir as output dir
135H.OUTDIR_RADIO1 = uicontrol('parent',H.OUTDIR_UIPANEL,...
136  'units','pixels',...
137  'position',[tmp(1) tmp(2)+tmp(4)+3 350 tmp(4)],...
138  'style','radio',...
139  'value',0,...
140  'String','Use custom folder',...
141  'BackGroundColor',GD.col.frame,...
142  'callback',{@l_SelectOutputDir,'custom'});
143tmp = get(H.OUTDIR_RADIO1,'position');
144
145H.OUTDIR_RADIO2 = uicontrol('parent',H.OUTDIR_UIPANEL,...
146  'units','pixels',...
147  'position',[tmp(1) tmp(2)+tmp(4)+3 tmp(3) tmp(4)],...
148  'style','radio',...
149  'value',1,...
150  'String','Use data input folder as output folder',...
151  'BackGroundColor',GD.col.frame,...
152  'callback',{@l_SelectOutputDir,'input'});
153
154% Maptype and fit values uipanel ------------------
155tmp = get(H.OUTDIR_UIPANEL,'position');
156panel_w = 215;
157panel_h = 190;
158H.MAPTYPE_UIPANEL = uipanel('parent',H.OPTIONS_UIPANEL,...
159  'units','pixels',...
160  'position',[5 tmp(2)+tmp(4)+5 panel_w panel_h],...
161  'backgroundcolor',GD.col.frame);
162tmp = get(H.MAPTYPE_UIPANEL,'position');
163
164% Maptype popup --------------------------
165H.MAPTYPE_TX = uicontrol('parent',H.MAPTYPE_UIPANEL,...
166  'units','pixels',...
167  'position',[5 tmp(4)-10-15 70 15],...
168  'style','text',...
169  'String','Map type',...
170  'backgroundcolor',GD.col.frame,...
171  'horizontalalign','left');
172tmp = get(H.MAPTYPE_TX,'position');
173maptypes = l_GetMapTypes;
174H.MAPTYPE_POPUP = uicontrol('parent',H.MAPTYPE_UIPANEL,...
175  'units','pixels',...
176  'position',[tmp(1) tmp(2)-20-3 200 20],...
177  'style','popup',...
178  'string',maptypes);
179tmp = get(H.MAPTYPE_TX,'position');
180
181% Fit values edit and popup -------------------
182H.FITVALS_TX = uicontrol('parent',H.MAPTYPE_UIPANEL,...
183  'units','pixels',...
184  'position',[tmp(1) tmp(2)-15-40 tmp(3) 15],...
185  'style','text',...
186  'String','Fit values',...
187  'backgroundcolor',GD.col.frame,...
188  'horizontalalign','left');
189tmp = get(H.FITVALS_TX,'position');
190
191H.FITVALS_EDIT = uicontrol('parent',H.MAPTYPE_UIPANEL,...
192  'units','pixels',...
193  'position',[tmp(1) tmp(2)-22-3 200 22],...
194  'style','edit',...
195  'String','',...
196  'backgroundcolor',GD.col.edit,...
197  'horizontalalign','left');
198tmp = get(H.FITVALS_EDIT,'position');
199
200% % Fit value multiplication
201% H.FITVALS_MULTI = uicontrol('parent',H.MAPTYPE_UIPANEL,...
202%   'units','pixels',...
203%   'position',[tmp(1) tmp(2)-22-2 tmp(3) 22],...
204%   'style','popup',...
205%   'String',{'Multiplication: 1',...
206%   'Multiplication: 1000',...
207%   'Multiplication: 100',...
208%   'Multiplication: 10',...
209%   'Multiplication: 0.1',...
210%   'Multiplication: 0.01',...
211%   'Multiplication: 0.001',...
212%   'Multiplication: custom'});
213% tmp = get(H.FITVALS_MULTI,'position');
214
215% Use procpar field --------------------------
216H.FITVALS_USE_PROCPAR = uicontrol('parent',H.MAPTYPE_UIPANEL,...
217  'units','pixels',...
218  'position',[tmp(1) tmp(2)-22-2 tmp(3) 22],...
219  'style','popup',...
220  'tooltip',sprintf('Select the procpar field\n that contains the fit values'),...
221  'String',{'Use procpar field...'},...
222  'horizontalalign','left');
223tmp = get(H.FITVALS_USE_PROCPAR,'position');
224H.FITVALS_USE_PROCPAR_SAVE = uicontrol('parent',H.MAPTYPE_UIPANEL,...
225  'units','pixels',...
226  'position',[tmp(1) tmp(2)-20-2 tmp(3) 20],...
227  'style','checkbox',...
228  'tooltip',sprintf('Use this procpar field as\n default for this map type'),...
229  'String','Use as default for this map type',...
230  'horizontalalign','left',...
231  'backgroundcolor',GD.col.frame,...
232  'fontsize',8);
233
234
235%% Output file name and mask file controls
236tmp=get(H.MAPTYPE_UIPANEL,'position');
237H.OUTPUTFILE_UIPANEL = uipanel('parent',H.OPTIONS_UIPANEL,...
238  'units','pixels',...
239  'position',[tmp(1)+tmp(3)+5 tmp(2) 270 tmp(4)],...
240  'backgroundcolor',GD.col.frame);
241tmp=get(H.OUTPUTFILE_UIPANEL,'position');
242
243% Output file name text and edit
244H.OUTPUTFILE_TX = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
245  'units','pixels',...
246  'position',[5 tmp(4)-15-10 120 15],...
247  'style','text',...
248  'String','Output File Name',...
249  'backgroundcolor',GD.col.frame,...
250  'horizontalalign','left');
251tmp = get(H.OUTPUTFILE_TX,'position');
252outputfile_tooltip = ...
253  sprintf(['The following special formatting can be\n',...
254  'used in this dialog:\n',...
255  '%%m = map type identifier (t2map, t1rmap, etc.)\n',...
256  '%%f = file name from input folder (e.g. MyData.fid -> %%f = MyData)\n',...
257  ' \n',...
258  'Note that numbering and file extension are handled automatically.']);
259H.OUTPUTFILE_EDIT = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
260  'units','pixels',...
261  'position',[tmp(1) tmp(2)-22-3 250 22],...
262  'style','edit',...
263  'String','%m_%f',...
264  'backgroundcolor',GD.col.edit,...
265  'horizontalalign','left',...
266  'tooltip',outputfile_tooltip);
267tmp = get(H.OUTPUTFILE_EDIT,'position');
268
269% Overwrite without warning checkbox
270H.OUTPUTFILE_OVERWRITE = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
271  'units','pixels',...
272  'position',[tmp(1) tmp(2)-20-2 tmp(3) 20],...
273  'style','checkbox',...
274  'value',0,...
275  'String','Overwrite without warning',...
276  'backgroundcolor',GD.col.frame,...
277  'horizontalalign','left');
278tmp = get(H.OUTPUTFILE_OVERWRITE,'position');
279
280% Fit type text
281H.FITTYPE_TX = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
282  'units','pixels',...
283  'position',[5 tmp(2)-15-20 120 15],...
284  'style','text',...
285  'String','Fit type',...
286  'backgroundcolor',GD.col.frame,...
287  'horizontalalign','left');
288tmp = get(H.FITTYPE_TX,'position');
289
290% Linearized or non-linear fit
291H.LINEARFIT_RADIO = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
292  'units','pixels',...
293  'position',[tmp(1) tmp(2)-22-3 200 22],...
294  'style','radio',...
295  'value',1,...
296  'string','Linearized fit',...
297  'backgroundcolor',GD.col.frame);
298tmp = get(H.LINEARFIT_RADIO,'position');
299H.NONLINEARFIT_RADIO = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
300  'units','pixels',...
301  'position',[tmp(1) tmp(2)-22-3 tmp(3) 22],...
302  'style','radio',...
303  'value',0,...
304  'string','Non-linear fit',...
305  'backgroundcolor',GD.col.frame);
306tmp = get(H.NONLINEARFIT_RADIO,'position');
307
308% % Initial values -------------------------------
309% H.INITIALVAL_TX = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
310%   'units','pixels',...
311%   'position',[35 tmp(2)-15-3 90 15],...
312%   'style','text',...
313%   'String','Initial values',...
314%   'backgroundcolor',GD.col.frame,...
315%   'horizontalalign','left');
316% tmp = get(H.INITIALVAL_TX,'position');
317%
318% H.INITIALVAL_POPUP = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
319%   'units','pixels',...
320%   'position',[tmp(1)+tmp(3) tmp(2)-2 70 22],...
321%   'style','popup',...
322%   'string',{'Auto','Custom'},...
323%   'enable','off');
324% tmp = get(H.INITIALVAL_POPUP,'position');
325% H.INITIALVAL_EDIT = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
326%   'units','pixels',...
327%   'position',[tmp(1)+tmp(3) tmp(2) 60 22],...
328%   'style','edit',...
329%   'String','',...
330%   'backgroundcolor',GD.col.edit,...
331%   'horizontalalign','left',...
332%   'enable','off');
333
334% % Mask File ---------------------------------
335% H.MASKFILE_TX = uicontrol('parent',H.MASK_UIPANEL,...
336%   'units','pixels',...
337%   'position',[tmp(1) tmp(2)-15-20 tmp(3) 15],...
338%   'style','text',...
339%   'String','Mask File',...
340%   'backgroundcolor','r',...GD.col.frame,...
341%   'horizontalalign','left');
342% tmp = get(H.MASKFILE_TX,'position');
343% H.MASKFILE_EDIT = uicontrol('parent',H.MASK_UIPANEL,...
344%   'units','pixels',...
345%   'position',[tmp(1) tmp(2)-22 tmp(3) 22],...
346%   'style','edit',...
347%   'String','',...
348%   'backgroundcolor',GD.col.edit,...
349%   'horizontalalign','left');
350
351% Add options to selected files -------------
352tmp = get(H.OUTPUTFILE_UIPANEL,'position');
353btn_h = 30;
354btn_w = 130;
355H.ADD_OPT_TO_SEL = uicontrol('parent',H.OPTIONS_UIPANEL,...
356  'units','pixels',...
357  'position',[tmp(1)+tmp(3)+5 tmp(2)+tmp(4)-btn_h btn_w btn_h],...
358  'style','pushbutton',...
359  'string','Add to selected',...
360  'tooltip','Add options to selected files');
361tmp = get(H.ADD_OPT_TO_SEL,'position');
362H.ADD_OPT_TO_ALL = uicontrol('parent',H.OPTIONS_UIPANEL,...
363  'units','pixels',...
364  'position',[tmp(1) tmp(2)-btn_h-3 tmp(3) tmp(4)],...
365  'style','pushbutton',...
366  'string','Add to all',...
367  'tooltip','Add options to all files');
368
369
370%% FILES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
371
372% Files uipanel ---------------------
373tmp = get(H.OPTIONS_UIPANEL,'position');
374H.FILES_UIPANEL = uipanel('parent',H.FIG,...
375  'units','pixels',...
376  'position',[tmp(1) tmp(2)+tmp(4)+5 fig_w-10 220],...
377  'BackGroundColor',GD.col.frame,...
378  'title','Data Files',...
379  'fontweight','bold');
380tmp = get(H.FILES_UIPANEL,'position');
381
382% Quit button --------------------------
383btn_h = 30;
384btn_w = 90;
385H.QUIT_BTN = uicontrol('parent',H.FIG,...
386  'units','pixels',...
387  'position',[fig_w-btn_w-5 5 btn_w btn_h],...
388  'style','pushbutton',...
389  'string','Quit');
390tmp = get(H.QUIT_BTN,'position');
391
392% Fit maps btn-------------------------
393H.FIT_MAPS_BTN = uicontrol('parent',H.FIG,...
394  'units','pixels',...
395  'position',[tmp(1)-tmp(3)-3 tmp(2) tmp(3) tmp(4)],...
396  'style','pushbutton',...
397  'string','Fit Maps');
398
399% Files listbox -------------------------
400tmp = get(H.FILES_UIPANEL,'position');
401H.FILES_LBOX = uicontrol('parent',H.FILES_UIPANEL,...
402  'style','listbox',...
403  'string',{'*/home/tjniskan/MyMapData/070907/MapFromARat.fid/fid',...
404  '*/home/tjniskan/MyMapData/070907/MapFromARat.fid/fid',...
405  '*/home/tjniskan/MyMapData/090907/MapFromARat.fid/fid',...
406  '*/home/tjniskan/MyMapData/100907/MapFromARat.fid/fid',...
407  '*/home/tjniskan/MyMapData/120907/MapFromARat.fid/fid',...
408  '/home/tjniskan/MyMapData/150907/MapFromARat.fid/fid',...
409  '/home/tjniskan/MyMapData/180907/MapFromARat.fid/fid',...
410  '/home/tjniskan/MyMapData/230907/MapFromARat.fid/fid',...
411  '/home/tjniskan/MyMapData/011007/MapFromARat.fid/fid',...
412  '/home/tjniskan/MyMapData/051007/MapFromARat.fid/fid',...
413  '/home/tjniskan/MyMapData/131007/MapFromARat.fid/fid'},...
414  'units','pixel',...
415  'position',[5 5 tmp(3)-10 tmp(4)-70],...
416  'backgroundcolor',GD.col.listbox,...
417  'Max',3,'Min',1);
418tmp = get(H.FILES_LBOX,'position');
419
420% Add files btn --------------------------
421H.FILES_ADD = uicontrol('parent',H.FILES_UIPANEL,...
422  'style','pushbutton',...
423  'units','pixels',...
424  'position',[5 tmp(2)+tmp(4)+3 40 40],...
425  'tooltip','Add files to list',...
426  'cdata',Dat.cdata.add);
427tmp = get(H.FILES_ADD,'position');
428
429% Remove selected ------------------------
430H.FILES_REMSEL = uicontrol('parent',H.FILES_UIPANEL,...
431  'style','pushbutton',...
432  'units','pixels',...
433  'position',[tmp(1)+tmp(3)+3 tmp(2) tmp(3) tmp(4)],...
434  'tooltip','Remove selected files from list',...
435  'cdata',Dat.cdata.delete);
436tmp = get(H.FILES_REMSEL,'position');
437
438% Remove all -----------------------------
439H.FILES_REMALL = uicontrol('parent',H.FILES_UIPANEL,...
440  'style','pushbutton',...
441  'units','pixels',...
442  'position',[tmp(1)+tmp(3)+3 tmp(2) tmp(3) tmp(4)],...
443  'tooltip','Remove all files from list',...
444  'cdata',Dat.cdata.deleteall);
445tmp = get(H.FILES_REMALL,'position');
446
447
448
449
450end % function l_DrawGUI()
451
452%%%%%%%%%%%%%%%%%%%%%
453%% Get Map Types
454%%%%%%%%%%%%%%%%%%%%%
455  function maptypes = l_GetMapTypes()
456        maptypes = {'T2','T1','T2 rho','T1 rho','ADC',...
457          'Perfusion','B1'};
458  end
459
460%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
461%% Callback for output folder selection radiobuttons
462%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
463  function l_SelectOutputDir(h,evd,opt)
464       
465        if strcmpi(opt,'custom')
466          set(H.OUTDIR_EDIT,'enable','on')
467          set(H.OUTDIR_BROWSE,'enable','on')
468          set(H.OUTDIR_RADIO1,'value',1)
469          set(H.OUTDIR_RADIO2,'value',0)
470        elseif strcmpi(opt,'input')
471          set(H.OUTDIR_EDIT,'enable','off')
472          set(H.OUTDIR_BROWSE,'enable','off')
473          set(H.OUTDIR_RADIO1,'value',0)
474          set(H.OUTDIR_RADIO2,'value',1)
475        end
476       
477  end
478
479end % aedes_maptool()
Note: See TracBrowser for help on using the repository browser.

Powered by Trac 1.0.9.Copyright © Juha-Pekka Niskanen 2008