Skip to content

Commit

Permalink
updated supportfile/pgrid.m to work with older versions of MATLAB (se…
Browse files Browse the repository at this point in the history
…e issue #13, thanks to lrq3000 for catching and help with troubleshooting)
  • Loading branch information
spunt committed Nov 22, 2016
1 parent b3e8491 commit 5597721
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
3 changes: 2 additions & 1 deletion bspmview.m
Original file line number Diff line number Diff line change
Expand Up @@ -1929,7 +1929,7 @@ function cb_clustexplore(varargin)
subname = regexprep(subname, '_', ' ');
conname = replace(subdescrip(1:ncond), {'.+\d:', '- All Sessions$', '_'}, {'' '' ' '});
otherwise
headsup('Unrecognized or unsupported design type! Click to return to the main window...');
headsup('Unrecognized or unsupported design type! Plotting currently works only with one or two-sample t-tests, and flexible factorial designs.');
return;
end

Expand Down Expand Up @@ -3943,6 +3943,7 @@ function uisavefig(defname, hfig)
'Name',titlestr,...
'Visible','on',...
'Toolbar','none');

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', ...
'pos', [.050 .375 .900 .525], 'fontname', 'arial', 'fontw', 'bold', 'fontsize', st.fonts.sz4, 'string', question, 'visible', 'on');
h(3) = uicontrol('parent', h(1), 'units', 'norm', 'style', 'push', 'foreg', [0 0 0], 'horiz', 'center', ...
Expand Down
41 changes: 21 additions & 20 deletions supportfiles/pgrid.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
% ncol: number of cols in grid
% ________________________________________________________________________________________
% VARARGIN
% | NAME | DEFAULT | DESCRIPTION
% | NAME | DEFAULT | DESCRIPTION
% |-----------------|---------------|-----------------------------------------------------
% | parent | gcf | parent object for grid
% | relwidth | ones(1, ncol) | relative width of columns (arbitrary units)
% | relheight | ones(1, nrow) | relative height of rows (arbitrary units)
% | marginsep | 0.0100 | size of margin surrounding grid (normalized units)
% | panelsep | 0.0100 | size of space between panels (normalized units)
% | backgroundcolor | [.08 .09 .09] | uipanel background color
% | parent | gcf | parent object for grid
% | relwidth | ones(1, ncol) | relative width of columns (arbitrary units)
% | relheight | ones(1, nrow) | relative height of rows (arbitrary units)
% | marginsep | 0.0100 | size of margin surrounding grid (normalized units)
% | panelsep | 0.0100 | size of space between panels (normalized units)
% | backgroundcolor | [.08 .09 .09] | uipanel background color
% | foregroundcolor | [.97 .97 .97] | uipanel foreground color
% | bordertype | 'none' | etchedin, etchedout, beveledin, beveledout, line
% | bordertype | 'none' | etchedin, etchedout, beveledin, beveledout, line
% | borderwidth | 1 | uipanel border width in pixels
% ________________________________________________________________________________________
%
Expand Down Expand Up @@ -55,16 +55,17 @@
if length(relwidth)~=ncol, printmsg('Length of RELWIDTH must equal NCOL. Try again!'); phandle = []; pidx = []; return; end
if length(relheight)~=nrow, printmsg('Length of RELHEIGHT must equal NROW. Try again!'); phandle = []; pidx = []; return; end

% | Get normalized positions for each panel
% | Get normalized positions for each panel
pos = getpositions(relwidth, relheight, marginsep, panelsep);
pidx = pos(:,1:2);
hpos = pos(:,3:end);

% | pgrid loop
npanel = size(hpos, 1);
phandle = gobjects(npanel, 1);
% phandle = gobjects(npanel, 1);
phandle = zeros(npanel, 1);
for i = 1:npanel

phandle(i) = uipanel( ...
'Parent' , parent ,...
'Units' , 'normalized' ,...
Expand Down Expand Up @@ -98,14 +99,14 @@
if size(relheight,1) > 1, relheight = relheight'; end
if size(relwidth, 1) > 1, relwidth = relwidth'; end
ncol = length(relwidth);
nrow = length(relheight);
nrow = length(relheight);
if top2bottomidx, relheight = relheight(end:-1:1); end

% width
rowwidth = 1-(marginsep*2)-(uicontrolsep*(ncol-1));
rowwidth = 1-(marginsep*2)-(uicontrolsep*(ncol-1));
uiwidths = (relwidth/sum(relwidth))*rowwidth;
allsep = [marginsep repmat(uicontrolsep, 1, ncol-1)];
uilefts = ([0 cumsum(uiwidths(1:end-1))]) + cumsum(allsep);
uilefts = ([0 cumsum(uiwidths(1:end-1))]) + cumsum(allsep);

% height
colheight = 1-(marginsep*2)-(uicontrolsep*(nrow-1));
Expand All @@ -119,9 +120,9 @@
pos = zeros(ncol*nrow, 6);
pos(:,1) = reshape(repmat(nrow:-1:1, ncol, 1), size(pos,1), 1);
pos(:,2) = reshape(repmat(1:ncol, 1, nrow), size(pos,1), 1);
pos(:,3) = uilefts(pos(:,2));
pos(:,4) = uibottoms(pos(:,1));
pos(:,5) = uiwidths(pos(:,2));
pos(:,3) = uilefts(pos(:,2));
pos(:,4) = uibottoms(pos(:,1));
pos(:,5) = uiwidths(pos(:,2));
pos(:,6) = uiheights(pos(:,1));
pos = sortrows(pos, 1);
end
Expand All @@ -135,10 +136,10 @@ function mfile_showhelp(varargin)
% SETARGS Name/value parsing and assignment of varargin with default values
if nargin < 1, mfile_showhelp; return; end
if nargin < 2, optargs = []; end
defaults = reshape(defaults, 2, length(defaults)/2)';
defaults = reshape(defaults, 2, length(defaults)/2)';
if ~isempty(optargs)
if mod(length(optargs), 2)
error('Optional inputs must be entered as Name, Value pairs, e.g., myfunction(''name'', value)');
error('Optional inputs must be entered as Name, Value pairs, e.g., myfunction(''name'', value)');
end
arg = reshape(optargs, 2, length(optargs)/2)';
for i = 1:size(arg,1)
Expand All @@ -149,7 +150,7 @@ function mfile_showhelp(varargin)
error('Input "%s" does not match a valid input.', arg{i,1});
else
defaults{idx,2} = arg{i,2};
end
end
end
end
for i = 1:size(defaults,1), assignin('caller', defaults{i,1}, defaults{i,2}); end
Expand Down

0 comments on commit 5597721

Please sign in to comment.