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

波变换

开发平台:

Matlab

  1. function varargout = sw1dtool(option,varargin)
  2. %SW1DTOOL Stationary Wavelet Transform 1-D tool.
  3. %   VARARGOUT = SW1DTOOL(OPTION,VARARGIN)
  4. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 17-Dec-97.
  5. %   Last Revision: 05-Feb-2004.
  6. %   Copyright 1995-2004 The MathWorks, Inc.
  7. %   $Revision: 1.10.4.1 $  $Date: 2004/03/15 22:41:45 $
  8. % Test inputs.
  9. %-------------
  10. if nargin==0 , option = 'create'; end
  11. [option,winAttrb] = utguidiv('ini',option,varargin{:});
  12. % Default values.
  13. %----------------
  14. max_lev_anal = 8;
  15. def_lev_anal = 5;
  16. % Memory Blocks of stored values.
  17. %================================
  18. % MB1.
  19. %-----
  20. n_membloc1   = 'MB_1';
  21. ind_status   = 1;
  22. ind_sav_menu = 2;
  23. ind_filename = 3;
  24. ind_pathname = 4;
  25. ind_sig_name = 5;
  26. ind_NB_lev   = 6;
  27. ind_wave     = 7;
  28. nb1_stored   = 7;
  29. % MB2.
  30. %-----
  31. n_membloc2   = 'MB_2';
  32. ind_pus_dec  = 1;
  33. ind_chk_den  = 2;
  34. ind_axe_hdl  = 3;
  35. ind_lin_hdl  = 4;
  36. ind_txt_hdl  = 5;
  37. ind_lin_den  = 6;
  38. ind_gra_area = 7;
  39. nb2_stored   = 7;
  40. % MB3.
  41. %-----
  42. n_membloc3 = 'MB_3';
  43. ind_coefs  = 1;
  44. nb3_stored = 1;
  45. % Tag property.
  46. %---------------
  47. tag_sig_ori = 'Sig_ori';
  48. tag_app     = 'App';
  49. tag_sig_den = 'Sig_den';
  50. tag_noise   = 'Noise';
  51. if ~isequal(option,'create') , win_tool = varargin{1}; end
  52. switch option
  53.     case 'create'
  54.         % Get Globals.
  55.         %-------------
  56.         [Def_Btn_Height,X_Spacing,Y_Spacing] = ...
  57.             mextglob('get','Def_Btn_Height','X_Spacing','Y_Spacing');
  58.         % Window initialization.
  59.         %-----------------------
  60.         win_title = 'Stationary Wavelet Transform De-noising 1-D';
  61.         [win_tool,pos_win,win_units,str_numwin,...
  62.             frame0,pos_frame0,Pos_Graphic_Area,pus_close] = ...
  63.                 wfigmngr('create',win_title,winAttrb, ...
  64.                    'ExtFig_Tool_3',mfilename,1,1,0);
  65.         if nargout>0 , varargout{1} = win_tool; end
  66. % Add Help for Tool.
  67. %------------------
  68. wfighelp('addHelpTool',win_tool, ...
  69. 'One-Dimensional Analysis for De-&noising','SW1D_GUI');
  70. % Add Help Item.
  71. %----------------
  72. wfighelp('addHelpItem',win_tool,'Stationary Wavelet Transform','SWT');
  73. wfighelp('addHelpItem',win_tool,'Available Methods','COMP_DENO_METHODS');
  74. wfighelp('addHelpItem',win_tool,'Variance Adaptive Thresholding','VARTHR');
  75. wfighelp('addHelpItem',win_tool,'Loading and Saving','SW1D_LOADSAVE');
  76.         % Menu construction for current figure.
  77.         %--------------------------------------
  78.         [m_files,m_save] = wfigmngr('getmenus',win_tool,'file','save');
  79.         cba_menu = [mfilename '(''load'','  str_numwin ');'];
  80.         uimenu(m_files,...
  81.                       'Label','&Load Signal', ...
  82.                       'Position',1,           ...
  83.                       'Callback', cba_menu    ...
  84.                       );
  85.         cba_menu = [mfilename '(''save'','  str_numwin ');'];
  86.         m_save = uimenu(m_files,...
  87.                         'Label','&Save De-Noised Signal',...
  88.                         'Position',2,        ...
  89.                         'Enable','Off',      ...
  90.                         'Callback', cba_menu ...
  91.                         );
  92. m_demo = uimenu(m_files,'Label','&Example Analysis','Position',3);
  93.         m_demo_1 = uimenu(m_demo,'Label','Noisy Signals');
  94.         m_demo_2 = uimenu(m_demo,...
  95. 'Label','Noisy Signals - Interval Dependent Noise Variance');
  96.         demoSET = {...
  97.           'Noisy blocks'    , 'noisbloc' , 'haar', 5 , '{}'  ; ...
  98.           'Noisy bumps'     , 'noisbump' , 'sym4', 5 , '{}'  ; ...
  99.           'Noisy heavysin'  , 'heavysin' , 'sym8', 5 , '{}'  ; ...
  100.           'Noisy Doppler'   , 'noisdopp' , 'sym4', 5 , '{}'  ; ...
  101.           'Noisy quadchirp' , 'noischir' , 'db1' , 5 , '{}'  ; ...
  102.           'Noisy mishmash'  , 'noismima' , 'db3' , 6 , '{}'  ; ...
  103.           'Noisy blocks'    , 'noisbloc' , 'haar', 5 , '{''penallo''}' ...
  104.           };    
  105.         setDEMOS(m_demo_1,mfilename,str_numwin,demoSET,0)
  106.         demoSET = {...
  107.           'Noisy blocks (I)  - 3 intervals' , 'nblocr1' , 'haar', 5 , '{3}'  ; ...
  108.           'Noisy blocks (II) - 3 intervals' , 'nblocr2' , 'haar', 5 , '{3}'  ; ...
  109.           'Noisy Doppler (I) - 3 intervals' , 'ndoppr1' , 'haar', 5 , '{3}'  ; ...
  110.           'Noisy bumps (I)   - 3 intervals' , 'nbumpr1' , 'haar', 5 , '{3}'  ; ...
  111.           'Noisy bumps (II)  - 2 intervals' , 'nbumpr2' , 'haar', 5 , '{2}'  ; ...
  112.           'Noisy bumps (III) - 4 intervals' , 'nbumpr3' , 'haar', 5 , '{4}'  ; ...
  113.           'Elec. consumption - 3 intervals' , 'nelec'   , 'haar', 4 , '{3}'    ...
  114.           };
  115.         setDEMOS(m_demo_2,mfilename,str_numwin,demoSET,0)
  116.         % Begin waiting.
  117.         %---------------
  118.         wwaiting('msg',win_tool,'Wait ... initialization');
  119.         % General parameters initialization.
  120.         %-----------------------------------
  121.         dy = Y_Spacing;
  122.         str_pus_dec = 'Decompose Signal';
  123.         str_chk_den = 'Overlay De-noised Signal';
  124.         % Command part of the window.
  125.         %============================
  126.         % Data, Wavelet and Level parameters.
  127.         %------------------------------------
  128.         xlocINI = pos_frame0([1 3]);
  129.         ytopINI = pos_win(4)-dy;
  130.         toolPos = utanapar('create',win_tool, ...
  131.                     'xloc',xlocINI,'top',ytopINI,...
  132.                     'enable','off',        ...
  133.                     'wtype','dwt',         ...
  134.                     'deflev',def_lev_anal, ...
  135.                     'maxlev',max_lev_anal  ...
  136.                     );
  137.         
  138.         % Decompose pushbutton.
  139.         %----------------------
  140.         h_uic = 3*Def_Btn_Height/2;
  141.         y_uic = toolPos(2)-h_uic-2*dy;
  142.         w_uic = (3*pos_frame0(3))/4;
  143.         x_uic = pos_frame0(1)+(pos_frame0(3)-w_uic)/2;
  144.         pos_pus_dec = [x_uic, y_uic, w_uic, h_uic];
  145.         pus_dec = uicontrol(...
  146.                             'Parent',win_tool,      ...
  147.                             'Style','Pushbutton',   ...
  148.                             'Unit',win_units,       ...
  149.                             'Position',pos_pus_dec, ...
  150.                             'String',xlate(str_pus_dec),   ...
  151.                             'Enable','off',         ...
  152.                             'Interruptible','On'    ...
  153.                             );
  154.         % De-noising tool.
  155.         %-----------------
  156.         ytopTHR = pos_pus_dec(2)-4*dy;
  157.         toolPos = utthrw1d('create',win_tool, ...
  158.                     'xloc',xlocINI,'top',ytopTHR,...
  159.                     'ydir',-1, ...
  160.                     'levmax',def_lev_anal,    ...
  161.                     'levmaxMAX',max_lev_anal, ...
  162.                     'status','Off',  ...
  163.                     'toolOPT','deno' ...
  164.                     );
  165.         x_uic = pos_frame0(1)+(pos_frame0(3)-w_uic)/2;
  166.         h_uic = Def_Btn_Height;
  167.         y_uic = toolPos(2)-Def_Btn_Height/2-h_uic;
  168.         pos_chk_den = [x_uic, y_uic, w_uic, h_uic];
  169.         chk_den = uicontrol(...
  170.                             'Parent',win_tool,      ...
  171.                             'Style','checkbox',     ...
  172.                             'Visible','on',         ...
  173.                             'Unit',win_units,       ...
  174.                             'Position',pos_chk_den, ...
  175.                             'String',str_chk_den,   ...
  176.                             'Enable','off'          ...
  177.                             );
  178.         % Callbacks update.
  179.         %------------------
  180.         hdl_den = utthrw1d('handles',win_tool);
  181.         utanapar('set_cba_num',win_tool,[m_files;hdl_den(:)]);
  182.         pop_lev = utanapar('handles',win_tool,'lev');
  183.         tmp     = num2mstr([pop_lev chk_den]);
  184.         end_cba = [str_numwin ',' tmp ');'];
  185.         cba_pop_lev = [mfilename '(''update_level'',' end_cba];
  186.         cba_pus_dec = [mfilename '(''decompose'',' str_numwin ');'];
  187.         cba_chk_den = [mfilename '(''show_lin_den'',' str_numwin ');'];
  188.         set(pop_lev,'Callback',cba_pop_lev);
  189.         set(pus_dec,'Callback',cba_pus_dec);
  190.         set(chk_den,'Callback',cba_chk_den);
  191.         % General graphical parameters initialization.
  192.         %--------------------------------------------
  193.         fontsize    = wmachdep('fontsize','normal',9,max_lev_anal);
  194.         txtfontsize = 14;
  195.                
  196.         % Axes parameters initialization.
  197.         %--------------------------------
  198.         w_gra_rem = Pos_Graphic_Area(3);
  199.         h_gra_rem = Pos_Graphic_Area(4);
  200.         NB_lev    = max_lev_anal;      % dummy
  201.         ecx_left  = 0.08*pos_win(3);
  202.         ecx_med   = 0.07*pos_win(3);
  203.         ecx_right = 0.06*pos_win(3);
  204.         w_left    = (w_gra_rem-ecx_left-ecx_med-ecx_right)/2;
  205.         w_right   = w_left;
  206.         w_medium  = w_left;
  207.         x_left    = ecx_left;
  208.         x_right   = x_left+w_left+ecx_med;
  209.         x_medium  = (w_gra_rem-w_medium)/2;
  210.         ecy_up    = 0.06*pos_win(4);
  211.         ecy_mid_1 = 0.08*pos_win(4);
  212.         ecy_mid_2 = 0.08*pos_win(4);
  213.         ecy_det   = (0.04*pos_win(4))/1.4;
  214.         ecy_mid_3 = ecy_det;
  215.         ecy_down  = 0.04*pos_win(4);        
  216.         h_min     = h_gra_rem/12;
  217.         h_max     = h_gra_rem/5;
  218.         h_axe_std = (h_min*NB_lev+h_max*(max_lev_anal-NB_lev))/max_lev_anal;
  219.         h_space   = ecy_up+ecy_mid_1+ecy_mid_2+ecy_mid_3+ ...
  220.                     NB_lev*ecy_det+ecy_down;
  221.         h_detail  = (h_gra_rem-2*h_axe_std-h_space)/(NB_lev+1);
  222.         y_low_ini = pos_win(4);
  223.         % Building data axes.
  224.         %--------------------
  225.         commonProp = {...
  226.            'Parent',win_tool,...
  227.            'Visible','Off', ...
  228.            'Units',win_units,...
  229.            'Drawmode','fast',...
  230.            'Box','On'...
  231.            };
  232.         y_low_ini   = y_low_ini-h_axe_std-ecy_up;
  233.         pos_left    = [x_left y_low_ini w_left h_axe_std];
  234.         axe_left_1  = axes(commonProp{:},'Position',pos_left);
  235.         pos_right   = [x_right y_low_ini w_right h_axe_std];
  236.         axe_right_1 = axes(commonProp{:},'Position',pos_right);
  237.         y_low_ini   = y_low_ini-h_axe_std-ecy_mid_1;
  238.         pos_medium  = [x_medium y_low_ini w_medium h_axe_std];
  239.         axe_medium  = axes(commonProp{:},'Position',pos_medium);
  240.         y_low_ini   = y_low_ini-ecy_mid_2;
  241.         % Building approximation & details axes on the left part.
  242.         %--------------------------------------------------------
  243.         axe_left = zeros(1,max_lev_anal);
  244.         txt_left = zeros(1,max_lev_anal);
  245.         y_left   = y_low_ini;
  246.         pos_left = [x_left y_left w_left h_detail];
  247.         % Left approximation axes.
  248.         %-------------------------
  249.         pos_left(2) = pos_left(2)-pos_left(4);
  250.         axe_app_l = axes(commonProp{:},'Position',pos_left);
  251.         str_txt = ['a_' int2str(max_lev_anal)];
  252.         txt_app_l = txtinaxe('create',str_txt, ...
  253.                               axe_app_l,'l','off','bold',txtfontsize);
  254.         pos_left(2) = pos_left(2)-ecy_mid_3;
  255.         % Left details axes.
  256.         %-------------------
  257.         for j = 1:NB_lev
  258.             k =  NB_lev-j+1;
  259.             pos_left(2) = pos_left(2)-pos_left(4)-ecy_det;
  260.             axe_left(k) = axes(commonProp{:}, ...
  261.                             'Position',pos_left,      ...
  262.                             'XTicklabelMode','manual',...
  263.                             'XTickLabel',[]           ...
  264.                             );
  265.             str_txt     = ['d' wnsubstr(k)];
  266.             txt_left(k) = txtinaxe('create',str_txt, ...
  267.                               axe_left(k),'l','off','bold',txtfontsize);
  268.         end
  269.         set(axe_left(1),'XTicklabelMode','auto');
  270.         % Building approximation & details axes on the right part.
  271.         %---------------------------------------------------------
  272.         axe_right = zeros(1,max_lev_anal);
  273.         txt_right = zeros(1,max_lev_anal);
  274.         y_right   = y_low_ini;
  275.         pos_right = [x_right y_right w_right h_detail];
  276.         % Right approximation axes.
  277.         %--------------------------
  278.         pos_right(2) = pos_right(2)-pos_right(4);
  279.         axe_app_r = axes(commonProp{:},'Position',pos_right);
  280.         str_txt = ['a' wnsubstr(max_lev_anal)];
  281.         txt_app_r = txtinaxe('create',str_txt, ...
  282.                               axe_app_r,'r','off','bold',txtfontsize);
  283.         pos_right(2) = pos_right(2)-ecy_mid_3;
  284.         % Right details axes.
  285.         %--------------------
  286.         for j = 1:NB_lev
  287.             k =  NB_lev-j+1;
  288.             pos_right(2) = pos_right(2)-pos_right(4)-ecy_det;
  289.             axe_right(k) = axes(commonProp{:}, ...
  290.                             'Position',pos_right,     ...
  291.                             'XTicklabelMode','manual',...
  292.                             'XTickLabel',[]           ...
  293.                             );
  294.             str_txt      = ['d' wnsubstr(k)];
  295.             txt_right(k) = txtinaxe('create',str_txt, ...
  296.                               axe_right(k),'r','off','bold',txtfontsize);
  297.         end
  298.         set(axe_right(1),'XTicklabelMode','auto');
  299.         %  Normalization.
  300.         %----------------
  301.         Pos_Graphic_Area = wfigmngr('normalize',win_tool,Pos_Graphic_Area);
  302.         drawnow
  303.         % Handles and Positions.
  304.         %-----------------------
  305.         axes_hdl = [axe_left_1 axe_right_1 axe_medium ... 
  306.                     axe_left axe_app_l axe_right axe_app_r];
  307.         lin_hdl  = NaN*ones(1,length(axes_hdl));
  308.         text_hdl = [NaN NaN NaN txt_left txt_app_l txt_right txt_app_r];
  309.         pos_axes = get(axes_hdl,'Position');
  310.         pos_axes = cat(1,pos_axes{:});
  311.         % Memory blocks update.
  312.         %----------------------
  313.         utthrw1d('set',win_tool,'axes',axe_left);
  314.         wmemtool('ini',win_tool,n_membloc1,nb1_stored);
  315.         wmemtool('ini',win_tool,n_membloc2,nb2_stored);
  316.         wmemtool('wmb',win_tool,n_membloc1, ...
  317.                        ind_status,-1,      ...
  318.                        ind_sav_menu,m_save ...
  319.                        );
  320.         wmemtool('wmb',win_tool,n_membloc2,  ...
  321.                        ind_pus_dec,pus_dec,  ...
  322.                        ind_chk_den,chk_den,  ...
  323.                        ind_axe_hdl,axes_hdl, ...
  324.                        ind_lin_hdl,lin_hdl,  ...
  325.                        ind_gra_area,Pos_Graphic_Area, ...
  326.                        ind_txt_hdl,text_hdl, ...
  327.                        ind_lin_den,NaN       ...
  328.                        );
  329.         % End waiting.
  330.         %---------------
  331.         wwaiting('off',win_tool);
  332.     case {'load','demo'}
  333.         % Loading file.
  334.         %-------------
  335.         switch option
  336.           case 'load'
  337.             [sigInfos,sig_Anal,ok] = ...
  338.                 utguidiv('load_sig',win_tool,'Signal_Mask','Load Signal');
  339.             sig_Name = sigInfos.name;
  340.           case 'demo'
  341.             sig_Name = deblank(varargin{2});
  342.             wav_Name = deblank(varargin{3});
  343.             lev_Anal = varargin{4};
  344.             if length(varargin)>4  & ~isempty(varargin{5})
  345.                 par_Demo = varargin{5};
  346.             else
  347.                 par_Demo = '';
  348.             end
  349.             filename = [sig_Name '.mat'];
  350.             pathname = utguidiv('WTB_DemoPath',filename);
  351.             [sigInfos,sig_Anal,ok] = ...
  352.                 utguidiv('load_dem1D',win_tool,pathname,filename);
  353.         end
  354.         if ~ok, return; end
  355.         % Begin waiting.
  356.         %---------------
  357.         wwaiting('msg',win_tool,'Wait ... cleaning');
  358.         % Setting Analysis parameters.
  359.         %-----------------------------
  360.         wmemtool('wmb',win_tool,n_membloc1, ...
  361.                        ind_status,-1,       ...
  362.                        ind_filename,sigInfos.filename, ...
  363.                        ind_pathname,sigInfos.pathname, ...
  364.                        ind_sig_name,sigInfos.name  ...
  365.                        );
  366.         % Cleaning and setting GUI. 
  367.         %--------------------------
  368.         cbanapar('enable',win_tool,'Off');
  369.         dynvtool('stop',win_tool)
  370.         utthrset('stop',win_tool);
  371.         ax_hdl  = wmemtool('rmb',win_tool,n_membloc2,ind_axe_hdl);
  372.         obj2del = findobj(ax_hdl,'type','line');
  373.         delete(obj2del)
  374.         utthrw1d('clean_thr',win_tool);
  375.  
  376.         % Setting analysis  & GUI values.
  377.         %--------------------------------
  378.         levm   = wmaxlev(sigInfos.size,'haar');
  379.         levmax = min(levm,max_lev_anal);
  380.         if isequal(option,'demo')
  381.             anaPar = {'wav',wav_Name};
  382.         else
  383.             lev_Anal = min(nextpow2(sigInfos.size),def_lev_anal);
  384.             anaPar = {};
  385.         end
  386.         strlev = int2str([1:levmax]');
  387.         anaPar = {anaPar{:},'n_s',{sig_Name,sigInfos.size}, ...
  388.                   'lev',{'String',strlev,'Value',lev_Anal}};
  389.         cbanapar('set',win_tool,anaPar{:});
  390.         % Initial drawing (& analysis). 
  391.         %------------------------------
  392.         chk_den = wmemtool('rmb',win_tool,n_membloc2,ind_chk_den);
  393.         sw1dtool('position',win_tool,lev_Anal,chk_den);
  394.         sw1dtool('set_axes',win_tool,-1);
  395.         sw1dtool('enable',win_tool,'ini','on');
  396.         sw1dtool('plot_ini',win_tool,sig_Anal);
  397.         if isequal(option,'demo')
  398.             sw1dtool('decompose',win_tool);
  399.             if ~isempty(par_Demo)
  400.                  utthrw1d('demo',win_tool,'sw1d',par_Demo);
  401.             end
  402.             sw1dtool('denoise',win_tool);
  403.             sw1dtool('show_lin_den',win_tool,'On')
  404.         end
  405.         cbanapar('enable',win_tool,'On');
  406.         % End waiting.
  407.         %-------------
  408.         wwaiting('off',win_tool);
  409.     case 'save'
  410.         % Testing file.
  411.         %--------------
  412.         [filename,pathname,ok] = utguidiv('test_save',win_tool, ...
  413.                                      '*.mat','Save De-noised Signal');
  414.         if ~ok, return; end
  415.         % Begin waiting.
  416.         %--------------
  417.         wwaiting('msg',win_tool,'Wait ... saving');
  418.         % Saving file.
  419.         %--------------
  420.         [name,ext] = strtok(filename,'.');
  421.         if isempty(ext) | isequal(ext,'.')
  422.             ext = '.mat'; filename = [name ext];
  423.         end
  424.         % Get de-noising parameters & de-noised signal.
  425.         %-----------------------------------------------
  426.         [NB_lev,wname] = ...
  427.             wmemtool('rmb',win_tool,n_membloc1,ind_NB_lev,ind_wave);
  428.         [thrStruct,hdl_den] = utthrw1d('get',win_tool,'thrstruct','handleTHR');
  429.         thrParams = {thrStruct(1:NB_lev).thrParams};
  430.         sig_den   = get(hdl_den,'Ydata');
  431.         try
  432.           eval([name ' = sig_den ;']);
  433.           saveStr = {name,'thrParams','wname'};
  434.           save([pathname filename],saveStr{:});
  435.         catch
  436.           errargt(mfilename,'Save FAILED !','msg');
  437.         end
  438.    
  439.         % End waiting.
  440.         %-------------
  441.         wwaiting('off',win_tool);
  442.     case 'decompose'
  443.         % Compute decomposition and plot.                   
  444.         %--------------------------------
  445.         wwaiting('msg',win_tool,'Wait ... computing');
  446.         % Analysis parameters.
  447.         %---------------------
  448.         [wname,lev_Anal] = cbanapar('get',win_tool,'wav','lev');
  449.         % Test decomposition.
  450.         %--------------------
  451.         hdl_ori = utthrw1d('get',win_tool,'handleORI');
  452.         sig_ori = get(hdl_ori,'Ydata');
  453.         xmin = 1;
  454.         xmax = length(sig_ori);
  455.         pow = 2^lev_Anal;
  456.         if rem(xmax,pow)>0
  457.             LenOK = ceil(xmax/pow)*pow;
  458.             wwaiting('off',win_tool);
  459.             msg = strvcat(...
  460.             ['The level of decomposition ' int2str(lev_Anal)],...
  461.             ['and the length of the signal ' int2str(xmax)],...
  462.             'are not compatible.',...
  463.             ['Suggested length: ' int2str(LenOK)],...
  464.             '(see Signal Extension Tool)', ...
  465.             ' ', ...
  466.             ['2^Level has to divide the length of the signal.'] ...
  467.             );
  468.             errargt(mfilename,msg,'msg');
  469.             return
  470.         end        
  471.         % Clean.
  472.         %--------
  473.         utthrw1d('clean_thr',win_tool);
  474.         sw1dtool('show_lin_den',win_tool,'off')
  475.         wmemtool('wmb',win_tool,n_membloc1, ...
  476.                        ind_status,0,ind_NB_lev,lev_Anal,ind_wave,wname);
  477.         % Decomposition.
  478.         %---------------
  479.         wDEC = swt(sig_ori,lev_Anal,wname);
  480.         wmemtool('wmb',win_tool,n_membloc3,ind_coefs,wDEC);
  481.         % Initializing by level threshold.
  482.         %---------------------------------
  483.         maxTHR = zeros(1,lev_Anal);
  484.         for k = 1:lev_Anal , maxTHR(k) = max(abs(wDEC(k,:))); end
  485.         valTHR = sw1dtool('compute_LVL_THR',win_tool);
  486.         valTHR = min(valTHR,maxTHR);
  487.         % Plotting Decomposition.
  488.         %------------------------
  489.         hdl_lines = sw1dtool('plot_dec',win_tool,wDEC,valTHR,maxTHR,'Off');
  490.         % Initialization of Denoising structure.
  491.         %--------------------------------------- 
  492.         utthrw1d('set',win_tool,...
  493.                        'thrstruct',{xmin,xmax,valTHR,hdl_lines},...
  494.                        'intdepthr',[]);
  495.         % Enabling HDLG.
  496.         %---------------
  497.         sw1dtool('enable',win_tool,'dec','on');
  498.         % End waiting.
  499.         %-------------
  500.         wwaiting('off',win_tool);
  501.     case 'denoise'
  502.         % De-noise and Plot.
  503.         %-----------------------------------------------------
  504.         % axes_hdl = [axe_left_1 axe_right_1 axe_medium ... 
  505.         %             axe_left axe_app_l axe_right axe_app_r];
  506.         %----------------------------------------------------
  507.         % Begin waiting.
  508.         %---------------
  509.         wwaiting('msg',win_tool,'Wait ... computing');
  510.         % Diseable De-noising Tool.
  511.         %---------------------------
  512.         utthrw1d('enable',win_tool,'off');
  513.         [axe_hdl,lin_hdl] = wmemtool('rmb',win_tool,n_membloc2, ...
  514.                                            ind_axe_hdl,ind_lin_hdl);
  515.         NB_axes = length(axe_hdl);
  516.         NB_lev  = wmemtool('rmb',win_tool,n_membloc1,ind_NB_lev);
  517.         sig  = get(lin_hdl(1),'Ydata');
  518.         wDEC = wmemtool('rmb',win_tool,n_membloc3,ind_coefs);
  519.         wDEC = utthrw1d('den_M1',win_tool,wDEC,length(sig));
  520.         d_axe = 3+max_lev_anal+1;
  521.         for k = 1:NB_lev
  522.             ind = k+d_axe;
  523.             vis = get(axe_hdl(ind),'Visible');
  524.             set(lin_hdl(ind),'Ydata',wDEC(k,:),'Visible',vis);
  525.         end
  526.         % Set right approximation visible'.
  527.         %----------------------------------
  528.         set(lin_hdl(end),'Visible','On');
  529.         % Plotting de-noised Signal.
  530.         %---------------------------
  531.         wname   = wmemtool('rmb',win_tool,n_membloc1,ind_wave);
  532.         den_sig = iswt(wDEC,wname);
  533.         set(lin_hdl(2),'Ydata',den_sig,'Visible','On');
  534.         lin_den = wmemtool('rmb',win_tool,n_membloc2,ind_lin_den);
  535.         set(lin_den,'Ydata',den_sig);
  536.         % Plotting "Noise".
  537.         %-------------------
  538.         residual = sig-den_sig;
  539.         set(lin_hdl(3),'Ydata',residual,'Visible','On');
  540.         % Dynvtool Attachement.
  541.         %---------------------
  542.         dynvtool('ini_his',win_tool,0);
  543.         set(axe_hdl(3),'Ylim',getylim(residual));
  544.         dynvtool('put',win_tool)
  545.         % Enabling HDLG.
  546.         %---------------
  547.         utthrw1d('enable',win_tool,'on');
  548.         sw1dtool('enable',win_tool,'den','on');
  549.         % End waiting.
  550.         %-------------
  551.         wwaiting('off',win_tool);
  552.     case 'show_lin_den'
  553.         chk_den = wmemtool('rmb',win_tool,n_membloc2,ind_chk_den);
  554.         if length(varargin)>1
  555.             vis = lower(varargin{2});
  556.             if isequal(vis,'on') , val = 1; else , val = 0; end 
  557.             set(chk_den,'value',val);
  558.         else
  559.             vis = deblank(getonoff(get(chk_den,'value')));
  560.         end
  561.         [axe_hdl,lin_den] = wmemtool('rmb',win_tool,n_membloc2,...
  562.                                            ind_axe_hdl,ind_lin_den);
  563.         strTitle = 'Signal (S)';
  564.         if isequal(vis,'on')
  565.             strTitle = [strTitle ' and De-Noised Signal (D_S)'];
  566.         end
  567.         set(lin_den,'Visible',vis);
  568.         wtitle(strTitle,'Parent',axe_hdl(1))
  569.     case 'position'
  570.         lev_Anal = varargin{2};
  571.         chk_den  = varargin{3};
  572.         set(chk_den,'Visible','off');
  573.         pos_old  = utthrw1d('get',win_tool,'position');
  574.         utthrw1d('set',win_tool,'position',{1,lev_Anal})
  575.         pos_new  = utthrw1d('get',win_tool,'position');
  576.         ytrans   = pos_new(2)-pos_old(2);
  577.         pos_chk  = get(chk_den,'Position');        
  578.         pos_chk(2) = pos_chk(2)+ytrans;
  579.         set(chk_den,'Position',pos_chk,'Visible','on');
  580.     case 'update_level'
  581.         pop_lev  = varargin{2}(1);
  582.         chk_den  = varargin{2}(2);
  583.         lev_New  = get(pop_lev,'value');
  584.         sw1dtool('position',win_tool,lev_New,chk_den);
  585.         [status,lev_Anal] = wmemtool('rmb',win_tool,n_membloc1,...
  586.             ind_status,ind_NB_lev);
  587.         sw1dtool('set_axes',win_tool,status);
  588.         vis_Lines = 'off';
  589.         vis_den_ovr = 'off';
  590.         if isequal(lev_New,lev_Anal)
  591.             switch status
  592.                 case -1 , 
  593.                     sw1dtool('enable',win_tool,'ini');
  594.                 case  0 ,
  595.                     sw1dtool('enable',win_tool,'dec');
  596.                 case  1 ,
  597.                     vis_Lines = 'on';
  598.                     val = get(chk_den,'Value');
  599.                     if val==1 , vis_den_ovr = 'on'; end
  600.                     sw1dtool('enable',win_tool,'dec','on');
  601.                     sw1dtool('enable',win_tool,'den','on');
  602.                     set(chk_den,'Value',val);
  603.             end
  604.         else
  605.             sw1dtool('enable',win_tool,'ini');
  606.         end
  607.         
  608.         % Get Handles.
  609.         %-------------
  610.         [axe_hdl,lin_hdl,lin_den] = wmemtool('rmb',win_tool,n_membloc2,...
  611.             ind_axe_hdl,ind_lin_hdl,ind_lin_den);
  612.         NBaxes = length(axe_hdl);
  613.         %-----------------------------------------------------
  614.         % axes_hdl = [axe_left_1 axe_right_1 axe_medium ...
  615.         %             axe_left axe_app_l axe_right axe_app_r];
  616.         %-----------------------------------------------------
  617.         NBaxdet = (NBaxes-5)/2;
  618.         i_app_l = 3+NBaxdet+1;
  619.         indOff  = [2,3,i_app_l+[1:NBaxdet],NBaxes];
  620.         axe_Off = axe_hdl(indOff);
  621.         axe_Off = axe_Off(ishandle(axe_Off));
  622.         lin_Off = findobj(axe_Off,'type','line');
  623.         set(lin_Off,'Visible',vis_Lines);
  624.         set(lin_den(1),'Visible',vis_den_ovr);
  625.     case 'compute_LVL_THR'
  626.         [numMeth,meth,alfa,sorh] = utthrw1d('get_LVL_par',win_tool);
  627.         wDEC = wmemtool('rmb',win_tool,n_membloc3,ind_coefs);
  628.         varargout{1} = wthrmngr('sw1ddenoLVL',meth,wDEC,alfa);
  629.     case 'update_LVL_meth'
  630.         sw1dtool('clear_GRAPHICS',win_tool);
  631.         valTHR = sw1dtool('compute_LVL_THR',win_tool);
  632.         utthrw1d('update_LVL_meth',win_tool,valTHR);
  633.     case 'clear_GRAPHICS'
  634.         status = wmemtool('rmb',win_tool,n_membloc1,ind_status);
  635.         if status<1 , return; end
  636.         % Diseable Toggle and Menus.
  637.         %---------------------------
  638.         sw1dtool('enable',win_tool,'den','off');
  639.         % Get Handles.
  640.         %-------------
  641.         [axe_hdl,lin_hdl] = wmemtool('rmb',win_tool,n_membloc2,...
  642.                                            ind_axe_hdl,ind_lin_hdl);
  643.         NBaxes = length(axe_hdl);
  644.         %-----------------------------------------------------
  645.         % axes_hdl = [axe_left_1 axe_right_1 axe_medium ...
  646.         %             axe_left axe_app_l axe_right axe_app_r];
  647.         %-----------------------------------------------------
  648.         lin_den = wmemtool('rmb',win_tool,n_membloc2,ind_lin_den);
  649.         sw1dtool('show_lin_den',win_tool,'off')
  650.         set(lin_den,'Ydata',get(lin_hdl(1),'Ydata'));
  651.         NBaxdet = (NBaxes-5)/2;
  652.         i_app_l = 3+NBaxdet+1;
  653.         indOff  = [2,3,i_app_l+[1:NBaxdet],NBaxes];
  654.         axe_Off = axe_hdl(indOff);
  655.         axe_Off = axe_Off(ishandle(axe_Off));
  656.         lin_Off = findobj(axe_Off,'type','line');
  657.         set(lin_Off,'Visible','off');
  658.     case 'enable'
  659.         type    = varargin{2};        
  660.         m_sav   = wmemtool('rmb',win_tool,n_membloc1,ind_sav_menu);
  661.         uic     = findobj(get(win_tool,'children'),'flat','type','uicontrol');
  662.         chk_den = wmemtool('rmb',win_tool,n_membloc2,ind_chk_den);
  663.         switch type 
  664.           case 'ini'
  665.             pus_dec = wmemtool('rmb',win_tool,n_membloc2,ind_pus_dec);
  666.             set([m_sav;chk_den],'Enable','off');
  667.             utthrw1d('status',win_tool,'off');
  668.             set(pus_dec,'Enable','on');
  669.           case 'dec'
  670.             level = wmemtool('rmb',win_tool,n_membloc1,ind_NB_lev);
  671.             set(m_sav,'Enable','off');
  672.             utthrw1d('status',win_tool,'on');
  673.             utthrw1d('enable',win_tool,'on',[1:level]);
  674.           case 'den'
  675.             enaVal = varargin{3};
  676.             set([m_sav;chk_den],'Enable',enaVal);
  677.             utthrw1d('enable_tog_res',win_tool,enaVal);
  678.             if strncmpi(enaVal,'on',2) , status = 1; else , status = 0; end
  679.             wmemtool('wmb',win_tool,n_membloc1,ind_status,status);
  680.         end
  681.     case 'set_axes'
  682.         %*************************************************************%
  683.         %** OPTION = 'set_axes' - Set axes positions and visibility **%
  684.         %*************************************************************%
  685.         status = varargin{2};
  686.         pos_win = get(win_tool,'Position');
  687.         [ax_hdl,lin_hdl,Pos_Graphic_Area] = ...
  688.             wmemtool('rmb',win_tool,n_membloc2, ...
  689.                      ind_axe_hdl,ind_lin_hdl,ind_gra_area);
  690.         [wname,NB_lev] = cbanapar('get',win_tool,'wav','lev');
  691.         delta_i_axe = 0;
  692.         % Hide axes
  693.         %-----------
  694.         lin_den = wmemtool('rmb',win_tool,n_membloc2,ind_lin_den);
  695.         if ishandle(lin_den)
  696.             vis_den = get(lin_den,'Visible');
  697.         else
  698.             vis_den = 'off';
  699.         end
  700.         obj_in_axes = findobj(ax_hdl);
  701.         set(obj_in_axes,'Visible','off');
  702.         % Plots.
  703.         %---------------------------------------------------
  704.         % ax_hdl = [axe_left_1 axe_right_1 axe_medium ... 
  705.         %           axe_left axe_app_l axe_right axe_app_r];
  706.         %---------------------------------------------------
  707.         NBaxes  = length(ax_hdl);
  708.         ax_l_1  = ax_hdl(1);
  709.         ax_r_1  = ax_hdl(2);
  710.         ax_med  = ax_hdl(3);
  711.         NBaxdet = (NBaxes-5)/2;
  712.         i_app_l = 3+NBaxdet+1;
  713.         i_app_r = NBaxes;
  714.         ax_det   = ax_hdl(4:i_app_l-1);
  715.         ax_app_l = ax_hdl(i_app_l);
  716.         ax_deno  = ax_hdl(i_app_l+1:i_app_r-1);
  717.         ax_app_r = ax_hdl(i_app_r);
  718.         % Axes parameters initialization.
  719.         %--------------------------------
  720.         pos_win   = get(win_tool,'Position');
  721.         h_gra_rem = Pos_Graphic_Area(4);
  722.         ecy_up    = 0.06*pos_win(4);
  723.         ecy_mid_1 = 0.08*pos_win(4);
  724.         ecy_mid_2 = 0.08*pos_win(4);
  725.         ecy_det   = (0.04*pos_win(4))/1.4;
  726.         ecy_mid_3 = ecy_det;
  727.         ecy_down  = 0.04*pos_win(4);        
  728.         h_min     = h_gra_rem/12;
  729.         h_max     = h_gra_rem/5;
  730.         h_axe_std = (h_min*NB_lev+h_max*(max_lev_anal-NB_lev))/max_lev_anal;
  731.         h_space   = ecy_up+ecy_mid_1+ecy_mid_2+ecy_mid_3+ ...
  732.                     NB_lev*ecy_det+ecy_down;
  733.         h_detail  = (h_gra_rem-2*h_axe_std-h_space)/(NB_lev+1);
  734.         y_low_ini = 1;
  735.  
  736.         % Building data axes.
  737.         %--------------------
  738.         y_low_ini       = y_low_ini-h_axe_std-ecy_up;
  739.         pos_axes        = get(ax_l_1,'Position');
  740.         pos_axes([2 4]) = [y_low_ini h_axe_std];
  741.         set(ax_l_1,'Position',pos_axes);
  742.         axe_vis         = [ax_l_1];
  743.         pos_axes        = get(ax_r_1,'Position');
  744.         pos_axes([2 4]) = [y_low_ini h_axe_std];
  745.         set(ax_r_1,'Position',pos_axes)
  746.         axe_vis         = [axe_vis ax_r_1];
  747.         
  748.         y_low_ini       = y_low_ini-h_axe_std-ecy_mid_1;
  749.         pos_axes        = get(ax_med,'Position');
  750.         pos_axes([2 4]) = [y_low_ini h_axe_std];
  751.         set(ax_med,'Position',pos_axes)
  752.         axe_vis         = [axe_vis ax_med];
  753.         % Position for approximation & details axes on the left part.
  754.         %------------------------------------------------------------
  755.         y_low_ini = y_low_ini-ecy_mid_2;
  756.         pos_axes  = get(ax_l_1,'Position');
  757.         pos_y     = [y_low_ini , h_detail];
  758.         % Left approximation axes.
  759.         %-------------------------
  760.         pos_y(1) = pos_y(1)-h_detail;
  761.         pos_axes([2 4]) = pos_y;
  762.         set(ax_app_l,'Position',pos_axes);
  763.         axe_vis  = [axe_vis ax_app_l];
  764.         pos_y(1) = pos_y(1)-ecy_mid_3;
  765.         % Left details axes.
  766.         %-------------------
  767.         for j = 1:NB_lev
  768.             i_axe   = NB_lev-j+1;
  769.             ax_act  = ax_det(i_axe);
  770.             pos_axes = get(ax_act,'Position');
  771.             pos_y(1) = pos_y(1)-h_detail-ecy_det;
  772.             pos_axes([2 4]) = pos_y;
  773.             set(ax_act,'Position',pos_axes);
  774.             axe_vis = [axe_vis ax_act];
  775.         end
  776.         i_ax_det_Title = NB_lev;
  777.         % Position for approximation & details axes on the right part.
  778.         %-------------------------------------------------------------
  779.         pos_axes = get(ax_r_1,'Position');
  780.         pos_y    = [y_low_ini , h_detail];
  781.         % Right approximation axes.
  782.         %--------------------------
  783.         pos_y(1) = pos_y(1)-h_detail;
  784.         pos_axes([2 4]) = pos_y;
  785.         set(ax_app_r,'Position',pos_axes);
  786.         axe_vis = [axe_vis ax_app_r];
  787.         pos_y(1) = pos_y(1)-ecy_mid_3;
  788.         % Right details axes.
  789.         %--------------------
  790.         for j = 1:NB_lev
  791.             i_axe   = NB_lev-j+1;
  792.             ax_act  = ax_deno(i_axe);
  793.             pos_axes = get(ax_act,'Position');
  794.             pos_y(1) = pos_y(1)-h_detail-ecy_det;
  795.             pos_axes([2 4]) = pos_y;
  796.             set(ax_act,'Position',pos_axes);
  797.             axe_vis = [axe_vis ax_act];
  798.         end
  799.         i_ax_den_Title = NB_lev;
  800.         % Modification of app_text.
  801.         %--------------------------
  802.         if status<0  % Initialize
  803.             txt_hdl = wmemtool('rmb',win_tool,n_membloc2,ind_txt_hdl);
  804.             txt_app_l = txt_hdl(i_app_l);
  805.             txt_app_r = txt_hdl(i_app_r);
  806.             num_app = NB_lev;
  807.             str_app = ['a' wnsubstr(num_app)];
  808.             set(txt_app_l,'string',str_app);
  809.             set(txt_app_r,'string',str_app);
  810.         end
  811.         % Set axes.
  812.         %-----------
  813.         axeNoXTick = [ax_app_l,ax_det([2:NB_lev]),ax_app_r,ax_deno([2:NB_lev])];
  814.         set(axeNoXTick,'Xtick',[],'XtickLabel',[]);
  815.         titles = get([ax_det;ax_deno],'title');
  816.         set(cat(1,titles{:}),'String','');
  817.         obj_in_axes_vis = findobj(axe_vis);
  818.         
  819.         if isequal(vis_den,'off')
  820.             indLineDEN = [2,3,i_app_l+1:i_app_r];
  821.             notVisible = lin_hdl(indLineDEN)';
  822.             obj_in_axes_vis = setdiff(obj_in_axes_vis,notVisible);
  823.         end
  824.         set(obj_in_axes_vis,'Visible','on');
  825.         if ishandle(lin_den) , set(lin_den,'Visible',vis_den); end
  826.         % Setting axes title
  827.         %--------------------
  828.         wtitle('Signal (S)','Parent',ax_l_1)
  829.         wtitle('Residuals = S - D_S','Parent',ax_med)
  830.         wtitle('De-Noised Signal (D_S)','Parent',ax_r_1)
  831.         axAct = ax_det(i_ax_det_Title);
  832.         wtitle('Non-decimated Details Coefficients','Parent',axAct);
  833.         axAct = ax_deno(i_ax_den_Title);
  834.         wtitle('De-noised non-decimated Details Coefficients','Parent',axAct);
  835.         wtitle('Non-decimated Approximation Coefficients','Parent',ax_app_l);
  836.         wtitle('Non-decimated Approximation Coefficients','Parent',ax_app_r);
  837.     case 'plot_ini'
  838.         sig_anal = varargin{2};
  839.         [ax_hdl,lin_hdl] = wmemtool('rmb',win_tool,n_membloc2, ...
  840.                                           ind_axe_hdl,ind_lin_hdl);
  841.         ax_data = ax_hdl(1);
  842.         color   = wtbutils('colors','sig');
  843.         xmin    = 1;
  844.         xmax    = length(sig_anal);
  845.         xdata   = [xmin:xmax];
  846.         lin_hdl(1) = line(...
  847.                           'Parent',ax_data, ...
  848.                           'Xdata',xdata,    ...
  849.                           'Ydata',sig_anal, ...
  850.                           'Color',color,    ...
  851.                           'tag',tag_sig_ori ...
  852.                           );
  853.         color = wtbutils('colors','ssig');
  854.         lin_den = line(...
  855.                        'Parent',ax_data,    ...
  856.                        'Visible','off',     ...
  857.                        'Xdata',xdata,       ...
  858.                        'Ydata',sig_anal,    ...
  859.                        'Color',color        ...
  860.                        );
  861.         ylim = getylim(sig_anal);
  862.         set(ax_data,'Ylim',ylim)
  863.         wtitle(['Signal (S)'],'Parent',ax_data);
  864.         set(ax_hdl,'Xlim',[xmin xmax]);
  865.         wmemtool('wmb',win_tool,n_membloc2,...
  866.                        ind_lin_hdl,lin_hdl,ind_lin_den,lin_den);
  867.         utthrw1d('set',win_tool,'handleORI',lin_hdl(1));
  868.     case 'plot_dec'
  869.         %****************************%
  870.         %** OPTION = 'plot_dec' -  **%
  871.         %****************************%
  872.         % out1 = hdl_line_cfs
  873.         %------------------
  874.         wDEC   = varargin{2};
  875.         valTHR = varargin{3};
  876.         maxTHR = varargin{4};
  877.         visFLG = varargin{5};
  878.         %------------------
  879.         [nbrow,lon] = size(wDEC);
  880.         % Plots.
  881.         %-----------------------------------------------------
  882.         % axes_hdl = [axe_left_1 axe_right_1 axe_medium ... 
  883.         %             axe_left axe_app_l axe_right axe_app_r];
  884.         %----------------------------------------------------
  885.         nbdet   = nbrow-1;
  886.         [ax_hdl,lin_hdl,txt_hdl,lin_den] = ...
  887.                 wmemtool('rmb',win_tool,n_membloc2, ...
  888.                                ind_axe_hdl,ind_lin_hdl,ind_txt_hdl,ind_lin_den);
  889.         NBaxes  = length(ax_hdl);
  890.         ax_l_1  = ax_hdl(1);
  891.         ax_r_1  = ax_hdl(2);
  892.         ax_med  = ax_hdl(3);
  893.         NBaxdet = (NBaxes-5)/2;
  894.         i_app_l = 3+NBaxdet+1;
  895.         i_app_r = NBaxes;
  896.         ax_det   = ax_hdl(4:i_app_l-1);
  897.         ax_app_l = ax_hdl(i_app_l);
  898.         ax_deno  = ax_hdl(i_app_l+1:i_app_r-1);
  899.         ax_app_r = ax_hdl(i_app_r);
  900.         ind_den  = i_app_l+[1:nbdet];
  901.         % Reset lin_den.
  902.         %---------------
  903.         set(lin_den,'Ydata',get(lin_hdl(1),'Ydata'));
  904.         % Clean axes.
  905.         %------------
  906.         axes2clean = [ax_r_1,ax_med,ax_det,ax_app_l,ax_deno,ax_app_r];
  907.         obj2del = findobj(axes2clean,'type','line');
  908.         delete(obj2del)
  909.         lin_hdl([2:NBaxes]) = NaN;
  910.         % Compute X-interval.
  911.         %--------------------
  912.         xmin = 1;   xmax = lon;
  913.         % Plotting details.
  914.         %------------------
  915.         delta_i_axe = 0;
  916.         colorDET = wtbutils('colors','det',nbdet);
  917.         ideb  = 1;
  918.         out1  = zeros(nbdet,1);
  919.         for k = 1:nbdet
  920.           i_axe  = k+delta_i_axe;
  921.           ax_act = ax_det(i_axe);
  922.           ybounds = [-valTHR(k) , valTHR(k) , -maxTHR(k) , maxTHR(k)];
  923.           tag     = ['cfs_' int2str(i_axe)];
  924.           out1(k) = plotline(ax_act,[xmin:xmax],wDEC(k,:), ...
  925.                              colorDET(k,:),tag,'On',ybounds);
  926.           utthrw1d('plot_dec',win_tool,i_axe,{maxTHR(k),valTHR(k),xmin,xmax,k});
  927.         end
  928.         lin_hdl(3+[1:nbdet]) = out1;
  929.         i_last_det = i_axe;
  930.         % Plotting coarse approximation.
  931.         %-------------------------------
  932.         app = wDEC(nbrow,:);
  933.         txt = ['a' wnsubstr(nbdet)];
  934.         color = wtbutils('colors','app',1);
  935.         lin_hdl(i_app_l) = plotline(ax_app_l,[xmin:xmax],app,color,tag_app,'On');
  936.         set(txt_hdl(i_app_l),'String',txt);
  937.         lin_hdl(i_app_r) = plotline(ax_app_r,[xmin:xmax],app,...
  938.                                     color,tag_app,visFLG);
  939.         set(txt_hdl(i_app_r),'String',txt);
  940.         % Plotting de-noised details.
  941.         %----------------------------
  942.         for k = 1:nbdet
  943.             i_axe = k+delta_i_axe;
  944.             tag_det = ['det_' int2str(i_axe)];
  945.             ax_act  = ax_deno(i_axe);
  946.             lin_hdl(ind_den(k)) = ...  
  947.              plotline(ax_act,[xmin:xmax],wDEC(k,:),colorDET(k,:),tag_det,visFLG);
  948.         end
  949.         % Plotting de-noised Signal.
  950.         %---------------------------
  951.         color = wtbutils('colors','ssig');
  952.         sig  = get(lin_hdl(1),'Ydata');
  953.         lin_hdl(2) = plotline(ax_r_1,[xmin:xmax],sig,color,tag_sig_den,visFLG);
  954.         % Plotting residuals.
  955.         %--------------------
  956.         color = wtbutils('colors','res');
  957.         lin_hdl(3) = plotline(ax_med,[xmin:xmax],zeros(size(sig)),...
  958.                      color,tag_noise,'Off');
  959.         wmemtool('wmb',win_tool,n_membloc2,ind_lin_hdl,lin_hdl);
  960.         utthrw1d('set',win_tool,'handleTHR',lin_hdl(2),'handleRES',lin_hdl(3));
  961.         axeNoXTick = [ax_det(2:NBaxdet),ax_app_l,ax_deno(2:NBaxdet),ax_app_r];
  962.         set(axeNoXTick,'Xtick',[],'XtickLabel',[]);
  963.         set(ax_hdl,'Xlim',[xmin xmax])
  964.         % Dynvtool Attachement.
  965.         %---------------------
  966.         dynvtool('init',win_tool,[],ax_hdl,[],[1 0],'','','')
  967.  
  968.         varargout = {out1};
  969.  
  970.     case 'close'
  971.     otherwise
  972.         errargt(mfilename,'Unknown Option','msg');
  973.         error('*');
  974. end
  975. %=============================================================================%
  976. % INTERNAL FUNCTIONS
  977. %=============================================================================%
  978. %-----------------------------------------------------------------------------%
  979. function setDEMOS(m_demo,funcName,str_numwin,demoSET,sepFlag)
  980. beg_call_str = [funcName '(''demo'',' str_numwin ','''];
  981. nbDEM = size(demoSET,1);
  982. for k=1:nbDEM
  983.     nam = demoSET{k,1};
  984.     fil = demoSET{k,2};
  985.     wav = demoSET{k,3};
  986.     lev = int2str(demoSET{k,4});
  987.     par = demoSET{k,5};       
  988.     libel = ['with ' wav ' at level ' lev  '  --->  ' nam];
  989.     action = [beg_call_str fil ''',''' wav ''',' lev ',' par ');'];
  990.     if sepFlag & (k==1) , sep = 'on'; else , sep = 'off'; end
  991.     uimenu(m_demo,'Label',libel,'Separator',sep,'Callback',action);
  992. end
  993. %-----------------------------------------------------------------------------%
  994. function ylim = getylim(sig)
  995. mini = min(sig);
  996. maxi = max(sig);
  997. if abs(maxi-mini)<eps
  998.     maxi = maxi+0.0001;
  999.     mini = mini-0.0001;
  1000. end;
  1001. yec  = 0.05*(maxi-mini);
  1002. ylim = [mini-yec maxi+yec];
  1003. %-----------------------------------------------------------------------------%
  1004. function ll = plotlineOLD(axe,x,y,color,tag,ylimplus)
  1005. ll = findobj(axe,'type','line','tag',tag);
  1006. if isempty(ll)
  1007.     ll = line('Parent',axe,'Xdata',x,'Ydata',y,'Color',color,'tag',tag);
  1008. else
  1009.     set(ll,'Xdata',x,'Ydata',y,'Color',color,'tag',tag);
  1010. end
  1011. if nargin<6
  1012.     ylim = getylim(y);
  1013. else
  1014.     ylim = getylim([y(:) ; ylimplus(:)]);
  1015. end
  1016. set(axe,'Ylim',ylim);
  1017. %-----------------------------------------------------------------------------%
  1018. function ll = plotline(axe,x,y,color,tag,vis,ylimplus)
  1019. ll = findobj(axe,'type','line','tag',tag);
  1020. if isempty(ll)
  1021.     ll = line('Parent',axe,'Xdata',x,'Ydata',y,...
  1022.               'Visible',vis,'Color',color,'tag',tag);
  1023. else
  1024.     set(ll,'Xdata',x,'Ydata',y,'Color','Visible',vis,color,'tag',tag);
  1025. end
  1026. if nargin<7
  1027.     ylim = getylim(y);
  1028. else
  1029.     ylim = getylim([y(:) ; ylimplus(:)]);
  1030. end
  1031. set(axe,'Ylim',ylim);
  1032. %-----------------------------------------------------------------------------%
  1033. %=============================================================================%