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

波变换

开发平台:

Matlab

  1. function varargout = utthrw1d(option,fig,varargin)
  2. %UTTHRW1D Utilities for wavelet thresholding 1-D.
  3. %   VARARGOUT = UTTHRW1D(OPTION,FIG,VARARGIN)
  4. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 01-Jun-98.
  5. %   Last Revision: 22-May-2003.
  6. %   Copyright 1995-2004 The MathWorks, Inc.
  7. %   $Revision: 1.11.4.2 $  $Date: 2004/03/15 22:42:11 $
  8. % MemBloc of stored values.
  9. %--------------------------
  10. n_memblocTHR   = 'MB_ThrStruct';
  11. ind_thr_struct = 1;
  12. ind_int_thr    = 2;
  13. % Default values.
  14. %----------------
  15. max_lev_anal = 12;
  16. def_lev_anal = 5;
  17. % Tag property of objects.
  18. %-------------------------
  19. tag_fra_tool   = ['Fra_' mfilename];
  20. tag_lineH_up   = 'LH_u';
  21. tag_lineH_down = 'LH_d';
  22. tag_lineV      = 'LV';
  23. switch option
  24.   case {'create'}
  25.   otherwise
  26.     % ud.handlesUIC = ...
  27.     %   [fra_utl;txt_top;pop_met; ...
  28.     %    rad_sof;rad_har;txt_noi;pop_noi; ...
  29.     %    txt_BMS;sli_BMS;txt_tit(1:4),...
  30.     %    txt_nor;edi_nor;txt_npc; ...
  31.     %    txt_zer;edi_zer;txt_zpc; ...
  32.     %    tog_thr;tog_res;pus_est];
  33.     %-----------------------------------------
  34.     if ~ishandle(fig) , varargout{1} = []; return; end
  35.     uic = findobj(get(fig,'Children'),'flat','type','uicontrol');
  36.     fra = findobj(uic,'style','frame','tag',tag_fra_tool);
  37.     if isempty(fra) , return; end
  38.     calledFUN = wfigmngr('getWinPROP',fig,'calledFUN');
  39.     ud  = get(fra,'Userdata');
  40.     toolOPT = ud.toolOPT;
  41.     toolStatus = ud.status;
  42.     handlesUIC = ud.handlesUIC;
  43.     h_CMD_LVL  = ud.h_CMD_LVL;
  44.     h_GRA_LVL  = ud.h_GRA_LVL;
  45.     switch option
  46.       case 'handles'
  47.         handles = [handlesUIC(:);h_CMD_LVL(:)];
  48.         varargout{1} = handles(ishandle(handles));
  49.         return;
  50.       case {'handlesUIC','handlesuic'}
  51.         varargout{1} = handlesUIC;
  52.         return;
  53.       case {'h_CMD_LVL','h_cmd_lvl'}
  54.         varargout{1} = h_CMD_LVL;
  55.         return;
  56.     end
  57.     ind = 2;
  58.     txt_top = handlesUIC(ind); ind = ind+1;
  59.     pop_met = handlesUIC(ind); ind = ind+1;
  60.     rad_sof = handlesUIC(ind); ind = ind+1;
  61.     rad_har = handlesUIC(ind); ind = ind+1;
  62.     txt_noi = handlesUIC(ind); ind = ind+1;
  63.     pop_noi = handlesUIC(ind); ind = ind+1;
  64.     txt_BMS = handlesUIC(ind); ind = ind+1;  
  65.     sli_BMS = handlesUIC(ind); ind = ind+1;
  66.     txt_tit(1:4) = handlesUIC(ind:ind+3); ind = ind+4;
  67.     txt_nor = handlesUIC(ind); ind = ind+1;
  68.     edi_nor = handlesUIC(ind); ind = ind+1;
  69.     txt_npc = handlesUIC(ind); ind = ind+1;
  70.     txt_zer = handlesUIC(ind); ind = ind+1;
  71.     edi_zer = handlesUIC(ind); ind = ind+1;
  72.     txt_zpc = handlesUIC(ind); ind = ind+1;
  73.     tog_thr = handlesUIC(ind); ind = ind+1;
  74.     tog_res = handlesUIC(ind); ind = ind+1;
  75.     pus_est = handlesUIC(ind); ind = ind+1;
  76. end
  77. switch option
  78.     case 'create'
  79.         % Get Globals.
  80.         %--------------
  81.         [Def_Txt_Height,Def_Btn_Height,Def_Btn_Width,Pop_Min_Width, ...
  82.          X_Spacing,Y_Spacing,sliYProp,...
  83.          Def_FraBkColor,Def_EdiBkColor] = ...
  84.             mextglob('get',...
  85.                 'Def_Txt_Height','Def_Btn_Height','Def_Btn_Width',   ...
  86.                 'Pop_Min_Width','X_Spacing','Y_Spacing','Sli_YProp', ...
  87.                 'Def_FraBkColor','Def_EdiBkColor'   ...
  88.                 );
  89.         % Defaults.
  90.         %----------
  91.         xleft = Inf; xright  = Inf; xloc = Inf;
  92.         ytop  = Inf; ybottom = Inf; yloc = Inf;
  93.         bkColor = Def_FraBkColor;
  94.         enaVal  = 'Off';
  95.         %------------------------
  96.         ydir   = -1;
  97.         levmin = 1;
  98.         levmax = def_lev_anal;
  99.         levmaxMAX = max_lev_anal;
  100.         levANAL = def_lev_anal;
  101.         visVal = 'on';
  102.         isbior = 0;
  103.         statusINI = 'On';
  104.         toolOPT   = 'deno';
  105.         %------------------------
  106.         % Inputs.
  107.         %--------        
  108.         nbarg = length(varargin);
  109.         for k=1:2:nbarg
  110.             arg = lower(varargin{k});
  111.             switch arg
  112.               case 'left'     , xleft     = varargin{k+1};
  113.               case 'right'    , xright    = varargin{k+1};
  114.               case 'xloc'     , xloc      = varargin{k+1};
  115.               case 'bottom'   , ybottom   = varargin{k+1};
  116.               case 'top'      , ytop      = varargin{k+1};
  117.               case 'yloc'     , yloc      = varargin{k+1};
  118.               case 'bkcolor'  , bkColor   = varargin{k+1};
  119.               case 'visible'  , visVal    = varargin{k+1};
  120.               case 'enable'   , enaVal    = varargin{k+1};
  121.               case 'isbior'   , isbior    = varargin{k+1};
  122.               case 'ydir'     , ydir      = varargin{k+1};
  123.               case 'levmin'   , levmin    = varargin{k+1};
  124.               case 'levmax'   , levmax    = varargin{k+1};
  125.               case 'levmaxmax', levmaxMAX = varargin{k+1};
  126.               case 'levanal'  , levANAL   = varargin{k+1};
  127.               case 'status'   , statusINI = varargin{k+1};
  128.               case 'toolopt'  , toolOPT   = varargin{k+1};
  129.             end 
  130.         end
  131.         % Structure initialization.
  132.         %--------------------------
  133.         % h_CMD_LVL: [txt_lev ; pop_int; sli_lev ; edi_lev] x Level
  134.         % h_GRA_LVL: [axe_thr ; lin_min ; lin_max] x Level
  135.         h_CMD_LVL = NaN*ones(4,levmaxMAX);        
  136.         h_GRA_LVL = NaN*ones(3,levmaxMAX);
  137.         thrStruct = struct(...
  138.                         'thrParams',cell(levmaxMAX,1), ...
  139.                         'hdlLines',cell(levmaxMAX,1)   ...                        '
  140.                         );
  141.         wmemtool('wmb',fig,n_memblocTHR, ...
  142.                   ind_thr_struct,thrStruct,ind_int_thr,[]);
  143.         ud = struct(...
  144.                 'toolOPT',toolOPT, ...
  145.                 'status',statusINI,...
  146.                 'levmin',levmin, ...
  147.                 'levmax',levmax, ...
  148.                 'levmaxMAX',levmaxMAX, ...
  149.                 'levANAL',levANAL, ...
  150.                 'visible',lower(visVal),...
  151.                 'ydir', ydir,    ...
  152.                 'isbior',isbior, ...
  153.                 'handlesUIC',[], ...
  154.                 'h_CMD_LVL',h_CMD_LVL, ...
  155.                 'h_GRA_LVL',h_GRA_LVL, ...
  156.                 'handleORI' ,[], ... 
  157.                 'handleTHR',[],  ... 
  158.                 'handleRES' ,[]  ... 
  159.                 );
  160.         % Figure units.
  161.         %--------------
  162.         str_numfig = num2mstr(fig);
  163.         old_units  = get(fig,'units');
  164.         fig_units  = 'pixels';
  165.         if ~isequal(old_units,fig_units), set(fig,'units',fig_units); end       
  166.         % Positions utilities.
  167.         %---------------------
  168.         nblevs = abs(levmax-levmin)+1;        
  169.         dx = X_Spacing; bdx = 3;
  170.         dy = Y_Spacing; 
  171.         d_txt  = (Def_Btn_Height-Def_Txt_Height);
  172.         deltaY = (Def_Btn_Height+dy);
  173.         [bdy,d_lev] = get_DLEV(nblevs,toolOPT);
  174.         sli_hi = Def_Btn_Height*sliYProp;
  175.         sli_dy = 0.5*Def_Btn_Height*(1-sliYProp);
  176.         % Setting frame position.
  177.         %------------------------
  178.         if ~isequal(toolOPT,'esti_DEN') , multiY = 1; else , multiY = 1; end
  179.         switch  toolOPT
  180.           case {'deno','esti'} , NB_Height = 6;
  181.           case {'esti_REG'}    , NB_Height = 6;
  182.           case {'esti_DEN'}    , NB_Height = 4+2*multiY;
  183.           case {'comp'}        , NB_Height = 7;
  184.         end
  185.         w_fra   = wfigmngr('get',fig,'fra_width');
  186.         h_fra   = (levmaxMAX+NB_Height)*Def_Btn_Height+...
  187.                    levmaxMAX*d_lev+ ...
  188.                    depOfMachine(Def_Btn_Height)+(NB_Height-1)*bdy;
  189.         xleft   = utposfra(xleft,xright,xloc,w_fra);
  190.         ybottom = utposfra(ybottom,ytop,yloc,h_fra);
  191.         pos_fra = [xleft,ybottom,w_fra,h_fra];
  192.         % String properties.
  193.         %-------------------
  194.         str_txt_top = 'Select thresholding method';
  195.         str_txt_BMS = '-       Sparsity       +';
  196.         str_txt_tit = strvcat('Lev','Int','Select','Thresh');
  197.         str_tog_thr = ['Int. dependent threshold settings'];
  198.         str_tog_res = 'Residuals';
  199.         str_pop_met = wthrmeth(toolOPT,'names');
  200.         switch  toolOPT
  201.           case {'deno','esti','esti_REG'}
  202.             str_rad_sof = 'soft';
  203.             str_rad_har = 'hard';
  204.             str_txt_noi = 'Select noise structure';
  205.             str_pop_noi = strvcat(...
  206.                 'Unscaled white noise', ...
  207.                 'Scaled white noise',   ...
  208.                 'Non-white noise'       ...
  209.                 );
  210.           case {'esti_DEN'}
  211.             str_rad_sof = 'soft';
  212.             str_rad_har = 'hard';
  213.             str_txt_noi = 'Select noise structure';
  214.             str_pop_noi = strvcat(...
  215.                 'Unscaled white noise', ...
  216.                 'Scaled white noise',   ...
  217.                 'Non-white noise'       ...
  218.                 );
  219.           case 'comp'
  220.             if ud.isbior
  221.                 str_txt_nor = 'Norm cfs recovery';
  222.             else
  223.                 str_txt_nor = 'Retained energy';
  224.             end
  225.             str_txt_zer = 'Number of zeros';
  226.         end
  227.         switch  toolOPT
  228.           case 'deno' , str_pus_est = 'De-noise'; estOPT = 'denoise';
  229.           case 'comp' , str_pus_est = 'Compress'; estOPT = 'compress';
  230.           case {'esti','esti_REG','esti_DEN'} ,
  231.                         str_pus_est = 'Estimate'; estOPT = 'estimate';
  232.         end
  233.         % Position properties.
  234.         %---------------------
  235.         txt_width   = Def_Btn_Width;
  236.         dy_lev      = Def_Btn_Height+d_lev;
  237.         xleft       = xleft+bdx;
  238.         w_rem       = w_fra-2*bdx;
  239.         ylow        = ybottom+h_fra-Def_Btn_Height-bdy;
  240.         w_uic       = (5*txt_width)/2;
  241.         x_uic       = xleft+(w_rem-w_uic)/2;
  242.         y_uic       = ylow;
  243.         pos_txt_top = [x_uic, y_uic+d_txt/2, w_uic, Def_Txt_Height];
  244.         y_uic       = y_uic-Def_Btn_Height;
  245.         pos_pop_met = [x_uic, y_uic, w_uic, Def_Btn_Height];
  246.         y_uic       = y_uic-Def_Btn_Height;
  247.         switch toolOPT
  248.           case {'deno','esti','esti_REG','esti_DEN'}
  249.             y_uic       = y_uic-bdy;
  250.             w_rad       = Pop_Min_Width;
  251.             w_sep       = (w_uic-2*w_rad)/3;
  252.             x_rad       = x_uic+w_sep;
  253.             pos_rad_sof = [x_rad, y_uic, w_rad, Def_Btn_Height];
  254.             x_rad       = x_rad+w_rad+w_sep;
  255.             pos_rad_har = [x_rad, y_uic, w_rad, Def_Btn_Height];
  256.             y_uic       = y_uic-multiY*Def_Btn_Height;
  257.             y_BMS       = y_uic;
  258.             pos_txt_noi = [x_uic, y_uic, w_uic, Def_Txt_Height];
  259.             y_uic       = y_uic-multiY*Def_Btn_Height;
  260.             pos_pop_noi = [x_uic, y_uic, w_uic, Def_Btn_Height];
  261.           case 'comp'
  262.             y_BMS       = y_uic;
  263.             y_uic       = y_uic-Def_Btn_Height;
  264.         end
  265.         pos_txt_BMS = [x_uic, y_BMS, w_uic, Def_Txt_Height];
  266.         y_BMS       = y_BMS-multiY*Def_Btn_Height;
  267.         w_BMS       = (w_uic-bdx)/3;
  268.         pos_sli_BMS = [x_uic+w_BMS/2, y_BMS+sli_dy, 2*w_BMS, sli_hi];
  269.         wx          = 2;
  270.         wbase       = 2*(w_rem-5*wx)/5;
  271.         w_lev       = [4*wbase ; 7*wbase ; 12*wbase ; 7*wbase]/12;
  272.         x_uic       = xleft+wx;
  273.         y_uic       = y_uic-Def_Btn_Height;
  274.         pos_lev_tit = [x_uic, y_uic, w_lev(1), Def_Txt_Height];
  275.         pos_lev_tit = pos_lev_tit(ones(1,4),:);
  276.         pos_lev_tit(:,3) = w_lev; 
  277.         for k=1:3 , pos_lev_tit(k+1,1) = pos_lev_tit(k,1)+pos_lev_tit(k,3); end
  278.         y_uic = pos_lev_tit(1,2)-levmaxMAX*(Def_Btn_Height+d_lev);
  279.         switch  toolOPT
  280.           case {'deno','esti','esti_REG','esti_DEN'}
  281.           case {'comp'}
  282.             wid1 = (15*w_rem)/26;
  283.             wid2 = (8*w_rem)/26;
  284.             wid3 = (2*w_rem)/26;
  285.             wx   = (w_rem-wid1-wid2-wid3)/4;
  286.             y_uic       = y_uic-Def_Btn_Height-bdy;
  287.             pos_txt_nor = [xleft, y_uic+d_txt/2, wid1, Def_Txt_Height];
  288.             x_uic       = pos_txt_nor(1)+pos_txt_nor(3)+wx;
  289.             pos_edi_nor = [x_uic, y_uic, wid2, Def_Btn_Height];
  290.             x_uic       = pos_edi_nor(1)+pos_edi_nor(3)+wx;
  291.             pos_txt_npc = [x_uic, y_uic+d_txt/2, wid3, Def_Txt_Height];
  292.             y_uic       = y_uic-Def_Btn_Height-bdy;
  293.             pos_txt_zer = [xleft, y_uic+d_txt/2, wid1, Def_Txt_Height];
  294.             x_uic       = pos_txt_zer(1)+pos_txt_zer(3)+wx;
  295.             pos_edi_zer = [x_uic, y_uic, wid2, Def_Btn_Height];
  296.             x_uic       = pos_edi_zer(1)+pos_edi_zer(3)+wx;
  297.             pos_txt_zpc = [x_uic, y_uic+d_txt/2, wid3, Def_Txt_Height];
  298.         end
  299.         w_uic = w_rem-2*bdx;
  300.         x_uic = xleft+bdx;
  301.         h_uic = depOfMachine(Def_Btn_Height);        
  302.         y_uic = y_uic-2*bdy-h_uic;
  303.         pos_tog_thr = [x_uic, y_uic, w_uic, h_uic];
  304.         w_uic = w_fra/2-bdx;
  305.         x_uic = pos_fra(1);
  306.         h_uic = (3*Def_Btn_Height)/2;
  307.         y_uic = pos_fra(2)-h_uic-Def_Btn_Height/2;     
  308.         pos_pus_est = [x_uic, y_uic, w_uic, h_uic];
  309.         x_uic = x_uic+w_uic+2*bdx;
  310.         pos_tog_res = [x_uic, y_uic, w_uic, h_uic];
  311.         % Create UIC.
  312.         %------------
  313.         comProp = {...
  314.            'Parent',fig,    ...
  315.            'Unit',fig_units ...
  316.            'Visible','Off'  ...
  317.            };
  318.         comTxtProp = {comProp{:}, ...
  319.            'Style','Text',...
  320.            'HorizontalAlignment','center', ...
  321.            'Backgroundcolor',bkColor ...
  322.            };
  323.         fra_utl = uicontrol(comProp{:}, ...
  324.                             'Style','frame', ...
  325.                             'Position',pos_fra, ...
  326.                             'Backgroundcolor',bkColor, ...
  327.                             'Tag',tag_fra_tool ...
  328.                             );
  329.         txt_top = uicontrol(comProp{:}, ...
  330.                             'Style','Text', ...
  331.                             'Position',pos_txt_top,   ...
  332.                             'String',str_txt_top,     ...
  333.                             'Backgroundcolor',bkColor ...
  334.                             );
  335.         cba = [mfilename '(''update_methName'',' str_numfig ');'];
  336.         pop_met = uicontrol(comProp{:}, ...
  337.                             'Style','Popup',...
  338.                             'Position',pos_pop_met,...
  339.                             'Enable',statusINI, ...
  340.                             'String',str_pop_met,...
  341.                             'HorizontalAlignment','center',...
  342.                             'Userdata',1,...
  343.                             'Callback',cba ...
  344.                             );
  345.         switch toolOPT
  346.           case {'deno','esti','esti_REG','esti_DEN'}
  347.             rad_sof = uicontrol(comProp{:}, ...
  348.                                 'Style','RadioButton',...
  349.                                 'Position',pos_rad_sof,...
  350.                                 'Enable',statusINI, ...
  351.                                 'HorizontalAlignment','center',...
  352.                                 'String',str_rad_sof,...
  353.                                 'Value',1,'Userdata',1 ...
  354.                                 );
  355.             rad_har = uicontrol(comProp{:}, ...
  356.                                 'Style','RadioButton',...
  357.                                 'Position',pos_rad_har,...
  358.                                 'Enable',statusINI, ...
  359.                                 'HorizontalAlignment','center',...
  360.                                 'String',str_rad_har,...
  361.                                 'Value',0,'Userdata',0 ...
  362.                                 );
  363.             cba = [mfilename '(''update_thrType'',' str_numfig ');'];
  364.             set(rad_sof,'Callback',cba);
  365.             set(rad_har,'Callback',cba);
  366.             txt_noi = uicontrol(comProp{:}, ...
  367.                                 'Style','Text',...
  368.                                 'Position',pos_txt_noi,...
  369.                                 'Backgroundcolor',bkColor,...
  370.                                 'String',str_txt_noi...
  371.                                 );
  372.             cba = [mfilename '(''update_by_Caller'',' str_numfig ');'];
  373.             pop_noi = uicontrol(comProp{:}, ...
  374.                                 'Style','Popup',...
  375.                                 'Position',pos_pop_noi,...
  376.                                 'Enable',statusINI, ...
  377.                                 'String',str_pop_noi,...
  378.                                 'HorizontalAlignment','center',...
  379.                                 'Userdata',1,...
  380.                                 'Callback',cba ...
  381.                                 );
  382.           case {'comp'}
  383.         end
  384.         txt_BMS = uicontrol(comProp{:}, ...
  385.                             'Style','Text',...
  386.                             'Position',pos_txt_BMS,...
  387.                             'Backgroundcolor',bkColor,...
  388.                             'String',str_txt_BMS...
  389.                             );
  390.         cba = [mfilename '(''update_by_Caller'',' str_numfig ');'];
  391.         sli_BMS = uicontrol(comProp{:}, ...
  392.                             'Style','Slider',...
  393.                             'Position',pos_sli_BMS,...
  394.                             'Enable',statusINI,    ...
  395.                             'Min',1+sqrt(eps),     ...
  396.                             'Max',5-sqrt(eps),     ...
  397.                             'Value',1.5,           ...
  398.                             'Backgroundcolor',bkColor, ...
  399.                             'Callback',cba         ...
  400.                             );
  401.         txt_tit = zeros(4,1);
  402.         for k=1:4
  403.             txt_tit(k) = uicontrol(...
  404.                                    comTxtProp{:}, ...
  405.                                    'Position',pos_lev_tit(k,:), ...
  406.                                    'String',deblank(str_txt_tit(k,:))...
  407.                                    );
  408.         end
  409.         xbtn0 = xleft;
  410.         ybtn0 = pos_lev_tit(1,2)-Def_Btn_Height;
  411.         xbtn  = xbtn0;
  412.         ybtn  = ybtn0;
  413.         if ud.ydir==1
  414.             index = [1:levmaxMAX];
  415.         else
  416.             index = [levmaxMAX:-1:1];
  417.             ybtn  = ybtn0+(levmaxMAX-levmax)*dy_lev;
  418.         end
  419.         for j=1:length(index)
  420.             i = index(j);
  421.             max_lev = 1;
  422.             val_lev = 0.5;
  423.             pos_lev = [xbtn ybtn+d_txt/2 w_lev(1) Def_Txt_Height];
  424.             str_lev = sprintf('%.0f',i);
  425.             txt_lev = uicontrol(...
  426.                          comTxtProp{:},     ...
  427.                          'Position',pos_lev,...
  428.                          'String',str_lev,  ...
  429.                          'Userdata',i       ...
  430.                          );
  431.             xbtn      = xbtn+w_lev(1)+wx;
  432.             pos_lev = [xbtn ybtn w_lev(2) Def_Btn_Height];
  433.             pop_lev = uicontrol(...
  434.                          comProp{:}, ...
  435.                          'Style','popupmenu',...
  436.                          'Enable',enaVal,  ...
  437.                          'Position',pos_lev,...
  438.                          'String','1',...
  439.                          'Backgroundcolor',bkColor, ...
  440.                          'Userdata',i ...
  441.                          );
  442.             xbtn    = xbtn+w_lev(2)+wx;
  443.             pos_lev = [xbtn, ybtn+sli_dy, w_lev(3), sli_hi];
  444.             sli_lev = uicontrol(...
  445.                          comProp{:},         ...
  446.                          'Style','Slider',   ...
  447.                          'Enable',enaVal,    ...
  448.                          'Position',pos_lev, ...
  449.                          'Min',0,            ...
  450.                          'Max',max_lev,      ...
  451.                          'Value',val_lev,    ...
  452.                          'Userdata',i        ...
  453.                          );
  454.             xbtn    = xbtn+w_lev(3)+wx;
  455.             pos_lev = [xbtn ybtn w_lev(4) Def_Btn_Height];
  456.             str_val = sprintfLOC('%7.3f',val_lev);
  457.             edi_lev = uicontrol(...
  458.                          comProp{:},         ...
  459.                          'Style','Edit',     ...
  460.                          'Enable',enaVal,    ...
  461.                          'Position',pos_lev, ...
  462.                          'String',str_val,   ...
  463.                          'HorizontalAlignment','center',...
  464.                          'Backgroundcolor',Def_EdiBkColor,...
  465.                          'Userdata',i          ...
  466.                          );
  467.             beg_cba = [mfilename '(''update_by_UIC'',' str_numfig ',' str_lev];
  468.             cba_pop = [beg_cba ',''pop'');'];
  469.             cba_sli = [beg_cba ',''sli'');'];
  470.             cba_edi = [beg_cba ',''edi'');'];
  471.             set(pop_lev,'Callback',cba_pop);
  472.             set(sli_lev,'Callback',cba_sli);
  473.             set(edi_lev,'Callback',cba_edi);
  474.             h_CMD_LVL(:,i) = [txt_lev;pop_lev;sli_lev;edi_lev];
  475.             xbtn = xbtn0;
  476.             ybtn = ybtn-dy_lev;
  477.         end
  478.         switch  toolOPT
  479.           case {'deno','esti','esti_REG','esti_DEN'}
  480.           case {'comp'}
  481.             comEdiProp = {comProp{:}, ...
  482.                 'Style','Edit',...
  483.                 'String','',...
  484.                 'Enable','Inactive', ...
  485.                 'Backgroundcolor',bkColor,...
  486.                 'HorizontalAlignment','center'...
  487.                 };
  488.             txt_nor = uicontrol(comTxtProp{:}, ...
  489.                                 'Position',pos_txt_nor,...
  490.                                 'HorizontalAlignment','left',...
  491.                                 'String',str_txt_nor...
  492.                                 );
  493.             cba_nor = [mfilename '(''updateTHR'',' str_numfig ',''nor'');'];
  494.             edi_nor = uicontrol(comEdiProp{:}, ...
  495.                                 'Position',pos_edi_nor,...
  496.                                 'Callback',cba_nor ...
  497.                                 );
  498.             txt_npc = uicontrol(comTxtProp{:}, ...
  499.                                 'Position',pos_txt_npc,...
  500.                                 'String','%'...
  501.                                 );
  502.             txt_zer = uicontrol(comTxtProp{:}, ...
  503.                                 'Position',pos_txt_zer,...
  504.                                 'HorizontalAlignment','left',...
  505.                                 'String',str_txt_zer...
  506.                                 );
  507.             cba_zer = [mfilename '(''updateTHR'',' str_numfig ',''zer'');'];
  508.             edi_zer = uicontrol(comEdiProp{:}, ...
  509.                                 'Position',pos_edi_zer,...
  510.                                 'Callback',cba_zer ...
  511.                                 );
  512.             txt_zpc = uicontrol(comTxtProp{:}, ...
  513.                                 'Position',pos_txt_zpc,...
  514.                                 'String','%'...
  515.                                 );
  516.         end
  517.         cba = [mfilename '(''init_SetThr'',' str_numfig ');'];
  518.         tip = 'Interval dependent threshold Settings';
  519.         tog_thr = uicontrol(...
  520.                             comProp{:},             ...
  521.                             'Style','Togglebutton', ...
  522.                             'Position',pos_tog_thr, ...
  523.                             'String',str_tog_thr,   ...
  524.                             'Enable',enaVal,        ...
  525.                             'Callback',cba,         ...
  526.                             'tooltip',tip,          ...
  527.                             'Interruptible','Off'   ...
  528.                             );
  529.         cba = [mfilename '(''residuals'',' str_numfig ');'];
  530.         tip = 'More on Residuals';
  531.         tog_res = uicontrol(...
  532.                             comProp{:},             ...
  533.                             'Style','Togglebutton', ...
  534.                             'Position',pos_tog_res, ...
  535.                             'String',str_tog_res,   ...
  536.                             'Enable','off',         ...
  537.                             'Callback',cba,         ...
  538.                             'tooltip',tip,...
  539.                             'Interruptible','Off'   ...
  540.                             );
  541.         if isequal(toolOPT,'esti_DEN')
  542.            set(tog_res,'Visible','Off')
  543.            pos_pus_est(1) =  pos_pus_est(1)+pos_pus_est(3)/2;
  544.         end
  545.         cba_pus_est = [mfilename '(''' estOPT ''',' str_numfig ');'];
  546.         pus_est = uicontrol(comProp{:},             ...
  547.                             'Style','Pushbutton',   ...
  548.                             'Position',pos_pus_est, ...
  549.                             'String',xlate(str_pus_est),   ...
  550.                             'Enable',enaVal,        ...
  551.                             'callback',cba_pus_est  ...
  552.                             );
  553. % Add Context Sensitive Help (CSHelp).
  554. %-------------------------------------
  555.         switch  toolOPT
  556.           case {'deno','esti','esti_REG','esti_DEN'}
  557. hdl_DENO_SOFTHARD   = [rad_sof,rad_har];
  558. hdl_DENO_NOISSTRUCT = [txt_noi,pop_noi];
  559. wfighelp('add_ContextMenu',fig,hdl_DENO_SOFTHARD,'DENO_SOFTHARD');
  560. wfighelp('add_ContextMenu',fig,hdl_DENO_NOISSTRUCT,'DENO_NOISSTRUCT');
  561.           case {'comp'}
  562. hdl_COMP_SCORES = [...
  563. txt_nor,edi_nor,txt_npc,txt_zer,edi_zer,txt_zpc ...
  564. ];
  565. wfighelp('add_ContextMenu',fig,hdl_COMP_SCORES,'COMP_SCORES');
  566.         end
  567.         hdl_COMP_DENO_STRA = [...
  568. fra_utl,txt_top,pop_met,txt_BMS,sli_BMS,  ...
  569. ];
  570. hdl_IDTS_GUI = tog_thr;
  571. wfighelp('add_ContextMenu',fig,hdl_COMP_DENO_STRA,'COMP_DENO_STRA');
  572. wfighelp('add_ContextMenu',fig,hdl_IDTS_GUI,'IDTS_GUI');
  573. %-------------------------------------
  574. % Store handles.
  575. %--------------
  576. switch  toolOPT
  577.           case {'deno','esti','esti_REG'}
  578.             ud.handlesUIC = ...
  579.                 [fra_utl;txt_top;pop_met;...
  580.                 rad_sof;rad_har;txt_noi;pop_noi; ...
  581.                 txt_BMS;sli_BMS;txt_tit(1:4); ...
  582.                 NaN;NaN;NaN;NaN;NaN;NaN; ...
  583.                 tog_thr;tog_res;pus_est];
  584.           case {'esti_DEN'}
  585.             ud.handlesUIC = ...
  586.                 [fra_utl;txt_top;pop_met;...
  587.                 rad_sof;rad_har;txt_noi;pop_noi; ...
  588.                 txt_BMS;sli_BMS;txt_tit(1:4); ...
  589.                 NaN;NaN;NaN;NaN;NaN;NaN; ...
  590.                 tog_thr;tog_res;pus_est];
  591.           case {'comp'}
  592.             ud.handlesUIC = ...
  593.                 [fra_utl;txt_top;pop_met; ...
  594.                 NaN;NaN;NaN;NaN; ...
  595.                 txt_BMS;sli_BMS;txt_tit(1:4);...
  596.                 txt_nor;edi_nor;txt_npc;txt_zer;edi_zer;txt_zpc; ...
  597.                 tog_thr;tog_res;pus_est];
  598.         end
  599.         ud.h_CMD_LVL = h_CMD_LVL;
  600.         ud.h_GRA_LVL = h_GRA_LVL;
  601.         set(fra_utl,'Userdata',ud);
  602.         varargout{1} = utthrw1d('set',fig,'position',{levmin,levmax});
  603.     case {'denoise','compress','estimate'}
  604.         feval(calledFUN,option,fig);
  605.     case 'get_LVL_par'
  606.         numMeth = get(pop_met,'value');
  607.         meth    = wthrmeth(toolOPT,'shortnames',numMeth);
  608.         switch  toolOPT
  609.           case {'deno','esti','esti_REG'}
  610.              valType = get(rad_sof,'value');
  611.              if valType==1 , sorh = 's'; else , sorh = 'h'; end
  612.              switch numMeth
  613.                case {1,2,3,4}
  614.                  valNoise = get(pop_noi,'value');
  615.                  switch valNoise
  616.                    case 1 , scal = 'sln';
  617.                    case 2 , scal = 'one';
  618.                    case 3 , scal = 'mln';
  619.                  end
  620.                case {5,6,7}  , scal = get(sli_BMS,'value');
  621.              end
  622.              varargout = {numMeth,meth,scal,sorh};
  623.           case {'esti_DEN'}
  624.              valType = get(rad_sof,'value');
  625.              if valType==1 , sorh = 's'; else , sorh = 'h'; end
  626.              switch numMeth
  627.                case {1,2,3} , scal = [];
  628.                case {4}  , scal = get(sli_BMS,'value');
  629.              end
  630.              varargout = {numMeth,meth,scal,sorh};
  631.           case {'comp'}
  632.              sorh = 'h'; 
  633.              switch numMeth
  634.                case {1,2,3} , scal = get(sli_BMS,'value');
  635.                case {4,5}   , scal = NaN;
  636.              end
  637.              varargout = {numMeth,meth,scal,sorh};
  638.         end
  639.     case 'update_methName'
  640.         numMeth = get(pop_met,'value');
  641.         switch toolOPT
  642.           case {'deno','esti','esti_REG'}
  643.             HDL_1 = [txt_BMS;sli_BMS];
  644.             HDL_2 = [txt_noi;pop_noi];
  645.             switch numMeth
  646.               case {1,2,3,4}
  647.                 invis  = HDL_1;   vis = HDL_2;
  648.                 radDef = rad_sof; radNoDef = rad_har;
  649.               case {5,6,7}
  650.                 invis  = HDL_2;   vis = HDL_1;
  651.                 radDef = rad_har; radNoDef = rad_sof;
  652.             end
  653.             set(sli_BMS,'value',3)
  654.             set(invis,'Visible','off')
  655.             set(vis,'Visible','on')
  656.             set(radDef,'Value',1,'Userdata',1);
  657.             set(radNoDef,'Value',0,'Userdata',0);
  658.           case {'esti_DEN'}
  659.             switch numMeth
  660.               case {1,2,3}
  661.                 set([txt_noi;pop_noi;txt_BMS;sli_BMS],'Visible','off')
  662.                 radDef = rad_sof; radNoDef = rad_har;
  663.               case {4}
  664.                 set([txt_noi;pop_noi],'Visible','off')
  665.                 set([txt_BMS;sli_BMS],'Visible','on')
  666.                 radDef = rad_sof; radNoDef = rad_har;
  667.             end
  668.             set(sli_BMS,'value',3)
  669.             set(radDef,'Value',1,'Userdata',1);
  670.             set(radNoDef,'Value',0,'Userdata',0);
  671.           case {'comp'}
  672.             HDL_1 = [txt_BMS;sli_BMS];
  673.             HDL_2 = [];
  674.             switch numMeth
  675.               case {1,2,3} , invis = HDL_2; vis = HDL_1;                
  676.               case {4,5}   , invis = HDL_1; vis = HDL_2;
  677.             end
  678.             set(sli_BMS,'value',1.5);
  679.             set(invis,'Visible','off')
  680.             set(vis,'Visible','on')
  681.         end
  682.         utthrw1d('update_by_Caller',fig)
  683.     case 'update_thrType'
  684.         rad = gcbo;
  685.         old = get(rad,'userdata');
  686.         if isequal(old,1) , set(rad,'Value',1); return; end
  687.         if isequal(rad,rad_sof)
  688.            type = 's'; other = rad_har;
  689.         else
  690.            type = 'h'; other = rad_sof;           
  691.         end
  692.         set(other,'Value',0,'Userdata',0);
  693.         set(rad,'Value',1,'Userdata',1);
  694.         feval(calledFUN,'clear_GRAPHICS',fig);
  695.     case 'update_hdlDEN'
  696.         thrStruct = varargin{1};
  697.         NB_lev  = size(thrStruct,1);
  698.         pop_int = h_CMD_LVL(2,1:NB_lev);
  699.         sli_lev = h_CMD_LVL(3,1:NB_lev);
  700.         edi_lev = h_CMD_LVL(4,1:NB_lev);
  701.         for k = 1:NB_lev
  702.             thrParams = thrStruct(k).thrParams;
  703.             if ~isempty(thrParams)
  704.                 linvalHdl = thrStruct(k).hdlLines;
  705.                 if ishandle(linvalHdl)
  706.                    NB_int  = size(thrParams,1);
  707.                    act_int = 1;
  708.                    set(pop_int(k),'String',int2str([1:NB_int]'),'Value',act_int);
  709.                    thr     = thrParams(act_int,3);
  710.                    oldMax  = get(sli_lev(k),'Max');
  711.                    newMax  = max([thr oldMax]);
  712.                    set(sli_lev(k),'Max',newMax,'Value',thr);
  713.                    set(edi_lev(k),'string',sprintfLOC('%7.3f',thr));
  714.                    axeHdl  = get(linvalHdl,'Parent');
  715.                    lv      = findobj(axeHdl,'tag',tag_lineV);
  716.                    if ~isempty(lv) , delete(lv); end
  717.                    lu      = findobj(axeHdl,'tag',tag_lineH_up);
  718.                    ld      = findobj(axeHdl,'tag',tag_lineH_down);
  719.                    [xHOR,yHOR] = getxy(thrParams);
  720.                    yHOR    = abs(yHOR);
  721.                    set(lu,'Xdata',xHOR,'Ydata',yHOR);
  722.                    ind     = find(yHOR<sqrt(eps));
  723.                    tmp     = yHOR;
  724.                    if ~isempty(ind) , tmp(ind) = NaN; end
  725.                    set(ld,'Xdata',xHOR,'Ydata',-tmp);
  726.                    yVMin   = 2*max(abs(get(linvalHdl,'Ydata')));
  727.                    cbthrw1d('plotLV',[fig ; lu ; ld],[xHOR ; yHOR],yVMin);
  728.                 end
  729.             end
  730.         end
  731.         utthrw1d('set',fig,'thrstruct',thrStruct);
  732.     case 'update_by_UIC'
  733.         level    = varargin{1};
  734.         type_hdl = varargin{2};
  735.         pop      = h_CMD_LVL(2,level);
  736.         sli      = h_CMD_LVL(3,level);
  737.         edi      = h_CMD_LVL(4,level);
  738.         lHu      = h_GRA_LVL(2,level);
  739.         lHd      = h_GRA_LVL(3,level);
  740.         % Updating threshold.
  741.         %---------------------
  742.         ok = 0;
  743.         switch type_hdl
  744.             case 'pop'
  745.             case 'sli'
  746.               thresh = get(sli,'value');
  747.               set(edi,'string',sprintfLOC('%7.3f',thresh));
  748.             case 'edi'
  749.               valstr = get(edi,'string');
  750.               [thresh,count,err] = sscanf(valstr,'%f');
  751.               if (count~=1) || ~isempty(err)
  752.                   thresh = get(sli,'Value');
  753.                   set(edi,'string',sprintfLOC('%7.3f',thresh));
  754.                   return
  755.               else
  756.                   mi = get(sli,'Min');
  757.                   ma = get(sli,'Max');
  758.                   if     thresh<mi , thresh = mi;
  759.                   elseif thresh>ma , thresh = ma;
  760.                   end
  761.                   set(sli,'Value',thresh);
  762.                   set(edi,'string',sprintfLOC('%7.3f',thresh));
  763.               end
  764.         end
  765.         num_int = get(pop,'Value');
  766.         ydata   = get(lHu,'Ydata');
  767.         i_beg   = 3*(num_int-1)+1;
  768.         switch type_hdl
  769.             case 'pop'
  770.               thresh  = ydata(i_beg);
  771.               set(sli,'Value',thresh);
  772.               set(edi,'string',sprintfLOC('%7.3f',thresh));
  773.             case {'sli','edi'}
  774.               i_end   = i_beg+1;
  775.               ydata([i_beg i_end]) = [thresh thresh];
  776.               set(lHu,'Ydata', ydata);
  777.               if thresh<sqrt(eps)
  778.                   ydata([i_beg i_end]) = [NaN NaN];
  779.               end
  780.               set(lHd,'Ydata',-ydata);
  781.               cbthrw1d('upd_thrStruct',fig,lHu);
  782.               ok = 1;
  783.         end
  784.         feval(calledFUN,'clear_GRAPHICS',fig);
  785.         if ok , utthrw1d('show_LVL_perfos',fig); end
  786.     case 'update_by_Caller'
  787.         feval(calledFUN,'update_LVL_meth',fig);
  788.     case 'update_LVL_meth'
  789.         % called by : calledFUN('update_LVL_meth', ...)
  790.         %----------------------------------------------
  791.         valTHR = varargin{1};
  792.         NB_lev = length(valTHR);
  793.         maxTHR = utthrw1d('get',fig,'maxTHR');
  794.         maxTHR = maxTHR(ud.levmin:ud.levmin+NB_lev-1);
  795.         valTHR = min(valTHR,maxTHR);
  796.         thrStruct = wmemtool('rmb',fig,n_memblocTHR,ind_thr_struct);
  797.         xmin = thrStruct(ud.levmin).thrParams(1,1);
  798.         xmax = thrStruct(ud.levmin).thrParams(end,2);
  799.         nb_MAX = min([ud.levmax,ud.levmin+NB_lev-1]);
  800.         for k=ud.levmin:nb_MAX
  801.             thrStruct(k).thrParams = [xmin xmax valTHR(k)];
  802.         end
  803.         utthrw1d('update_hdlDEN',fig,thrStruct);
  804.     case 'show_LVL_perfos'
  805.         if isequal(toolOPT,'comp')
  806.             feval(calledFUN,'show_LVL_perfos',fig);
  807.         end
  808.     case 'init_SetThr'
  809.         utthrset('init');
  810.     case 'return_SetThr'
  811.         if isempty(varargin{1}) , return; end        
  812.         feval(calledFUN,'clear_GRAPHICS',fig);
  813.         utthrw1d('update_hdlDEN',fig,varargin{:})
  814.         utthrw1d('show_LVL_perfos',fig);
  815.     case 'status'
  816.       if length(varargin)>0
  817.          toolStatus = varargin{1};
  818.          ud.status  = toolStatus;
  819.          set(fra,'Userdata',ud);
  820.          set([pop_met;rad_sof;rad_har;pop_noi;sli_BMS],'Enable',toolStatus)
  821.          if isequal(lower(toolStatus),'off')
  822.              utthrw1d('enable',fig,'off')
  823.          end       
  824.       end
  825.       varargout{1} = toolStatus;
  826.               
  827.     case 'enable'
  828.         enaVal = varargin{1};
  829.         if length(varargin)>1
  830.             levs = varargin{2};
  831.         else
  832.             levs = [1:size(h_GRA_LVL,2)];
  833.         end
  834.         uic = h_CMD_LVL(2:4,:);
  835.         set([uic(:);tog_thr;tog_res;pus_est],'Enable','off');
  836.         if isequal(lower(enaVal),'on')
  837.             uic = h_CMD_LVL(2:4,levs);
  838.             set([uic(:);tog_thr;pus_est],'Enable',enaVal);
  839.         end
  840.     case 'enable_tog_res'
  841.         enaVal = varargin{1};
  842.         set(tog_res,'Enable',enaVal);
  843.     case 'visible'
  844.         visVal     = lower(varargin{1});
  845.         ud.visible = visVal;
  846.         handlesAXE = h_GRA_LVL(1,ud.levmin:ud.levmax);
  847.         handlesAXE = findobj(handlesAXE(ishandle(handlesAXE(:))));
  848.         if isequal(visVal,'on')
  849.             h_CMD_LVL = h_CMD_LVL(1:4,ud.levmin:ud.levmax);
  850.             numMeth = get(pop_met,'value');
  851.             switch toolOPT
  852.               case {'deno','esti','esti_REG'}
  853.                 switch numMeth
  854.                   case {1,2,3,4} , invis = [txt_BMS;sli_BMS];
  855.                   case {5,6,7}   , invis = [txt_noi;pop_noi];
  856.                 end
  857.               case {'esti_DEN'}
  858.                 switch numMeth
  859.                   case {1,2,3} , invis = [txt_noi;pop_noi;txt_BMS;sli_BMS];
  860.                   case {4}     , invis = [txt_BMS;sli_BMS];
  861.                 end
  862.               case {'comp'}
  863.                 switch numMeth
  864.                    case {1,2,3} , invis = [];
  865.                    case {4,5}   , invis = [txt_BMS;sli_BMS];
  866.                 end 
  867.             end
  868.             handlesUIC = setdiff(handlesUIC,invis);
  869.         end
  870.         handles = [h_CMD_LVL(:);handlesAXE(:);handlesUIC(:)];
  871.         set(handles(ishandle(handles)),'visible',visVal);
  872.         if isequal(toolOPT,'esti_DEN')
  873.            set(tog_res,'Visible','Off')
  874.         end
  875.         
  876.     case 'set'
  877.         nbarg = length(varargin);
  878.         if nbarg<1 , return; end
  879.         for k = 1:2:nbarg
  880.            argType = lower(varargin{k});
  881.            argVal  = varargin{k+1};
  882.            switch argType
  883.              case 'position'
  884.                [levmin,levmax] = deal(argVal{:});
  885.                nblevs = levmax-levmin+1;
  886.                if ud.ydir==1
  887.                    dnum_lev = (levmin-ud.levmin);
  888.                else
  889.                    dnum_lev = (ud.levmax-levmax);
  890.                end
  891.                ud.levmin = levmin;
  892.                ud.levmax = levmax;
  893.                set(fra,'Userdata',ud);
  894.                old_units = get(fig,'units');
  895.                tmpHandles = [h_CMD_LVL(:);handlesUIC(:)];
  896.                tmpHandles = tmpHandles(ishandle(tmpHandles));
  897.                set(tmpHandles,'visible','off');
  898.                set([fig;tmpHandles],'units','pixels');
  899.                [pos_fra,dy_lev,y_thr,y_res,y_est] = ...
  900.                        getPosFraThr(fra,nblevs,toolOPT);
  901.                set(fra,'Position',pos_fra);
  902.                ytrans = dnum_lev*dy_lev;
  903.                for j=1:size(h_CMD_LVL,2)
  904.                    for k = 1:4
  905.                        p = get(h_CMD_LVL(k,j),'Position');
  906.                        set(h_CMD_LVL(k,j),'Position',[p(1),p(2)+ytrans,p(3:4)]);
  907.                    end
  908.                end
  909.                p = get(tog_thr,'Position');
  910.                set(tog_thr,'Position',[p(1),y_thr,p(3:4)]);
  911.                ytrans = y_thr-p(2);
  912.                p = get(tog_res,'Position');
  913.                set(tog_res,'Position',[p(1),y_res,p(3:4)]);
  914.                p = get(pus_est,'Position');
  915.                set(pus_est,'Position',[p(1),y_est,p(3:4)]);
  916.                switch toolOPT
  917.                  case {'comp'}
  918.                    tmpHDL = [txt_nor;edi_nor;txt_npc;txt_zer;edi_zer;txt_zpc];
  919.                    for k = 1:length(tmpHDL)
  920.                        p = get(tmpHDL(k),'Position');
  921.                        set(tmpHDL(k),'Position',[p(1),p(2)+ytrans,p(3:4)]);
  922.                    end
  923.                end
  924.                set([fig;tmpHandles],'units',old_units);
  925.                utthrw1d('visible',fig,ud.visible);
  926.                if nargout>0
  927.                    varargout{1} = [pos_fra(1) , y_est , pos_fra([3 4])];
  928.                end
  929.              case 'thrstruct'
  930.                if iscell(argVal)
  931.                    [xmin,xmax,thr,hdl_lines] = deal(argVal{:});
  932.                    first = ud.levmin;
  933.                    last  = ud.levmax;
  934.                    argVal = struct(...
  935.                                 'thrParams',cell(ud.levmaxMAX,1), ...
  936.                                 'hdlLines',cell(ud.levmaxMAX,1)   ...
  937.                                 );
  938.                    for k=first:last
  939.                        argVal(k).thrParams = [xmin xmax thr(k)];
  940.                        argVal(k).hdlLines  = hdl_lines(k);
  941.                    end
  942.                  end
  943.                  wmemtool('wmb',fig,n_memblocTHR,ind_thr_struct,argVal);
  944.              case 'intdepthr'
  945.                  wmemtool('wmb',fig,n_memblocTHR,ind_int_thr,argVal);
  946.              case 'axes'
  947.                h_GRA_LVL(1,1:length(argVal)) = argVal;
  948.                ud.h_GRA_LVL = h_GRA_LVL;
  949.                set(fra,'Userdata',ud);
  950.              case 'handleori' , ud.handleORI = argVal; set(fra,'Userdata',ud);
  951.              case 'handlethr' , ud.handleTHR = argVal; set(fra,'Userdata',ud);
  952.              case 'handleres' , ud.handleRES = argVal; set(fra,'Userdata',ud);
  953.              case 'perfos'
  954.                switch toolOPT
  955.                  case {'comp'}
  956.                    set(edi_nor,'string',sprintf('%5.2f',argVal{1}));
  957.                    set(edi_zer,'string',sprintf('%5.2f',argVal{2}));
  958.                end
  959.            end
  960.         end
  961.     case 'get'
  962.         nbarg = length(varargin);
  963.         if nbarg<1 , return; end
  964.         for k = 1:nbarg
  965.            outType = lower(varargin{k});
  966.            switch outType
  967.              case 'position'
  968.                pos_fra = get(fra,'Position');
  969.                pos_est = get(pus_est,'Position');
  970.                varargout{k} = [pos_fra(1) , pos_est(2) , pos_fra([3 4])];
  971.              case 'thrstruct'
  972.                varargout{k} = wmemtool('rmb',fig,n_memblocTHR,ind_thr_struct);
  973.              case 'intdepthr'
  974.                varargout{k} = wmemtool('rmb',fig,n_memblocTHR,ind_int_thr);
  975.              case 'maxthr'
  976.                val = get(h_CMD_LVL(3,:),'Max');
  977.                val = cat(2,val{:});
  978.                varargout{k} = val;
  979.              case 'valthr'
  980.                val = get(h_CMD_LVL(3,:),'Value');
  981.                val = cat(2,val{ud.levmin:ud.levmax});
  982.                varargout{k} = val;
  983.              case 'tog_thr'   , varargout{k} = tog_thr;
  984.              case 'tog_res'   , varargout{k} = tog_res;
  985.              case {'pus_den','pus_est','pus_com'} , varargout{k} = pus_est;
  986.              case 'handleori' , varargout{k} = ud.handleORI;
  987.              case 'handlethr' , varargout{k} = ud.handleTHR;
  988.              case 'handleres' , varargout{k} = ud.handleRES;
  989.            end
  990.         end
  991.     case 'clean_thr'
  992.         set(h_CMD_LVL(2,:),'String','1','Value',1);       % pop_int;
  993.         set(h_CMD_LVL(3,:),'Min',0,'Max',1,'Value',0.5);  % sli_lev;
  994.         set(h_CMD_LVL(4,:),'String','');                  % edi_lev
  995.     case 'plot_dec'
  996.         lev = varargin{1};
  997.         [max_det,val_lev,xmin,xmax,k] = deal(varargin{2}{:});
  998.         set(h_CMD_LVL(3,lev),'Min',0,'Max',max_det,'Value',val_lev);
  999.         set(h_CMD_LVL(4,lev),'String',sprintfLOC('%7.3f',val_lev));
  1000.         xHOR    = [xmin xmax];
  1001.         yHOR    = [val_lev val_lev];
  1002.         [lu,ld] = cbthrw1d('plotLH',[h_CMD_LVL(2:4,lev);h_GRA_LVL(1,lev)], ...
  1003.                            xHOR,yHOR,k,max_det);
  1004.         h_GRA_LVL(2:3,lev) = [lu;ld];
  1005.         ud.h_GRA_LVL = h_GRA_LVL;
  1006.         set(fra,'Userdata',ud);
  1007.  
  1008.     case 'residuals'
  1009.         [handleORI,handleTHR,handleRES] = ...
  1010.             utthrw1d('get',fig,'handleORI','handleTHR','handleRES');
  1011.         wmoreres('create',fig,tog_res,handleRES,handleORI,handleTHR,'blocPAR');
  1012.     case 'den_M1'
  1013.         cfs = varargin{1};
  1014.         len = varargin{2};
  1015.         thrStruct = utthrw1d('get',fig,'thrstruct');
  1016.         switch toolOPT
  1017.           case {'deno','esti','esti_REG','esti_DEN'}
  1018.             v = get(rad_sof,'Value');
  1019.             if v==1 , sorh = 's'; else , sorh = 'h'; end
  1020.           case {'comp'} , sorh = 'h';
  1021.         end
  1022.         NB_lev = size(thrStruct,1);
  1023.         for k = 1:NB_lev
  1024.             thr_par = thrStruct(k).thrParams;
  1025.             if ~isempty(thr_par)
  1026.                 NB_int = size(thr_par,1);
  1027.                 x      = [thr_par(:,1) ; thr_par(NB_int,2)];
  1028.                 x      = round(x);
  1029.                 x(x<1) = 1;
  1030.                 x(x>len) = len;
  1031.                 thr = thr_par(:,3);
  1032.                 for j = 1:NB_int
  1033.                     if j==1 , d_beg = 0; else , d_beg = 1; end
  1034.                     j_beg = x(j)+d_beg;
  1035.                     j_end = x(j+1);
  1036.                     j_ind = [j_beg:j_end];
  1037.                     cfs(k,j_ind) = wthresh(cfs(k,j_ind),sorh,thr(j));
  1038.                 end
  1039.             end
  1040.         end
  1041.         varargout{1} = cfs;
  1042.     case 'den_M2'
  1043.         coefs = varargin{1};
  1044.         longs = varargin{2};
  1045.         len   = longs(end);
  1046.         first = cumsum(longs)+1;
  1047.         first = first(end-2:-1:1);
  1048.         tmp   = longs(end-1:-1:2);
  1049.         last  = first+tmp-1;
  1050.         longs = longs(end-1:-1:2);
  1051.         thrStruct = utthrw1d('get',fig,'thrstruct');
  1052.         switch toolOPT
  1053.           case {'deno','esti','esti_REG','esti_DEN'}
  1054.             v = get(rad_sof,'Value');
  1055.             if v==1 , sorh = 's'; else , sorh = 'h'; end
  1056.           case {'comp'} , sorh = 'h';
  1057.         end
  1058.         NB_lev  = size(thrStruct,1);        
  1059.         for k = 1:NB_lev
  1060.             thr_par = thrStruct(k).thrParams;
  1061.             if ~isempty(thr_par)
  1062.                 cfs = coefs(first(k):last(k));
  1063.                 nbCFS = longs(k);            
  1064.                 NB_int = size(thr_par,1);
  1065.                 x   = [thr_par(:,1) ; thr_par(NB_int,2)];
  1066.                 alf = (nbCFS-1)/(x(end)-x(1));
  1067.                 bet = 1 - alf*x(1);
  1068.                 x   = round(alf*x+bet);
  1069.                 x(x<1) = 1;
  1070.                 x(x>nbCFS) = nbCFS;
  1071.                 thr = thr_par(:,3);
  1072.                 for j = 1:NB_int
  1073.                     if j==1 , d_beg = 0; else , d_beg = 1; end
  1074.                     j_beg = x(j)+d_beg;
  1075.                     j_end = x(j+1);
  1076.                     j_ind = [j_beg:j_end];
  1077.                     cfs(j_ind) = wthresh(cfs(j_ind),sorh,thr(j));
  1078.                 end
  1079.                 coefs(first(k):last(k)) = cfs;
  1080.             end
  1081.         end
  1082.         varargout{1} = coefs;
  1083.     case 'demo'
  1084.     % SPECIAL for DEMOS
  1085.     %------------------
  1086.     [tool,parDemo] = deal(varargin{:});
  1087.     switch tool
  1088.        case {'sw1d','wdre'}
  1089.          if ischar(parDemo{1})
  1090.              shortnames = wthrmeth(toolOPT,'shortnames');
  1091.              ind = strmatch(deblank(parDemo{1}),shortnames);
  1092.              if isempty(ind) , return; end
  1093.              set(pop_met,'Value',ind)
  1094.              utthrw1d('update_methName',fig)
  1095.          elseif isnumeric(parDemo{1})
  1096.              utthrset('demo',tog_thr,parDemo{1})
  1097.          end
  1098.     end
  1099.     otherwise
  1100.         errargt(mfilename,'Unknown Option','msg');
  1101.         error('*');
  1102. end
  1103. %=============================================================================%
  1104. % INTERNAL FUNCTIONS
  1105. %=============================================================================%
  1106. %-----------------------------------------------------------------------------%
  1107. function varargout = wthrmeth(toolOPT,varargin)
  1108. switch toolOPT
  1109.   case {'deno','esti','esti_REG'}
  1110.     thrMethods = {...
  1111.         'Fixed form threshold',  'sqtwolog',    1; ...
  1112.         'Rigorous SURE',         'rigrsure',    2; ...
  1113.         'Heuristic SURE',        'heursure',    3; ...
  1114.         'Minimax',               'minimaxi',    4; ...
  1115.         'Penalize high',         'penalhi',     5; ...
  1116.         'Penalize medium',       'penalme',     6; ...
  1117.         'Penalize low',          'penallo',     7  ...
  1118.         };
  1119.   case {'esti_DEN'}
  1120.     thrMethods = {...
  1121.         'Global threshold',      'globalth',    1; ...
  1122.         'By level threshold 1',  'bylevth1',    2; ...
  1123.         'By level threshold 2',  'bylevth2',    3; ...
  1124.         'By level threshold 3',  'bylevsth',    4  ...
  1125.         };
  1126.   case 'comp'
  1127.     thrMethods = {...
  1128.         'Scarce high',           'scarcehi',     1; ...
  1129.         'Scarce medium',         'scarceme',     2; ...
  1130.         'Scarce low',            'scarcelo',     3; ...
  1131.         'Balance sparsity-norm', 'bal_sn',       4; ...
  1132.         'Remove near 0',         'rem_n0',       5  ...
  1133.         };
  1134. end
  1135. nbin = length(varargin);
  1136. if nbin==0 , varargout{1} = thrMethods; return; end
  1137. option = varargin{1};
  1138. switch option
  1139.   case 'names'
  1140.      out = strvcat(1,thrMethods{:,1});
  1141.      varargout{1} = out(2:end,:);
  1142.      if nbin==2
  1143.          num = varargin{2};
  1144.          varargout{1} = deblank(varargout{1}(num,:));
  1145.      end
  1146.   case 'shortnames'
  1147.      out = strvcat(1,thrMethods{:,2});
  1148.      varargout{1} = out(2:end,:);
  1149.      if nbin==2
  1150.          num = varargin{2};
  1151.          varargout{1} = deblank(varargout{1}(num,:));
  1152.      end
  1153.   case 'nums'
  1154.      varargout{1} = cat(1,thrMethods{:,3});
  1155. end
  1156. %-----------------------------------------------------------------------------%
  1157. function [pos_fra,dy_lev,y_thr,y_res,y_est] = getPosFraThr(fra,nblevs,toolOPT)
  1158. Def_Btn_Height = mextglob('get','Def_Btn_Height');
  1159. [bdy,d_lev] = get_DLEV(nblevs,toolOPT);
  1160. pos_fra = get(fra,'Position');
  1161. top_fra = pos_fra(2)+pos_fra(4);
  1162. if ~isequal(toolOPT,'esti_DEN') , multiY = 1; else , multiY = 1; end
  1163. switch  toolOPT
  1164.   case {'deno','esti'} , NB_Height = 6;
  1165.   case {'esti_REG'}    , NB_Height = 6;
  1166.   case {'esti_DEN'}    , NB_Height = 4+2*multiY;  
  1167.   case {'comp'}        , NB_Height = 7;
  1168. end
  1169. h_ini   = (NB_Height-1)*bdy+NB_Height*Def_Btn_Height;
  1170. h_fra   = h_ini+ nblevs*(Def_Btn_Height+d_lev)+ ...
  1171.           depOfMachine(Def_Btn_Height);
  1172. pos_fra(2) = top_fra-h_fra;
  1173. pos_fra(4) = h_fra;
  1174. dy_lev = d_lev+Def_Btn_Height;
  1175. y_thr  = pos_fra(2)+bdy;
  1176. y_est = pos_fra(2)-(3*Def_Btn_Height)/2-Def_Btn_Height/2;
  1177. y_res = y_est;
  1178. %-----------------------------------------------------------------------------%
  1179. function [x,y] = getxy(arg)
  1180.         
  1181. NB_int  = size(arg,1);
  1182. if NB_int>1
  1183.     x = [arg(:,1:2) NaN*ones(NB_int,1)]';
  1184.     x = x(:)';
  1185.     l = 3*NB_int-1;
  1186.     x = x(1:l);
  1187.     y = [arg(:,[3 3]) NaN*ones(NB_int,1)]';
  1188.     y = y(:)';
  1189.     y = y(1:l);
  1190. else
  1191.     x = arg(1,1:2); y = arg(1,[3 3]);
  1192. end
  1193. %-----------------------------------------------------------------------------%
  1194. function varargout = depOfMachine(varargin)
  1195. btn_height = varargin{1};
  1196. scrSize = get(0,'ScreenSize');
  1197. if scrSize(4)<600
  1198.     height = btn_height;
  1199. elseif scrSize(4)<800
  1200.     height = 3*btn_height/2;
  1201. else
  1202.     height = 3*btn_height/2;
  1203. end
  1204. varargout = {height};
  1205. %-----------------------------------------------------------------------------%
  1206. function s = sprintfLOC(frm,x);
  1207. s = sprintf(frm,x);
  1208. s(s==' ') = [];
  1209. %-----------------------------------------------------------------------------%
  1210. function [bdy,d_lev] = get_DLEV(nblevs,toolOPT)
  1211. if isequal(toolOPT,'comp') && (nblevs>10)
  1212.     bdy = 2; d_lev = 0;    
  1213. else
  1214.     bdy = 4; d_lev = 2;
  1215. end
  1216. %=============================================================================%