Skip to content

Commit 5597721

Browse files
committed
updated supportfile/pgrid.m to work with older versions of MATLAB (see issue #13, thanks to lrq3000 for catching and help with troubleshooting)
1 parent b3e8491 commit 5597721

2 files changed

Lines changed: 23 additions & 21 deletions

File tree

bspmview.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1929,7 +1929,7 @@ function cb_clustexplore(varargin)
19291929
subname = regexprep(subname, '_', ' ');
19301930
conname = replace(subdescrip(1:ncond), {'.+\d:', '- All Sessions$', '_'}, {'' '' ' '});
19311931
otherwise
1932-
headsup('Unrecognized or unsupported design type! Click to return to the main window...');
1932+
headsup('Unrecognized or unsupported design type! Plotting currently works only with one or two-sample t-tests, and flexible factorial designs.');
19331933
return;
19341934
end
19351935

@@ -3943,6 +3943,7 @@ function uisavefig(defname, hfig)
39433943
'Name',titlestr,...
39443944
'Visible','on',...
39453945
'Toolbar','none');
3946+
39463947
h(2) = uicontrol('parent', h(1), 'units', 'norm', 'style', 'text', 'backg', [0.8941 0.1020 0.1098]*.60,'foreg', [248/255 248/255 248/255], 'horiz', 'center', ...
39473948
'pos', [.050 .375 .900 .525], 'fontname', 'arial', 'fontw', 'bold', 'fontsize', st.fonts.sz4, 'string', question, 'visible', 'on');
39483949
h(3) = uicontrol('parent', h(1), 'units', 'norm', 'style', 'push', 'foreg', [0 0 0], 'horiz', 'center', ...

supportfiles/pgrid.m

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
% ncol: number of cols in grid
1313
% ________________________________________________________________________________________
1414
% VARARGIN
15-
% | NAME | DEFAULT | DESCRIPTION
15+
% | NAME | DEFAULT | DESCRIPTION
1616
% |-----------------|---------------|-----------------------------------------------------
17-
% | parent | gcf | parent object for grid
18-
% | relwidth | ones(1, ncol) | relative width of columns (arbitrary units)
19-
% | relheight | ones(1, nrow) | relative height of rows (arbitrary units)
20-
% | marginsep | 0.0100 | size of margin surrounding grid (normalized units)
21-
% | panelsep | 0.0100 | size of space between panels (normalized units)
22-
% | backgroundcolor | [.08 .09 .09] | uipanel background color
17+
% | parent | gcf | parent object for grid
18+
% | relwidth | ones(1, ncol) | relative width of columns (arbitrary units)
19+
% | relheight | ones(1, nrow) | relative height of rows (arbitrary units)
20+
% | marginsep | 0.0100 | size of margin surrounding grid (normalized units)
21+
% | panelsep | 0.0100 | size of space between panels (normalized units)
22+
% | backgroundcolor | [.08 .09 .09] | uipanel background color
2323
% | foregroundcolor | [.97 .97 .97] | uipanel foreground color
24-
% | bordertype | 'none' | etchedin, etchedout, beveledin, beveledout, line
24+
% | bordertype | 'none' | etchedin, etchedout, beveledin, beveledout, line
2525
% | borderwidth | 1 | uipanel border width in pixels
2626
% ________________________________________________________________________________________
2727
%
@@ -55,16 +55,17 @@
5555
if length(relwidth)~=ncol, printmsg('Length of RELWIDTH must equal NCOL. Try again!'); phandle = []; pidx = []; return; end
5656
if length(relheight)~=nrow, printmsg('Length of RELHEIGHT must equal NROW. Try again!'); phandle = []; pidx = []; return; end
5757

58-
% | Get normalized positions for each panel
58+
% | Get normalized positions for each panel
5959
pos = getpositions(relwidth, relheight, marginsep, panelsep);
6060
pidx = pos(:,1:2);
6161
hpos = pos(:,3:end);
6262

6363
% | pgrid loop
6464
npanel = size(hpos, 1);
65-
phandle = gobjects(npanel, 1);
65+
% phandle = gobjects(npanel, 1);
66+
phandle = zeros(npanel, 1);
6667
for i = 1:npanel
67-
68+
6869
phandle(i) = uipanel( ...
6970
'Parent' , parent ,...
7071
'Units' , 'normalized' ,...
@@ -98,14 +99,14 @@
9899
if size(relheight,1) > 1, relheight = relheight'; end
99100
if size(relwidth, 1) > 1, relwidth = relwidth'; end
100101
ncol = length(relwidth);
101-
nrow = length(relheight);
102+
nrow = length(relheight);
102103
if top2bottomidx, relheight = relheight(end:-1:1); end
103104

104105
% width
105-
rowwidth = 1-(marginsep*2)-(uicontrolsep*(ncol-1));
106+
rowwidth = 1-(marginsep*2)-(uicontrolsep*(ncol-1));
106107
uiwidths = (relwidth/sum(relwidth))*rowwidth;
107108
allsep = [marginsep repmat(uicontrolsep, 1, ncol-1)];
108-
uilefts = ([0 cumsum(uiwidths(1:end-1))]) + cumsum(allsep);
109+
uilefts = ([0 cumsum(uiwidths(1:end-1))]) + cumsum(allsep);
109110

110111
% height
111112
colheight = 1-(marginsep*2)-(uicontrolsep*(nrow-1));
@@ -119,9 +120,9 @@
119120
pos = zeros(ncol*nrow, 6);
120121
pos(:,1) = reshape(repmat(nrow:-1:1, ncol, 1), size(pos,1), 1);
121122
pos(:,2) = reshape(repmat(1:ncol, 1, nrow), size(pos,1), 1);
122-
pos(:,3) = uilefts(pos(:,2));
123-
pos(:,4) = uibottoms(pos(:,1));
124-
pos(:,5) = uiwidths(pos(:,2));
123+
pos(:,3) = uilefts(pos(:,2));
124+
pos(:,4) = uibottoms(pos(:,1));
125+
pos(:,5) = uiwidths(pos(:,2));
125126
pos(:,6) = uiheights(pos(:,1));
126127
pos = sortrows(pos, 1);
127128
end
@@ -135,10 +136,10 @@ function mfile_showhelp(varargin)
135136
% SETARGS Name/value parsing and assignment of varargin with default values
136137
if nargin < 1, mfile_showhelp; return; end
137138
if nargin < 2, optargs = []; end
138-
defaults = reshape(defaults, 2, length(defaults)/2)';
139+
defaults = reshape(defaults, 2, length(defaults)/2)';
139140
if ~isempty(optargs)
140141
if mod(length(optargs), 2)
141-
error('Optional inputs must be entered as Name, Value pairs, e.g., myfunction(''name'', value)');
142+
error('Optional inputs must be entered as Name, Value pairs, e.g., myfunction(''name'', value)');
142143
end
143144
arg = reshape(optargs, 2, length(optargs)/2)';
144145
for i = 1:size(arg,1)
@@ -149,7 +150,7 @@ function mfile_showhelp(varargin)
149150
error('Input "%s" does not match a valid input.', arg{i,1});
150151
else
151152
defaults{idx,2} = arg{i,2};
152-
end
153+
end
153154
end
154155
end
155156
for i = 1:size(defaults,1), assignin('caller', defaults{i,1}, defaults{i,2}); end

0 commit comments

Comments
 (0)