function varargout = JEMRIS_seq(varargin)
%GUI for jemris sequence tree design

%
%  JEMRIS Copyright (C) 
%                        2006-2025  Tony Stoecker
%                        2007-2015  Kaveh Vahedipour
%                        2009-2019  Daniel Pflugfelder
%                                  
%
%  This program is free software; you can redistribute it and/or modify
%  it under the terms of the GNU General Public License as published by
%  the Free Software Foundation; either version 2 of the License, or
%  (at your option) any later version.
%
%  This program is distributed in the hope that it will be useful,
%  but WITHOUT ANY WARRANTY; without even the implied warranty of
%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%  GNU General Public License for more details.
%
%  You should have received a copy of the GNU General Public License
%  along with this program; if not, write to the Free Software
%  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
%

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @JEMRIS_seq_OpeningFcn, ...
                   'gui_OutputFcn',  @JEMRIS_seq_OutputFcn, ...
                   'gui_LayoutFcn',  [ ] , ...
                   'gui_Callback',   [ ]);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before JEMRIS_seq is made visible.
function JEMRIS_seq_OpeningFcn(hObject, eventdata, handles, varargin)
colordef white

% Choose default command line output for JEMRIS_seq
handles.output = hObject;
handles.seqfile = '';
handles.seqdir  = pwd;
handles.exportdir = pwd;
handles.exportArgs='';
handles.Seq=[ ];       % the sequence structure
handles.SeqBackup=[ ]; % a backup
handles.SO=struct('Attribute',cell(10,1),'Value',cell(10,1)); %sequence object properties
hax{1}=handles.axes0; hax{2}=handles.axes1; hax{3}=handles.axes2; hax{4}=handles.axes3;
hax{5}=handles.axes4; hax{6}=handles.axes5; hax{7}=handles.axes6; hax{8}=handles.axes7;
for i=1:length(hax);set(hax{i},'color',[1 1 1],'visible','off');end
handles.hax=hax;
linkaxes([hax{1:6}],'x');
handles.plotSD=0;
handles.dm=0;
handles.cd=0;
handles.ax=0;
handles.CWD=pwd;
handles.win = (strcmp(computer,'PCWIN') || strcmp(computer,'PCWIN64'));
if (handles.win)
    if (strcmp(computer,'PCWIN64'))
        handles.JemrisPath=['"',winqueryreg('HKEY_LOCAL_MACHINE', 'SOFTWARE\Wow6432Node\jemris', 'Path')];
    else
        handles.JemrisPath=['"',winqueryreg('HKEY_LOCAL_MACHINE', 'SOFTWARE\jemris', 'Path')];
    end
    handles.JemrisShare=[''];
    handles.JemrisCall=[fullfile(handles.JemrisPath,'jemris.exe"')];
else
    handles.JemrisPath='@prefix@/bin';
    handles.JemrisShare='@prefix@/share/jemris/matlab';
    [s,w]=system('setenv');
    if s==0 % a TCSH
        handles.JemrisCall=['setenv LD_LIBRARY_PATH ""; ',fullfile(handles.JemrisPath,'jemris')];
    else    % a BASH 
        handles.JemrisCall=['LD_LIBRARY_PATH=""; PATH=/usr/local/bin:$PATH; ',fullfile(handles.JemrisPath,'jemris')];
    end
end
%get all modules + attributes which are currently supported by JEMRIS
[Modules,Params]=getAllModules(handles.JemrisCall,handles.CWD);
for i=1:length(Modules)
    handles.ModType{i}   = Modules(i).type; 
    handles.Modules{i}   = Modules(i).name; 
    handles.Attributes{i}= Modules(i).attr.name; 
    handles.Values{i}    = Modules(i).attr.val;
    handles.HiddenAttributes{i}= Modules(i).hidden_attr; 
