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

波变换

开发平台:

Matlab

  1. function varargout = dw1ddeno(option,varargin)
  2. %DW1DDENO Wavelet 1-D de-noising.
  3. %   VARARGOUT = DW1DDENO(OPTION,VARARGIN)
  4. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 12-Mar-96.
  5. %   Last Revision: 03-Feb-2003.
  6. %   Copyright 1995-2004 The MathWorks, Inc.
  7. %   $Revision: 1.19.4.2 $
  8. % Default Value(s).
  9. %------------------
  10. def_nbCodeOfColors = 128;
  11. % Memory Blocks of stored values.
  12. %================================
  13. % MB1.
  14. %-----
  15. n_param_anal   = 'DWAn1d_Par_Anal';
  16. ind_sig_name   = 1;
  17. ind_sig_size   = 2;
  18. ind_wav_name   = 3;
  19. ind_lev_anal   = 4;
  20. ind_axe_ref    = 5;
  21. ind_act_option = 6;
  22. ind_ssig_type  = 7;
  23. ind_thr_val    = 8;
  24. nb1_stored     = 8;
  25. % MB2.
  26. %-----
  27. n_coefs_longs = 'Coefs_and_Longs';
  28. ind_coefs     = 1;
  29. ind_longs     = 2;
  30. nb2_stored    = 2;
  31. % MB1 (local).
  32. %-------------
  33. n_misc_loc = ['MB1_' mfilename];
  34. ind_sav_menus  = 1;
  35. ind_status     = 2;
  36. ind_win_caller = 3;
  37. ind_axe_datas  = 4;
  38. ind_hdl_datas  = 5;
  39. ind_cfsMode    = 6;
  40. ind_lin_cfs    = 7;
  41. nbLOC_1_stored = 7;
  42. % MB2 (local).
  43. %-------------
  44. n_thrDATA = 'thrDATA';
  45. ind_value = 1;
  46. nbLOC_2_stored = 1;
  47. if ~isequal(option,'create') , win_denoise = varargin{1}; end
  48. switch option
  49.     case 'create'
  50.         % Get Globals.
  51.         %-------------
  52.         [Def_Btn_Height,Y_Spacing,Def_FraBkColor] = ...
  53.             mextglob('get','Def_Btn_Height','Y_Spacing','Def_FraBkColor');
  54.         % Calling figure.
  55.         %----------------
  56.         win_caller     = varargin{1};
  57.         str_win_caller = sprintf('%.0f',win_caller);
  58.         % Window initialization.
  59.         %----------------------
  60.         win_name = 'Wavelet 1-D  --  De-noising';
  61.         [win_denoise,pos_win,win_units,str_win_denoise,...
  62.                 frame0,pos_frame0,Pos_Graphic_Area,pus_close] = ...
  63.                     wfigmngr('create',win_name,'','ExtFig_CompDeno', ...
  64.                         strvcat(mfilename,'cond'),1,1,0);
  65.         set(win_denoise,'userdata',win_caller);
  66.         varargout{1} = win_denoise;
  67. % Add Help for Tool.
  68. %------------------
  69. wfighelp('addHelpTool',win_denoise,'Signal De-noising','DW1D_DENO_GUI');
  70. % Add Help Item.
  71. %----------------
  72. wfighelp('addHelpItem',win_denoise,'De-noising Procedure','DENO_PROCEDURE');
  73. wfighelp('addHelpItem',win_denoise,'Available Methods','COMP_DENO_METHODS');
  74. wfighelp('addHelpItem',win_denoise,'Variance Adaptive Thresholding','VARTHR');
  75.         % Menu construction for current figure.
  76.         %--------------------------------------
  77. m_save  = wfigmngr('getmenus',win_denoise,'save');
  78.         sav_menus(1) = uimenu(m_save,...
  79.                                 'Label','De-noised &Signal ',...
  80.                                 'Position',1,                    ...
  81.                                 'Enable','Off',                  ...
  82.                                 'Callback',                      ...
  83.                                 [mfilename '(''save_synt'','     ...
  84.                                         str_win_denoise ');']    ...
  85.                                 );
  86.         sav_menus(2) = uimenu(m_save,...
  87.                                'Label','&Coefficients ',  ...
  88.                                'Position',2,                  ...
  89.                                'Enable','Off',                ...
  90.                                'Callback',                    ...
  91.                                [mfilename '(''save_cfs'','    ...
  92.                                        str_win_denoise ');']  ...
  93.                                );
  94.         sav_menus(3) = uimenu(m_save,...
  95.                                 'Label','&Decomposition ', ...
  96.                                 'Position',3,                  ...
  97.                                 'Enable','Off',                ...
  98.                                 'Callback',                    ...
  99.                                 [mfilename '(''save_dec'','    ...
  100.                                         str_win_denoise ');']  ...
  101.                                 );
  102.         % Begin waiting.
  103.         %---------------
  104.         wwaiting('msg',win_denoise,'Wait ... initialization');
  105.         % Getting variables from dw1dtool figure memory block.
  106.         %-----------------------------------------------------
  107.         [Sig_Name,Wav_Name,Lev_Anal,Sig_Size] = ...
  108.                         wmemtool('rmb',win_caller,n_param_anal, ...
  109.                                 ind_sig_name,ind_wav_name,      ...
  110.                                 ind_lev_anal,ind_sig_size);
  111.         Wav_Fam = wavemngr('fam_num',Wav_Name);
  112.         [coefs,longs] = wmemtool('rmb',win_caller,n_coefs_longs, ...
  113.                                        ind_coefs,ind_longs);
  114.         % Parameters initialization.
  115.         %---------------------------
  116.         dy = Y_Spacing;
  117.         % Command part of the window.
  118.         %============================
  119.         
  120.         % Position property of objects.
  121.         %------------------------------
  122.         xlocINI = pos_frame0([1 3]);
  123.         ytopINI = pos_win(4)-dy;
  124.         % Data, Wavelet and Level parameters.
  125.         %------------------------------------
  126.         toolPos = utanapar('create_copy',win_denoise, ...
  127.                     {'xloc',xlocINI,'top',ytopINI},...
  128.                     {'n_s',{Sig_Name,Sig_Size},'wav',Wav_Name,'lev',Lev_Anal} ...
  129.                     );
  130.         % Threshold tool.
  131.         %----------------
  132.         ytopTHR = toolPos(2)-4*dy;
  133.         utthrw1d('create',win_denoise, ...
  134.                  'xloc',xlocINI,'top',ytopTHR,...
  135.                  'ydir',-1, ...
  136.                  'levmax',Lev_Anal, ...
  137.                  'levmaxMAX',Lev_Anal, ...
  138.                  'caller',mfilename, ...
  139.                  'toolOPT','deno' ...
  140.                  );
  141.         % Adding colormap GUI.
  142.         %---------------------
  143.         [viewType,hdl_cfs] = dw1dvdrv('get_imgcfs',win_caller);
  144.         if isequal(viewType,'image') & (Lev_Anal<8)
  145.             [pop_pal_caller,mapName,nbColors] = ...
  146.                 cbcolmap('get',win_caller,'pop_pal','mapName','nbColors');
  147.             utcolmap('create',win_denoise, ...
  148.                      'xloc',xlocINI, ...
  149.                      'bkcolor',Def_FraBkColor, ...
  150.                      'briflag',0, ...
  151.                      'enable','on');
  152.             pop_pal_loc = cbcolmap('get',win_denoise,'pop_pal');
  153.             set(pop_pal_loc,'Userdata',get(pop_pal_caller,'Userdata'));
  154.             cbcolmap('set',win_denoise,'pal',{mapName,nbColors});
  155.         end
  156.         % General graphical parameters initialization.
  157.         %--------------------------------------------
  158.         bdx      = 0.08*pos_win(3);
  159.         bdy      = 0.06*pos_win(4);
  160.         ecy      = 0.03*pos_win(4);
  161.         y_graph  = 2*Def_Btn_Height+dy;
  162.         h_graph  = pos_frame0(4)-y_graph;
  163.         w_graph  = pos_frame0(1);
  164.         fontsize = wmachdep('fontsize','normal',9,Lev_Anal);
  165.         % Axes construction parameters.
  166.         %------------------------------
  167.         w_left     = (w_graph-3*bdx)/2;
  168.         x_left     = bdx;
  169.         w_right    = w_left;
  170.         x_right    = x_left+w_left+5*bdx/4;
  171.         n_axeleft  = Lev_Anal;
  172.         n_axeright = 3;
  173.         ind_left   = n_axeleft;
  174.         ind_right  = n_axeright;
  175.         % Vertical separation.
  176.         %---------------------
  177.         w_fra = 0.01*pos_win(3);
  178.         x_fra = (w_graph-w_fra)/2;
  179.         uicontrol('Parent',win_denoise,...
  180.                   'Style','frame',...
  181.                   'Unit',win_units,...
  182.                   'Position',[x_fra,y_graph,w_fra,h_graph],...
  183.                   'Backgroundcolor',Def_FraBkColor ...
  184.                   );
  185.         % Building axes on the right part.
  186.         %---------------------------------
  187.         ecy_right = 2*ecy;
  188.         h_right =(h_graph-2*bdy-(n_axeright-1)*ecy_right)/n_axeright;
  189.         y_right = y_graph+bdy;
  190.         axe_datas = zeros(1,n_axeright);
  191.         pos_right = [x_right y_right w_right h_right];
  192.         for k = 1:n_axeright
  193.             axe_datas(k) = axes(...
  194.                                 'Parent',win_denoise, ...
  195.                                 'Units',win_units,     ...
  196.                                 'Position',pos_right,  ...
  197.                                 'Drawmode','fast',     ...
  198.                                 'Box','On'             ...
  199.                                 );
  200.             pos_right(2) = pos_right(2)+pos_right(4)+ecy_right;
  201.         end
  202.         set(axe_datas(1),'visible','off');
  203.         % Displaying the signal.
  204.         %-----------------------
  205.         sig = dw1dfile('sig',win_caller,1);
  206.         axeAct = axe_datas(3);
  207.         axes(axeAct)
  208.         curr_color = wtbutils('colors','sig');
  209.         lin_sig = line(...
  210.                        'Xdata',1:length(sig),...
  211.                        'Ydata',sig,...
  212.                        'erasemode','none',...
  213.                        'Color',curr_color,...
  214.                        'Parent',axeAct);
  215.         wtitle('Original signal','Parent',axeAct);
  216.         xlim = [1         Sig_Size];
  217.         ylim = [min(sig)  max(sig)];
  218.         if xlim(1)==xlim(2) , xlim = xlim+0.01*[-1 1]; end
  219.         if ylim(1)==ylim(2) , ylim = ylim+0.01*[-1 1]; end
  220.         set(axeAct,'Xlim',xlim,'Ylim',ylim);
  221.         utthrw1d('set',win_denoise,'handleORI',lin_sig);
  222.         % Displaying original details coefficients.
  223.         %------------------------------------------
  224.         axeAct = axe_datas(2);
  225.         [viewType,hdl_cfs] = dw1dvdrv('get_imgcfs',win_caller);
  226.         [details,set_ylim,ymin,ymax] = dw1dfile('cfs_beg',win_caller,...
  227.                             [1:Lev_Anal],1);
  228.         
  229.         if isequal(viewType,'image')
  230.             flagType = 1;
  231.             cfsMode  = [];
  232.             set(win_denoise,'Colormap',get(win_caller,'Colormap'));
  233.             [nul,i_min] = min(abs(details(:)));
  234.             if ~isempty(hdl_cfs)
  235.                 col_cfs = flipud(get(hdl_cfs,'Cdata'));
  236.             else
  237.                 col_cfs = wcodemat(details,def_nbCodeOfColors,'row',1);
  238.             end
  239.             col_min = col_cfs(i_min);
  240.             col_cfs = flipud(col_cfs);
  241.             axes(axeAct);
  242.             cfs_ori = image(col_cfs,'Parent',axeAct,'Userdata',col_min);
  243.             clear col_cfs
  244.             levlab = int2str([Lev_Anal:-1:1]');
  245.         else
  246.             flagType = -1;
  247.             axes(axeAct);
  248.             hdl_stem = copyobj(hdl_cfs,axeAct);
  249.             set(hdl_stem,'Visible','on');
  250.             cfsMode = get(hdl_stem(1),'Userdata');
  251.             levlab  = int2str([1:Lev_Anal]');
  252.             cfs_ori = '';
  253.         end
  254.         set(axeAct,...
  255.               'Userdata',cfs_ori,       ...
  256.               'Xlim',[1 Sig_Size],      ...
  257.               'YTicklabelMode','manual',...
  258.               'YTick',[1:Lev_Anal],     ...
  259.               'YTickLabel',levlab,      ...
  260.               'Ylim',[0.5 Lev_Anal+0.5] ...
  261.               );
  262.         wtitle('Original coefficients','Parent',axeAct);
  263.         wylabel('Level number','Parent',axeAct);
  264.         xylim = get(axeAct,{'Xlim','Ylim'});        
  265.         set(axe_datas(1),'Xlim',xylim{1},'Ylim',xylim{2});
  266.         % Building axes on the left part.
  267.         %--------------------------------
  268.         ecy_left = ecy/2;
  269.         h_left   = (h_graph-2*bdy-(n_axeleft-1)*ecy_left)/n_axeleft;
  270.         y_left   = y_graph+0.75*bdy;
  271.         axe_left = zeros(1,n_axeleft);
  272.         txt_left = zeros(1,n_axeleft);
  273.         pos_left = [x_left y_left w_left h_left];
  274.         commonProp = {...
  275.            'Parent',win_denoise,...
  276.            'Units',win_units,...
  277.            'Drawmode','fast',...
  278.            'Box','On'...
  279.            };
  280.         for k = 1:n_axeleft
  281.             if k~=1
  282.                 axe_left(k) = axes(commonProp{:}, ...
  283.                                   'Position',pos_left,...
  284.                                   'XTicklabelMode','manual','XTickLabel',[]);
  285.             else
  286.                 axe_left(k) = axes(commonProp{:},'Position',pos_left);
  287.             end
  288.             pos_left(2) = pos_left(2)+pos_left(4)+ecy_left;
  289.             txt_left(k) = txtinaxe('create',['d' wnsubstr(k)],...
  290.                                     axe_left(k),'left',...
  291.                                     'on','bold',fontsize);
  292.         end
  293.         utthrw1d('set',win_denoise,'axes',axe_left);
  294.         % Initializing by level threshold.
  295.         %---------------------------------
  296.         maxTHR = zeros(1,Lev_Anal);
  297.         for k = 1:Lev_Anal , maxTHR(k) = max(abs(details(k,:))); end
  298.         valTHR = dw1ddeno('compute_LVL_THR',win_denoise,win_caller);
  299.         valTHR = min(valTHR,maxTHR);
  300.         % Displaying details.
  301.         %-------------------
  302.         col_det = wtbutils('colors','det',Lev_Anal);
  303.         for k = Lev_Anal:-1:1
  304.             axeAct  = axe_left(ind_left);
  305.             axes(axeAct);
  306.             lin_cfs(k) = line(...
  307.                              'Parent',axeAct,...
  308.                              'Xdata',1:Sig_Size,...
  309.                              'Ydata',details(k,:),...
  310.                              'Color',col_det(k,:));
  311.             utthrw1d('plot_dec',win_denoise,k, ...
  312.                      {maxTHR(k),valTHR(k),1,Sig_Size,k})
  313.             maxi = max([abs(ymax(k)),abs(ymin(k))]);
  314.             if abs(maxi)<eps , maxi = maxi+0.01; end;
  315.             ylim = 1.1*[-maxi maxi];
  316.             set(axe_left(ind_left),'Xlim',xlim,'Ylim',ylim);
  317.             ind_left = ind_left-1;
  318.         end
  319.         axeAct = axe_left(Lev_Anal);
  320.         wtitle('Original details coefficients','Parent',axeAct);
  321.         % Axes attachment.
  322.         %-----------------
  323.         if flagType~=-1
  324.             axe_cmd = [axe_datas(1:3) axe_left(1:n_axeleft)];
  325.             axe_act = [];
  326.             axe_cfs = [axe_datas(1:2)];
  327.         else
  328.             axe_cmd = [axe_datas(1:3) axe_left(1:n_axeleft)];
  329.             axe_act = [];
  330.             axe_cfs = [axe_datas(1:2)];
  331.         end
  332.         dynvtool('init',win_denoise,[],axe_cmd,axe_act,[1 0], ...
  333.                         '','','dw1dcoor',[win_caller,axe_cfs,flagType*Lev_Anal]);
  334. %        dynvtool('init',win_denoise,[],axe_cmd,axe_act,[1 0], ...
  335. %                        '','','dw1dcoor',[axe_cfs flagType*Lev_Anal],...
  336. %                        'cbthrw1d',[axe_left(1:n_axeleft)]);
  337.         % Initialization of  Denoising structure.
  338.         %----------------------------------------
  339.         xmin = 1; xmax = Sig_Size;
  340.         utthrw1d('set',win_denoise,...
  341.                        'thrstruct',{xmin,xmax,valTHR,lin_cfs},...
  342.                        'intdepthr',[]);
  343.         % Memory blocks update.
  344.         %----------------------
  345.         wmemtool('ini',win_denoise,n_misc_loc,nbLOC_1_stored);
  346.         wmemtool('wmb',win_denoise,n_misc_loc,    ...
  347.                        ind_sav_menus,sav_menus,   ...
  348.                        ind_status,0,              ...
  349.                        ind_win_caller,win_caller, ...
  350.                        ind_axe_datas,axe_datas,   ...
  351.                        ind_cfsMode,cfsMode,       ...
  352.                        ind_lin_cfs,lin_cfs        ...
  353.                        );
  354.         wmemtool('ini',win_denoise,n_thrDATA,nbLOC_2_stored);
  355.         % Setting units to normalized.
  356.         %-----------------------------
  357.         wfigmngr('normalize',win_denoise);
  358.         % End waiting.
  359.         %-------------
  360.         utthrw1d('enable',win_denoise,'on',[1:Lev_Anal]);
  361.         wwaiting('off',win_denoise);
  362.     case 'denoise'
  363.         % Waiting message.
  364.         %-----------------
  365.         wwaiting('msg',win_denoise,'Wait ... computing');
  366.         % Clear & Get Handles.
  367.         %----------------------
  368.         dw1ddeno('clear_GRAPHICS',win_denoise);
  369.         win_caller = wmemtool('rmb',win_denoise,n_misc_loc,ind_win_caller);
  370.         axe_datas = wmemtool('rmb',win_denoise,n_misc_loc,ind_axe_datas);
  371.         % Getting memory blocks.
  372.         %-----------------------
  373.         [Wav_Name,Lev_Anal,Sig_Size] = ...
  374.                         wmemtool('rmb',win_caller,n_param_anal, ...
  375.                                        ind_wav_name,ind_lev_anal,ind_sig_size);
  376.         [coefs,longs] = wmemtool('rmb',win_caller,n_coefs_longs, ...
  377.                                        ind_coefs,ind_longs);
  378.         % De-noising depending on the selected thresholding mode.
  379.         %--------------------------------------------------------
  380.         cxc = utthrw1d('den_M2',win_denoise,coefs,longs);
  381.         lxc = longs;
  382.         xc  = waverec(cxc,longs,Wav_Name);
  383.         % Displaying denoised signal.
  384.         %----------------------------
  385.         lin_den = utthrw1d('get',win_denoise,'handleTHR');
  386.         if ishandle(lin_den)
  387.             set(lin_den,'Ydata',xc,'Visible','on');
  388.         else
  389.             curr_color = wtbutils('colors','ssig');
  390.             lin_den = line(...
  391.                            'Parent',axe_datas(3), ...
  392.                            'Xdata',1:length(xc),  ...
  393.                            'Ydata',xc,            ...
  394.                            'color',curr_color     ...
  395.                            );
  396.             utthrw1d('set',win_denoise,'handleTHR',lin_den);
  397.         end     
  398.         wtitle('Original and de-noised signals','Parent',axe_datas(3));
  399.         % Displaying thresholded details coefficients.
  400.         %---------------------------------------------
  401.         cfsMode = wmemtool('rmb',win_denoise,n_misc_loc,ind_cfsMode);
  402.         if isempty(cfsMode)
  403.             col_cfs   = wrepcoef(cxc,lxc);
  404.             nz_cfs    = find(col_cfs~=0);
  405.             [nbr,nbc] = size(col_cfs);
  406.             img_cfs   = get(axe_datas(2),'Userdata');
  407.             col_min   = get(img_cfs,'Userdata');
  408.             cfs_ori   = flipud(get(img_cfs,'Cdata'));
  409.             col_cfs   = col_min*ones(nbr,nbc);
  410.             col_cfs(nz_cfs) = cfs_ori(nz_cfs);
  411.             image(flipud(col_cfs),'Parent',axe_datas(1));
  412.             levlab = int2str([Lev_Anal:-1:1]');
  413.         else
  414.             dw1dstem(axe_datas(1),cxc,lxc,'mode',cfsMode,'colors','WTBX');
  415.             levlab = int2str([1:Lev_Anal]');
  416.         end
  417.         set(axe_datas(1),...
  418.                 'clipping','on',            ...
  419.                 'Xlim',get(axe_datas(2),'Xlim'),...                    
  420.                 'YTicklabelMode','manual',  ...
  421.                 'YTick',[1:Lev_Anal],       ...
  422.                 'YTickLabel',levlab,        ...
  423.                 'Ylim',[0.5 Lev_Anal+0.5]   ...
  424.                 );
  425.         wtitle('Thresholded coefficients','Parent',axe_datas(1));
  426.         wylabel('Level number','Parent',axe_datas(1));
  427.         set(findobj(axe_datas(1)),'Visible','on');
  428.         % Memory blocks update.
  429.         %----------------------
  430.         thrStruct = utthrw1d('get',win_denoise,'thrstruct');
  431.         thrParams = {thrStruct(1:Lev_Anal).thrParams};
  432.         wmemtool('wmb',win_denoise,n_thrDATA,ind_value,{xc,cxc,lxc,thrParams});
  433.         dw1ddeno('enable_menus',win_denoise,'on');
  434.         % End waiting.
  435.         %-------------
  436.         wwaiting('off',win_denoise);
  437.     case 'compute_LVL_THR'
  438.         win_caller = varargin{2};
  439.         [numMeth,meth,alfa,sorh] = utthrw1d('get_LVL_par',win_denoise);
  440.         [coefs,longs] = wmemtool('rmb',win_caller,n_coefs_longs,...
  441.                                        ind_coefs,ind_longs);
  442.         varargout{1} = wthrmngr('dw1ddenoLVL',meth,coefs,longs,alfa);
  443.     case 'update_LVL_meth'
  444.         dw1ddeno('clear_GRAPHICS',win_denoise);
  445.         win_caller = wmemtool('rmb',win_denoise,n_misc_loc,ind_win_caller);
  446.         valTHR = dw1ddeno('compute_LVL_THR',win_denoise,win_caller);
  447.         utthrw1d('update_LVL_meth',win_denoise,valTHR);
  448.     case 'clear_GRAPHICS'
  449.         status = wmemtool('rmb',win_denoise,n_misc_loc,ind_status);
  450.         if status == 0 , return; end
  451.         % Diseable Toggle and Menus.
  452.         %---------------------------
  453.         dw1ddeno('enable_menus',win_denoise,'off');
  454.         % Get Handles.
  455.         %-------------
  456.         axe_datas = wmemtool('rmb',win_denoise,n_misc_loc,ind_axe_datas);
  457.         % Setting the de-noised coefs axes invisible.
  458.         %--------------------------------------------
  459.         lin_den = utthrw1d('get',win_denoise,'handleTHR');
  460.         if ~isempty(lin_den)
  461.            vis = get(lin_den,'Visible');
  462.            if vis(1:2)=='on'
  463.                set(findobj(axe_datas(1)),'Visible','off');
  464.                axes(axe_datas(3));
  465.                wtitle('Original signal','Parent',axe_datas(3));
  466.                set(lin_den,'Visible','off');
  467.            end
  468.         end
  469.     case 'enable_menus'
  470.         enaVal = varargin{2};
  471.         sav_menus = wmemtool('rmb',win_denoise,n_misc_loc,ind_sav_menus);
  472.         set(sav_menus,'Enable',enaVal);
  473.         utthrw1d('enable_tog_res',win_denoise,enaVal);     
  474.         if strncmpi(enaVal,'on',2) , status = 1; else , status = 0; end
  475.         wmemtool('wmb',win_denoise,n_misc_loc,ind_status,status);
  476.     case 'save_synt'
  477.         % Testing file.
  478.         %--------------
  479.         [filename,pathname,ok] = utguidiv('test_save',win_denoise, ...
  480.                                      '*.mat','Save De-noised Signal');
  481.         if ~ok, return; end
  482.         % Begin waiting.
  483.         %--------------
  484.         wwaiting('msg',win_denoise,'Wait ... saving');
  485.         % Getting Analysis values.
  486.         %-------------------------
  487.         win_caller = wmemtool('rmb',win_denoise,n_misc_loc,ind_win_caller);
  488.         wname = wmemtool('rmb',win_caller,n_param_anal,ind_wav_name);
  489.         thrDATA = wmemtool('rmb',win_denoise,n_thrDATA,ind_value);
  490.         xc = thrDATA{1};
  491.         thrParams = thrDATA{4};
  492.         % Saving file.
  493.         %--------------
  494.         [name,ext] = strtok(filename,'.');
  495.         if isempty(ext) | isequal(ext,'.')
  496.             ext = '.mat'; filename = [name ext];
  497.         end
  498.         saveStr = name;
  499.         eval([saveStr '= xc ;']);
  500.         wwaiting('off',win_denoise);
  501.         try
  502.           save([pathname filename],saveStr,'thrParams','wname');
  503.         catch          
  504.           errargt(mfilename,'Save FAILED !','msg');
  505.         end
  506.     case 'save_cfs'
  507.         % Testing file.
  508.         %--------------
  509.         [filename,pathname,ok] = utguidiv('test_save',win_denoise, ...
  510.                                      '*.mat','Save Coefficients (1D)');
  511.         if ~ok, return; end
  512.         % Begin waiting.
  513.         %--------------
  514.         wwaiting('msg',win_denoise,'Wait ... saving coefficients');
  515.         % Getting Analysis values.
  516.         %-------------------------
  517.         win_caller = wmemtool('rmb',win_denoise,n_misc_loc,ind_win_caller);
  518.         wname = wmemtool('rmb',win_caller,n_param_anal,ind_wav_name);
  519.         thrDATA = wmemtool('rmb',win_denoise,n_thrDATA,ind_value);
  520.         coefs = thrDATA{2};
  521.         longs = thrDATA{3};
  522.         thrParams = thrDATA{4};
  523.         % Saving file.
  524.         %--------------
  525.         [name,ext] = strtok(filename,'.');
  526.         if isempty(ext) | isequal(ext,'.')
  527.             ext = '.mat'; filename = [name ext];
  528.         end
  529.         saveStr = {'coefs','longs','thrParams','wname'};
  530.         wwaiting('off',win_denoise);
  531.         try
  532.           save([pathname filename],saveStr{:});
  533.         catch          
  534.           errargt(mfilename,'Save FAILED !','msg');
  535.         end
  536.     case 'save_dec'
  537.         % Testing file.
  538.         %--------------
  539.         [filename,pathname,ok] = utguidiv('test_save',win_denoise, ...
  540.                                      '*.wa1','Save Wavelet Analysis (1D)');
  541.         if ~ok, return; end
  542.         % Begin waiting.
  543.         %--------------
  544.         wwaiting('msg',win_denoise,'Wait ... saving decomposition');
  545.         % Getting Analysis values.
  546.         %-------------------------
  547.         win_caller = wmemtool('rmb',win_denoise,n_misc_loc,ind_win_caller);
  548.         [wave_name,data_name] = wmemtool('rmb',win_caller,n_param_anal, ...
  549.                                           ind_wav_name,ind_sig_name);
  550.         thrDATA = wmemtool('rmb',win_denoise,n_thrDATA,ind_value);
  551.         coefs = thrDATA{2};
  552.         longs = thrDATA{3};
  553.         thrParams = thrDATA{4};
  554.         % Saving file.
  555.         %--------------
  556.         [name,ext] = strtok(filename,'.');
  557.         if isempty(ext) | isequal(ext,'.')
  558.             ext = '.wa1'; filename = [name ext];
  559.         end
  560.         saveStr = {'coefs','longs','thrParams','wave_name','data_name'};
  561.         wwaiting('off',win_denoise);
  562.         try
  563.           save([pathname filename],saveStr{:});
  564.         catch          
  565.           errargt(mfilename,'Save FAILED !','msg');
  566.         end
  567.     case 'close'
  568.         [status,win_caller] = wmemtool('rmb',win_denoise,n_misc_loc, ...
  569.                                              ind_status,ind_win_caller);
  570.         if status==1
  571.             % Test for Updating.
  572.             %--------------------
  573.             status = wwaitans(win_denoise,...
  574.                               'Update the synthesized signal ?',2,'cond');
  575.         end
  576.         switch status
  577.           case 1
  578.             wwaiting('msg',win_denoise,'Wait ... computing');
  579.             thrDATA = wmemtool('rmb',win_denoise,n_thrDATA,ind_value);
  580.             valTHR  = thrDATA{4};
  581.             lin_den = utthrw1d('get',win_denoise,'handleTHR');
  582.             wmemtool('wmb',win_caller,n_param_anal,...
  583.                      ind_ssig_type,'ds',ind_thr_val,valTHR);
  584.             dw1dmngr('return_deno',win_caller,status,lin_den);
  585.             wwaiting('off',win_denoise);
  586.           case 0 , dw1dmngr('return_deno',win_caller,status);
  587.         end
  588.         varargout{1} = status;
  589.     otherwise
  590.         errargt(mfilename,'Unknown Option','msg');
  591.         error('*');
  592. end
  593. %-------------------------------------------------
  594. function varargout = depOfMachine(varargin)
  595. btn_height = varargin{1};
  596. scrSize = get(0,'ScreenSize');
  597. if scrSize(4)<600
  598.     hvisu = btn_height;
  599. elseif scrSize(4)<700
  600.     hvisu = 3*btn_height/2;
  601. else
  602.     hvisu = 2*btn_height;
  603. end
  604. varargout{1} = hvisu;
  605. %-------------------------------------------------