utthrgbl.m
上传用户:haiyisale
上传日期:2013-01-09
资源大小:3246k
文件大小:25k
源码类别:

波变换

开发平台:

Matlab

  1. function varargout = utthrgbl(option,fig,varargin)
  2. %UTTHRGBL Utilities for global thresholding (compression).
  3. %   VARARGOUT = UTTHRGBL(OPTION,FIG,VARARGIN)
  4. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 15-Sep-98.
  5. %   Last Revision: 31-Jan-2003.
  6. %   Copyright 1995-2004 The MathWorks, Inc.
  7. %   $Revision: 1.7.4.2 $  $Date: 2004/03/15 22:42:10 $
  8. % Tag property.
  9. %--------------
  10. tag_fra_tool = ['Fra_' mfilename];
  11. switch option
  12.   case {'move','up','down','create'} , 
  13.   otherwise
  14.     % ud.handlesUIC = ...
  15.     %   [fra_utl;txt_top;pop_met; ...
  16.     %    txt_sel;sli_sel;edi_sel; ...
  17.     %    txt_nor;edi_nor;txt_npc; ...
  18.     %    txt_zer;edi_zer;txt_zpc; ...
  19.     %    tog_res;pus_est];
  20.     %---------------------------------
  21.     uic = findobj(get(fig,'Children'),'flat','type','uicontrol');
  22.     fra = findobj(uic,'style','frame','tag',tag_fra_tool);
  23.     if isempty(fra) , return; end
  24.     calledFUN = wfigmngr('getWinPROP',fig,'calledFUN');
  25.     ud = get(fra,'Userdata');
  26.     toolOPT = ud.toolOPT;
  27.     handlesUIC = ud.handlesUIC;
  28.     handlesOBJ = ud.handlesOBJ;
  29.     switch option
  30.       case 'handles'
  31.         handles = [handlesUIC(:);handlesOBJ(:)];
  32.         varargout{1} = handles(ishandle(handles));
  33.         return;
  34.       case {'handlesUIC','handlesuic'}
  35.         varargout{1} = handlesUIC;
  36.         return;
  37.     end
  38.     ind = 2;
  39.     txt_top = handlesUIC(ind); ind = ind+1;
  40.     pop_met = handlesUIC(ind); ind = ind+1;
  41.     txt_sel = handlesUIC(ind); ind = ind+1;
  42.     sli_sel = handlesUIC(ind); ind = ind+1;
  43.     edi_sel = handlesUIC(ind); ind = ind+1;
  44.     txt_nor = handlesUIC(ind); ind = ind+1;
  45.     edi_nor = handlesUIC(ind); ind = ind+1;
  46.     txt_npc = handlesUIC(ind); ind = ind+1;  
  47.     txt_zer = handlesUIC(ind); ind = ind+1;
  48.     edi_zer = handlesUIC(ind); ind = ind+1;
  49.     txt_zpc = handlesUIC(ind); ind = ind+1;  
  50.     tog_res = handlesUIC(ind); ind = ind+1;
  51.     pus_est = handlesUIC(ind); ind = ind+1;  
  52. end
  53. switch option
  54.     case 'down'
  55.         % in2 = [ axe_perf ;  
  56.         %         lin_norm ; lin_zero ; lin_perf ; ...
  57.         %         sli_sel ;  edi_sel ; edi_nor ; edi_zer ];
  58.         %--------------------------------------------------------------
  59.         sel_type = get(fig,'SelectionType');
  60.         if strcmp(sel_type,'open') , return; end
  61.         axe = varargin{1}(1);
  62.         if (axe~=gca) , axes(axe); end;
  63.     
  64.         % Setting the thresholded coefs axes invisible.
  65.         %----------------------------------------------
  66.         calledFUN = wfigmngr('getWinPROP',fig,'calledFUN');
  67.         feval(calledFUN,'clear_GRAPHICS',fig);
  68.         lin_perf = varargin{1}(4);
  69.         set(lin_perf,'Color','g');
  70.         drawnow
  71.         argCbstr = [num2mstr(fig) ',' num2mstr(varargin{1})];
  72.         cba_move = [mfilename '(''move'',' argCbstr ');'];
  73.         cba_up   = [mfilename '(''up'','  argCbstr ');'];
  74.         wtbxappdata('new',fig,'save_WindowButtonUpFcn',get(fig,'WindowButtonUpFcn'));
  75.         set(fig,'WindowButtonMotionFcn',cba_move,'WindowButtonUpFcn',cba_up);
  76.     case 'move'
  77.         % in2 = [ axe_perf ;  
  78.         %         lin_norm ; lin_zero ; lin_perf ; ...
  79.         %         sli_sel ;  edi_sel ; edi_nor ; edi_zer ];
  80.         %--------------------------------------------------
  81.         axe = varargin{1}(1);
  82.         p = get(axe,'currentpoint');
  83.         new_thresh = p(1,1);
  84.         sli_sel = varargin{1}(5);
  85.         min_sli = get(sli_sel,'Min');
  86.         max_sli = get(sli_sel,'Max');
  87.         new_thresh = max(min_sli,min(new_thresh,max_sli));
  88.         xnew = [new_thresh new_thresh];
  89.         xold = get(varargin{1}(4),'Xdata');
  90.         if isequal(xold,xnew) , return; end
  91.         [new_rl2scr,new_n0scr,new_thresh_BIS] = ...
  92.                 key2info(varargin{1}(2),varargin{1}(3),new_thresh,'T');
  93.         if new_rl2scr~=100 ,  new_thresh = new_thresh_BIS; end
  94.         set(varargin{1}(4),'Xdata',xnew);
  95.         set(sli_sel,'value',new_thresh);
  96.         set(varargin{1}(6),'string',sprintf('%1.4g',new_thresh));
  97.         set(varargin{1}(7),'string',sprintf('%5.2f',new_rl2scr));
  98.         set(varargin{1}(8),'string',sprintf('%5.2f',new_n0scr));
  99.     case 'up'
  100.         % in2 = [ axe_perf ;  
  101.         %         lin_norm ; lin_zero ; lin_perf ; ...
  102.         %         sli_sel ;  edi_sel ; edi_nor ; edi_zer ];
  103.         %--------------------------------------------------
  104.         save_WindowButtonUpFcn = wtbxappdata('del',fig,'save_WindowButtonUpFcn');
  105.         set(fig,'WindowButtonMotionFcn','wtmotion',...
  106. 'WindowButtonUpFcn',save_WindowButtonUpFcn);
  107.         set(varargin{1}(4),'Color',wtbutils('colors','linTHR'));
  108.         drawnow;
  109.     case 'create'
  110.         % Get Globals.
  111.         %--------------
  112.         [Def_Txt_Height,Def_Btn_Height,Def_Btn_Width,Pop_Min_Width, ...
  113.          X_Spacing,Y_Spacing,sliYProp,Def_FraBkColor,Def_EdiBkColor] = ...
  114.             mextglob('get',...
  115.                 'Def_Txt_Height','Def_Btn_Height','Def_Btn_Width',   ...
  116.                 'Pop_Min_Width','X_Spacing','Y_Spacing','Sli_YProp', ...
  117.                 'Def_FraBkColor','Def_EdiBkColor');
  118.         % Defaults.
  119.         %----------
  120.         xleft = Inf; xright  = Inf; xloc = Inf;
  121.         ytop  = Inf; ybottom = Inf; yloc = Inf;
  122.         bkColor = Def_FraBkColor;
  123.         enaVal = 'off';
  124.         visVal = 'on';
  125.         isbior = 0;
  126.         toolOPT = 'dw1dcomp';
  127.         % Inputs.
  128.         %--------        
  129.         nbarg = length(varargin);
  130.         for k=1:2:nbarg
  131.             arg = lower(varargin{k});
  132.             switch arg
  133.               case 'left'    , xleft   = varargin{k+1};
  134.               case 'right'   , xright  = varargin{k+1};
  135.               case 'xloc'    , xloc    = varargin{k+1};
  136.               case 'bottom'  , ybottom = varargin{k+1};
  137.               case 'top'     , ytop    = varargin{k+1};
  138.               case 'yloc'    , yloc    = varargin{k+1};
  139.               case 'bkcolor' , bkColor = varargin{k+1};
  140.               case 'visible' , visVal  = varargin{k+1};
  141.               case 'isbior'  , isbior  = varargin{k+1};
  142.               case 'toolopt' , toolOPT = varargin{k+1};
  143.             end 
  144.         end
  145.         % Structure initialization.
  146.         %--------------------------
  147.         ud = struct(...
  148.                 'toolOPT',toolOPT, ...
  149.                 'visible',lower(visVal),...
  150.                 'isbior',isbior, ...
  151.                 'handlesUIC',[], ...
  152.                 'handlesOBJ',[], ...
  153.                 'handleORI' ,[], ... 
  154.                 'handleTHR' ,[], ... 
  155.                 'handleRES' ,[]  ... 
  156.                 );
  157.         % Figure units.
  158.         %--------------
  159.         str_numfig = num2mstr(fig);
  160.         old_units  = get(fig,'units');
  161.         fig_units  = 'pixels';
  162.         if ~isequal(old_units,fig_units), set(fig,'units',fig_units); end       
  163.         % Positions utilities.
  164.         %---------------------
  165.         dx = X_Spacing; bdx = 3;
  166.         dy = Y_Spacing; bdy = 4;       
  167.         d_txt  = (Def_Btn_Height-Def_Txt_Height);
  168.         deltaY = (Def_Btn_Height+dy);
  169.         d_lev  = 2;
  170.         sli_hi = Def_Btn_Height*sliYProp;
  171.         sli_dy = 0.5*Def_Btn_Height*(1-sliYProp);
  172.         txt_width = Def_Btn_Width;
  173.         dy_lev    = Def_Btn_Height+d_lev;
  174.         % Setting frame position.
  175.         %------------------------
  176.         w_fra   = wfigmngr('get',fig,'fra_width');
  177.         h_fra   = 6*Def_Btn_Height+5.5*bdy;
  178.                    
  179.         xleft   = utposfra(xleft,xright,xloc,w_fra);
  180.         ybottom = utposfra(ybottom,ytop,yloc,h_fra);
  181.         pos_fra = [xleft,ybottom,w_fra,h_fra];
  182.         % Position property.
  183.         %-------------------
  184.         xleft = xleft+bdx;
  185.         w_rem = w_fra-2*bdx;
  186.         ylow  = ybottom+h_fra-Def_Btn_Height-bdy;
  187.         w_uic       = (5*txt_width)/2;
  188.         x_uic       = xleft+(w_rem-w_uic)/2;
  189.         y_uic       = ylow;
  190.         pos_txt_top = [x_uic, y_uic+d_txt/2, w_uic, Def_Txt_Height];
  191.         y_uic       = y_uic-Def_Btn_Height;
  192.         pos_pop_met = [x_uic, y_uic, w_uic, Def_Btn_Height];
  193.         y_uic       = y_uic-Def_Btn_Height-bdy;
  194.         pos_txt_sel = [x_uic, y_uic+d_txt/2, w_uic, Def_Txt_Height];
  195.         y_uic       = y_uic-Def_Btn_Height;
  196.         wid1        = (15*w_rem)/26;
  197.         wid2        = (8*w_rem)/26;
  198.         wid3        = (2*w_rem)/26;
  199.         wx          = (w_rem-wid1-wid2-wid3)/4;
  200.         
  201.         pos_sli_sel = [xleft+wx, y_uic+sli_dy, wid1-wx, sli_hi];
  202.         x_uic       = pos_sli_sel(1)+pos_sli_sel(3)+wx;
  203.         pos_edi_sel = [x_uic, y_uic, wid2, Def_Btn_Height];
  204.         y_uic       = y_uic-Def_Btn_Height-bdy;        
  205.         pos_txt_nor = [xleft, y_uic+d_txt/2, wid1, Def_Txt_Height];
  206.         x_uic       = pos_txt_nor(1)+pos_txt_nor(3)+wx;
  207.         pos_edi_nor = [x_uic, y_uic, wid2, Def_Btn_Height];
  208.         x_uic       = pos_edi_nor(1)+pos_edi_nor(3)+wx;
  209.         pos_txt_npc = [x_uic, y_uic+d_txt/2, wid3, Def_Txt_Height];
  210.         y_uic       = y_uic-Def_Btn_Height-bdy;       
  211.         pos_txt_zer = [xleft, y_uic+d_txt/2, wid1, Def_Txt_Height];
  212.         x_uic       = pos_txt_zer(1)+pos_txt_zer(3)+wx;
  213.         pos_edi_zer = [x_uic, y_uic, wid2, Def_Btn_Height];
  214.         x_uic       = pos_edi_zer(1)+pos_edi_zer(3)+wx;
  215.         pos_txt_zpc = [x_uic, y_uic+d_txt/2, wid3, Def_Txt_Height];
  216.         w_uic = w_fra/2-bdx;
  217.         x_uic = pos_fra(1);
  218.         h_uic = (3*Def_Btn_Height)/2;
  219.         y_uic = pos_fra(2)-h_uic-Def_Btn_Height;     
  220.         pos_pus_est = [x_uic, y_uic, w_uic, h_uic];
  221.         x_uic = pos_fra(1)+w_uic+2*bdx;
  222.         pos_tog_res = [x_uic, y_uic, w_uic, h_uic];
  223.         % String property.
  224.         %-----------------
  225.         str_txt_top = 'Select thresholding method';
  226.         str_pop_met = wthrmeth(toolOPT,'names');
  227.         if ud.isbior
  228.             str_txt_nor = 'Norm cfs recovery';
  229.         else
  230.             str_txt_nor = 'Retained energy';
  231.         end
  232.         str_txt_sel = 'Select Global Threshold';
  233.         str_txt_zer = 'Number of zeros';
  234.         str_tog_res = 'Residuals';
  235.         str_pus_est = 'Compress';
  236.         % Create UIC.
  237.         %------------
  238.         comProp = {...
  239.            'Parent',fig,    ...
  240.            'Unit',fig_units ...
  241.            'Visible',visVal ...
  242.            };
  243.         commonTxtProp = {comProp{:}, ...
  244.             'Style','Text',...
  245.             'Backgroundcolor',Def_FraBkColor...
  246.             };        
  247.         commonEdiProp = {comProp{:}, ...
  248.             'Style','Edit',...
  249.             'String','',...
  250.             'Backgroundcolor',Def_EdiBkColor,...
  251.             'HorizontalAlignment','center'...
  252.             };        
  253.         fra_utl = uicontrol(comProp{:}, ...
  254.                             'Style','frame', ...
  255.                             'Position',pos_fra, ...
  256.                             'Backgroundcolor',bkColor, ...
  257.                             'Tag',tag_fra_tool ...
  258.                             );
  259.         txt_top = uicontrol(commonTxtProp{:},      ...
  260.                             'Position',pos_txt_top,...
  261.                             'HorizontalAlignment','center',...
  262.                             'String',str_txt_top   ...
  263.                             );
  264.         cba = [mfilename '(''update_methName'',' str_numfig ');'];
  265.         pop_met = uicontrol(comProp{:}, ...
  266.                             'Style','Popup',...
  267.                             'Position',pos_pop_met,...
  268.                             'String',str_pop_met,...
  269.                             'HorizontalAlignment','center',...
  270.                             'Userdata',1,...
  271.                             'Callback',cba ...
  272.                             );
  273.         txt_sel = uicontrol(commonTxtProp{:},      ...
  274.                             'Position',pos_txt_sel,...
  275.                             'HorizontalAlignment','center',...
  276.                             'String',str_txt_sel   ...
  277.                             );
  278.         cba_sli = [mfilename '(''updateTHR'',' str_numfig ',''sli'');'];
  279.         sli_sel = uicontrol(comProp{:}, ...
  280.                             'Style','Slider',...
  281.                             'Position',pos_sli_sel,...
  282.                             'Min',0,...
  283.                             'Max',1,...
  284.                             'Value',0.5, ...
  285.                             'Callback',cba_sli ...
  286.                             );
  287.         cba_edi = [mfilename '(''updateTHR'',' str_numfig ',''edi'');'];
  288.         edi_sel = uicontrol(commonEdiProp{:}, ...
  289.                             'Position',pos_edi_sel,...
  290.                             'Callback',cba_edi ...
  291.                             );
  292.         txt_nor = uicontrol(commonTxtProp{:}, ...
  293.                             'Position',pos_txt_nor,...
  294.                             'HorizontalAlignment','left',...
  295.                             'String',str_txt_nor...
  296.                             );
  297.         cba_nor = [mfilename '(''updateTHR'',' str_numfig ',''nor'');'];
  298.         edi_nor = uicontrol(commonEdiProp{:}, ...
  299.                             'Position',pos_edi_nor,...
  300.                             'Callback',cba_nor ...
  301.                             );
  302.         txt_npc = uicontrol(commonTxtProp{:}, ...
  303.                             'Position',pos_txt_npc,...
  304.                             'HorizontalAlignment','center',...
  305.                             'String','%'...
  306.                             );
  307.         txt_zer = uicontrol(commonTxtProp{:}, ...
  308.                             'Position',pos_txt_zer,...
  309.                             'HorizontalAlignment','left',...
  310.                             'String',str_txt_zer...
  311.                             );
  312.         cba_zer = [mfilename '(''updateTHR'',' str_numfig ',''zer'');'];
  313.         edi_zer = uicontrol(commonEdiProp{:}, ...
  314.                             'Position',pos_edi_zer,...
  315.                             'Callback',cba_zer ...
  316.                             );
  317.         txt_zpc = uicontrol(commonTxtProp{:}, ...
  318.                             'Position',pos_txt_zpc,...
  319.                             'HorizontalAlignment','center',...
  320.                             'String','%'...
  321.                             );
  322.  
  323.         cba = [mfilename '(''residuals'',' str_numfig ');'];
  324.         tip = 'More on Residuals';
  325.         tog_res = uicontrol(comProp{:},             ...
  326.                             'Style','Togglebutton', ...
  327.                             'Position',pos_tog_res, ...
  328.                             'String',str_tog_res,   ...
  329.                             'Enable','off',         ...
  330.                             'Callback',cba,         ...
  331.                             'tooltip',tip,          ...
  332.                             'Interruptible','On'    ...
  333.                             );
  334.         cba_pus_est = [mfilename '(''compress'',' str_numfig ');'];
  335.         pus_est = uicontrol(comProp{:},             ...
  336.                             'Style','Pushbutton',   ...
  337.                             'Position',pos_pus_est, ...
  338.                             'String',xlate(str_pus_est),   ...
  339.                             'callback',cba_pus_est  ...
  340.                             );
  341. % Add Context Sensitive Help (CSHelp).
  342. %-------------------------------------
  343.         hdl_COMP_DENO_STRA = [...
  344. fra_utl,txt_top,pop_met; ...
  345.             txt_sel,sli_sel,edi_sel  ...
  346. ];
  347.         hdl_COMP_SCORES = [...
  348.              txt_nor,edi_nor,txt_npc, ...
  349.              txt_zer,edi_zer,txt_zpc  ...
  350.   ];
  351. wfighelp('add_ContextMenu',fig,hdl_COMP_DENO_STRA,'COMP_DENO_STRA');
  352. wfighelp('add_ContextMenu',fig,hdl_COMP_SCORES,'COMP_SCORES');
  353. %-------------------------------------
  354. % Store handles.
  355. %--------------
  356. ud.handlesUIC = ...
  357.             [fra_utl;txt_top;pop_met; ...
  358.              txt_sel;sli_sel;edi_sel; ...
  359.              txt_nor;edi_nor;txt_npc; ...
  360.              txt_zer;edi_zer;txt_zpc; ...
  361.              tog_res;pus_est];
  362.         set(fra_utl,'Userdata',ud);
  363.         if nargout>0
  364.             varargout{1} = [pos_fra(1) , pos_pus_est(2) , pos_fra([3 4])];
  365.         end
  366.     case 'displayPerf'
  367.         % Displaying perfos.
  368.         %-------------------
  369.         [pos_axe_perf,pos_axe_legend, ...
  370.             thresh,n0scr,rl2scr,suggthr] = deal(varargin{:});
  371.         fig_units = get(fig,'units');
  372.         comAxeProp = {...
  373.           'Parent',fig, ...
  374.           'Units',fig_units, ...
  375.           'Drawmode','fast', ...
  376.           'Box','On' ...
  377.           };
  378.         [colLINE,colPERF,colZERO] = wtbutils('colors','legend');
  379.         axe_perf = axes(comAxeProp{:},'Position',pos_axe_perf);
  380.         epsx = 0.0001;
  381.         xlim = [-epsx    1.01*max(thresh)+epsx];
  382.         set(axe_perf,'Xlim',xlim,'Ylim',[0 104]);
  383.         lin_zero = line('Xdata',thresh,...
  384.                        'Ydata',n0scr,...
  385.                        'Color',colZERO,...
  386.                        'EraseMode','none',...
  387.                        'Parent',axe_perf);
  388.         lin_norm = line('Xdata',thresh,...
  389.                        'Ydata',rl2scr,...
  390.                        'Color',colPERF,...
  391.                        'EraseMode','none',...
  392.                        'Parent',axe_perf);
  393.         if max(n0scr)==min(n0scr)   , set(lin_zero,'Linewidth',2); end
  394.         if max(rl2scr)==min(rl2scr) , set(lin_norm,'Linewidth',2); end
  395.         lin_perf = line('Xdata',[suggthr suggthr],...
  396.                         'Ydata',[0.5 104],...
  397.                         'Color',colLINE,...
  398.                         'EraseMode','xor',...
  399.                         'linestyle',':',...
  400.                         'Parent',axe_perf);
  401.         setappdata(lin_perf,'selectPointer','V')
  402.         handles = [axe_perf ; lin_norm ; lin_zero ; lin_perf; ...
  403.                    sli_sel ; edi_sel ; edi_nor ; edi_zer        ...
  404.                    ];
  405.         argCbstr = [num2mstr(fig) ',' num2mstr(handles)];
  406.         cba_lin_perf = [mfilename '(''down'',' argCbstr ');'];
  407.         set(lin_perf,'ButtonDownFcn',cba_lin_perf);
  408.         % Displaying legend.
  409.         %-------------------
  410.         ftnsize = get(0,'DefaultAxesFontSize');
  411.         ud.dynvzaxe.enable = 'off';
  412.         axe_legend  = axes(comAxeProp{:}, ...
  413.                            'Position',pos_axe_legend,       ...
  414.                            'XTicklabelMode','manual',       ...
  415.                            'YTicklabelMode','manual',       ...
  416.                            'XTicklabel',[],'YTicklabel',[], ...
  417.                            'XTick',[],'YTick',[],           ...
  418.                            'Xlim',[0 180],                  ...
  419.                            'Ylim',[0 20],                   ...
  420.                            'Fontsize',ftnsize,              ...
  421.                            'Userdata',ud                    ...
  422.                            );
  423.         
  424.         line(...
  425.              'Parent',axe_legend,...
  426.              'Xdata',11:25,...
  427.              'Ydata',ones(1,15)*15,...
  428.              'LineStyle',':',...
  429.              'Color',colLINE);
  430.         line(...
  431.              'Parent',axe_legend,...
  432.              'Xdata',11:25,...
  433.              'Ydata',ones(1,15)*10,...
  434.              'Color',colPERF);
  435.         line(...
  436.              'Parent',axe_legend,...
  437.              'Xdata',11:25,...
  438.              'Ydata',ones(1,15)*5,...
  439.              'Color',colZERO);
  440.         text(30,15,'  Global threshold','Parent',axe_legend);
  441.         if ud.isbior
  442.             str_norm_txt = '  Norm coefs recovery in %';
  443.         else
  444.             str_norm_txt = '  Retained energy in %';
  445.         end
  446.         text(30,10,str_norm_txt,'Parent',axe_legend);
  447.         text(30,5,'  Number of zeros in %','Parent',axe_legend);
  448.         ud.handlesOBJ.axes  = [axe_perf ; axe_legend]; 
  449.         ud.handlesOBJ.lines = [lin_norm ; lin_zero ; lin_perf]; 
  450.         set(fra,'Userdata',ud);
  451.     case 'visible'
  452.         visVal     = lower(varargin{1});
  453.         ud.visible = visVal;
  454.         axe_datas = ud.handlesOBJ.axes;
  455.         handles = [findobj(axe_datas(:));handlesUIC(:)];
  456.         set(handles(ishandle(handles)),'visible',visVal);
  457.     case 'get'
  458.         nbarg = length(varargin);
  459.         if nbarg<1 , return; end
  460.         for k = 1:nbarg
  461.            outType = lower(varargin{k});
  462.            switch outType
  463.              case 'position'  , varargout{k} = get(fra,'Position');
  464.              case 'valthr'    , varargout{k} = get(sli_sel,'Value');
  465.              case 'handleori' , varargout{k} = ud.handleORI;
  466.              case 'handlethr' , varargout{k} = ud.handleTHR;
  467.              case 'handleres' , varargout{k} = ud.handleRES;
  468.              case 'handlesuic', varargout{k} = ud.handlesUIC;
  469.            end
  470.         end
  471.     case 'getPerfo'
  472.        lin_norm  = handlesOBJ.lines(1);
  473.        lin_zero  = handlesOBJ.lines(2);
  474.        threshold = get(sli_sel,'Value');
  475.        [varargout{1},varargout{2}] = key2info(lin_norm,lin_zero,threshold,'T');
  476.     case 'set'
  477.         nbarg = length(varargin);
  478.         if nbarg<1 , return; end
  479.         for k = 1:2:nbarg
  480.            argType = lower(varargin{k});
  481.            argVal  = varargin{k+1};
  482.            switch argType
  483.              case 'handleori' , ud.handleORI = argVal; set(fra,'Userdata',ud);
  484.              case 'handlethr' , ud.handleTHR = argVal; set(fra,'Userdata',ud);
  485.              case 'handleres' , ud.handleRES = argVal; set(fra,'Userdata',ud);
  486.              case 'thrbounds'
  487.                set(sli_sel,'Min',argVal(1),'Value',argVal(2),'Max',argVal(3));
  488.                set(edi_sel,'String',sprintf('%1.4g',argVal(2)));
  489.              case 'perfo'
  490.                set(edi_nor,'String',sprintf('%5.2f',argVal(1)));
  491.                set(edi_zer,'String',sprintf('%5.2f',argVal(2)));
  492.            end
  493.         end
  494.     case 'compress'
  495.         feval(calledFUN,'compress',fig);
  496.     case 'update_by_Caller'
  497.         feval(calledFUN,'update_GBL_meth',fig);
  498.     case 'get_GBL_par'
  499.         numMeth = get(pop_met,'value');
  500.         meth    = wthrmeth(toolOPT,'shortnames',numMeth);
  501.         varargout = {numMeth , meth , get(sli_sel,'Value')};
  502.     case 'update_GBL_meth'
  503.         % called by : calledFUN('update_GBL_meth', ...)
  504.         %------------------------------------------------
  505.         valTHR = varargin{1};
  506.         utthrgbl('updateTHR',fig,'meth',valTHR);
  507.     case 'enable_tog_res'
  508.         enaVal = varargin{1};
  509.         set(tog_res,'Enable',enaVal);
  510.     case 'update_methName'
  511.         utthrgbl('update_by_Caller',fig)
  512.     case 'updateTHR'
  513.         upd_orig = varargin{1};
  514.         lin_norm = handlesOBJ.lines(1);
  515.         lin_zero = handlesOBJ.lines(2);
  516.         lin_perf = handlesOBJ.lines(3);
  517.         % Updating compression information.
  518.         %----------------------------------
  519.         count = 0; err = '';
  520.         switch upd_orig
  521.            case 'sli' , % Default
  522.            case 'edi'
  523.              keytype = 'T';
  524.              valstr = get(edi_sel,'string');
  525.              [keyval,count,err] = sscanf(valstr,'%f');
  526.            case 'nor'
  527.              keytype = 'N';
  528.              valstr = get(edi_nor,'string');
  529.              [keyval,count,err] = sscanf(valstr,'%f');
  530.            case 'zer'
  531.              keytype = 'Z';
  532.              valstr = get(edi_zer,'string');
  533.              [keyval,count,err] = sscanf(valstr,'%f');
  534.            case 'meth'
  535.              keytype = 'T';
  536.              keyval  = varargin{2};
  537.              count  = 1;
  538.         end
  539.         if (count~=1) | ~isempty(err)
  540.             keytype = 'T';
  541.             keyval = get(sli_sel,'Value');
  542.         end
  543.         [new_rl2scr,new_n0scr,new_thresh] = ...
  544.                         key2info(lin_norm,lin_zero,keyval,keytype);
  545.         set(sli_sel,'value',new_thresh);
  546.         set(edi_sel,'string',sprintf('%1.4g',new_thresh));
  547.         set(edi_nor,'string',sprintf('%5.2f',new_rl2scr));
  548.         set(edi_zer,'string',sprintf('%5.2f',new_n0scr));
  549.         xold = get(lin_perf,'Xdata');
  550.         xnew = [new_thresh new_thresh];
  551.         if ~isequal(xold,xnew)
  552.             set(lin_perf,'Xdata',xnew);
  553.             feval(calledFUN,'clear_GRAPHICS',fig);
  554.         end
  555.     case 'residuals'
  556.         [handleORI,handleTHR,handleRES] = ...
  557.             utthrgbl('get',fig,'handleORI','handleTHR','handleRES');
  558.         wmoreres('create',fig,tog_res,handleRES,handleORI,handleTHR,'blocPAR');
  559.     otherwise
  560.         errargt(mfilename,'Unknown Option','msg');
  561.         error('*');
  562. end
  563. %=============================================================================%
  564. % INTERNAL FUNCTIONS
  565. %=============================================================================%
  566. %-----------------------------------------------------------------------------%
  567. function varargout = wthrmeth(toolOPT,varargin)
  568. switch toolOPT
  569.   case {'dw1dcomp','wp1dcomp'}
  570.     thrMethods = {...
  571.         'Balance sparsity-norm',       'bal_sn',       1; ...
  572.         'Remove near 0',               'rem_n0',       2  ...
  573.         };
  574.   case {'dw2dcomp','wp2dcomp'}
  575.     thrMethods = {...
  576.         'Balance sparsity-norm',       'bal_sn',       1; ...
  577.         'Remove near 0',               'rem_n0',       2; ...
  578.         'Bal. sparsity-norm (sqrt)',   'sqrtbal_sn',   3  ...
  579.         };
  580. end
  581. nbin = length(varargin);
  582. if nbin==0 , varargout{1} = thrMethods; return; end
  583. option = varargin{1};
  584. switch option
  585.   case 'names'
  586.      out = strvcat(1,thrMethods{:,1});
  587.      varargout{1} = out(2:end,:);
  588.      if nbin==2
  589.          num = varargin{2};
  590.          varargout{1} = deblank(varargout{1}(num,:));
  591.      end
  592.   case 'shortnames'
  593.      out = strvcat(1,thrMethods{:,2});
  594.      varargout{1} = out(2:end,:);
  595.      if nbin==2
  596.          num = varargin{2};
  597.          varargout{1} = deblank(varargout{1}(num,:));
  598.      end
  599.   case 'nums'
  600.      varargout{1} = cat(1,thrMethods{:,3});
  601. end
  602. %-----------------------------------------------------------------------------%
  603. %=============================================================================%