end
handles.Parameter=Params.a.name;
handles.ParameterHidden=Params.ha;
%sort: put first all gradient pulses to the end
NM=length(handles.Modules);
I=strfind(handles.Modules,'GRAD');
J=[];K=[];for i=1:NM; if ~isempty(I{i}),J(end+1)=i;else;K(end+1)=i;end,end
I=[K J];
handles.Modules=handles.Modules(I);
handles.ModType=handles.ModType(I);
handles.HiddenAttributes=handles.HiddenAttributes(I);
handles.Attributes=handles.Attributes(I);
handles.Values=handles.Values(I);
%sort: then put all RF pulses to the end
NM=length(handles.Modules);
I=strfind(handles.Modules,'RF');
J=[];K=[];for i=1:NM; if ~isempty(I{i}),J(end+1)=i;else;K(end+1)=i;end,end
I=[K J];
handles.Modules=handles.Modules(I);
handles.ModType=handles.ModType(I);
handles.HiddenAttributes=handles.HiddenAttributes(I);
handles.Attributes=handles.Attributes(I);
handles.Values=handles.Values(I);

set(handles.HiddenAttr,'Visible','off');

set(handles.addADCs,'Visible','off');
set(handles.ContDraw,'Visible','off');
for i=1:22
    eval(['set(handles.SOtag',num2str(i),',''Visible'',''off'');'])
    eval(['set(handles.SOEtag',num2str(i),',''Visible'',''off'');'])
end

global INSERT_MODULE_NUMBER MODULE_TYPE_COUNTER
INSERT_MODULE_NUMBER=0;
MODULE_TYPE_COUNTER=[0 0 0 0 0];

%create the toolbar
handles.icons=load(fullfile(handles.JemrisShare,'ModuleIcons'));
handles.hpt=seqcad_uitoolbar(hObject,handles);

guidata(hObject, handles);



% --- Outputs from this function are returned to the command line.
function varargout = JEMRIS_seq_OutputFcn(hObject, eventdata, handles) 
varargout{1} = handles;

% --- runs jemris on the current seqence. This is *not* an object of the GUI!
function call_jemris(hObject,handles)
if (handles.win)
 [status,dump]=system(sprintf('%s %s %s > .seq.out',handles.JemrisCall,handles.exportArgs,fullfile(               handles.seqfile)));
else
 [status,dump]=system(sprintf('%s %s %s > .seq.out',handles.JemrisCall,handles.exportArgs,fullfile(handles.seqdir,handles.seqfile)));
end
 if status==0
  C={};
  fid=fopen('.seq.out');
  while 1
    tline = fgetl(fid);
    if ~ischar(tline), break, end
    C{end+1}=tline;
  end
  fclose(fid);
 else
     C{1}='Error occured:';
     C{2}='';
     C{3}=dump;
 end
 set(handles.seq_dump,'String',C);
 set(handles.seq_dump,'FontName','monospaced');
 set(handles.seq_dump,'FontSize',8)
 guidata(hObject, handles);

% --- Executes on button press in update.
function update_Callback(hObject, eventdata, handles)
if (handles.win)
	  writeXMLseq(handles,handles.Seq,                        handles.seqfile);
else
    writeXMLseq(handles,handles.Seq,fullfile(handles.seqdir,handles.seqfile));
end
set(handles.SeqNameTag,'String',['Sequence: ',handles.seqfile])
handles.CWD=pwd;
for i=1:length(handles.hpt);
    set(handles.hpt{i},'State','off'); 
end
call_jemris(hObject,handles);
if get(handles.DrawSD,'Value')==0
    handles.Seq=plotseq(handles,1,1+get(handles.addADCs,'Value'));
elseif get(handles.kspace_flag,'Value')
    plotseq(handles,1,1+get(handles.addADCs,'Value'));
else
    [dummy,ax]=plotseq(handles,handles.dm);
    set(handles.show_interval,'String',num2str(ax));
end
handles.SeqBackup=handles.Seq;
set(handles.zoomFlag,'Value',0);
guidata(hObject, handles);

% --- Executes on button press in draw_moments.
function draw_moments_Callback(hObject, eventdata, handles)
handles.dm=get(hObject,'Value');
plotseq(handles,handles.dm);
guidata(hObject, handles);

% --- Executes on button press in undo.
function undo_Callback(hObject, eventdata, handles)
handles.Seq=parseXMLseq(handles);
guidata(hObject, handles);
update_Callback(hObject, eventdata, handles)
if 0
 [a,b,c]=fileparts(handles.seqfile);
 D=dir([b,'*_seq*.pdf']);

 pdfname=sprintf('%s_seq%03d',b,length(D)+1);
 set(gcf,'PaperPositionMode','auto','InvertHardcopy','off')
 print('-dpdf',pdfname)
