source: aedes_readfidprefs.m

Last change on this file was 213, checked in by tjniskan, 2 years ago
  • Fixed Aedes for Handle Graphics version 2 (HG2).

M aedes.m
M aedes_createmosaic.m
M aedes_export_gui.m
M aedes_gui_defaults.m
M aedes_headerbrowser.m
M aedes_helpabout.m
M aedes_inputdlg.m
M aedes_juigetfiles.m
M aedes_readfidprefs.m
M aedes_resviewer.m
M aedes_revision.m

File size: 14.0 KB
Line 
1function aedes_readfidprefs()
2% AEDES_READFIDPREFS - GUI for editing preferences for AEDES and
3% AEDES_DATA_READ for VNMR format files
4%   
5%
6% Synopsis:
7%        aedes_readfidprefs;
8%
9% Description:
10%
11% Examples:
12%
13% See also:
14%        AEDES, AEDES_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%% Get defaults for read function
150if ispref('Aedes','VnmrUseOldReadFcn')
151  if getpref('Aedes','VnmrUseOldReadFcn')
152    Dat.VnmrUseOldReadFcn = true;
153  else
154    Dat.VnmrUseOldReadFcn = false;
155  end
156else
157  Dat.VnmrUseOldReadFcn = true;
158  setpref('Aedes','VnmrUseOldReadFcn',Dat.VnmrUseOldReadFcn)
159end
160
161%% Load default font and colors
162%FigColor=get(0,'DefaultUicontrolBackgroundcolor');
163GD=aedes_gui_defaults;
164%GD.col.mainfig = FigColor;
165fig_h = 300;
166fig_w = 270;
167fig_location = aedes_dialoglocation([fig_w,fig_h]);
168fig_pos = [fig_location(1) fig_location(2) fig_w fig_h];
169
170%% The main figure
171fh = figure('position',fig_pos,...
172            'Units','Pixel', ...
173            'Name','Edit VNMR preferences', ...
174            'Numbertitle','off', ...
175            'Tag','readfid_prefs', ...
176            'Color',GD.col.mainfig, ...
177            'Toolbar','none', ...
178            'Menubar','none', ...
179            'DockControls','off',...
180            'renderer','painters',...
181            'KeyPressFcn','',...
182            'resize','off',...
183            'windowstyle','normal');
184if ~GD.HG2graphics
185        set(fh,'DoubleBuffer','on')
186end
187
188%% Main Uipanel
189uipanel_h = uipanel('parent',fh,...
190                    'Units','pixel',...
191                    'position',[5 40 fig_w-10 fig_h-45],...
192                    'title','Preferences for reading VNMR files',...
193                    'fontweig','bold',...
194                                        'backgroundcolor',GD.col.frame);
195
196%% OK button
197ok_btn = uicontrol('parent',fh,...
198                   'units','pixel',...
199                   'position',[fig_w-170 5 80 30],...
200                   'string','OK',...
201                   'style','pushbutton',...
202                   'callback',@l_ChangePrefs);
203
204%% Cancel button
205tmp=get(ok_btn,'position');
206cancel_btn = uicontrol('parent',fh,...
207                       'units','pixel',...
208                       'position',[tmp(1)+tmp(3)+5 tmp(2:4)],...
209                       'string','Cancel',...
210                       'style','pushbutton',...
211                       'callback','delete(gcbf)');
212
213%% Returned data popup
214if Dat.ReturnKSpace==true & Dat.ReturnFTData==false
215  val=2;
216elseif Dat.ReturnKSpace==false & Dat.ReturnFTData==true
217  val=1;
218else
219  val=3;
220end
221tmp=get(uipanel_h,'position');
222return_tx = uicontrol('parent',uipanel_h,...
223                      'units','pixel',...
224                      'position',[10 tmp(4)-50 100 20],...
225                      'style','text',...
226                      'horizontalalign','left',...
227                      'string','Returned data',...
228                                          'backgroundcolor',GD.col.frame,...
229                                          'fontsize',GD.text_fs);
230tmp=get(return_tx,'position');
231return_popup = uicontrol('parent',uipanel_h,...
232                         'units','pixel',...
233                         'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
234                         'style','popup',...
235                         'backgroundcolor','w',...
236                         'string',{'FT-Data','K-Space','FT-Data and K-Space'},...
237                         'value',val);
238
239%% DC correction
240if Dat.DCcorrection
241  val=1;
242else
243  val=2;
244end
245tmp=get(return_tx,'position');
246dc_tx = uicontrol('parent',uipanel_h,...
247                  'units','pixel',...
248                  'position',[10 tmp(2)-tmp(4)-5 tmp(3) 20],...
249                  'style','text',...
250                  'horizontalalign','left',...
251                  'string','DC correction',...
252                                  'backgroundcolor',GD.col.frame);
253tmp=get(dc_tx,'position');
254dc_popup = uicontrol('parent',uipanel_h,...
255                     'units','pixel',...
256                     'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
257                     'style','popup',...
258                     'backgroundcolor','w',...
259                     'string',{'On','Off'},...
260                     'value',val);
261
262%% Zeropadding
263if Dat.ZeroPadding==1
264  val=1;
265elseif Dat.ZeroPadding==0
266  val=2;
267elseif Dat.ZeroPadding==2
268  val=3;
269end
270tmp=get(dc_tx,'position');
271zeropadding_tx = uicontrol('parent',uipanel_h,...
272                           'units','pixel',...
273                           'position',[10 tmp(2)-tmp(4)-5 tmp(3) 20],...
274                           'style','text',...
275                           'horizontalalign','left',...
276                           'string','Zeropadding',...
277                                                   'backgroundcolor',GD.col.frame);
278tmp=get(zeropadding_tx,'position');
279zeropadding_popup = uicontrol('parent',uipanel_h,...
280                              'units','pixel',...
281                              'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
282                              'style','popup',...
283                              'backgroundcolor','w',...
284                              'string',{'On','Off','Auto'},...
285                              'value',val);
286
287%% Sorting
288if Dat.Sorting
289  val=1;
290else
291  val=2;
292end
293tmp=get(zeropadding_tx,'position');
294sorting_tx = uicontrol('parent',uipanel_h,...
295                       'units','pixel',...
296                       'position',[10 tmp(2)-tmp(4)-5 tmp(3) 20],...
297                       'style','text',...
298                       'horizontalalign','left',...
299                       'string','Sorting',...
300                                           'backgroundcolor',GD.col.frame);
301tmp=get(sorting_tx,'position');
302sorting_popup = uicontrol('parent',uipanel_h,...
303                          'units','pixel',...
304                          'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
305                          'style','popup',...
306                          'backgroundcolor','w',...
307                          'string',{'On','Off'},...
308                          'value',val);
309%% Fast Read
310if Dat.FastDataRead
311  val=1;
312else
313  val=2;
314end
315tmp=get(sorting_tx,'position');
316fastread_tx = uicontrol('parent',uipanel_h,...
317  'units','pixel',...
318  'position',[10 tmp(2)-tmp(4)-5 tmp(3) 20],...
319  'style','text',...
320  'horizontalalign','left',...
321  'string','FastRead',...
322  'backgroundcolor',GD.col.frame);
323tmp=get(fastread_tx,'position');
324fastread_popup = uicontrol('parent',uipanel_h,...
325  'units','pixel',...
326  'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
327  'style','popup',...
328  'backgroundcolor','w',...
329  'string',{'On','Off'},...
330  'value',val);
331
332%% Precision
333if strcmpi(Dat.Precision,'single')
334  val=1;
335else
336  val=2;
337end
338tmp=get(fastread_tx,'position');
339precision_tx = uicontrol('parent',uipanel_h,...
340  'units','pixel',...
341  'position',[10 tmp(2)-tmp(4)-5 tmp(3) 20],...
342  'style','text',...
343  'horizontalalign','left',...
344  'string','Precision',...
345  'backgroundcolor',GD.col.frame);
346tmp=get(precision_tx,'position');
347precision_popup = uicontrol('parent',uipanel_h,...
348  'units','pixel',...
349  'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
350  'style','popup',...
351  'backgroundcolor','w',...
352  'string',{'single','double'},...
353  'value',val);
354
355%% Default read function
356if Dat.VnmrUseOldReadFcn
357  val=1;
358else
359  val=2;
360end
361tmp=get(precision_tx,'position');
362readfcn_tx = uicontrol('parent',uipanel_h,...
363  'units','pixel',...
364  'position',[10 tmp(2)-tmp(4)-5 tmp(3) 20],...
365  'style','text',...
366  'horizontalalign','left',...
367  'string','Read Fcn',...
368  'backgroundcolor',GD.col.frame);
369tmp=get(readfcn_tx,'position');
370readfcn_popup = uicontrol('parent',uipanel_h,...
371  'units','pixel',...
372  'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
373  'style','popup',...
374  'backgroundcolor','w',...
375  'string',{'readfid (old)','readvnmr'},...
376  'value',val);
377
378
379%% Reorient images according to procpar.orient
380if strcmpi(Dat.OrientImages,'on')
381  val=1;
382else
383  val=0;
384end
385tmp=get(readfcn_tx,'position');
386orient_images_chbox = uicontrol('parent',uipanel_h,...
387  'units','pixel',...
388  'position',[10 tmp(2)-tmp(4)-5 240 20],...
389  'style','checkbox',...
390  'horizontalalign','left',...
391  'backgroundcolor',GD.col.frame,...
392  'string','Orient images using PROCPAR.orient',...
393  'value',val);
394
395%% Remove phase image frim EPI data
396if strcmpi(Dat.RemoveEPIphaseIm,'on')
397  val=1;
398else
399  val=0;
400end
401tmp=get(orient_images_chbox,'position');
402removeepiphaseim_chbox = uicontrol('parent',uipanel_h,...
403  'units','pixel',...
404  'position',[10 tmp(2)-tmp(4)-5 240 20],...
405  'style','checkbox',...
406  'horizontalalign','left',...
407  'backgroundcolor',GD.col.frame,...
408  'string','Remove phase image from EPI data',...
409  'value',val);
410
411% Store handles to a structure
412H.fh = fh;
413H.return_h = return_popup;
414H.dccorr_h = dc_popup;
415H.zeropadding_h = zeropadding_popup;
416H.sorting_h = sorting_popup;
417H.fastread_h = fastread_popup;
418H.precision_h = precision_popup;
419H.readfcn_h = readfcn_popup;
420H.orient_images_h = orient_images_chbox;
421H.removeepiphaseim_h = removeepiphaseim_chbox;
422set(ok_btn,'userdata',H)
423
424%%%%%%%%%%%%%%%%%%%%%%%%%%%%
425% OK button press callback
426%%%%%%%%%%%%%%%%%%%%%%%%%%%%
427function l_ChangePrefs(h,evd)
428
429H = get(h,'userdata');
430
431try
432% Get popup values
433return_val = get(H.return_h,'value');
434dccorr_val = get(H.dccorr_h,'value');
435zeropadding_val = get(H.zeropadding_h,'value');
436sorting_val = get(H.sorting_h,'value');
437fastread_val = get(H.fastread_h,'value');
438precision_val = get(H.precision_h,'value');
439readfcn_val = get(H.readfcn_h,'value');
440orient_images_val = get(H.orient_images_h,'value');
441removeepiphaseim_val = get(H.removeepiphaseim_h,'value');
442
443% Set preferences
444%% -------------------------------------------------------------------
445
446%% Return value
447setpref('Aedes','ReadfidReturn',return_val)
448
449%% DC correction
450if dccorr_val==1
451  setpref('Aedes','ReadfidDCcorrection',true)
452else
453  setpref('Aedes','ReadfidDCcorrection',false)
454end
455
456%% Zeropadding
457if zeropadding_val==1
458  setpref('Aedes','ReadfidZeropadding',1)
459elseif zeropadding_val==2
460  setpref('Aedes','ReadfidZeropadding',0)
461else
462  setpref('Aedes','ReadfidZeropadding',2)
463end
464
465%% Sorting
466if sorting_val==1
467  setpref('Aedes','ReadfidSorting',true)
468else
469  setpref('Aedes','ReadfidSorting',false)
470end
471
472%% FastRead
473if fastread_val==1
474  setpref('Aedes','ReadfidFastRead',true)
475else
476  setpref('Aedes','ReadfidFastRead',false)
477end
478
479%% Precision
480if precision_val==1
481  setpref('Aedes','ReadfidPrecision','single')
482else
483  setpref('Aedes','ReadfidPrecision','double')
484end
485
486%% Read fcn
487if readfcn_val==1
488  setpref('Aedes','VnmrUseOldReadFcn',true)
489else
490  setpref('Aedes','VnmrUseOldReadFcn',false)
491end
492
493%% Orient images
494if orient_images_val==1
495  setpref('Aedes','ReadfidOrientImages','on')
496else
497  setpref('Aedes','ReadfidOrientImages','off')
498end
499
500%% Remove phase image from EPI
501if removeepiphaseim_val==1
502  setpref('Aedes','ReadfidRemoveEPIphaseIm','on')
503else
504  setpref('Aedes','ReadfidRemoveEPIphaseIm','off')
505end
506
507catch
508  hh=errordlg('An error occurred! Could not save preferences.',...
509              'Could not save preferences','modal');
510end
511
512delete(H.fh)
Note: See TracBrowser for help on using the repository browser.

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