-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathaedes_rotateflip.m
More file actions
310 lines (273 loc) · 9.08 KB
/
aedes_rotateflip.m
File metadata and controls
310 lines (273 loc) · 9.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
function Out = aedes_rotateflip(DATA,squareImages)
% AEDES_ROTATEFLIP - GUI for rotating and flipping files
%
%
% Synopsis:
%
% Description:
%
% Examples:
%
% See also:
%
% This function is a part of Aedes - A graphical tool for analyzing
% medical images
%
% Copyright (C) 2006 Juha-Pekka Niskanen <Juha-Pekka.Niskanen@uku.fi>
%
% Department of Physics, Department of Neurobiology
% University of Kuopio, FINLAND
%
% This program may be used under the terms of the GNU General Public
% License version 2.0 as published by the Free Software Foundation
% and appearing in the file LICENSE.TXT included in the packaging of
% this program.
%
% This program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
% WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
% Public variables
H = [];
Out = [];
Dat = [];
cancel = true;
% Get file names and paths
for ii=1:length(DATA)
Dat.fnames{ii} = DATA{ii}.HDR.fname;
Dat.fpaths{ii} = DATA{ii}.HDR.fpath;
Dat.fullfiles{ii} = [DATA{ii}.HDR.fpath,...
DATA{ii}.HDR.fname];
end
H = l_DrawGUI;
% Wait for quit
waitfor(H.FH)
if cancel
clear H Dat cancel
return
end
function H=l_DrawGUI()
%% Load default font and colors
%FigColor=get(0,'DefaultUicontrolBackgroundcolor');
GD=aedes_gui_defaults;
%GD.col.mainfig = FigColor;
fig_h = 305;
fig_w = 500;
fig_location = aedes_dialoglocation([fig_w,fig_h]);
fig_pos = [fig_location(1) fig_location(2) fig_w fig_h];
%% The main figure
H.FH = figure('position',fig_pos,...
'Units','Pixel', ...
'Name','Rotate/Flip images', ...
'Numbertitle','off', ...
'Tag','im_rotate_gui', ...
'Color',GD.col.mainfig, ...
'Toolbar','none', ...
'Menubar','none', ...
'DoubleBuffer','on', ...
'DockControls','off',...
'renderer','painters',...
'KeyPressFcn','',...
'resize','off',...
'windowstyle','modal');
% Options uipanel
H.OPTUIPANEL = uipanel('parent',H.FH,...
'units','pixel',...
'backgroundcolor',GD.col.mainfig, ...
'position',[5 40 fig_w-10 fig_h-45]);
% Rotation uipanel
H.ROTUIGRP = uibuttongroup('parent',H.OPTUIPANEL,...
'units','pixel',...
'position',[10 135 110 105],...
'title','Rotation (CCW)',...
'backgroundcolor',GD.col.mainfig, ...
'SelectionChangeFcn',@l_SelectionChanged);
% Rotation Radio buttons
H.ROTNONE=uicontrol('parent',H.ROTUIGRP,...
'units','pixel',...
'style','radio',...
'position',[20 70 80 15],...
'backgroundcolor',GD.col.mainfig, ...
'string','none',...
'value',1);
tmp=get(H.ROTNONE,'position');
H.ROT90=uicontrol('parent',H.ROTUIGRP,...
'units','pixel',...
'style','radio',...
'position',[tmp(1) tmp(2)-20 tmp(3) tmp(4)],...
'string',['90',char(186)],...
'backgroundcolor',GD.col.mainfig, ...
'value',0);
tmp=get(H.ROT90,'position');
H.ROT180=uicontrol('parent',H.ROTUIGRP,...
'units','pixel',...
'style','radio',...
'position',[tmp(1) tmp(2)-20 tmp(3) tmp(4)],...
'string',['180',char(186)],...
'backgroundcolor',GD.col.mainfig, ...
'value',0);
tmp=get(H.ROT180,'position');
H.ROT270=uicontrol('parent',H.ROTUIGRP,...
'units','pixel',...
'style','radio',...
'position',[tmp(1) tmp(2)-20 tmp(3) tmp(4)],...
'string',['270',char(186)],...
'backgroundcolor',GD.col.mainfig, ...
'value',0);
if ~squareImages
set([H.ROT90,H.ROT270],'enable','off')
end
% Flip uipanel
tmp = get(H.ROTUIGRP,'position');
H.FLIPUIGRP = uibuttongroup('parent',H.OPTUIPANEL,...
'units','pixel',...
'position',[tmp(1) tmp(2)-85-15 tmp(3) 85],...
'title','Flipping',...
'backgroundcolor',GD.col.mainfig, ...
'SelectionChangeFcn',@l_SelectionChanged);
% Flipping radio buttons
H.FLIPNONE=uicontrol('parent',H.FLIPUIGRP,...
'units','pixel',...
'style','radio',...
'position',[20 50 80 15],...
'backgroundcolor',GD.col.mainfig, ...
'string','none',...
'value',1);
tmp=get(H.FLIPNONE,'position');
H.FLIPUD=uicontrol('parent',H.FLIPUIGRP,...
'units','pixel',...
'style','radio',...
'position',[tmp(1) tmp(2)-20 tmp(3) tmp(4)],...
'string','Up/Down',...
'backgroundcolor',GD.col.mainfig, ...
'value',0);
tmp=get(H.FLIPUD,'position');
H.FLIPLR=uicontrol('parent',H.FLIPUIGRP,...
'units','pixel',...
'style','radio',...
'position',[tmp(1) tmp(2)-20 tmp(3) tmp(4)],...
'string','Left/Right',...
'backgroundcolor',GD.col.mainfig, ...
'value',0);
% File listbox
tmp = get(H.FLIPUIGRP,'position');
H.FILELBOX = uicontrol('parent',H.OPTUIPANEL,...
'units','pixel',...
'style','listbox',...
'position',[tmp(1)+tmp(3)+10 tmp(2) fig_w-tmp(1)-tmp(3)-35 ...
200],...
'backgroundcolor','w',...
'string',Dat.fullfiles,...
'Min',0,'Max',2);
tmp = get(H.FILELBOX,'position');
files_tx = uicontrol('parent',H.OPTUIPANEL,...
'units','pixel',...
'style','text',...
'position',[tmp(1) tmp(2)+tmp(4) 150 12],...
'string','Files (slices)',...
'horizontalalign','left',...
'backgroundcolor',GD.col.mainfig, ...
'fontweig','bold');
% Select all and select none buttons
tmp = get(H.FILELBOX,'position');
H.SELALL = uicontrol('parent',H.OPTUIPANEL,...
'units','pixel',...
'style','pushbutton',...
'position',[tmp(1) tmp(2)-25-5 tmp(3)/2-5 25],...
'string','Select All',...
'callback',@l_SelectAll);
tmp = get(H.SELALL,'position');
H.SELNONE = uicontrol('parent',H.OPTUIPANEL,...
'units','pixel',...
'style','pushbutton',...
'position',[tmp(1)+tmp(3)+10 tmp(2) tmp(3) 25],...
'string','Select None',...
'userdata',H.FILELBOX,...
'callback','set(get(gcbo,''userdata''),''value'',[])');
% OK button
H.OKBTN = uicontrol('parent',H.FH,...
'units','pixel',...
'position',[350 5 70 30],...
'string','OK',...
'callback',@l_OKCallBack);
% Cancel button
tmp = get(H.OKBTN,'position');
H.CANCELTN = uicontrol('parent',H.FH,...
'units','pixel',...
'position',[tmp(1)+tmp(3)+5 tmp(2) tmp(3) tmp(4)],...
'string','Cancel',...
'callback','delete(gcbf)');
end % function l_DrawGUI()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Select All Files
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function l_SelectAll(h,evd)
lbox_length = length(get(H.FILELBOX,'string'));
set(H.FILELBOX,'value',1:lbox_length);
end % function l_SelectAll(h,
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Selection Changed
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function l_SelectionChanged(h,evd)
if h==H.ROTUIGRP
if evd.NewValue==H.ROTNONE
set([H.FLIPNONE,H.FLIPUD,H.FLIPLR],'enable','on')
else
set([H.FLIPNONE,H.FLIPUD,H.FLIPLR],'enable','off')
end
elseif h==H.FLIPUIGRP
if evd.NewValue==H.FLIPNONE
if ~squareImages
set([H.ROTNONE,H.ROT180],'enable','on')
else
set([H.ROTNONE,H.ROT90,H.ROT180,H.ROT270],'enable','on')
end
else
set([H.ROTNONE,H.ROT90,H.ROT180,H.ROT270],'enable','off')
end
end
end % function
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% OK Selected
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function l_OKCallBack(h,evd)
cancel = false;
val = get(H.FILELBOX,'value');
str = get(H.FILELBOX,'string');
RotSelObject = get(H.ROTUIGRP,'SelectedObject');
FlipSelObject = get(H.FLIPUIGRP,'SelectedObject');
%% Flipping vector:
%% 0 = none
%% 1 = Up/Down
%% 2 = Left/Right
Out.Flip = zeros(1,length(str));
if ~isempty(val)
if FlipSelObject==H.FLIPUD
Out.Flip(val)=1;
elseif FlipSelObject==H.FLIPLR
Out.Flip(val)=2;
end
end
%% Rotate vector
%% 0 = none
%% 1 = 90
%% 2 = 180
%% 3 = 270
Out.Rotate = zeros(1,length(str));
if ~isempty(val)
if RotSelObject==H.ROT90
Out.Rotate(val)=1;
elseif RotSelObject==H.ROT180
Out.Rotate(val)=2;
elseif RotSelObject==H.ROT270
Out.Rotate(val)=3;
end
end
%% Delete figure window
delete(H.FH)
end % function l_OKCallBack(h,
end