end

% --- Executes on setting the interval in show_interval
function show_interval_Callback(hObject, eventdata, handles)
 handles.ax=str2num(get(hObject,'String'));
 if isempty(handles.ax),handles.ax=0;end
 [dummy,ax]=plotseq(handles,handles.dm);
 set(handles.show_interval,'String',num2str(ax));
 guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function show_interval_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% --- Executes on selection change in seq_dump.
function seq_dump_Callback(hObject, eventdata, handles)

% --- Executes during object creation, after setting all properties.
function seq_dump_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% --- Executes on button press in zoomFlag.
function zoomFlag_Callback(hObject, eventdata, handles)
if get(hObject,'Value')
    zoom(gcf,'on')
else
    if get(handles.kspace_flag,'Value')
        plotseq(handles,1,1+get(handles.addADCs,'Value'));
    else
        plotseq(handles,handles.dm);
    end
    zoom(gcf,'off')
end

% --- Executes on button press in DrawSD.
function DrawSD_Callback(hObject, eventdata, handles)
if get(hObject,'Value')
    handles.plotSD=1;
    [dummy,handles.ax]=plotseq(handles,handles.dm);
    set(handles.show_interval,'String',num2str(handles.ax));
else
    handles.plotSD=0;
    handles.Seq=plotseq(handles,1,1+get(handles.addADCs,'Value'));
end
guidata(hObject, handles);


% --- Executes on button press in kspace_flag.
function kspace_flag_Callback(hObject, eventdata, handles)
handles.dm=0;
if get(hObject,'Value')
    plotseq(handles,1,1+get(handles.addADCs,'Value'));
else
    plotseq(handles,handles.dm);

end
guidata(hObject, handles);


% --- Executes on button press in addADCs.
function addADCs_Callback(hObject, eventdata, handles)
if get(hObject,'Value')
    plotseq(handles,1,2);
    set(handles.zoomFlag,'Value',0);
else
    plotseq(handles,1,1);
    set(handles.zoomFlag,'Value',0);
end
guidata(hObject, handles);


% --- Executes on button press in ContDraw.
function ContDraw_Callback(hObject, eventdata, handles)

handles.cd=get(hObject,'Value');
plotseq(handles,1,get(handles.kspace_flag,'Value')+get(handles.addADCs,'Value'));
set(handles.zoomFlag,'Value',0);
guidata(hObject, handles);


% Hint: get(hObject,'Value') returns toggle state of ContDraw
% --------------------------------------------------------------------
function FileTag_Callback(hObject, eventdata, handles)

% --------------------------------------------------------------------
function OpenSeqTag_Callback(hObject, eventdata, handles)
[FileName,PathName] = uigetfile('*.xml','Select the Sequence XML file');
if FileName==0,return;end
handles.seqfile=FileName;
handles.seqdir=PathName;
set(handles.SeqNameTag,'string',['Sequence: ',FileName]);
handles.Seq=parseXMLseq(handles);
handles.SeqBackup=handles.Seq;
handles.dm=0;
call_jemris(hObject,handles);
handles.plotSD=0;
[handles.Seq,handles.ax]=plotseq(handles,1,1+get(handles.addADCs,'Value'));
guidata(hObject, handles);

% --------------------------------------------------------------------
function SaveSeqTag_Callback(hObject, eventdata, handles)
[FileName,PathName] = uiputfile('*.xml');
if FileName==0,return;end
handles.seqfile=FileName;
guidata(hObject, handles);
update_Callback(hObject, eventdata, handles);

% --------------------------------------------------------------------
function ExportSeqTag_Callback(hObject, eventdata, handles)
[FileName,PathName] = uiputfile('*.seq',[],fullfile(handles.exportdir,'external.seq'));
if FileName==0,return;end
[~,BaseName,~]=fileparts(FileName);
handles.exportArgs=['-x -o ' PathName ' -f ' BaseName];
call_jemris(hObject,handles);
handles.exportArgs='';
handles.exportdir=PathName;
guidata(hObject, handles);



