sad grad student can't handle GUIs - please help

Hi, all. I have no experience building GUIs in MATLAB so sorry if this is a naive question. I am trying to use a toolbox called DETECT which uses autoregressive model for feature extraction with EEG data. I have attached the PDF labeled "DETECT" which describes the toolbox in depth. And here is a link to the article: https://pubmed.ncbi.nlm.nih.gov /23638169/
The last update of this toolbox was in 2013, according to Github. I am running into trouble with the function getLabels, which calls eegplot2, a modified version of the function eegplot from EEGLAB. From input 2D array of size (channels, frames), getLabels should return a GUI with scrolling visualization of the EEG signal and color-coded tabs for each feature category the user defines to use for model building. However, when I run getLabels, no GUI appears, and instead, I get the following error:
Error using matlab.graphics.Graphics/set
The name 'Units' is not an accessible property for an instance of class 'matlab.graphics.GraphicsPlaceholder'.
Error in eegplot2 (line 631)
set(u,'Units','Normalized')
What does this error mean and how do I fix it? Here is that section of code:
% %%%%%%%%%%%%%%%%%%%%%%%%%
% Set up uicontrols
% %%%%%%%%%%%%%%%%%%%%%%%%%
% positions of buttons
posbut(1,:) = [ 0.0464 0.0254 0.0385 0.0339 ]; % <<
posbut(2,:) = [ 0.0924 0.0254 0.0288 0.0339 ]; % <
posbut(3,:) = [ 0.1924 0.0254 0.0299 0.0339 ]; % >
posbut(4,:) = [ 0.2297 0.0254 0.0385 0.0339 ]; % >>
posbut(5,:) = [ 0.1287 0.0203 0.0561 0.0390 ]; % Eposition
posbut(6,:) = [ 0.4744 0.0236 0.0582 0.0390 ]; % Espacing
posbut(7,:) = [ 0.2762 0.01 0.0582 0.0390 ]; % elec
posbut(8,:) = [ 0.3256 0.01 0.0707 0.0390 ]; % g.time
posbut(9,:) = [ 0.4006 0.01 0.0582 0.0390 ]; % value
posbut(14,:) = [ 0.2762 0.05 0.0582 0.0390 ]; % elec tag
posbut(15,:) = [ 0.3256 0.05 0.0707 0.0390 ]; % g.time tag
posbut(16,:) = [ 0.4006 0.05 0.0582 0.0390 ]; % value tag
posbut(10,:) = [ 0.5437 0.0458 0.0275 0.0270 ]; % +
posbut(11,:) = [ 0.5437 0.0134 0.0275 0.0270 ]; % -
% posbut(12,:) = [ 0.6 0.02 0.14 0.05 ]; % cancel
% posbut(13,:) = [-0.15 0.02 0.07 0.05 ]; % cancel
posbut(12,:) = [ 0.6 0.02 0.14 0.05 ]; % cancel
posbut(13,:) = [ 0.6 0.02 0.14 0.05 ]; % cancel
posbut(17,:) = [-0.06 0.02 0.09 0.05 ]; % events types
posbut(20,:) = [-0.17 0.15 0.015 0.8 ]; % slider
posbut(:,1) = posbut(:,1)+0.2;
% Five move buttons: << < text > >>
u(1) = uicontrol('Parent',figh, ...
'Units', 'normalized', ...
'Position', posbut(1,:), ...
'Tag','Pushbutton1',...
'string','<<',...
'Callback','eegplot2(''drawp'',[],[],1)');
u(2) = uicontrol('Parent',figh, ...
'Units', 'normalized', ...
'Position', posbut(2,:), ...
'Tag','Pushbutton2',...
'string','<',...
'Callback','eegplot2(''drawp'',[],[],2)');
u(5) = uicontrol('Parent',figh, ...
'Units', 'normalized', ...
'BackgroundColor',[1 1 1], ...
'Position', posbut(5,:), ...
'Style','edit', ...
'Tag','EPosition',...
'string', fastif(g.trialstag(1) == -1, '0', '1'),...
'Callback', 'eegplot2(''drawp'',[],[],0);' );
u(3) = uicontrol('Parent',figh, ...
'Units', 'normalized', ...
'Position',posbut(3,:), ...
'Tag','Pushbutton3',...
'string','>',...
'Callback','eegplot2(''drawp'',[],[],3)');
u(4) = uicontrol('Parent',figh, ...
'Units', 'normalized', ...
'Position',posbut(4,:), ...
'Tag','Pushbutton4',...
'string','>>',...
'Callback','eegplot2(''drawp'',[],[],4)');
% Text edit fields: ESpacing
u(6) = uicontrol('Parent',figh, ...
'Units', 'normalized', ...
'BackgroundColor',[1 1 1], ...
'Position', posbut(6,:), ...
'Style','edit', ...
'Tag','ESpacing',...
'string',num2str(g.spacing),...
'Callback', 'eegplot2(''draws'',[],[],0);' );
% Slider for vertical motion
u(20) = uicontrol('Parent',figh, ...
'Units', 'normalized', ...
'Position', posbut(20,:), ...
'Style','slider', ...
'visible', 'off', ...
'sliderstep', [0.9 1], ...
'Tag','eegslider', ...
'callback', [ 'tmpg = get(gcbf, ''userdata'');' ...
'tmpg.elecoffset = get(gcbo, ''value'')*(tmpg.chans-tmpg.dispchans);' ...
'set(gcbf, ''userdata'', tmpg);' ...
'eegplot2(''drawp'',[], [], 0);' ...
'clear tmpg;' ], ...
'value', 0);
% Channels, position, value and tag
u(9) = uicontrol('Parent',figh, ...
'Units', 'normalized', ...
'BackgroundColor',DEFAULT_FIG_COLOR, ...
'Position', posbut(7,:), ...
'Style','text', ...
'Tag','Eelec',...c
'string',' ');
u(10) = uicontrol('Parent',figh, ...
'Units', 'normalized', ...
'BackgroundColor',DEFAULT_FIG_COLOR, ...
'Position', posbut(8,:), ...
'Style','text', ...
'Tag','Etime',...
'string','0.00');
u(11) = uicontrol('Parent',figh, ...
'Units', 'normalized', ...
'BackgroundColor',DEFAULT_FIG_COLOR, ...
'Position',posbut(9,:), ...
'Style','text', ...
'Tag','Evalue',...
'string','0.00');
u(14)= uicontrol('Parent',figh, ...
'Units', 'normalized', ...
'BackgroundColor',DEFAULT_FIG_COLOR, ...
'Position', posbut(14,:), ...
'Style','text', ...
'Tag','Eelecname',...
'string','Chan.');
u(15) = uicontrol('Parent',figh, ...
'Units', 'normalized', ...
'BackgroundColor',DEFAULT_FIG_COLOR, ...
'Position', posbut(15,:), ...
'Style','text', ...
'Tag','Etimename',...
'string','Time');
u(16) = uicontrol('Parent',figh, ...
'Units', 'normalized', ...
'BackgroundColor',DEFAULT_FIG_COLOR, ...
'Position',posbut(16,:), ...
'Style','text', ...
'Tag','Evaluename',...
'string','Value');
% ESpacing buttons: + -
u(7) = uicontrol('Parent',figh, ...
'Units', 'normalized', ...
'Position',posbut(10,:), ...
'Tag','Pushbutton5',...
'string','+',...
'FontSize',8,...
'Callback','eegplot2(''draws'',[],[],1)');
u(8) = uicontrol('Parent',figh, ...
'Units', 'normalized', ...
'Position',posbut(11,:), ...
'Tag','Pushbutton6',...
'string','-',...
'FontSize',8,...
'Callback','eegplot2(''draws'',[],[],2)');
%if isempty(g.command) %tmpcom = 'fprintf(''Rejections saved in variable TMPREJ\n'');';
%else
tmpcom = g.command;
%end;
acceptcommand = [ 'g = get(gcbf, ''userdata'');' ...
'TMPREJ = g.winrej;' ...
'if g.children, delete(g.children); end;' ...
'delete(gcbf);' ...
tmpcom ...
'; clear g;']; % quitting expression
u(13) = uicontrol('Parent',figh, ...
'Units', 'normalized', ...
'Position',posbut(13,:), ...
'string',fastif(isempty(g.command),'CLOSE', 'CONTINUE'), 'callback', ...
[ 'g = get(gcbf, ''userdata'');' ...
'if g.children, delete(g.children); end;' ...
'close(gcbf);' ...
'clear TMPREJ g;'] );
if ~isempty(g.command)
u(12) = uicontrol('Parent',figh, ...
'Units', 'normalized', ...
'Position',posbut(12,:), ...
'Tag','Accept',...
'string',g.butlabel, 'callback', acceptcommand);
end;
if ~isempty(g.events)
u(17) = uicontrol('Parent',figh, ...
'Units', 'normalized', ...
'Position',posbut(17,:), ...
'string', 'Event types', 'callback', 'eegplot2(''drawlegend'', [],[],gcbf)');
end;
set(u,'Units','Normalized')

 Accepted Answer

u(12) and u(17) are only created conditionally . If either of them is not set, then at least one element of u would not be a valid graphics object, and would instead have been filled in with a matlab.graphics.GraphicsPlaceholder object. Such objects mean "this is the right data type to be a graphics object of some kind, but no graphics was assigned to it"
You have two ways to proceed:
  1. You could create u(12) and u(17) unconditionally, but use conditions to determine whether you make them visible; OR
  2. set( u(ishghandle(u)), 'Units', 'Normalized' )

1 Comment

Thank you so much! Your explanation of the error message was really helpful. It works now!

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!