-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathspm_Menu.m
159 lines (141 loc) · 5.82 KB
/
spm_Menu.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
function Fmenu = spm_Menu(action, varargin)
% SPM Menu window
% FORMAT Fmenu = spm_Menu('Create',Vis)
% Create the SPM Menu window (tag property set to 'Menu')
% Vis - visibility: {'on'} or 'off'
% Fmenu - handle of figure created
%
% FORMAT Fmenu = spm_Menu('Switch',Modality)
% Switch the SPM Menu window to the specified modality
%
% FORMAT spm_Menu('Close')
% Close the SPM Menu window
%__________________________________________________________________________
% Copyright (C) 2018-2019 Wellcome Trust Centre for Neuroimaging
% Guillaume Flandin
% $Id: spm_Menu.m 7755 2019-12-16 13:19:28Z spm $
if nargin < 1, action = 'Create'; end
switch lower(action)
case 'create'
spm_Menu('Close');
Fmenu = create_menu(varargin{1:end});
case 'switch'
Fmenu = spm_figure('FindWin','Menu');
[Modality,ModNum] = spm('CheckModality',varargin{1});
if ~isempty(Fmenu)
if strcmpi(Modality,'PET')
set(findobj(Fmenu, '-regexp', 'Tag', 'FMRI'), 'Visible', 'off');
set(findobj(Fmenu, '-regexp', 'Tag', 'EEG'), 'Visible', 'off');
set(findobj(Fmenu, '-regexp', 'Tag', 'PET'), 'Visible', 'on' );
elseif strcmpi(Modality,'FMRI')
set(findobj(Fmenu, '-regexp', 'Tag', 'EEG'), 'Visible', 'off');
set(findobj(Fmenu, '-regexp', 'Tag', 'PET'), 'Visible', 'off');
set(findobj(Fmenu, '-regexp', 'Tag', 'FMRI'), 'Visible', 'on' );
else
set(findobj(Fmenu, '-regexp', 'Tag', 'PET'), 'Visible', 'off');
set(findobj(Fmenu, '-regexp', 'Tag', 'FMRI'), 'Visible', 'off');
set(findobj(Fmenu, '-regexp', 'Tag', 'EEG'), 'Visible', 'on' );
end
set(findobj(Fmenu,'Tag','Modality'),'Value',ModNum,'UserData',ModNum);
else
warning('SPM Menu window not found.');
end
case 'close'
Fmenu = spm_figure('FindWin','Menu');
delete(Fmenu);
otherwise
error('Unknown action ''%s''.',action);
end
%==========================================================================
%-function Fmenu = create_menu(Vis)
%==========================================================================
function Fmenu = create_menu(Vis)
if ~nargin, Vis = 'on'; end
%-Get size and scalings
%--------------------------------------------------------------------------
PF = spm_platform('fonts'); %-Font names (for this platform)
FS = spm('FontSizes'); %-Scaled font sizes
WS = spm('WinScale'); %-Window scaling factors
Rect0 = spm('WinSize','0',1);
RectM = spm('WinSize','Menu',1).*WS; %-Menu window rectangle: 400x445
Pos = [Rect0(1) Rect0(2) 0 0] + RectM;
%-Create Menu window
%--------------------------------------------------------------------------
if ~isempty(which('openfig'))
Fmenu = openfig(fullfile(spm('Dir'),'spm_Menu.fig'),'new','invisible');
else
fprintf('\nFunction openfig.m is missing. Download it from:\n');
fprintf(' https://savannah.gnu.org/bugs/download.php?file_id=33499\n');
Fmenu = [];
end
set(Fmenu,'Name',[spm('Version') ': Menu']);
set(Fmenu,'Units','pixels', 'Position',Pos);
set(Fmenu,'Color',[1 1 1]*.8);
% Fmenu = figure('Tag','Menu',...
% 'Name',[spm('Version') ': Menu'],...
% 'IntegerHandle','off',...
% 'NumberTitle','off',...
% 'Units','pixels',...
% 'Position',Pos,...
% 'Resize','on',...
% 'Pointer','arrow',...
% 'Color',[1 1 1]*.8,...
% 'MenuBar','none',...
% 'DockControls','off',...
% 'CloseRequestFcn','spm(''Quit'')',...
% 'HandleVisibility','off',...
% 'DefaultUicontrolFontName',PF.helvetica,...
% 'Visible','off');
%-Set SPM colour
%--------------------------------------------------------------------------
set(findobj(Fmenu,'Tag', 'frame'),'BackgroundColor',spm('colour'));
if ispc && strcmpi(spm_check_version,'matlab')
try
%M = getframe(Fmenu);
%col = double(M.cdata(floor(size(M.cdata,1)/3),floor(size(M.cdata,2)/2),:));
col = [204 204 204];
set(findobj(Fmenu,'UserData','LABEL'),'BackgroundColor',col/255);
end
elseif ismac
set(findobj(Fmenu,'UserData','LABEL'),'Visible','off','Tag','');
end
%-Set Utils
%--------------------------------------------------------------------------
set(findobj(Fmenu,'Tag', 'Utils'), 'String',{'Utils...',...
'CD',...
'PWD',...
'Run M-file',...
'Load MAT-file',...
'Save MAT-file',...
'Delete files',...
'Show SPM',...
'Show MATLAB'});
set(findobj(Fmenu,'Tag', 'Utils'), 'UserData',{...
['spm(''FnBanner'',''CD'');' ...
'cd(spm_select(1,''dir'',''Select new working directory''));' ...
'spm(''alert"'',{''New working directory:'',['' '',pwd]},''CD'',1);'],...
['spm(''FnBanner'',''PWD'');' ...
'spm(''alert"'',{''Present working directory:'',['' '',pwd]},''PWD'',1);'],...
['spm(''FnBanner'',''Run M-file'');' ...
'spm(''Run'');' ...
'fprintf(''%-40s: %30s\n'',''Completed'',spm(''time''));'],...
['spm(''FnBanner'',''Load MAT-file'');' ...
'load(spm_select(1,''mat'',''Select MAT-file''));'],...
['spm(''FnBanner'',''Save MAT-file'');' ...
'save(spm_input(''Output filename'',1,''s''), spm_get_defaults(''mat.format''));'],...
['spm(''FnBanner'',''Delete files'');' ...
'spm(''Delete'');'],...
['spm(''FnBanner'',''Show SPM'');' ...
'spm(''Show'');'],...
['spm(''FnBanner'',''Show Command Window'');' ...
'commandwindow;']});
%-Set Toolboxes
%--------------------------------------------------------------------------
xTB = spm('tbs');
if ~isempty(xTB)
set(findobj(Fmenu,'Tag', 'Toolbox'),'String',{'Toolbox:' xTB.name });
set(findobj(Fmenu,'Tag', 'Toolbox'),'UserData',xTB);
else
set(findobj(Fmenu,'Tag', 'Toolbox'),'Enable','off');
end
set(Fmenu,'Visible',Vis);