source: an2_maptool.m @ 73

Last change on this file since 73 was 45, checked in by tjniskan, 11 years ago
  • Changed a small thing in license notices

M an2_export_gui.m
M an2_cellsprintf.m
M an2_getfilefilter.m
M an2_calc_wait.m
M an2_smiswrite.m
M misclib/spectrsum.m
M misclib/shiftind.m
M misclib/nifti4dto3d.m
M misclib/nifti3dto4d.m
M misclib/dcm_info.m
M misclib/addicon.m
M misclib/makelcmraw.m
M an2_check_file_exist.m
M an2_iseven.m
M an2_cellwrite.m
M an2_wbar.m
M an2_rot3d.m
M an2_readfdf.m
M an2_revision.m
M an2_viewprocpar.m
M an2_checkcthdr.m
M an2_readprocpar.m
M an2_fitmaps.m
M an2_read_nifti.m
M an2_data_read.m
M an2_smisread.m
M an2_resviewer.m
M an2_maptool.m
M aedes.m
M an2_helpabout.m
M an2_res2table.m
M an2_copy_roi.m
M plugins/save_roi_as_mask.m
M plugins/write_difference_images.m
M plugins/plot_profile.m
M plugins/calculate_t2_map.m
M plugins/calculate_t1r_map.m
M plugins/view_kspace.m
M plugins/copy_data_to_workspace.m
M plugins/take_snapshot.m
M an2_inputdlg.m
M an2_roi_copy_gui.m
M an2_readctdata.m
M an2_readfid.m
M an2_readfidprefs.m
M an2_readtab.m
M an2_check_updates.m
M an2_killfigs.m
M an2_roi_stats.m
M an2_saveres.m
M an2_rotateflip.m
M an2_juigetfiles.m
M an2_gui_defaults.m
M an2_editstack.m
M an2_errordump.m
M an2_update.m
M an2_write_nifti.m

