   % test code for CreateSleepPatterns
   
  clear all
  clc

%select a excel file
[Filename,Pathname]=uigetfile(...   
   {'*.xlsx';'*.xls'},'upload your sleep raw data');
if (Filename~=0)
   HR=xlsread(Filename,'c3:c86400');
else
   clear;
end
            

            im=HR

            sigLength=length(im);
            
            for nn=1:1:round(size(im,1)/300)-1
                tmp=im((nn-1)*300+1:nn*300);
                [ratio(nn)]=SleepPatternManager.GetRatioLH(tmp);
            end
            depth = 1./ ratio*100;
       

            depth = depth./ max(depth(:));
            hypno = depth./ max(depth(:))*4;
        for i=1:length(hypno)
            if (hypno(i)<1)
            new_hypno(i)=1;
        elseif (hypno(i)>=1&&hypno(i)<2)
            new_hypno(i)=2;
            elseif (hypno(i)>=2&&hypno(i)<3.5)
            new_hypno(i)=3;
            else
            new_hypno(i)=4;
            end
        end
            
            stem(new_hypno);
            
            
            
            

           
    
            
