source: aedes_readfidprefs.m @ 151

Last change on this file since 151 was 138, checked in by tjniskan, 9 years ago
  • Added option to VNMR preferences to use the new version of the VNMR

read function

  • Added read support for certain CINE sequences
  • Added a command line preference option for inputting data aspect

ratio manually in created mosaic images

M aedes_readfidprefs.m
M aedes_data_read.m
M aedes_readvnmr.m
M aedes_export_gui.m
M aedes_revision.m
A vnmr_recon/cine_recon.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;
167scrsz = get(0,'screensize');
168fig_pos = [scrsz(3)/2-fig_w/2 scrsz(4)/2-fig_h/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            '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',...
191                    'fontweig','bold',...
192                                        'backgroundcolor',GD.col.frame);
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',...
222                      'position',[10 tmp(4)-50 100 20],...
223                      'style','text',...
224                      'horizontalalign','left',...
225                      'string','Returned data',...
226                                          'backgroundcolor',GD.col.frame,...
227                                          'fontsize',GD.text_fs);
228tmp=get(return_tx,'position');
229return_popup = uicontrol('parent',uipanel_h,...
230                         'units','pixel',...
231                         'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
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',...
246                  'position',[10 tmp(2)-tmp(4)-5 tmp(3) 20],...
247                  'style','text',...
248                  'horizontalalign','left',...
249                  'string','DC correction',...
250                                  'backgroundcolor',GD.col.frame);
251tmp=get(dc_tx,'position');
252dc_popup = uicontrol('parent',uipanel_h,...
253                     'units','pixel',...
254                     'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
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',...
271                           'position',[10 tmp(2)-tmp(4)-5 tmp(3) 20],...
272                           'style','text',...
273                           'horizontalalign','left',...
274                           'string','Zeropadding',...
275                                                   'backgroundcolor',GD.col.frame);
276tmp=get(zeropadding_tx,'position');
277zeropadding_popup = uicontrol('parent',uipanel_h,...
278                              'units','pixel',...
279                              'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
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',...
294                       'position',[10 tmp(2)-tmp(4)-5 tmp(3) 20],...
295                       'style','text',...
296                       'horizontalalign','left',...
297                       'string','Sorting',...
298                                           'backgroundcolor',GD.col.frame);
299tmp=get(sorting_tx,'position');
300sorting_popup = uicontrol('parent',uipanel_h,...
301                          'units','pixel',...
302                          'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
303                          'style','popup',...
304                          'backgroundcolor','w',...
305                          'string',{'On','Off'},...
306                          'value',val);
307%% Fast Read
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',...
316  'position',[10 tmp(2)-tmp(4)-5 tmp(3) 20],...
317  'style','text',...
318  'horizontalalign','left',...
319  'string','FastRead',...
320  'backgroundcolor',GD.col.frame);
321tmp=get(fastread_tx,'position');
322fastread_popup = uicontrol('parent',uipanel_h,...
323  'units','pixel',...
324  'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
325  'style','popup',...
326  'backgroundcolor','w',...
327  'string',{'On','Off'},...
328  'value',val);
329
330%% Precision
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);
352
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);
375
376
377%% Reorient images according to procpar.orient
378if strcmpi(Dat.OrientImages,'on')
379  val=1;
380else
381  val=0;
382end
383tmp=get(readfcn_tx,'position');
384orient_images_chbox = uicontrol('parent',uipanel_h,...
385  'units','pixel',...
386  'position',[10 tmp(2)-tmp(4)-5 240 20],...
387  'style','checkbox',...
388  'horizontalalign','left',...
389  'backgroundcolor',GD.col.frame,...
390  'string','Orient images using PROCPAR.orient',...
391  'value',val);
392
393%% Remove phase image frim EPI data
394if strcmpi(Dat.RemoveEPIphaseIm,'on')
395  val=1;
396else
397  val=0;
398end
399tmp=get(orient_images_chbox,'position');
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
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;
415H.fastread_h = fastread_popup;
416H.precision_h = precision_popup;
417H.readfcn_h = readfcn_popup;
418H.orient_images_h = orient_images_chbox;
419H.removeepiphaseim_h = removeepiphaseim_chbox;
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');
435fastread_val = get(H.fastread_h,'value');
436precision_val = get(H.precision_h,'value');
437readfcn_val = get(H.readfcn_h,'value');
438orient_images_val = get(H.orient_images_h,'value');
439removeepiphaseim_val = get(H.removeepiphaseim_h,'value');
440
441% Set preferences
442%% -------------------------------------------------------------------
443
444%% Return value
445setpref('Aedes','ReadfidReturn',return_val)
446
447%% DC correction
448if dccorr_val==1
449  setpref('Aedes','ReadfidDCcorrection',true)
450else
451  setpref('Aedes','ReadfidDCcorrection',false)
452end
453
454%% Zeropadding
455if zeropadding_val==1
456  setpref('Aedes','ReadfidZeropadding',1)
457elseif zeropadding_val==2
458  setpref('Aedes','ReadfidZeropadding',0)
459else
460  setpref('Aedes','ReadfidZeropadding',2)
461end
462
463%% Sorting
464if sorting_val==1
465  setpref('Aedes','ReadfidSorting',true)
466else
467  setpref('Aedes','ReadfidSorting',false)
468end
469
470%% FastRead
471if fastread_val==1
472  setpref('Aedes','ReadfidFastRead',true)
473else
474  setpref('Aedes','ReadfidFastRead',false)
475end
476
477%% Precision
478if precision_val==1
479  setpref('Aedes','ReadfidPrecision','single')
480else
481  setpref('Aedes','ReadfidPrecision','double')
482end
483
484%% Read fcn
485if readfcn_val==1
486  setpref('Aedes','VnmrUseOldReadFcn',true)
487else
488  setpref('Aedes','VnmrUseOldReadFcn',false)
489end
490
491%% Orient images
492if orient_images_val==1
493  setpref('Aedes','ReadfidOrientImages','on')
494else
495  setpref('Aedes','ReadfidOrientImages','off')
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
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