File size: 14.6 KB
Line 
1function an2_maptool()
2% AN2_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=an2_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','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('an2_cdata.mat');
70catch
71  error('Could not open an2_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%% FILES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86
87% Files uipanel ---------------------
88H.FILES_UIPANEL = uipanel('parent',H.FIG,...
89  'units','pixels',...
90  'position',[5 40 fig_w-10 220],...
91  'BackGroundColor',GD.col.frame,...
92  'title','Data Files',...
93  'fontweight','bold');
94tmp = get(H.FILES_UIPANEL,'position');
95
96% Quit button --------------------------
97btn_h = 30;
98btn_w = 90;
99H.QUIT_BTN = uicontrol('parent',H.FIG,...
100  'units','pixels',...
101  'position',[fig_w-btn_w-5 5 btn_w btn_h],...
102  'style','pushbutton',...
103  'string','Quit');
104tmp = get(H.QUIT_BTN,'position');
105
106% Fit maps btn-------------------------
107H.FIT_MAPS_BTN = uicontrol('parent',H.FIG,...
108  'units','pixels',...
109  'position',[tmp(1)-tmp(3)-3 tmp(2) tmp(3) tmp(4)],...
110  'style','pushbutton',...
111  'string','Fit Maps');
112
113% Files listbox -------------------------
114tmp = get(H.FILES_UIPANEL,'position');
115H.FILES_LBOX = uicontrol('parent',H.FILES_UIPANEL,...
116  'style','listbox',...
117  'string',{'*/home/tjniskan/MyMapData/070907/MapFromARat.fid/fid',...
118  '*/home/tjniskan/MyMapData/070907/MapFromARat.fid/fid',...
119  '*/home/tjniskan/MyMapData/090907/MapFromARat.fid/fid',...
120  '*/home/tjniskan/MyMapData/100907/MapFromARat.fid/fid',...
121  '*/home/tjniskan/MyMapData/120907/MapFromARat.fid/fid',...
122  '/home/tjniskan/MyMapData/150907/MapFromARat.fid/fid',...
123  '/home/tjniskan/MyMapData/180907/MapFromARat.fid/fid',...
124  '/home/tjniskan/MyMapData/230907/MapFromARat.fid/fid',...
125  '/home/tjniskan/MyMapData/011007/MapFromARat.fid/fid',...
126  '/home/tjniskan/MyMapData/051007/MapFromARat.fid/fid',...
127  '/home/tjniskan/MyMapData/131007/MapFromARat.fid/fid'},...
128  'units','pixel',...
129  'position',[5 5 tmp(3)-10 tmp(4)-70],...
130  'backgroundcolor',GD.col.listbox,...
131  'Max',3,'Min',1);
132tmp = get(H.FILES_LBOX,'position');
133
134% Add files btn --------------------------
135H.FILES_ADD = uicontrol('parent',H.FILES_UIPANEL,...
136  'style','pushbutton',...
137  'units','pixels',...
138  'position',[5 tmp(2)+tmp(4)+3 40 40],...
139  'tooltip','Add files to list',...
140  'cdata',Dat.cdata.add);
141tmp = get(H.FILES_ADD,'position');
142
143% Remove selected ------------------------
144H.FILES_REMSEL = uicontrol('parent',H.FILES_UIPANEL,...
145  'style','pushbutton',...
146  'units','pixels',...
147  'position',[tmp(1)+tmp(3)+3 tmp(2) tmp(3) tmp(4)],...
148  'tooltip','Remove selected files from list',...
149  'cdata',Dat.cdata.delete);
150tmp = get(H.FILES_REMSEL,'position');
151
152% Remove all -----------------------------
153H.FILES_REMALL = uicontrol('parent',H.FILES_UIPANEL,...
154  'style','pushbutton',...
155  'units','pixels',...
156  'position',[tmp(1)+tmp(3)+3 tmp(2) tmp(3) tmp(4)],...
157  'tooltip','Remove all files from list',...
158  'cdata',Dat.cdata.deleteall);
159tmp = get(H.FILES_REMALL,'position');
160
161
162%% OPTIONS %%%%%%%%%%%%%%%%%%%%%%%
163
164% Options uipanel ----------------------
165tmp = get(H.FILES_UIPANEL,'position');
166H.OPTIONS_UIPANEL = uipanel('parent',H.FIG,...
167  'units','pixels',...
168  'position',[tmp(1) tmp(2)+tmp(4)+5 fig_w-10 300],...
169  'BackGroundColor',GD.col.frame,...
170  'title','Options',...
171  'fontweight','bold');
172tmp = get(H.OPTIONS_UIPANEL,'position');
173
174H.OUTDIR_UIPANEL = uipanel('parent',H.OPTIONS_UIPANEL,...
175  'units','pixels',...
176  'position',[5 5 tmp(3)-10 80],...
177  'BackGroundColor',GD.col.frame);
178tmp = get(H.OUTDIR_UIPANEL,'position');
179
180% Output directory editbox ---------------
181
182% Get default output folder from preferences
183try
184  DefaultOutputFolder = getpref('Aedes','MapToolDefaultOutputFolder');
185catch
186  if isunix
187        DefaultOutputFolder = getenv('HOME');
188  else
189        DefaultOutputFolder = getenv('USERPROFILE');
190  end
191end
192H.OUTDIR_EDIT = uicontrol('parent',H.OUTDIR_UIPANEL,...
193  'style','edit',...
194  'units','pixels',...
195  'position',[5 5 tmp(3)-60 22],...
196  'backgroundcolor',GD.col.edit,...
197  'enable','off',...
198  'horizontalalign','left',...
199  'string',DefaultOutputFolder);
200tmp = get(H.OUTDIR_EDIT,'position');
201
202% Output directory browse btn ------------
203H.OUTDIR_BROWSE = uicontrol('parent',H.OUTDIR_UIPANEL,...
204  'style','pushbutton',...
205  'units','pixels',...
206  'position',[tmp(1)+tmp(3)+3 tmp(2) 47 tmp(4)],...
207  'string','...',...
208  'enable','off');
209tmp = get(H.OUTDIR_EDIT,'position');
210
211% Input dir as output dir
212H.OUTDIR_RADIO1 = uicontrol('parent',H.OUTDIR_UIPANEL,...
213  'units','pixels',...
214  'position',[tmp(1) tmp(2)+tmp(4)+3 350 tmp(4)],...
215  'style','radio',...
216  'value',0,...
217  'String','Use custom folder',...
218  'BackGroundColor',GD.col.frame,...
219  'callback',{@l_SelectOutputDir,'custom'});
220tmp = get(H.OUTDIR_RADIO1,'position');
221
222H.OUTDIR_RADIO2 = uicontrol('parent',H.OUTDIR_UIPANEL,...
223  'units','pixels',...
224  'position',[tmp(1) tmp(2)+tmp(4)+3 tmp(3) tmp(4)],...
225  'style','radio',...
226  'value',1,...
227  'String','Use data input folder as output folder',...
228  'BackGroundColor',GD.col.frame,...
229  'callback',{@l_SelectOutputDir,'input'});
230
231% Maptype and fit values uipanel ------------------
232tmp = get(H.OUTDIR_UIPANEL,'position');
233panel_w = 215;
234panel_h = 190;
235H.MAPTYPE_UIPANEL = uipanel('parent',H.OPTIONS_UIPANEL,...
236  'units','pixels',...
237  'position',[5 tmp(2)+tmp(4)+5 panel_w panel_h],...
238  'backgroundcolor',GD.col.frame);
239tmp = get(H.MAPTYPE_UIPANEL,'position');
240
241% Maptype popup --------------------------
242H.MAPTYPE_TX = uicontrol('parent',H.MAPTYPE_UIPANEL,...
243  'units','pixels',...
244  'position',[5 tmp(4)-10-15 70 15],...
245  'style','text',...
246  'String','Map type',...
247  'backgroundcolor',GD.col.frame,...
248  'horizontalalign','left');
249tmp = get(H.MAPTYPE_TX,'position');
250maptypes = l_GetMapTypes;
251H.MAPTYPE_POPUP = uicontrol('parent',H.MAPTYPE_UIPANEL,...
252  'units','pixels',...
253  'position',[tmp(1) tmp(2)-20-3 200 20],...
254  'style','popup',...
255  'string',maptypes);
256tmp = get(H.MAPTYPE_TX,'position');
257
258% Fit values edit and popup -------------------
259H.FITVALS_TX = uicontrol('parent',H.MAPTYPE_UIPANEL,...
260  'units','pixels',...
261  'position',[tmp(1) tmp(2)-15-40 tmp(3) 15],...
262  'style','text',...
263  'String','Fit values',...
264  'backgroundcolor',GD.col.frame,...
265  'horizontalalign','left');
266tmp = get(H.FITVALS_TX,'position');
267
268H.FITVALS_EDIT = uicontrol('parent',H.MAPTYPE_UIPANEL,...
269  'units','pixels',...
270  'position',[tmp(1) tmp(2)-22-3 200 22],...
271  'style','edit',...
272  'String','',...
273  'backgroundcolor',GD.col.edit,...
274  'horizontalalign','left');
275tmp = get(H.FITVALS_EDIT,'position');
276
277% % Fit value multiplication
278% H.FITVALS_MULTI = uicontrol('parent',H.MAPTYPE_UIPANEL,...
279%   'units','pixels',...
280%   'position',[tmp(1) tmp(2)-22-2 tmp(3) 22],...
281%   'style','popup',...
282%   'String',{'Multiplication: 1',...
283%   'Multiplication: 1000',...
284%   'Multiplication: 100',...
285%   'Multiplication: 10',...
286%   'Multiplication: 0.1',...
287%   'Multiplication: 0.01',...
288%   'Multiplication: 0.001',...
289%   'Multiplication: custom'});
290% tmp = get(H.FITVALS_MULTI,'position');
291
292% Use procpar field --------------------------
293H.FITVALS_USE_PROCPAR = uicontrol('parent',H.MAPTYPE_UIPANEL,...
294  'units','pixels',...
295  'position',[tmp(1) tmp(2)-22-2 tmp(3) 22],...
296  'style','popup',...
297  'tooltip',sprintf('Select the procpar field\n that contains the fit values'),...
298  'String',{'Use procpar field...'},...
299  'horizontalalign','left');
300tmp = get(H.FITVALS_USE_PROCPAR,'position');
301H.FITVALS_USE_PROCPAR_SAVE = uicontrol('parent',H.MAPTYPE_UIPANEL,...
302  'units','pixels',...
303  'position',[tmp(1) tmp(2)-20-2 tmp(3) 20],...
304  'style','checkbox',...
305  'tooltip',sprintf('Use this procpar field as\n default for this map type'),...
306  'String','Use as default for this map type',...
307  'horizontalalign','left',...
308  'backgroundcolor',GD.col.frame,...
309  'fontsize',8);
310
311
312%% Output file name and mask file controls
313tmp=get(H.MAPTYPE_UIPANEL,'position');
314H.OUTPUTFILE_UIPANEL = uipanel('parent',H.OPTIONS_UIPANEL,...
315  'units','pixels',...
316  'position',[tmp(1)+tmp(3)+5 tmp(2) 270 tmp(4)],...
317  'backgroundcolor',GD.col.frame);
318tmp=get(H.OUTPUTFILE_UIPANEL,'position');
319
320% Output file name text and edit
321H.OUTPUTFILE_TX = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
322  'units','pixels',...
323  'position',[5 tmp(4)-15-10 120 15],...
324  'style','text',...
325  'String','Output File Name',...
326  'backgroundcolor',GD.col.frame,...
327  'horizontalalign','left');
328tmp = get(H.OUTPUTFILE_TX,'position');
329outputfile_tooltip = ...
330  sprintf(['The following special formatting can be\n',...
331  'used in this dialog:\n',...
332  '%%m = map type identifier (t2map, t1rmap, etc.)\n',...
333  '%%f = file name from input folder (e.g. MyData.fid -> %%f = MyData)\n',...
334  ' \n',...
335  'Note that numbering and file extension are handled automatically.']);
336H.OUTPUTFILE_EDIT = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
337  'units','pixels',...
338  'position',[tmp(1) tmp(2)-22-3 250 22],...
339  'style','edit',...
340  'String','%m_%f',...
341  'backgroundcolor',GD.col.edit,...
342  'horizontalalign','left',...
343  'tooltip',outputfile_tooltip);
344tmp = get(H.OUTPUTFILE_EDIT,'position');
345
346% Overwrite without warning checkbox
347H.OUTPUTFILE_OVERWRITE = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
348  'units','pixels',...
349  'position',[tmp(1) tmp(2)-20-2 tmp(3) 20],...
350  'style','checkbox',...
351  'value',0,...
352  'String','Overwrite without warning',...
353  'backgroundcolor',GD.col.frame,...
354  'horizontalalign','left');
355tmp = get(H.OUTPUTFILE_OVERWRITE,'position');
356
357% Fit type text
358H.FITTYPE_TX = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
359  'units','pixels',...
360  'position',[5 tmp(2)-15-20 120 15],...
361  'style','text',...
362  'String','Fit type',...
363  'backgroundcolor',GD.col.frame,...
364  'horizontalalign','left');
365tmp = get(H.FITTYPE_TX,'position');
366
367% Linearized or non-linear fit
368H.LINEARFIT_RADIO = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
369  'units','pixels',...
370  'position',[tmp(1) tmp(2)-22-3 200 22],...
371  'style','radio',...
372  'value',1,...
373  'string','Linearized fit',...
374  'backgroundcolor',GD.col.frame);
375tmp = get(H.LINEARFIT_RADIO,'position');
376H.NONLINEARFIT_RADIO = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
377  'units','pixels',...
378  'position',[tmp(1) tmp(2)-22-3 tmp(3) 22],...
379  'style','radio',...
380  'value',0,...
381  'string','Non-linear fit',...
382  'backgroundcolor',GD.col.frame);
383tmp = get(H.NONLINEARFIT_RADIO,'position');
384
385% % Initial values -------------------------------
386% H.INITIALVAL_TX = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
387%   'units','pixels',...
388%   'position',[35 tmp(2)-15-3 90 15],...
389%   'style','text',...
390%   'String','Initial values',...
391%   'backgroundcolor',GD.col.frame,...
392%   'horizontalalign','left');
393% tmp = get(H.INITIALVAL_TX,'position');
394%
395% H.INITIALVAL_POPUP = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
396%   'units','pixels',...
397%   'position',[tmp(1)+tmp(3) tmp(2)-2 70 22],...
398%   'style','popup',...
399%   'string',{'Auto','Custom'},...
400%   'enable','off');
401% tmp = get(H.INITIALVAL_POPUP,'position');
402% H.INITIALVAL_EDIT = uicontrol('parent',H.OUTPUTFILE_UIPANEL,...
403%   'units','pixels',...
404%   'position',[tmp(1)+tmp(3) tmp(2) 60 22],...
405%   'style','edit',...
406%   'String','',...
407%   'backgroundcolor',GD.col.edit,...
408%   'horizontalalign','left',...
409%   'enable','off');
410
411% % Mask File ---------------------------------
412% H.MASKFILE_TX = uicontrol('parent',H.MASK_UIPANEL,...
413%   'units','pixels',...
414%   'position',[tmp(1) tmp(2)-15-20 tmp(3) 15],...
415%   'style','text',...
416%   'String','Mask File',...
417%   'backgroundcolor','r',...GD.col.frame,...
418%   'horizontalalign','left');
419% tmp = get(H.MASKFILE_TX,'position');
420% H.MASKFILE_EDIT = uicontrol('parent',H.MASK_UIPANEL,...
421%   'units','pixels',...
422%   'position',[tmp(1) tmp(2)-22 tmp(3) 22],...
423%   'style','edit',...
424%   'String','',...
425%   'backgroundcolor',GD.col.edit,...
426%   'horizontalalign','left');
427
428% Add options to selected files -------------
429tmp = get(H.OUTPUTFILE_UIPANEL,'position');
430btn_h = 30;
431btn_w = 130;
432H.ADD_OPT_TO_SEL = uicontrol('parent',H.OPTIONS_UIPANEL,...
433  'units','pixels',...
434  'position',[tmp(1)+tmp(3)+5 tmp(2)+tmp(4)-btn_h btn_w btn_h],...
435  'style','pushbutton',...
436  'string','Add to selected',...
437  'tooltip','Add options to selected files');
438tmp = get(H.ADD_OPT_TO_SEL,'position');
439H.ADD_OPT_TO_ALL = uicontrol('parent',H.OPTIONS_UIPANEL,...
440  'units','pixels',...
441  'position',[tmp(1) tmp(2)-btn_h-3 tmp(3) tmp(4)],...
442  'style','pushbutton',...
443  'string','Add to all',...
444  'tooltip','Add options to all files');
445
446
447end % function l_DrawGUI()
448
449%%%%%%%%%%%%%%%%%%%%%
450%% Get Map Types
451%%%%%%%%%%%%%%%%%%%%%
452  function maptypes = l_GetMapTypes()
453        maptypes = {'T2','T1','T2 rho','T1 rho','ADC',...
454          'Perfusion','B1'};
455  end
456
457%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
458%% Callback for output folder selection radiobuttons
459%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
460  function l_SelectOutputDir(h,evd,opt)
461       
462        if strcmpi(opt,'custom')
463          set(H.OUTDIR_EDIT,'enable','on')
464          set(H.OUTDIR_BROWSE,'enable','on')
465          set(H.OUTDIR_RADIO1,'value',1)
466          set(H.OUTDIR_RADIO2,'value',0)
467        elseif strcmpi(opt,'input')
468          set(H.OUTDIR_EDIT,'enable','off')
469          set(H.OUTDIR_BROWSE,'enable','off')
470          set(H.OUTDIR_RADIO1,'value',0)
471          set(H.OUTDIR_RADIO2,'value',1)
472        end
473       
474  end
475
476end % an2_maptool()
Note: See TracBrowser for help on using the repository browser.

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