% --------------------------------------------------------------------
function NewSeqTag_Callback(hObject, eventdata, handles)
[FileName,PathName] = uiputfile('*.xml');
if FileName==0,return;end
S.Name='Parameters'; S.Attributes.Name='Name';
S.Attributes.Value='P'; S.Data='';
P.Name='ConcatSequence'; P.Attributes(1).Name='Name'; P.Attributes(1).Value='C1';P.Attributes(1).DispName='C1';
P.Data=[ ]; P.Children=[ ]; P.current=0;
S.Children(1)=P;  S.current=1;
handles.seqfile=FileName;
handles.Seq=S;
hax=handles.hax;for i=1:length(hax); cla(hax{i},'reset'); set(hax{i},'visible','off'); end
guidata(hObject, handles);
update_Callback(hObject, eventdata, handles);

% --------------------------------------------------------------------
function PlotTag_Callback(hObject, eventdata, handles)

% --------------------------------------------------------------------
function PlotGUITag_Callback(hObject, eventdata, handles)
 [FileName,PathName] = uiputfile('*.jpg');
 if FileName==0,return;end
 set(gcf,'PaperPositionMode','auto','InvertHardcopy','off')
 print('-djpeg90',FileName)

% --------------------------------------------------------------------
function PlotPDTag_Callback(hObject, eventdata, handles)
if get(handles.kspace_flag,'Value')==0
    h=figure('name','pulse diagramme','numbertitle','off');
    p=[ 0.1300    0.7093    0.3347    0.2157;...
        0.5703    0.7093    0.3347    0.2157;...
        0.1300    0.4096    0.3347    0.2157;...
        0.5703    0.4096    0.3347    0.2157;...
        0.1300    0.1100    0.3347    0.2157;...
        0.5703    0.1100    0.3347    0.2157];
    I=[1 3 5 2 4 6];
    for j=1:6
         g(j)=copyobj(handles.hax{j},h);
         set(g(j),'units','normalized','position',p(I(j),:))
    end
else
    h=figure('name','k-space trajectory','numbertitle','off');
    g=copyobj(handles.hax{8},h);
    set(g,'units','normalized','position',[.1 .1 .8 .8])
    grid on
end
set(h,'color',[1 1 1],'paperunits','centimeter','paperposition',[0 0 12 8])
    
%this function is performed for all text-edit callbacks on the module card
function common_SOEtags(hObject,handles)
S=get(hObject,'UserData');  % attribute name
set(hObject,'TooltipString','')
%special case of adding a vector
if strcmpi(S,'Vector')
  s=sprintf('any matlab expression which evaluates to a vector');
  set(hObject,'TooltipString',s)
  v = eval(['[',get(hObject,'String'),']']); v=(v(:))';
  handles.Seq=changeSeqAttributes(S,num2str(v),handles.Seq,handles);
else
  handles.Seq=changeSeqAttributes(S,get(hObject,'String'),handles.Seq,handles);
end
%special case of external pulseshapes
if strcmpi(S,'FILENAME')
  s=sprintf('binary filename, or global variable\nfrom which the binary file is generated');
  set(hObject,'TooltipString',s)
end
%redraw tree
if handles.plotSD==0
 axes(handles.hax{7}); cla(handles.hax{7},'reset');
 handles.Seq=plotSeqTree(handles.Seq,handles);
end
guidata(hObject, handles);

function SOEtag1_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag2_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

function SOEtag2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag3_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag3_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag4_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag4_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag5_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag5_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag6_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag6_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag7_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag7_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag8_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag8_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag9_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag9_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag10_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag10_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag11_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag11_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag12_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag12_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag13_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag13_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag14_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag14_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag15_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag15_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag16_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag16_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag17_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag17_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag18_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag18_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag19_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag19_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag20_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag20_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag21_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag21_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function SOEtag22_Callback(hObject, eventdata, handles)
common_SOEtags(hObject,handles)

% --- Executes during object creation, after setting all properties.
function SOEtag22_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

% --- Executes on selection change in HiddenAttr.
function HiddenAttr_Callback(hObject, eventdata, handles)
set(handles.HiddenAttr,'Value',1);
guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function HiddenAttr_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
