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

波变换

开发平台:

Matlab

  1. function varargout = wp1dstat(option,varargin)
  2. %WP1DSTAT Wavelet packets 1-D statistics.
  3. %   VARARGOUT = WP1DSTAT(OPTION,VARARGIN)
  4. %   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 12-Mar-96.
  5. %   Last Revision: 21-May-2003.
  6. %   Copyright 1995-2004 The MathWorks, Inc.
  7. %   $Revision: 1.17.4.2 $
  8. % Memory Blocks of stored values.
  9. %================================
  10. % MB1.
  11. %-----
  12. n_param_anal   = 'WP1D_Par_Anal';
  13. ind_sig_name   = 1;
  14. ind_wav_name   = 2;
  15. ind_lev_anal   = 3;
  16. ind_ent_anal   = 4;
  17. ind_ent_par    = 5;
  18. ind_sig_size   = 6;
  19. ind_act_option = 7;
  20. ind_thr_val    = 8;
  21. nb1_stored     = 8;
  22. % MB2.
  23. %-----
  24. n_wp_utils = 'WP_Utils';
  25. ind_tree_lin  = 1;
  26. ind_tree_txt  = 2;
  27. ind_type_txt  = 3;
  28. ind_sel_nodes = 4;
  29. ind_gra_area  = 5;
  30. ind_nb_colors = 6;
  31. nb2_stored    = 6;
  32. % MB3.
  33. %-----
  34. n_structures = 'Structures';
  35. ind_tree_st  = 1;
  36. ind_data_st  = 2;
  37. nb3_stored   = 2;
  38. % MB1. (Local Bloc)
  39. %--------------------
  40. n_misc_loc = 'WPStat1D_Misc';
  41. ind_curr_sig   = 1;
  42. ind_curr_color = 2;
  43. nbLOC_1_stored = 2;
  44. % Tag properties.
  45. %----------------
  46. tag_sel_cfs    = 'Sel_Cfs';
  47. tag_sel_rec    = 'Sel_Rec';
  48. tag_txt_bin    = 'Bins_Txt';
  49. tag_edi_bin    = 'Bins_Data';
  50. tag_ax_signal  = 'Ax_Signal';
  51. tag_ax_hist    = 'Ax_Hist';
  52. tag_ax_cumhist = 'Ax_Cumhist';
  53. tag_pus_sta    = 'Show_Stat';
  54. if ~isequal(option,'create') , win_stats = varargin{1}; end
  55. switch option
  56.     case 'create'
  57.         % Get Globals.
  58.         %-------------
  59.         [Def_Txt_Height,Def_Btn_Height,Pop_Min_Width, ...
  60.          X_Spacing,Y_Spacing,Def_EdiBkColor,Def_FraBkColor] =  ...
  61.             mextglob('get',...
  62.                 'Def_Txt_Height','Def_Btn_Height','Pop_Min_Width', ...
  63.                 'X_Spacing','Y_Spacing', 'Def_EdiBkColor','Def_FraBkColor');
  64.         % Calling figure and node.
  65.         %-------------------------
  66.         win_caller     = varargin{1};
  67.         node           = varargin{2};
  68.         str_win_caller = sprintf('%.0f',win_caller);
  69.         str_node       = sprintf('%.0f',node);
  70.         % Window initialization.
  71.         %----------------------
  72.         win_name = 'Wavelet Packet 1-D  --  Statistics';
  73.         [win_stats,pos_win,win_units,str_numwin,...
  74.                 frame0,pos_frame0,Pos_Graphic_Area,pus_close] = ...
  75.                     wfigmngr('create',win_name,'','ExtFig_HistStat',mfilename,0);
  76.         if nargout>0 , varargout{1} = win_stats; end
  77.         % Begin waiting.
  78.         %---------------
  79.         set(wfindobj('figure'),'Pointer','watch');
  80.         % Getting variables from wp1dtool figure memory block.
  81.         %-----------------------------------------------------
  82.         WP_Tree = wmemtool('rmb',win_caller,n_structures,ind_tree_st);
  83.         depth   = treedpth(WP_Tree);
  84.         [Sig_Name,Sig_Size,Wave_Name,Ent_Nam,Ent_Par] = ...
  85.                 wmemtool('rmb',win_caller,n_param_anal,   ...
  86.                                ind_sig_name,ind_sig_size, ...
  87.                                ind_wav_name,ind_ent_anal,ind_ent_par);
  88.         Wav_Fam = wavemngr('fam_num',Wave_Name);
  89.         % General parameters initialization.
  90.         %-----------------------------------
  91.         dx = X_Spacing;
  92.         dy = Y_Spacing;  dy2 = 2*dy;
  93.         d_txt = Def_Btn_Height-Def_Txt_Height;
  94.         gra_width = Pos_Graphic_Area(3);
  95.         push_width = (pos_frame0(3)-4*dx)/2;
  96.         pop_width  = Pop_Min_Width;
  97.         default_bins = 30;
  98.         % Position property of objects.
  99.         %------------------------------
  100.         xlocINI     = pos_frame0([1 3]);
  101.         ybottomINI  = pos_win(4)-3.5*Def_Btn_Height-dy2;
  102.         ybottomENT  = ybottomINI-(Def_Btn_Height+dy2)-dy;
  103.         y_low       = ybottomENT-4*Def_Btn_Height;
  104.         px          = pos_frame0(1)+(pos_frame0(3)-5*push_width/4)/2;
  105.         pos_sel_cfs = [px, y_low, 5*push_width/4, 3*Def_Btn_Height/2];
  106.         y_low       = y_low-3*Def_Btn_Height;
  107.         pos_sel_rec = [px, y_low, 5*push_width/4, 3*Def_Btn_Height/2];
  108.         px          = pos_frame0(1)+(pos_frame0(3)-3*pop_width)/2;
  109.         y_low       = y_low-3*Def_Btn_Height;
  110.         pos_txt_bin = [px, y_low+d_txt/2, 2*pop_width, Def_Txt_Height];
  111.         px          = pos_txt_bin(1)+pos_txt_bin(3)+dx;
  112.         pos_edi_bin = [px, y_low, pop_width, Def_Btn_Height];
  113.         px          = pos_frame0(1)+(pos_frame0(3)-3*push_width/2)/2;
  114.         y_low       = pos_edi_bin(2)-3*Def_Btn_Height;
  115.         pos_pus_sta = [px, y_low, 3*push_width/2, 2*Def_Btn_Height];
  116.         % String property of objects.
  117.         %----------------------------
  118.         str_sel_cfs = 'Coefficients';
  119.         str_sel_rec = 'Reconstructed';
  120.         str_txt_bin = 'Number of bins';
  121.         str_edi_bin = sprintf('%.0f',default_bins);
  122.         str_pus_sta = 'Show statistics';
  123.         % Command part construction of the window.
  124.         %-----------------------------------------
  125.         if ~isequal(get(0,'CurrentFigure'),win_stats) , figure(win_stats); end
  126.         utanapar('create_copy',win_stats, ...
  127.                  {'xloc',xlocINI,'bottom',ybottomINI},...
  128.                  {'n_s',{Sig_Name,Sig_Size},'wav',Wave_Name,'lev',depth} ...
  129.                  );
  130.         utentpar('create_copy',win_stats, ...
  131.                  {'xloc',xlocINI,'bottom',ybottomENT,...
  132.                   'ent',{Ent_Nam,Ent_Par}} ...
  133.                  );
  134.         rad_cfs = uicontrol('Parent',win_stats,...
  135.                             'Style','Radiobutton',...
  136.                             'Unit',win_units,...
  137.                             'Position',pos_sel_cfs,...
  138.                             'String',str_sel_cfs,...
  139.                             'Tag',tag_sel_cfs,...
  140.                             'Userdata',0,...
  141.                             'Value',0);
  142.         rad_rec = uicontrol('Parent',win_stats,...
  143.                             'Style','Radiobutton',...
  144.                             'Unit',win_units,...
  145.                             'Position',pos_sel_rec,...
  146.                             'String',str_sel_rec,...
  147.                             'Tag',tag_sel_rec,...
  148.                             'Userdata',1,...
  149.                             'Value',1);
  150.         txt_bin = uicontrol('Parent',win_stats,...
  151.                             'Style','text',...
  152.                             'Unit',win_units,...
  153.                             'Position',pos_txt_bin,...
  154.                             'String',str_txt_bin,...
  155.                             'Backgroundcolor',Def_FraBkColor,...
  156.                             'Tag',tag_txt_bin...
  157.                             );
  158.         edi_bin = uicontrol('Parent',win_stats,...
  159.                             'Style','Edit',...
  160.                             'Units',win_units,...
  161.                             'Position',pos_edi_bin,...
  162.                             'String',str_edi_bin,...
  163.                             'Backgroundcolor',Def_EdiBkColor,...
  164.                             'Tag',tag_edi_bin...
  165.                             );
  166.         pus_sta = uicontrol('Parent',win_stats,...
  167.                             'Style','Pushbutton',...
  168.                             'Unit',win_units,...
  169.                             'Position',pos_pus_sta,...
  170.                             'String',xlate(str_pus_sta),...
  171.                             'Userdata',[],...
  172.                             'Tag',tag_pus_sta...
  173.                             );
  174.         % Frame Stats. construction.
  175.         %---------------------------
  176.         [infos_hdls,h_frame1] = utstats('create',win_stats,...
  177.                                         'xloc',Pos_Graphic_Area([1,3]), ...
  178.                                         'bottom',dy2);
  179.         % Callbacks update.
  180.         %------------------
  181.         str_infos_hdls = num2mstr(infos_hdls);
  182.         str_rad_rec = num2mstr(rad_rec);
  183.         str_rad_cfs = num2mstr(rad_cfs);
  184.         str_edi_bin = num2mstr(edi_bin);
  185.         cba_sel_rec = [mfilename '(''select'',' ...
  186.                             str_numwin ',' ...
  187.                             str_rad_rec ',' ...
  188.                             str_infos_hdls ...
  189.                             ');'];
  190.         cba_sel_cfs = [mfilename '(''select'',' ...
  191.                             str_numwin ',' ...
  192.                             str_rad_cfs ',' ...
  193.                             str_infos_hdls ...
  194.                             ');'];
  195.         cba_edi_bin = [mfilename '(''update_bins'',' ...
  196.                             str_numwin ',' ...
  197.                             str_edi_bin ...
  198.                             ');'];
  199.         cba_pus_sta = [mfilename '(''draw'','  ...
  200.                             str_numwin ','     ...
  201.                             str_win_caller ',' ...
  202.                             str_infos_hdls ',' ...
  203.                             str_node ...
  204.                             ');'];
  205.         set(rad_rec,'Callback',cba_sel_rec);
  206.         set(rad_cfs,'Callback',cba_sel_cfs);
  207.         set(edi_bin,'Callback',cba_edi_bin);
  208.         set(pus_sta,'Callback',cba_pus_sta);
  209.         % Axes construction.
  210.         %-------------------
  211.         xspace         = gra_width/10;
  212.         yspace         = pos_frame0(4)/10;
  213.         axe_height     = (pos_frame0(4)-Def_Btn_Height-h_frame1-4*dy)/2-yspace;
  214.         axe_width      = gra_width-2*xspace;
  215.         half_width     = axe_width/2-xspace/2;
  216.         pos_ax_signal  = [xspace h_frame1+2*dy2+axe_height+4*yspace/3 ...
  217.                                 axe_width axe_height];
  218.         pos_ax_hist    = [xspace h_frame1+2*dy2+yspace/3 ...
  219.                                 half_width axe_height];
  220.         pos_ax_cumhist = [2*xspace+half_width h_frame1+2*dy2+yspace/3 ...
  221.                                 half_width axe_height];
  222.         commonProp = {...
  223.            'Parent',win_stats,...
  224.            'Units',win_units,...
  225.            'Visible','Off',...
  226.            'box','on',...
  227.            'NextPlot','Replace',...
  228.            'Drawmode','fast'...
  229.            };
  230.         axe_signal  = axes(commonProp{:},...
  231.                            'Position',pos_ax_signal,'Tag',tag_ax_signal);
  232.         axe_hist    = axes(commonProp{:},...
  233.                            'Position',pos_ax_hist,'Tag',tag_ax_hist);
  234.         axe_cumhist = axes(commonProp{:},...
  235.                            'Position',pos_ax_cumhist,'Tag',tag_ax_cumhist);
  236.         % Displaying the window title.
  237.         %-----------------------------
  238.         str_par = utentpar('get',win_stats,'txt');
  239.         if ~isempty(str_par)
  240.             str_par = [' (' lower(str_par) ' = ',num2str(Ent_Par),')'];
  241.         end
  242.         str_wintitle = [Sig_Name,' analyzed at level ',...
  243.                         sprintf('%.0f',depth),' with ',Wave_Name,...
  244.                         ' and ''',Ent_Nam,''' entropy',str_par];
  245.         wfigtitl('string',win_stats,str_wintitle,'off');
  246.         % Setting units to normalized.
  247.         %-----------------------------
  248.         wfigmngr('normalize',win_stats);
  249.         % Computing statistics for the node.
  250.         %-----------------------------------
  251. wp1dstat('draw',win_stats,win_caller,infos_hdls,node);
  252.         % End waiting.
  253.         %-------------
  254.         set(wfindobj('figure'),'Pointer','arrow');
  255.     case 'select'
  256.         %***********************************************%
  257.         %** OPTION = 'select' - SIGNAL TYPE SELECTION **%
  258.         %***********************************************%
  259.         sel_rad_btn = varargin{2};
  260.         infos_hdls  = varargin{3};
  261.         % Set to the current selection.
  262.         %------------------------------
  263.         rad_handles = findobj(win_stats,'Style','radiobutton');
  264.         old_rad     = findobj(rad_handles,'Userdata',1);
  265.         set(rad_handles,'Value',0,'Userdata',0);
  266.         set(sel_rad_btn,'Value',1,'Userdata',1)
  267.         if old_rad==sel_rad_btn , return; end
  268.         % Reset all.
  269.         %-----------
  270.         set(infos_hdls,'Visible','off');
  271.         axe_handles = findobj(get(win_stats,'Children'),'flat','Type','axes');
  272.         axe_signal  = findobj(axe_handles,'flat','Tag',tag_ax_signal);
  273.         axe_hist    = findobj(axe_handles,'flat','Tag',tag_ax_hist);
  274.         axe_cumhist = findobj(axe_handles,'flat','Tag',tag_ax_cumhist);
  275.         set(findobj([axe_signal,axe_hist,axe_cumhist]),'visible','off');
  276.         drawnow
  277.     case 'draw'
  278.         %*********************************%
  279.         %** OPTION = 'draw' - DRAW AXES **%
  280.         %*********************************%
  281.         win_caller = varargin{2};
  282.         infos_hdls = varargin{3};
  283.         node       = varargin{4};
  284.         % Handles of tagged objects.
  285.         %---------------------------
  286.         children    = get(win_stats,'Children');
  287.         axe_handles = findobj(children,'flat','Type','axes');
  288.         uic_handles = findobj(children,'flat','Type','uicontrol');
  289.         pus_sta     = findobj(uic_handles,'Style','pushbutton','Tag',tag_pus_sta);
  290.         axe_signal  = findobj(axe_handles,'flat','Tag',tag_ax_signal);
  291.         axe_hist    = findobj(axe_handles,'flat','Tag',tag_ax_hist);
  292.         axe_cumhist = findobj(axe_handles,'flat','Tag',tag_ax_cumhist);
  293.         rad_handles = findobj(uic_handles,'Style','radiobutton');
  294.         edi_handles = findobj(uic_handles,'Style','edit');
  295.         rad_cfs     = findobj(rad_handles,'Tag',tag_sel_cfs);
  296.         edi_bin     = findobj(edi_handles,'Tag',tag_edi_bin);
  297.         % Main parameters selection before drawing.
  298.         %------------------------------------------
  299.         sel_cfs = (get(rad_cfs,'Value')~=0);
  300.         % Check the bins number.
  301.         %-----------------------
  302.         default_bins = 30;
  303.         old_params   = get(pus_sta,'Userdata');
  304.         if ~isempty(old_params) , default_bins = old_params(1); end
  305.         nb_bins = wstr2num(get(edi_bin,'String'));
  306.         if isempty(nb_bins) | (nb_bins<2)
  307.             nb_bins = default_bins;
  308.             set(edi_bin,'String',sprintf('%.0f',default_bins))
  309.         end
  310.         new_params = [nb_bins , sel_cfs , node];
  311.         if ~isempty(old_params) & (new_params==old_params)
  312.             vis = get(axe_hist,'Visible');
  313.             if vis(1:2)=='on', return, end
  314.         end
  315.         % Deseable new selection.
  316.         %-------------------------
  317.         set([edi_bin;rad_handles],'Enable','off');
  318.         % Updating parameters.
  319.         %--------------------- 
  320.         set(pus_sta,'Userdata',new_params);
  321.         % Show the status line.
  322.         %----------------------
  323.         wfigtitl('vis',win_stats,'on');
  324.         % Cleaning the graphical part.
  325.         %-----------------------------
  326.         set(infos_hdls,'Visible','off');
  327.         % Waiting message.
  328.         %-----------------
  329.         wwaiting('msg',win_stats,'Wait ... computing');
  330.         % Cleaning the graphical part continuing.
  331.         %----------------------------------------
  332.         set(findobj([axe_signal,axe_hist,axe_cumhist]),'visible','off');
  333.         drawnow
  334.         % Parameters initialization.
  335.         %---------------------------
  336.         if node>-1
  337.             % Getting memory blocks.
  338.             %-----------------------
  339.             [WP_Tree,WP_Data] = wmemtool('rmb',win_caller,n_structures,...
  340.                                                ind_tree_st,ind_data_st);
  341.             order = treeord(WP_Tree);
  342.             depth = treedpth(WP_Tree);            
  343.             % Current signal construction.
  344.             %-----------------------------
  345.             if sel_cfs
  346.                 if isa(WP_Tree,'wptree')
  347.                     curr_sig = wpcoef(WP_Tree,node);
  348.                 else
  349.                     curr_sig = wpcoef(WP_Tree,WP_Data,node);
  350.                 end
  351.                 str_title= 'Coefficients of ';
  352.             else
  353.                 if isa(WP_Tree,'wptree')
  354.                     curr_sig = wprcoef(WP_Tree,node);
  355.                 else
  356.                     curr_sig = wprcoef(WP_Tree,WP_Data,node);
  357.                 end
  358.                 str_title= 'Reconstructed ';
  359.             end
  360.             if length(curr_sig)<3
  361.                 wwarndlg([' Not enough coefficients ' ...
  362.                          'remaining at level ' ...
  363.                           sprintf('%.0f',level)],...
  364.                          'Wavelet Packet 1-D -- Statistics','modal');
  365.                 wwaiting('off',win_stats);
  366.                 return;
  367.             end
  368.             Tree_Type_TxtV  = wmemtool('rmb',win_caller,n_wp_utils,...
  369.                                              ind_type_txt);
  370.             [level,pos]     = ind2depo(order,node);
  371.             if strcmp(Tree_Type_TxtV,'i')
  372.                 ind     = depo2ind(order,node);
  373.                 str_pck = ['Packet ('  sprintf('%.0f',ind) ')'];
  374.             else
  375.                 str_pck = ['Packet (' sprintf('%.0f',level) ','  ...
  376.                                 sprintf('%.0f',pos), ')'];
  377.             end
  378.             if pos==0
  379.                 if level==0
  380.                     curr_color = wtbutils('colors','sig');
  381.                     str_title  = [str_title str_pck ...
  382.                                   ' ===> Original signal'];
  383.                 else
  384.                     col_app    = wtbutils('colors','app',depth);
  385.                     curr_color = col_app(level,:);
  386.                     str_title  = [str_title str_pck ...
  387.                                   ' ===> Approximation at level      ' ...
  388.                                   sprintf('%.0f',level)];
  389.                 end
  390.             else
  391.                 col_det    = wtbutils('colors','det',depth);
  392.                 curr_color = col_det(level,:);
  393.                 str_title  = [str_title str_pck];
  394.             end
  395.         else
  396.             curr_sig = get(wpssnode('r_synt',win_caller),'Userdata');
  397.             curr_color = wtbutils('colors','wp1d','hist');
  398.             if node==-1
  399.                 str_title = ['Compressed Signal'];
  400.             elseif node==-2
  401.                 str_title = ['De-noised Signal'];
  402.             end
  403.         end
  404.         % Displaying the signal.
  405.         %-----------------------
  406.         xaxis = [1              length(curr_sig)];
  407.         yaxis = [min(curr_sig)  max(curr_sig)];
  408.         if xaxis(1)==xaxis(2)
  409.             xaxis = xaxis+[-0.01 0.01];
  410.         end
  411.         if yaxis(1)==yaxis(2)
  412.             yaxis = yaxis+[-0.01 0.01];
  413.         end
  414.         axes(axe_signal);
  415.         plot(curr_sig,'Color',curr_color,'Parent',axe_signal);
  416.         set(axe_signal,'Visible','on','Xlim',xaxis,'Ylim',yaxis,...
  417.                 'Tag',tag_ax_signal);
  418.         wtitle(str_title,'Parent',axe_signal);
  419.         % Displaying histogram.
  420.         %----------------------
  421.         his       = wgethist(curr_sig,nb_bins);
  422.         [xx,imod] = max(his(2,:));
  423.         mode_val  = (his(1,imod)+his(1,imod+1))/2;
  424.         his(2,:)  = his(2,:)/length(curr_sig);
  425.         axes(axe_hist);
  426.         wplothis(axe_hist,his,curr_color);
  427.         wtitle('Histogram','Parent',axe_hist);
  428.         % Displaying cumulated histogram.
  429.         %--------------------------------
  430.         for i=6:4:length(his(2,:));
  431.             his(2,i)   = his(2,i)+his(2,i-4);
  432.             his(2,i+1) = his(2,i);
  433.         end
  434.         axes(axe_cumhist);
  435.         wplothis(axe_cumhist,[his(1,:);his(2,:)],curr_color);
  436.         wtitle('Cumulative histogram','Parent',axe_cumhist);
  437.         % Displaying statistics.
  438.         %-----------------------
  439.         mean_val     = mean(curr_sig);
  440.         max_val      = max(curr_sig);
  441.         min_val      = min(curr_sig);
  442.         sig_abs_cent = abs(curr_sig-mean_val);
  443.         range_val    = max_val-min_val;
  444.         std_val      = std(curr_sig);
  445.         med_val      = median(curr_sig);
  446.         utstats('display',win_stats, ...
  447.             [mean_val; med_val ; mode_val;  ...
  448.              max_val ; min_val ; range_val; ...
  449.              std_val ; median(abs(curr_sig-med_val)); ...
  450.              mean(abs(curr_sig-mean_val))]);
  451.         % Memory blocks update.
  452.         %----------------------
  453.         wmemtool('ini',win_stats,n_misc_loc,nbLOC_1_stored);
  454.         wmemtool('wmb',win_stats,n_misc_loc, ...
  455.                        ind_curr_sig,curr_sig,    ...
  456.                        ind_curr_color,curr_color ...
  457.                        );
  458.         % End waiting.
  459.         %-------------
  460.         wwaiting('off',win_stats);
  461.         % Setting infos visible.
  462.         %-----------------------
  463.         set(infos_hdls,'Visible','on');
  464.         % Enable new selection.
  465.         %-------------------------
  466.         set([edi_bin;rad_handles],'Enable','on');
  467.     case 'update_bins'
  468.         %**************************************************************%
  469.         %** OPTION = 'update_bins' - UPDATE HISTOGRAMS WITH NEW BINS **%
  470.         %**************************************************************%
  471.         edi_bin = varargin{2};
  472.         % Handles of tagged objects.
  473.         %---------------------------
  474.         children    = get(win_stats,'Children');
  475.         axe_handles = findobj(children,'flat','Type','axes');
  476.         uic_handles = findobj(children,'flat','Type','uicontrol');
  477.         pus_sta     = findobj(uic_handles,...
  478.                                         'Style','pushbutton',...
  479.                                         'Tag',tag_pus_sta...
  480.                                         );
  481.         axe_hist    = findobj(axe_handles,'flat','Tag',tag_ax_hist);
  482.         axe_cumhist = findobj(axe_handles,'flat','Tag',tag_ax_cumhist);
  483.         % Return if no current display.
  484.         %------------------------------
  485.         vis = get(axe_hist,'Visible');
  486.         if vis(1:2)=='of', return, end
  487.         % Check the bins number.
  488.         %-----------------------
  489.         default_bins = 30;
  490.         old_params   = get(pus_sta,'Userdata');
  491.         if ~isempty(old_params)
  492.             default_bins = old_params(1);
  493.         end
  494.         nb_bins = wstr2num(get(edi_bin,'String'));
  495.         if isempty(nb_bins) | (nb_bins<2)
  496.             nb_bins = default_bins;
  497.             set(edi_bin,'String',sprintf('%.0f',default_bins))
  498.         end
  499.         if default_bins==nb_bins , return; end
  500.         % Getting memory blocks.
  501.         %-----------------------
  502.         [curr_sig,curr_color] = wmemtool('rmb',win_stats,n_misc_loc,...
  503.                                                ind_curr_sig,ind_curr_color);
  504.         % Updating histograms.
  505.         %---------------------
  506.         if ~isempty(curr_sig)
  507.             old_params(1) = nb_bins;
  508.             set(pus_sta,'Userdata',old_params);
  509.             his      = wgethist(curr_sig,nb_bins);
  510.             his(2,:) = his(2,:)/length(curr_sig);
  511.             axes(axe_hist);
  512.             wplothis(axe_hist,his,curr_color);
  513.             wtitle('Histogram','Parent',axe_hist);
  514.             for i=6:4:length(his(2,:));
  515.                 his(2,i)   = his(2,i)+his(2,i-4);
  516.                 his(2,i+1) = his(2,i);
  517.             end
  518.             axes(axe_cumhist);
  519.             wplothis(axe_cumhist,[his(1,:);his(2,:)],curr_color);
  520.             wtitle('Cumulative histogram','Parent',axe_cumhist);
  521.         end
  522.     case 'demo'
  523.         %****************************************%
  524.         %** OPTION = 'demo' -  DEMOS or TESTS  **%
  525.         %****************************************%
  526.         pus_sta = findobj(win_stats,'Style','pushbutton','Tag',tag_pus_sta);
  527.         eval(get(pus_sta,'Callback'));
  528.     case 'close'
  529.     otherwise
  530.         errargt(mfilename,'Unknown Option','msg');
  531.         error('*');
  532. end