source: an2_readfidprefs.m @ 77

Last change on this file since 77 was 77, checked in by tjniskan, 10 years ago
  • Fixed a strange bug related to resizing Aedes window in Matlab

R2008a (and possibly R2008b and R2009a).

  • Fixed bugs of Voxel TimeSeries? and Overlay Control figure

handles not being properly destroyed on exit.

  • Changed default values for reading VNMR files (now Fast Read is on

by default, output precision is single and data is oriented using
PROCPAR.orient)

  • Fixed a bug in the calculate SNR -plugin
  • Made a temporary workaround for controlling the output in the "View

ROI statistics" -table. A proper GUI implementation will (hopefully) follow
shortly. The output can be controlled by using Aedes preferences. For
example setpref('Aedes','StatPrintDirs?','TXYZV') will print in the
output Total, X-dir, Y-dir, Z-dir and V-dir statistics.

M an2_revision.m
M an2_data_read.m
M an2_resviewer.m
M aedes.m
M an2_res2table.m
M plugins/calculate_snr.m
M an2_readfid.m
M an2_readfidprefs.m
M an2_roi_stats.m

File size: 12.9 KB
Line 
1function an2_readfidprefs()
2% AN2_READFIDPREFS - GUI for editing preferences for AEDES and
3% AN2_DATA_READ for VNMR format files
4%   
5%
6% Synopsis:
7%        an2_readfidprefs;
8%
9% Description:
10%
11% Examples:
12%
13% See also:
14%        AEDES, AN2_DATA_READ
15
16% This function is a part of Aedes - A graphical tool for analyzing
17% medical images
18%
19% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
20%
21% Department of Physics, Department of Neurobiology
22% University of Kuopio, FINLAND
23%
24% This program may be used under the terms of the GNU General Public
25% License version 2.0 as published by the Free Software Foundation
26% and appearing in the file LICENSE.TXT included in the packaging of
27% this program.
28%
29% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
30% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
31
32
33done=false;
34msg='';
35
36
37Dat = [];
38
39%% Try to read defaults from preferences
40%% Get defaults for Return
41if ispref('Aedes','ReadfidReturn')
42  if getpref('Aedes','ReadfidReturn')==1
43    Dat.ReturnKSpace  = false;
44    Dat.ReturnFTData  = true;
45  elseif getpref('Aedes','ReadfidReturn')==2
46      Dat.ReturnKSpace  = true;
47      Dat.ReturnFTData  = false;
48  elseif getpref('Aedes','ReadfidReturn')==3
49    Dat.ReturnKSpace  = true;
50    Dat.ReturnFTData  = true;
51  else
52    Dat.ReturnKSpace  = false;
53    Dat.ReturnFTData  = true;
54  end
55else
56  Dat.ReturnKSpace  = false;
57  Dat.ReturnFTData  = true;
58  setpref('Aedes','ReadfidReturn',1)
59end
60
61%% Get defaults for DC correction
62if ispref('Aedes','ReadfidDCcorrection')
63  if getpref('Aedes','ReadfidDCcorrection')
64    Dat.DCcorrection  = true;
65  else
66    Dat.DCcorrection  = false;
67  end
68else
69  Dat.DCcorrection  = false;
70  setpref('Aedes','ReadfidDCcorrection',Dat.DCcorrection)
71end
72
73%% Get defaults for Zeropadding
74if ispref('Aedes','ReadfidZeropadding')
75  if getpref('Aedes','ReadfidZeropadding')==0
76    Dat.ZeroPadding = 0;
77  elseif getpref('Aedes','ReadfidZeropadding')==1
78    Dat.ZeroPadding = 1;
79  elseif getpref('Aedes','ReadfidZeropadding')==2
80    Dat.ZeroPadding = 2;
81  else
82    Dat.ZeroPadding = 2;
83  end
84else
85  Dat.ZeroPadding = 2;
86  setpref('Aedes','ReadfidZeropadding',Dat.ZeroPadding)
87end
88
89%% Get defaults for Sorting
90if ispref('Aedes','ReadfidSorting')
91  if getpref('Aedes','ReadfidSorting')
92    Dat.Sorting = true;
93  else
94    Dat.Sorting = false;
95  end
96else
97  Dat.Sorting = true;
98  setpref('Aedes','ReadfidSorting',Dat.Sorting)
99end
100
101%% Get defaults for FastRead
102if ispref('Aedes','ReadfidFastRead')
103  if getpref('Aedes','ReadfidFastRead')
104    Dat.FastDataRead = true;
105  else
106    Dat.FastDataRead = false;
107  end
108else
109  Dat.FastDataRead = true;
110  setpref('Aedes','ReadfidFastRead',Dat.FastDataRead)
111end
112
113%% Get defaults for Precision
114if ispref('Aedes','ReadfidPrecision')
115  if strcmpi(getpref('Aedes','ReadfidPrecision'),'single')
116        Dat.Precision = 'single';
117  else
118        Dat.Precision = 'double';
119  end
120else
121  Dat.Precision = 'single';
122  setpref('Aedes','ReadfidPrecision',Dat.Precision)
123end
124
125% %% Get defaults for Reorienting EPI images
126% if ispref('Aedes','ReadfidReorientEPI')
127%   Dat.ReorientEPI = getpref('Aedes','ReadfidReorientEPI');
128% else
129%   Dat.ReorientEPI = 'off';
130%   setpref('Aedes','ReadfidReorientEPI','off')
131% end
132
133%% Get defaults for Reorienting images according to procpar.orient
134if ispref('Aedes','ReadfidOrientImages')
135  Dat.OrientImages = getpref('Aedes','ReadfidOrientImages');
136else
137  Dat.OrientImages = 'on';
138  setpref('Aedes','ReadfidOrientImages','on')
139end
140
141%% Get defaults for Removing phase image from EPI data
142if ispref('Aedes','ReadfidRemoveEPIphaseIm')
143  Dat.RemoveEPIphaseIm = getpref('Aedes','ReadfidRemoveEPIphaseIm');
144else
145  Dat.RemoveEPIphaseIm = 'off';
146  setpref('Aedes','ReadfidRemoveEPIphaseIm','off')
147end
148
149%% Load default font and colors
150%FigColor=get(0,'DefaultUicontrolBackgroundcolor');
151GD=an2_gui_defaults;
152%GD.col.mainfig = FigColor;
153fig_h = 280;
154fig_w = 270;
155scrsz = get(0,'screensize');
156fig_pos = [scrsz(3)/2-fig_w/2 scrsz(4)/2-fig_h/2 fig_w fig_h];
157
158%% The main figure
159fh = figure('position',fig_pos,...
160            'Units','Pixel', ...
161            'Name','Edit VNMR preferences', ...
162            'Numbertitle','off', ...
163            'Tag','readfid_prefs', ...
164            'Color',GD.col.mainfig, ...
165            'Toolbar','none', ...
166            'Menubar','none', ...
167            'DoubleBuffer','on', ...
168            'DockControls','off',...
169            'renderer','painters',...
170            'KeyPressFcn','',...
171            'resize','off',...
172            'windowstyle','normal');
173
174%% Main Uipanel
175uipanel_h = uipanel('parent',fh,...
176                    'Units','pixel',...
177                    'position',[5 40 fig_w-10 fig_h-45],...
178                    'title','Preferences for reading VNMR files',...
179                    'fontweig','bold',...
180                                        'backgroundcolor',GD.col.frame);
181
182%% OK button
183ok_btn = uicontrol('parent',fh,...
184                   'units','pixel',...
185                   'position',[fig_w-170 5 80 30],...
186                   'string','OK',...
187                   'style','pushbutton',...
188                   'callback',@l_ChangePrefs);
189
190%% Cancel button
191tmp=get(ok_btn,'position');
192cancel_btn = uicontrol('parent',fh,...
193                       'units','pixel',...
194                       'position',[tmp(1)+tmp(3)+5 tmp(2:4)],...
195                       'string','Cancel',...
196                       'style','pushbutton',...
197                       'callback','delete(gcbf)');
198
199%% Returned data popup
200if Dat.ReturnKSpace==true & Dat.ReturnFTData==false
201  val=2;
202elseif Dat.ReturnKSpace==false & Dat.ReturnFTData==true
203  val=1;
204else
205  val=3;
206end
207tmp=get(uipanel_h,'position');
208return_tx = uicontrol('parent',uipanel_h,...
209                      'units','pixel',...
210                      'position',[10 tmp(4)-50 100 20],...
211                      'style','text',...
212                      'horizontalalign','left',...
213                      'string','Returned data',...
214                                          'backgroundcolor',GD.col.frame,...
215                                          'fontsize',GD.text_fs);
216tmp=get(return_tx,'position');
217return_popup = uicontrol('parent',uipanel_h,...
218                         'units','pixel',...
219                         'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
220                         'style','popup',...
221                         'backgroundcolor','w',...
222                         'string',{'FT-Data','K-Space','FT-Data and K-Space'},...
223                         'value',val);
224
225%% DC correction
226if Dat.DCcorrection
227  val=1;
228else
229  val=2;
230end
231tmp=get(return_tx,'position');
232dc_tx = uicontrol('parent',uipanel_h,...
233                  'units','pixel',...
234                  'position',[10 tmp(2)-tmp(4)-5 tmp(3) 20],...
235                  'style','text',...
236                  'horizontalalign','left',...
237                  'string','DC correction',...
238                                  'backgroundcolor',GD.col.frame);
239tmp=get(dc_tx,'position');
240dc_popup = uicontrol('parent',uipanel_h,...
241                     'units','pixel',...
242                     'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
243                     'style','popup',...
244                     'backgroundcolor','w',...
245                     'string',{'On','Off'},...
246                     'value',val);
247
248%% Zeropadding
249if Dat.ZeroPadding==1
250  val=1;
251elseif Dat.ZeroPadding==0
252  val=2;
253elseif Dat.ZeroPadding==2
254  val=3;
255end
256tmp=get(dc_tx,'position');
257zeropadding_tx = uicontrol('parent',uipanel_h,...
258                           'units','pixel',...
259                           'position',[10 tmp(2)-tmp(4)-5 tmp(3) 20],...
260                           'style','text',...
261                           'horizontalalign','left',...
262                           'string','Zeropadding',...
263                                                   'backgroundcolor',GD.col.frame);
264tmp=get(zeropadding_tx,'position');
265zeropadding_popup = uicontrol('parent',uipanel_h,...
266                              'units','pixel',...
267                              'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
268                              'style','popup',...
269                              'backgroundcolor','w',...
270                              'string',{'On','Off','Auto'},...
271                              'value',val);
272
273%% Sorting
274if Dat.Sorting
275  val=1;
276else
277  val=2;
278end
279tmp=get(zeropadding_tx,'position');
280sorting_tx = uicontrol('parent',uipanel_h,...
281                       'units','pixel',...
282                       'position',[10 tmp(2)-tmp(4)-5 tmp(3) 20],...
283                       'style','text',...
284                       'horizontalalign','left',...
285                       'string','Sorting',...
286                                           'backgroundcolor',GD.col.frame);
287tmp=get(sorting_tx,'position');
288sorting_popup = uicontrol('parent',uipanel_h,...
289                          'units','pixel',...
290                          'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
291                          'style','popup',...
292                          'backgroundcolor','w',...
293                          'string',{'On','Off'},...
294                          'value',val);
295%% Fast Read
296if Dat.FastDataRead
297  val=1;
298else
299  val=2;
300end
301tmp=get(sorting_tx,'position');
302fastread_tx = uicontrol('parent',uipanel_h,...
303  'units','pixel',...
304  'position',[10 tmp(2)-tmp(4)-5 tmp(3) 20],...
305  'style','text',...
306  'horizontalalign','left',...
307  'string','FastRead',...
308  'backgroundcolor',GD.col.frame);
309tmp=get(fastread_tx,'position');
310fastread_popup = uicontrol('parent',uipanel_h,...
311  'units','pixel',...
312  'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
313  'style','popup',...
314  'backgroundcolor','w',...
315  'string',{'On','Off'},...
316  'value',val);
317
318%% Precision
319if strcmpi(Dat.Precision,'single')
320  val=1;
321else
322  val=2;
323end
324tmp=get(fastread_tx,'position');
325precision_tx = uicontrol('parent',uipanel_h,...
326  'units','pixel',...
327  'position',[10 tmp(2)-tmp(4)-5 tmp(3) 20],...
328  'style','text',...
329  'horizontalalign','left',...
330  'string','Precision',...
331  'backgroundcolor',GD.col.frame);
332tmp=get(precision_tx,'position');
333precision_popup = uicontrol('parent',uipanel_h,...
334  'units','pixel',...
335  'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
336  'style','popup',...
337  'backgroundcolor','w',...
338  'string',{'single','double'},...
339  'value',val);
340
341
342%% Reorient images according to procpar.orient
343if strcmpi(Dat.OrientImages,'on')
344  val=1;
345else
346  val=0;
347end
348tmp=get(precision_tx,'position');
349orient_images_chbox = uicontrol('parent',uipanel_h,...
350  'units','pixel',...
351  'position',[10 tmp(2)-tmp(4)-5 240 20],...
352  'style','checkbox',...
353  'horizontalalign','left',...
354  'backgroundcolor',GD.col.frame,...
355  'string','Orient images using PROCPAR.orient',...
356  'value',val);
357
358%% Remove phase image frim EPI data
359if strcmpi(Dat.RemoveEPIphaseIm,'on')
360  val=1;
361else
362  val=0;
363end
364tmp=get(orient_images_chbox,'position');
365removeepiphaseim_chbox = uicontrol('parent',uipanel_h,...
366  'units','pixel',...
367  'position',[10 tmp(2)-tmp(4)-5 240 20],...
368  'style','checkbox',...
369  'horizontalalign','left',...
370  'backgroundcolor',GD.col.frame,...
371  'string','Remove phase image from EPI data',...
372  'value',val);
373
374% Store handles to a structure
375H.fh = fh;
376H.return_h = return_popup;
377H.dccorr_h = dc_popup;
378H.zeropadding_h = zeropadding_popup;
379H.sorting_h = sorting_popup;
380H.fastread_h = fastread_popup;
381H.precision_h = precision_popup;
382H.orient_images_h = orient_images_chbox;
383H.removeepiphaseim_h = removeepiphaseim_chbox;
384
385set(ok_btn,'userdata',H)
386
387%%%%%%%%%%%%%%%%%%%%%%%%%%%%
388% OK button press callback
389%%%%%%%%%%%%%%%%%%%%%%%%%%%%
390function l_ChangePrefs(h,evd)
391
392H = get(h,'userdata');
393
394try
395% Get popup values
396return_val = get(H.return_h,'value');
397dccorr_val = get(H.dccorr_h,'value');
398zeropadding_val = get(H.zeropadding_h,'value');
399sorting_val = get(H.sorting_h,'value');
400fastread_val = get(H.fastread_h,'value');
401precision_val = get(H.precision_h,'value');
402orient_images_val = get(H.orient_images_h,'value');
403removeepiphaseim_val = get(H.removeepiphaseim_h,'value');
404
405% Set preferences
406%% -------------------------------------------------------------------
407
408%% Return value
409setpref('Aedes','ReadfidReturn',return_val)
410
411%% DC correction
412if dccorr_val==1
413  setpref('Aedes','ReadfidDCcorrection',true)
414else
415  setpref('Aedes','ReadfidDCcorrection',false)
416end
417
418%% Zeropadding
419if zeropadding_val==1
420  setpref('Aedes','ReadfidZeropadding',1)
421elseif zeropadding_val==2
422  setpref('Aedes','ReadfidZeropadding',0)
423else
424  setpref('Aedes','ReadfidZeropadding',2)
425end
426
427%% Sorting
428if sorting_val==1
429  setpref('Aedes','ReadfidSorting',true)
430else
431  setpref('Aedes','ReadfidSorting',false)
432end
433
434%% FastRead
435if fastread_val==1
436  setpref('Aedes','ReadfidFastRead',true)
437else
438  setpref('Aedes','ReadfidFastRead',false)
439end
440
441%% Precision
442if precision_val==1
443  setpref('Aedes','ReadfidPrecision','single')
444else
445  setpref('Aedes','ReadfidPrecision','double')
446end
447
448%% Orient images
449if orient_images_val==1
450  setpref('Aedes','ReadfidOrientImages','on')
451else
452  setpref('Aedes','ReadfidOrientImages','off')
453end
454
455%% Remove phase image from EPI
456if removeepiphaseim_val==1
457  setpref('Aedes','ReadfidRemoveEPIphaseIm','on')
458else
459  setpref('Aedes','ReadfidRemoveEPIphaseIm','off')
460end
461
462catch
463  hh=errordlg('An error occurred! Could not save preferences.',...
464              'Could not save preferences','modal');
465end
466
467delete(H.fh)
Note: See TracBrowser for help on using the repository browser.

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