Browse code

searchlight ready. missing nifti-image-write support. added timing to FBS

git-svn-id: https://svn.discofish.de/MATLAB/spmtoolbox/SVMCrossVal@167 83ab2cfd-5345-466c-8aeb-2b2739fb922d

Christoph Budziszewski authored on30/03/2009 17:54:25
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,251 @@
1
+%  Return orientation of the current image:
2
+%	orient is orientation 1x3 matrix, in that:
3
+%	Three elements represent: [x y z]
4
+%	Element value:	1 - Left to Right; 2 - Posterior to Anterior;
5
+%			3 - Inferior to Superior; 4 - Right to Left;
6
+%			5 - Anterior to Posterior; 6 - Superior to Inferior;
7
+%  e.g.:
8
+%	Standard RAS Orientation:	[1 2 3]
9
+%	Standard RHOS Orientation:	[2 4 3]
10
+
11
+%  Jimmy Shen (jimmy@rotman-baycrest.on.ca), 26-APR-04
12
+%
13
+function orient = rri_orient_ui(varargin)
14
+
15
+   if nargin == 0
16
+      init;
17
+      orient_ui_fig = gcf;
18
+      uiwait;					% wait for user finish
19
+
20
+      orient = getappdata(gcf, 'orient');
21
+
22
+      if isempty(orient)
23
+         orient = [1 2 3];
24
+      end
25
+
26
+      if ishandle(orient_ui_fig)
27
+         close(gcf);
28
+      end
29
+
30
+      return;
31
+   end
32
+
33
+   action = varargin{1};
34
+
35
+   if strcmp(action, 'done')
36
+      click_done;
37
+   elseif strcmp(action, 'cancel')
38
+      uiresume;
39
+   end
40
+
41
+   return;						% rri_orient_ui
42
+
43
+
44
+%----------------------------------------------------------------------
45
+function init
46
+
47
+   save_setting_status = 'on';
48
+   rri_orient_pos = [];
49
+
50
+   try
51
+      load('pls_profile');
52
+   catch
53
+   end
54
+
55
+   try
56
+      load('rri_pos_profile');
57
+   catch
58
+   end
59
+
60
+   if ~isempty(rri_orient_pos) & strcmp(save_setting_status,'on')
61
+
62
+      pos = rri_orient_pos;
63
+
64
+   else
65
+
66
+      w = 0.35;
67
+      h = 0.4;
68
+      x = (1-w)/2;
69
+      y = (1-h)/2;
70
+
71
+      pos = [x y w h];
72
+
73
+   end
74
+
75
+   handles.figure = figure('Color',[0.8 0.8 0.8], ...
76
+        'Units','normal', ...
77
+        'Name', 'Convert to standard RAS orientation', ...
78
+        'NumberTitle','off', ...
79
+        'MenuBar','none', ...
80
+        'Position',pos, ...
81
+        'WindowStyle', 'normal', ...
82
+        'ToolBar','none');
83
+
84
+   h0 = handles.figure;
85
+   Font.FontUnits  = 'point';
86
+   Font.FontSize   = 12;
87
+
88
+   margin = .1;
89
+   line_num = 6;
90
+   line_ht = (1 - margin*2) / line_num;
91
+
92
+   x = margin;
93
+   y = 1 - margin - line_ht;
94
+   w = 1 - margin * 2;
95
+   h = line_ht * .7;
96
+
97
+   pos = [x y w h];
98
+
99
+   handles.Ttit = uicontrol('parent', h0, ...
100
+	'style','text', ...
101
+	'unit', 'normal', ...
102
+	Font, ...
103
+	'Position',pos, ...
104
+	'HorizontalAlignment','left',...
105
+	'background', [0.8 0.8 0.8], ...
106
+	'string', 'Please input orientation of the current image:');
107
+
108
+   y = y - line_ht;
109
+   w = .2;
110
+
111
+   pos = [x y w h];
112
+
113
+   handles.Tx_orient = uicontrol('parent', h0, ...
114
+	'style','text', ...
115
+	'unit', 'normal', ...
116
+	Font, ...
117
+	'Position',pos, ...
118
+	'HorizontalAlignment','left',...
119
+	'background', [0.8 0.8 0.8], ...
120
+	'string', 'X   Axes:');
121
+
122
+   y = y - line_ht;
123
+
124
+   pos = [x y w h];
125
+
126
+   handles.Ty_orient = uicontrol('parent', h0, ...
127
+	'style','text', ...
128
+	'unit', 'normal', ...
129
+	Font, ...
130
+	'Position',pos, ...
131
+	'HorizontalAlignment','left',...
132
+	'background', [0.8 0.8 0.8], ...
133
+	'string', 'Y   Axes:');
134
+
135
+   y = y - line_ht;
136
+
137
+   pos = [x y w h];
138
+
139
+   handles.Tz_orient = uicontrol('parent', h0, ...
140
+	'style','text', ...
141
+	'unit', 'normal', ...
142
+	Font, ...
143
+	'Position',pos, ...
144
+	'HorizontalAlignment','left',...
145
+	'background', [0.8 0.8 0.8], ...
146
+	'string', 'Z   Axes:');
147
+
148
+   choice = {	'From Left to Right', 'From Posterior to Anterior', ...
149
+		'From Inferior to Superior', 'From Right to Left', ...
150
+		'From Anterior to Posterior', 'From Superior to Inferior'	};
151
+
152
+   y = 1 - margin - line_ht;
153
+   y = y - line_ht;
154
+   w = 1 - margin - x - w;
155
+   x = 1 - margin - w;
156
+
157
+   pos = [x y w h];
158
+
159
+   handles.x_orient = uicontrol('parent', h0, ...
160
+	'style','popupmenu', ...
161
+	'unit', 'normal', ...
162
+	Font, ...
163
+	'Position',pos, ...
164
+	'HorizontalAlignment','left',...
165
+	'string', choice, ...
166
+	'value', 1, ...
167
+	'background', [1 1 1]);
168
+
169
+   y = y - line_ht;
170
+
171
+   pos = [x y w h];
172
+
173
+   handles.y_orient = uicontrol('parent', h0, ...
174
+	'style','popupmenu', ...
175
+	'unit', 'normal', ...
176
+	Font, ...
177
+	'Position',pos, ...
178
+	'HorizontalAlignment','left',...
179
+	'string', choice, ...
180
+	'value', 2, ...
181
+	'background', [1 1 1]);
182
+
183
+   y = y - line_ht;
184
+
185
+   pos = [x y w h];
186
+
187
+   handles.z_orient = uicontrol('parent', h0, ...
188
+	'style','popupmenu', ...
189
+	'unit', 'normal', ...
190
+	Font, ...
191
+	'Position',pos, ...
192
+	'HorizontalAlignment','left',...
193
+	'string', choice, ...
194
+	'value', 3, ...
195
+	'background', [1 1 1]);
196
+
197
+   x = margin;
198
+   y = y - line_ht * 1.5;
199
+   w = .3;
200
+
201
+   pos = [x y w h];
202
+
203
+   handles.done = uicontrol('parent', h0, ...
204
+	'unit', 'normal', ...
205
+	Font, ...
206
+	'Position',pos, ...
207
+	'HorizontalAlignment','center',...
208
+        'callback', 'rri_orient_ui(''done'');', ...
209
+	'string', 'Done');
210
+
211
+   x = 1 - margin - w;
212
+
213
+   pos = [x y w h];
214
+
215
+   handles.cancel = uicontrol('parent', h0, ...
216
+	'unit', 'normal', ...
217
+	Font, ...
218
+	'Position',pos, ...
219
+	'HorizontalAlignment','center',...
220
+        'callback', 'rri_orient_ui(''cancel'');', ...
221
+	'string', 'Cancel');
222
+
223
+   setappdata(h0, 'handles', handles);
224
+   setappdata(h0, 'orient', [1 2 3]);
225
+
226
+   return;						% init
227
+
228
+
229
+%----------------------------------------------------------------------
230
+function click_done
231
+
232
+   handles = getappdata(gcf, 'handles');
233
+
234
+   x_orient = get(handles.x_orient, 'value');
235
+   y_orient = get(handles.y_orient, 'value');
236
+   z_orient = get(handles.z_orient, 'value');
237
+
238
+   orient = [x_orient y_orient z_orient];
239
+   test_orient = [orient, orient + 3];
240
+   test_orient = mod(test_orient, 3);
241
+
242
+   if length(unique(test_orient)) ~= 3
243
+      msgbox('Please don''t choose same or opposite direction','Error','modal');
244
+      return;
245
+   end
246
+
247
+   setappdata(gcf, 'orient', [x_orient y_orient z_orient]);
248
+   uiresume;
249
+
250
+   return;						% click_done
251
+