source: an2_readfidprefs.m @ 73

Last change on this file since 73 was 67, checked in by tjniskan, 11 years ago
  • Added new options for reading VNMR EPI and RASER data. It is now

possible to automatically reorient EPI and RASER data and remove the
phase image from EPI data. These options can be changed from
Tools->Edit VNMR defaults.

  • Added a possibility to change the overlay parameters when calling

Aedes from the command line and changed the basic_fmri_analysis plugin
accordingly.

  • The "Voxel time-series" figure is now in "Always-on-top" mode.

M misclib/fmri_analysis.m
M an2_revision.m
M an2_data_read.m
M aedes.m
M plugins/basic_fmri_analysis.m
M an2_readfid.m
M an2_readfidprefs.m

File size: 12.5 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',false)
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',2)
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',true)
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 = false;
110  setpref('Aedes','ReadfidFastRead',false)
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 = 'double';
122  setpref('Aedes','ReadfidPrecision','double')
123end
124
125%% Get defaults for Reorienting EPI images
126if ispref('Aedes','ReadfidReorientEPI')
127  Dat.ReorientEPI = getpref('Aedes','ReadfidReorientEPI');
128else
129  Dat.ReorientEPI = 'off';
130  setpref('Aedes','ReadfidReorientEPI','off')
131end
132
133%% Get defaults for Removing phase image from EPI data
134if ispref('Aedes','ReadfidRemoveEPIphaseIm')
135  Dat.RemoveEPIphaseIm = getpref('Aedes','ReadfidRemoveEPIphaseIm');
136else
137  Dat.RemoveEPIphaseIm = 'off';
138  setpref('Aedes','ReadfidRemoveEPIphaseIm','off')
139end
140
141%% Load default font and colors
142%FigColor=get(0,'DefaultUicontrolBackgroundcolor');
143GD=an2_gui_defaults;
144%GD.col.mainfig = FigColor;
145fig_h = 280;
146fig_w = 270;
147scrsz = get(0,'screensize');
148fig_pos = [scrsz(3)/2-fig_w/2 scrsz(4)/2-fig_h/2 fig_w fig_h];
149
150%% The main figure
151fh = figure('position',fig_pos,...
152            'Units','Pixel', ...
153            'Name','Edit VNMR preferences', ...
154            'Numbertitle','off', ...
155            'Tag','readfid_prefs', ...
156            'Color',GD.col.mainfig, ...
157            'Toolbar','none', ...
158            'Menubar','none', ...
159            'DoubleBuffer','on', ...
160            'DockControls','off',...
161            'renderer','painters',...
162            'KeyPressFcn','',...
163            'resize','off',...
164            'windowstyle','normal');
165
166%% Main Uipanel
167uipanel_h = uipanel('parent',fh,...
168                    'Units','pixel',...
169                    'position',[5 40 fig_w-10 fig_h-45],...
170                    'title','Preferences for reading VNMR files',...
171                    'fontweig','bold',...
172                                        'backgroundcolor',GD.col.frame);
173
174%% OK button
175ok_btn = uicontrol('parent',fh,...
176                   'units','pixel',...
177                   'position',[fig_w-170 5 80 30],...
178                   'string','OK',...
179                   'style','pushbutton',...
180                   'callback',@l_ChangePrefs);
181
182%% Cancel button
183tmp=get(ok_btn,'position');
184cancel_btn = uicontrol('parent',fh,...
185                       'units','pixel',...
186                       'position',[tmp(1)+tmp(3)+5 tmp(2:4)],...
187                       'string','Cancel',...
188                       'style','pushbutton',...
189                       'callback','delete(gcbf)');
190
191%% Returned data popup
192if Dat.ReturnKSpace==true & Dat.ReturnFTData==false
193  val=2;
194elseif Dat.ReturnKSpace==false & Dat.ReturnFTData==true
195  val=1;
196else
197  val=3;
198end
199tmp=get(uipanel_h,'position');
200return_tx = uicontrol('parent',uipanel_h,...
201                      'units','pixel',...
202                      'position',[10 tmp(4)-50 100 20],...
203                      'style','text',...
204                      'horizontalalign','left',...
205                      'string','Returned data',...
206                                          'backgroundcolor',GD.col.frame,...
207                                          'fontsize',GD.text_fs);
208tmp=get(return_tx,'position');
209return_popup = uicontrol('parent',uipanel_h,...
210                         'units','pixel',...
211                         'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
212                         'style','popup',...
213                         'backgroundcolor','w',...
214                         'string',{'FT-Data','K-Space','FT-Data and K-Space'},...
215                         'value',val);
216
217%% DC correction
218if Dat.DCcorrection
219  val=1;
220else
221  val=2;
222end
223tmp=get(return_tx,'position');
224dc_tx = uicontrol('parent',uipanel_h,...
225                  'units','pixel',...
226                  'position',[10 tmp(2)-tmp(4)-5 tmp(3) 20],...
227                  'style','text',...
228                  'horizontalalign','left',...
229                  'string','DC correction',...
230                                  'backgroundcolor',GD.col.frame);
231tmp=get(dc_tx,'position');
232dc_popup = uicontrol('parent',uipanel_h,...
233                     'units','pixel',...
234                     'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
235                     'style','popup',...
236                     'backgroundcolor','w',...
237                     'string',{'On','Off'},...
238                     'value',val);
239
240%% Zeropadding
241if Dat.ZeroPadding==1
242  val=1;
243elseif Dat.ZeroPadding==0
244  val=2;
245elseif Dat.ZeroPadding==2
246  val=3;
247end
248tmp=get(dc_tx,'position');
249zeropadding_tx = uicontrol('parent',uipanel_h,...
250                           'units','pixel',...
251                           'position',[10 tmp(2)-tmp(4)-5 tmp(3) 20],...
252                           'style','text',...
253                           'horizontalalign','left',...
254                           'string','Zeropadding',...
255                                                   'backgroundcolor',GD.col.frame);
256tmp=get(zeropadding_tx,'position');
257zeropadding_popup = uicontrol('parent',uipanel_h,...
258                              'units','pixel',...
259                              'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
260                              'style','popup',...
261                              'backgroundcolor','w',...
262                              'string',{'On','Off','Auto'},...
263                              'value',val);
264
265%% Sorting
266if Dat.Sorting
267  val=1;
268else
269  val=2;
270end
271tmp=get(zeropadding_tx,'position');
272sorting_tx = uicontrol('parent',uipanel_h,...
273                       'units','pixel',...
274                       'position',[10 tmp(2)-tmp(4)-5 tmp(3) 20],...
275                       'style','text',...
276                       'horizontalalign','left',...
277                       'string','Sorting',...
278                                           'backgroundcolor',GD.col.frame);
279tmp=get(sorting_tx,'position');
280sorting_popup = uicontrol('parent',uipanel_h,...
281                          'units','pixel',...
282                          'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
283                          'style','popup',...
284                          'backgroundcolor','w',...
285                          'string',{'On','Off'},...
286                          'value',val);
287%% Fast Read
288if Dat.FastDataRead
289  val=1;
290else
291  val=2;
292end
293tmp=get(sorting_tx,'position');
294fastread_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','FastRead',...
300  'backgroundcolor',GD.col.frame);
301tmp=get(fastread_tx,'position');
302fastread_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
310%% Precision
311if strcmpi(Dat.Precision,'single')
312  val=1;
313else
314  val=2;
315end
316tmp=get(fastread_tx,'position');
317precision_tx = uicontrol('parent',uipanel_h,...
318  'units','pixel',...
319  'position',[10 tmp(2)-tmp(4)-5 tmp(3) 20],...
320  'style','text',...
321  'horizontalalign','left',...
322  'string','Precision',...
323  'backgroundcolor',GD.col.frame);
324tmp=get(precision_tx,'position');
325precision_popup = uicontrol('parent',uipanel_h,...
326  'units','pixel',...
327  'position',[tmp(1)+tmp(3)+1 tmp(2)+3 140 20],...
328  'style','popup',...
329  'backgroundcolor','w',...
330  'string',{'single','double'},...
331  'value',val);
332
333%% Reorient EPI images
334if strcmpi(Dat.ReorientEPI,'on')
335  val=1;
336else
337  val=0;
338end
339tmp=get(precision_tx,'position');
340reorient_epi_chbox = uicontrol('parent',uipanel_h,...
341  'units','pixel',...
342  'position',[10 tmp(2)-tmp(4)-5 240 20],...
343  'style','checkbox',...
344  'horizontalalign','left',...
345  'backgroundcolor',GD.col.frame,...
346  'string','Reorient EPI/RASER data',...
347  'value',val);
348
349%% Remove phase image frim EPI data
350if strcmpi(Dat.RemoveEPIphaseIm,'on')
351  val=1;
352else
353  val=0;
354end
355tmp=get(reorient_epi_chbox,'position');
356removeepiphaseim_chbox = uicontrol('parent',uipanel_h,...
357  'units','pixel',...
358  'position',[10 tmp(2)-tmp(4)-5 240 20],...
359  'style','checkbox',...
360  'horizontalalign','left',...
361  'backgroundcolor',GD.col.frame,...
362  'string','Remove phase image from EPI data',...
363  'value',val);
364
365% Store handles to a structure
366H.fh = fh;
367H.return_h = return_popup;
368H.dccorr_h = dc_popup;
369H.zeropadding_h = zeropadding_popup;
370H.sorting_h = sorting_popup;
371H.fastread_h = fastread_popup;
372H.precision_h = precision_popup;
373H.reorient_epi_h = reorient_epi_chbox;
374H.removeepiphaseim_h = removeepiphaseim_chbox;
375
376set(ok_btn,'userdata',H)
377
378%%%%%%%%%%%%%%%%%%%%%%%%%%%%
379% OK button press callback
380%%%%%%%%%%%%%%%%%%%%%%%%%%%%
381function l_ChangePrefs(h,evd)
382
383H = get(h,'userdata');
384
385try
386% Get popup values
387return_val = get(H.return_h,'value');
388dccorr_val = get(H.dccorr_h,'value');
389zeropadding_val = get(H.zeropadding_h,'value');
390sorting_val = get(H.sorting_h,'value');
391fastread_val = get(H.fastread_h,'value');
392precision_val = get(H.precision_h,'value');
393reorientepi_val = get(H.reorient_epi_h,'value');
394removeepiphaseim_val = get(H.removeepiphaseim_h,'value');
395
396% Set preferences
397%% -------------------------------------------------------------------
398
399%% Return value
400setpref('Aedes','ReadfidReturn',return_val)
401
402%% DC correction
403if dccorr_val==1
404  setpref('Aedes','ReadfidDCcorrection',true)
405else
406  setpref('Aedes','ReadfidDCcorrection',false)
407end
408
409%% Zeropadding
410if zeropadding_val==1
411  setpref('Aedes','ReadfidZeropadding',1)
412elseif zeropadding_val==2
413  setpref('Aedes','ReadfidZeropadding',0)
414else
415  setpref('Aedes','ReadfidZeropadding',2)
416end
417
418%% Sorting
419if sorting_val==1
420  setpref('Aedes','ReadfidSorting',true)
421else
422  setpref('Aedes','ReadfidSorting',false)
423end
424
425%% FastRead
426if fastread_val==1
427  setpref('Aedes','ReadfidFastRead',true)
428else
429  setpref('Aedes','ReadfidFastRead',false)
430end
431
432%% Precision
433if precision_val==1
434  setpref('Aedes','ReadfidPrecision','single')
435else
436  setpref('Aedes','ReadfidPrecision','double')
437end
438
439%% Reorient EPI images
440if reorientepi_val==1
441  setpref('Aedes','ReadfidReorientEPI','on')
442else
443  setpref('Aedes','ReadfidReorientEPI','off')
444end
445
446%% Remove phase image from EPI
447if removeepiphaseim_val==1
448  setpref('Aedes','ReadfidRemoveEPIphaseIm','on')
449else
450  setpref('Aedes','ReadfidRemoveEPIphaseIm','off')
451end
452
453catch
454  hh=errordlg('An error occurred! Could not save preferences.',...
455              'Could not save preferences','modal');
456end
457
458delete(H.fh)
Note: See TracBrowser for help on using the repository browser.

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