source: an2_readfidprefs.m @ 22

Last change on this file since 22 was 22, checked in by tjniskan, 12 years ago
  • Added fast data read option in an2_readfid. This is way much faster

than the traditional method but is also less robust. Although the fast
read option should be viewed as experimental, it should however work
with most of files. This option can be toggled from analyze2 menu ->
Tools -> Edit VNMR defaults.

  • Fixed a bug in an2_readprocpar that caused a buffer overflow in some

cases.

  • Fixed a bug in an2_read_nifti with big endian byteorder.

M analyze2.m
M an2_revision.m
M an2_readprocpar.m
M an2_read_nifti.m
M an2_data_read.m
M an2_readfid.m
M an2_readfidprefs.m
M an2_errordump.m
M an2_write_nifti.m

File size: 8.9 KB
Line 
1function an2_readfidprefs()
2% AN2_READFIDPREFS - GUI for editing preferences for AN2_READFID
3%   
4%
5% Synopsis:
6%
7% Description:
8%
9% Examples:
10%
11% See also:
12%
13
14% Juha-Pekka Niskanen - <Juha-Pekka.Niskanen@uku.fi>  -  23.10.2006
15% Department of Neurology, University of Kuopio
16%
17% Last modified - 27.06.2007 - (J-P N)
18
19done=false;
20msg='';
21
22
23Dat = [];
24
25%% Try to read defaults from preferences
26%% Get defaults for Return
27if ispref('Analyze2','ReadfidReturn')
28  if getpref('Analyze2','ReadfidReturn')==1
29    Dat.ReturnKSpace  = false;
30    Dat.ReturnFTData  = true;
31  elseif getpref('Analyze2','ReadfidReturn')==2
32      Dat.ReturnKSpace  = true;
33      Dat.ReturnFTData  = false;
34  elseif getpref('Analyze2','ReadfidReturn')==3
35    Dat.ReturnKSpace  = true;
36    Dat.ReturnFTData  = true;
37  else
38    Dat.ReturnKSpace  = false;
39    Dat.ReturnFTData  = true;
40  end
41else
42  Dat.ReturnKSpace  = false;
43  Dat.ReturnFTData  = true;
44  setpref('Analyze2','ReadfidReturn',1)
45end
46
47%% Get defaults for DC correction
48if ispref('Analyze2','ReadfidDCcorrection')
49  if getpref('Analyze2','ReadfidDCcorrection')
50    Dat.DCcorrection  = true;
51  else
52    Dat.DCcorrection  = false;
53  end
54else
55  Dat.DCcorrection  = false;
56  setpref('Analyze2','ReadfidDCcorrection',false)
57end
58
59%% Get defaults for Zeropadding
60if ispref('Analyze2','ReadfidZeropadding')
61  if getpref('Analyze2','ReadfidZeropadding')==0
62    Dat.ZeroPadding = 0;
63  elseif getpref('Analyze2','ReadfidZeropadding')==1
64    Dat.ZeroPadding = 1;
65  elseif getpref('Analyze2','ReadfidZeropadding')==2
66    Dat.ZeroPadding = 2;
67  else
68    Dat.ZeroPadding = 2;
69  end
70else
71  Dat.ZeroPadding = 2;
72  setpref('Analyze2','ReadfidZeropadding',2)
73end
74
75%% Get defaults for Sorting
76if ispref('Analyze2','ReadfidSorting')
77  if getpref('Analyze2','ReadfidSorting')
78    Dat.Sorting = true;
79  else
80    Dat.Sorting = false;
81  end
82else
83  Dat.Sorting = true;
84  setpref('Analyze2','ReadfidSorting',true)
85end
86
87%% Get defaults for FastRead
88if ispref('Analyze2','ReadfidFastRead')
89  if getpref('Analyze2','ReadfidFastRead')
90    Dat.FastDataRead = true;
91  else
92    Dat.FastDataRead = false;
93  end
94else
95  Dat.FastDataRead = true;
96  setpref('Analyze2','ReadfidFastRead',true)
97end
98
99
100
101%% Load default font and colors
102FigColor=get(0,'DefaultUicontrolBackgroundcolor');
103GD=an2_gui_defaults;
104GD.col.mainfig = FigColor;
105fig_h = 200;
106fig_w = 250;
107scrsz = get(0,'screensize');
108fig_pos = [scrsz(3)/2-fig_w/2 scrsz(4)/2-fig_h/2 fig_w fig_h];
109
110%% The main figure
111fh = figure('position',fig_pos,...
112            'Units','Pixel', ...
113            'Name','Edit VNMR preferences', ...
114            'Numbertitle','off', ...
115            'Tag','readfid_prefs', ...
116            'Color',FigColor, ...
117            'Toolbar','none', ...
118            'Menubar','none', ...
119            'DoubleBuffer','on', ...
120            'DockControls','off',...
121            'renderer','painters',...
122            'KeyPressFcn','',...
123            'resize','off',...
124            'windowstyle','normal');
125
126%% Main Uipanel
127uipanel_h = uipanel('parent',fh,...
128                    'Units','pixel',...
129                    'position',[5 40 fig_w-10 fig_h-45],...
130                    'title','Preferences for reading VNMR files',...
131                    'fontweig','bold');
132
133%% OK button
134ok_btn = uicontrol('parent',fh,...
135                   'units','pixel',...
136                   'position',[fig_w-170 5 80 30],...
137                   'string','OK',...
138                   'style','pushbutton',...
139                   'callback',@l_ChangePrefs);
140
141%% Cancel button
142tmp=get(ok_btn,'position');
143cancel_btn = uicontrol('parent',fh,...
144                       'units','pixel',...
145                       'position',[tmp(1)+tmp(3)+5 tmp(2:4)],...
146                       'string','Cancel',...
147                       'style','pushbutton',...
148                       'callback','delete(gcbf)');
149
150%% Returned data popup
151if Dat.ReturnKSpace==true & Dat.ReturnFTData==false
152  val=2;
153elseif Dat.ReturnKSpace==false & Dat.ReturnFTData==true
154  val=1;
155else
156  val=3;
157end
158tmp=get(uipanel_h,'position');
159return_tx = uicontrol('parent',uipanel_h,...
160                      'units','pixel',...
161                      'position',[10 tmp(4)-50 80 20],...
162                      'style','text',...
163                      'horizontalalign','left',...
164                      'string','Returned data');
165tmp=get(return_tx,'position');
166return_popup = uicontrol('parent',uipanel_h,...
167                         'units','pixel',...
168                         'position',[tmp(1)+tmp(3) tmp(2)+3 140 20],...
169                         'style','popup',...
170                         'backgroundcolor','w',...
171                         'string',{'FT-Data','K-Space','FT-Data and K-Space'},...
172                         'value',val);
173
174%% DC correction
175if Dat.DCcorrection
176  val=1;
177else
178  val=2;
179end
180tmp=get(return_tx,'position');
181dc_tx = uicontrol('parent',uipanel_h,...
182                  'units','pixel',...
183                  'position',[10 tmp(2)-tmp(4)-5 80 20],...
184                  'style','text',...
185                  'horizontalalign','left',...
186                  'string','DC correction');
187tmp=get(dc_tx,'position');
188dc_popup = uicontrol('parent',uipanel_h,...
189                     'units','pixel',...
190                     'position',[tmp(1)+tmp(3) tmp(2)+3 140 20],...
191                     'style','popup',...
192                     'backgroundcolor','w',...
193                     'string',{'On','Off'},...
194                     'value',val);
195
196%% Zeropadding
197if Dat.ZeroPadding==1
198  val=1;
199elseif Dat.ZeroPadding==0
200  val=2;
201elseif Dat.ZeroPadding==2
202  val=3;
203end
204tmp=get(dc_tx,'position');
205zeropadding_tx = uicontrol('parent',uipanel_h,...
206                           'units','pixel',...
207                           'position',[10 tmp(2)-tmp(4)-5 80 20],...
208                           'style','text',...
209                           'horizontalalign','left',...
210                           'string','Zeropadding');
211tmp=get(zeropadding_tx,'position');
212zeropadding_popup = uicontrol('parent',uipanel_h,...
213                              'units','pixel',...
214                              'position',[tmp(1)+tmp(3) tmp(2)+3 140 20],...
215                              'style','popup',...
216                              'backgroundcolor','w',...
217                              'string',{'On','Off','Auto'},...
218                              'value',val);
219
220%% Sorting
221if Dat.Sorting
222  val=1;
223else
224  val=2;
225end
226tmp=get(zeropadding_tx,'position');
227sorting_tx = uicontrol('parent',uipanel_h,...
228                       'units','pixel',...
229                       'position',[10 tmp(2)-tmp(4)-5 80 20],...
230                       'style','text',...
231                       'horizontalalign','left',...
232                       'string','Sorting');
233tmp=get(sorting_tx,'position');
234sorting_popup = uicontrol('parent',uipanel_h,...
235                          'units','pixel',...
236                          'position',[tmp(1)+tmp(3) tmp(2)+3 140 20],...
237                          'style','popup',...
238                          'backgroundcolor','w',...
239                          'string',{'On','Off'},...
240                          'value',val);
241% Fast Read
242if Dat.FastDataRead
243  val=1;
244else
245  val=2;
246end
247tmp=get(sorting_tx,'position');
248fastread_tx = uicontrol('parent',uipanel_h,...
249  'units','pixel',...
250  'position',[10 tmp(2)-tmp(4)-5 80 20],...
251  'style','text',...
252  'horizontalalign','left',...
253  'string','FastRead');
254tmp=get(fastread_tx,'position');
255fastread_popup = uicontrol('parent',uipanel_h,...
256  'units','pixel',...
257  'position',[tmp(1)+tmp(3) tmp(2)+3 140 20],...
258  'style','popup',...
259  'backgroundcolor','w',...
260  'string',{'On','Off'},...
261  'value',val);
262                                               
263% Store handles to a structure
264H.fh = fh;
265H.return_h = return_popup;
266H.dccorr_h = dc_popup;
267H.zeropadding_h = zeropadding_popup;
268H.sorting_h = sorting_popup;
269H.fastread_h = fastread_popup;
270
271set(ok_btn,'userdata',H)
272
273%%%%%%%%%%%%%%%%%%%%%%%%%%%%
274% OK button press callback
275%%%%%%%%%%%%%%%%%%%%%%%%%%%%
276function l_ChangePrefs(h,evd)
277
278H = get(h,'userdata');
279
280try
281% Get popup values
282return_val = get(H.return_h,'value');
283dccorr_val = get(H.dccorr_h,'value');
284zeropadding_val = get(H.zeropadding_h,'value');
285sorting_val = get(H.sorting_h,'value');
286fastread_val = get(H.fastread_h,'value');
287
288% Set preferences
289%% -------------------------------------------------------------------
290
291%% Return value
292setpref('Analyze2','ReadfidReturn',return_val)
293
294%% DC correction
295if dccorr_val==1
296  setpref('Analyze2','ReadfidDCcorrection',true)
297else
298  setpref('Analyze2','ReadfidDCcorrection',false)
299end
300
301%% Zeropadding
302if zeropadding_val==1
303  setpref('Analyze2','ReadfidZeropadding',1)
304elseif zeropadding_val==2
305  setpref('Analyze2','ReadfidZeropadding',0)
306else
307  setpref('Analyze2','ReadfidZeropadding',2)
308end
309
310%% Sorting
311if sorting_val==1
312  setpref('Analyze2','ReadfidSorting',true)
313else
314  setpref('Analyze2','ReadfidSorting',false)
315end
316
317%% FastRead
318if fastread_val==1
319  setpref('Analyze2','ReadfidFastRead',true)
320else
321  setpref('Analyze2','ReadfidFastRead',false)
322end
323
324catch
325  hh=errordlg('An error occurred! Could not save preferences.',...
326              'Could not save preferences','modal');
327end
328
329delete(H.fh)
Note: See TracBrowser for help on using the repository browser.

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