source: aedes_readfidprefs.m @ 155

Last change on this file since 155 was 155, checked in by tjniskan, 8 years ago
  • Added support for multiple monitor systems

M aedes_inputdlg.m
M aedes_roi_copy_gui.m
A aedes_dialoglocation.m
M aedes_readfidprefs.m
M aedes_rotateflip.m
M aedes_resviewer.m
M aedes.m
M aedes_helpabout.m
M plugins/fat_analysis.m
M plugins/copy_data_to_workspace.m
M aedes_export_gui.m
M aedes_headerbrowser.m
M aedes_revision.m
M aedes_juigetfiles.m
M aedes_editstack.m

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

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