-
Notifications
You must be signed in to change notification settings - Fork 1
/
grocer_advance.m
216 lines (187 loc) · 8.88 KB
/
grocer_advance.m
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
function grocer_advance
clc
warning off all
a=which('fmri_grocer');
[a,b,c,d]=FG_fileparts(a);
addpath(genpath(a));
% fmri_grocer version
FGver = ' x.x'; % SPM8-based
FGaut ='Senhua Zhu';
% welcome~~
fprintf('\n');
fprintf( ' >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n');
fprintf( ' >>>> Welcome to utilize Grocer toolbox V%s (SPM5/8 based) <<<<\n',FGver);
fprintf( ' >>>> By Senhua Zhu, @CFN, UPenn Med. 09/2011 <<<<\n');
fprintf( ' >>>> QQ group #: 60524357 <<<<\n');
fprintf([' >>>> ....... http://www.fil.ion.ucl.ac.uk/spm/ext/#Grocer ........ <<<<\n']);
fprintf([' >>>> < You have installed ',spm('Ver'),' > <<<<\n']);
fprintf( '<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n');
%%
% only allow one instance of this toolbox
hdl=findobj('Tag','fmri_grocer');
if ~isempty(hdl)
close (hdl)
clear hdl
end
%-Open startup window, set window defaults
%-Get size and scalings and create Menu window
S = get(0,'ScreenSize');
if all(S==1), error('Can''t open any graphics windows...'), end
[WS FS PF Rect bno bgapr bh gh by bx bw]=Exec_getwinDef;
%-Draw fmri_grocer window
Fig_handle = figure( ...
'IntegerHandle','off',...
'Name',['fMRI Grocer Version' FGver],...
'NumberTitle','off',...
'Tag','fmri_grocer',...
'Position',Rect.*WS,...
'Resize','off',...
'Color',[1 1 1]*.6,...
'UserData',struct('FGver',FGver,'FGaut',FGaut),...
'MenuBar','none',...
'DefaultTextFontName',PF.helvetica,...
'DefaultTextFontSize',FS(6),...
'DefaultUicontrolFontName',PF.times,...
'DefaultUicontrolFontSize',FS(11),...
'DefaultUicontrolInterruptible','on',...
'Renderer','painters',...
'Visible','off' ...
);
%- Setting up PopUp menus functions and lists for "Callback"
%=======================================================================
line_n=1;
% menu 10
FGabout={
'FG_ica_easy_mode',...
'FG_ica_artifact_control_scripts2',...
'FG_ICA_spatially_sort_ICs',...
'FG_ICA_CBF_overlay_separation',...
'FG_create_Expt_def_for_Structural_ASCII_Probid',...
'FG_create_Expt_def_for_BOLD_ASL_Probid',...
'FG_copy_out_delete_in_for_DTI_PANDA',...
'edit FG_copy_out_delete_in_for_DTI_PANDA',...
'grocer'
};
about_L=[
['*** Advanced functions ***'],...
'| Run ICA in an easy mode',...
'| Run ICA fat-artifact detection script',...
'| Spatially sort ICs with templates',...
'| CBF% based on G/W-matter separation of ICA-networks',...
'| Create Expt_def for Structural & ASCII Probid',...
'| Create Expt_def for BOLD & ASL Probid',...
'| Copy/Move out files for PANDA-based DTI results',...
'| --- Edit FG_copy_out_delete_in_for_DTI_PANDA',...
'| ==== fMRI-Grocer ====',...
];
%% now setting up the PopUp menu in the Figure.
%=======================================================================
%=======================================================================
% menu 10
uicontrol(Fig_handle,'Style','PopUp',...
'String',about_L,...
'Position',[bx by(5) bw bh].*WS,...
'ToolTipString','SPM8 related batch works...',...
'CallBack','spm(''PopUpCB'',gcbo)',...
'UserData',FGabout);
%=setting up some buttons =
%=======================================================================
% button 11 == standby button
uicontrol(gcf,'String','Panel standby',...
'Position',[bx+20 by(10)*0.68 bw*0.4 bh*0.6].*WS,...
'ToolTipString','small this panel and set it on top',...
'ForeGroundColor',[0.8 0.3 0],...
'FontSize',FS(10),...
'FontWeight','BOLD',...
'Tag','standby_b',...
'Interruptible','off',...
'CallBack',@Exec_standby); % be careful: "@" means Function handle.
%=======================================================================
% button 12 == recover button
uicontrol(gcf,'String','Panel recover',...
'Position',[bx+20 by(11)*0.6+2 bw*0.4 bh*0.6].*WS,...
'ToolTipString','recover this panel',...
'ForeGroundColor',[0.5 0.2 0],...
'FontWeight','BOLD',...
'FontSize',FS(10),...
'Interruptible','off',...
'CallBack',@Exec_recover);
%=======================================================================
% button 21 == Run all jobs button
uicontrol(gcf,'String','Run selected jobs',...
'Position',[bx+bw*0.6-20 by(10)*0.68 bw*0.4 bh*0.6].*WS,...
'ToolTipString','Select jobs & Run them',...
'ForeGroundColor','r',...
'FontWeight','BOLD',...
'FontSize',FS(10),...
'Tag','run_b',...
'Interruptible','off',...
'CallBack','FG_run_all_jobs');
%=======================================================================
% button 22 == quit button
uicontrol(gcf,'String','Exit',...
'Position',[bx+bw*0.6-20 by(11)*0.6+2 bw*0.4 bh*0.6].*WS,...
'ToolTipString','exit the fmri_grocer',...
'ForeGroundColor','b',...
'FontSize',FS(12),...
'FontWeight','BOLD',...
'Interruptible','off',...
'CallBack',@Exit_goodbye);
%=======================================================================
% after drawing the figure, set it into visible and on top
set(Fig_handle,'Visible','on')
% FG_setAlwaysOnTop(gcf,1);
%--------------------------------------
%======= subfunctions ==========
%--------------------------------------
function [WS FS PF Rect bno bgapr bh gh by bx bw]=Exec_getwinDef
WS = spm('WinScale'); %-Window scaling factors
FS = spm('FontSizes'); %-Scaled font sizes
PF = spm_platform('fonts'); %-Font names (for this platform)
screenxy=get(0,'ScreenSize'); % four element:screenxy ==>[left, bottom, width, height]
Rect = [1/4*screenxy(3) 290 400 475];
% Rect = [1/4*screenxy(3) 1/5*screenxy(4) 1/4*screenxy(3) 1/2.3*screenxy(4)]; %-Raw size menu window; rect = [left, bottom, width, height]
bno = 11; bgno = bno+1; % bno= button num, bgno=button_gap num
bgapr = 0.10; % button gap ratio
bh = Rect(4) / (bno + bgno*bgapr); % Button height
gh = bh * bgapr; % Button gap height
by = fliplr(cumsum([0 ones(1, bno-1)*(bh+gh)])+gh);
bx = Rect(3)*0.02;
bw = Rect(3)*0.96;
function Exec_standby(hObject,eventdata) % "hObject" is the handle of the [callback] object, "eventdata" (see next function)
[WS FS PF Rect bno bgapr bh gh by bx bw]=Exec_getwinDef;
%Fig_handle=findobj('Tag','fmri_grocer');
set(gcf,'Position',[0 0 Rect(3)*WS(3) bh*0.5+10]);
h_std=findobj('Tag','standby_b');
h_run=findobj('Tag','run_b');
set(h_std,'Visible','off');
set(h_run,'Visible','off');
FG_setAlwaysOnTop(gcf,1);
function Exec_recover(hObject,eventdata) % while "eventdata" is just an unused variable for the function handle purpose
[WS FS PF Rect bno bgapr bh gh by bx bw]=Exec_getwinDef;
%Fig_handle=findobj('Tag','fmri_grocer');
set(gcf,'Resize','off');
set(gcf,'Position',Rect.*WS);
h_std=findobj('Tag','standby_b');
h_run=findobj('Tag','run_b');
set(h_std,'Visible','on');
set(h_run,'Visible','on');
FG_setAlwaysOnTop(gcf,0);
function Exit_goodbye(hObject,eventdata)
FGver = 'x.x';
close;clc;
fprintf('\n')
fprintf( '\n----------------------------------------------------- V%s --------------------------------------\n',FGver)
fprintf( '-------------00000000000----------------------- QQ group #: 60524357 ------------------------------\n')
fprintf( '----------000000000000000------------------- ^_^ Have a good one ^_^ ----------------------------\n')
fprintf( '---------000000----000000--------------------------------------------------------------------------\n')
fprintf( '-------0000000 00000---00000000-------0000000------00000000-----00000000------0000000----------\n')
fprintf( '-------00000 000000000000 00000000000 00000000000 000000000000 000000000000-------\n')
fprintf( '------00000 00000000000 0000 000 0000 000 0000 0000 00000000000--------\n')
fprintf( '------00000 0000000 000000 0000 000 0000 00000000000000 000000 ----------\n')
fprintf( '----- 00000 000000 00000 0000 000 0000 0000000000000 00000--------------\n')
fprintf( '------00000 00000 000000 0000 0000 0000 0000 00000--------------\n')
fprintf( '------00000 00000 0000000 0000 0000 0000 000 00000 000 000000--------------\n')
fprintf( '-------000000000000----000000000------00000000000----000000000---0000000000---00000000-------------\n')
fprintf( '--------000000000------000000000-------0000000--------0000000------000000-----00000000-------------\n')
fprintf( '---------------------------------------------------------------------------------------------------\n');