 %% Implement PSPR
 function [feature]=pspr_rr(data)
    allseq=[];
    myquant=[0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6];
    leng=8;
    allseq{1,1}=num2seq3_20161108(data, myquant);   

    oz=[];
    oz.list_symbol='abcde1234';
    oz.numletter=length(oz.list_symbol); 
    oz.nseries=size(allseq,1);
    oz.maxmem=7;
    oz.disttype='euc';
    oz.PTPtype='w';%nonw: rowsums=1, w=sum of all elements=1
    %oz.numcores=myCluster.NumWorkers;
    oz.numcores=10;% % assign all cores
    oz.col=zeros(1,length(oz.list_symbol));
    for i=1:length(oz.list_symbol)
        oz.col(1,i)=hex2num(oz.list_symbol(i));
    end
    
    nseries=oz.nseries;
    mypatterninfo=cell(1,1);
    oz.memselect=[6 7];
    
	mypatterninfo{1,1} = ptm_20161109( allseq{1,1},oz);
    
    %% Create pattern database
    patterndb = patterndb_20161109( mypatterninfo);
    
    
    % Load the reference pattern database
     load('Ref_RR_patterndB.mat');
     RefRR1_db=patterndb;
  
    % Load the reference pattern info
      load('Ref_RR_patterninfo.mat');
      matchedpatterninfo_refRR1=matchedpatterninfo;
        
      % Match the new patterns with the reference pattern database
      newmatchedpatterninfoRR1=match_ptm_20161109_toexternalDB(  mypatterninfo, RefRR1_db);
    
      % Calculate similarity between new patterns and reference database
     [~,alldistmat] = simmat_20161114_partial(newmatchedpatterninfoRR1,matchedpatterninfo_refRR1(1:25,1), oz);  % compared with afib
   
     %% Calculate SPR features 
    simmatrix1=alldistmat(:,:,6);
    myall=mean(simmatrix1,2);

    simmatrix1=alldistmat(:,:,7);
    myall1=mean(simmatrix1,2);
    
    [~,alldistmat] = simmat_20161114_partial(newmatchedpatterninfoRR1,matchedpatterninfo_refRR1(26:50,1), oz);  % compared with afib
   
     %% Calculate SPR features 
    simmatrix1=alldistmat(:,:,6);
    myall2=mean(simmatrix1,2);

    simmatrix1=alldistmat(:,:,7);
    myall3=mean(simmatrix1,2);
    
     [~,alldistmat] = simmat_20161114_partial(newmatchedpatterninfoRR1,matchedpatterninfo_refRR1(51:75,1), oz);  % compared with afib
   
     %% Calculate SPR features 
    simmatrix1=alldistmat(:,:,6);
    myall4=mean(simmatrix1,2);

    simmatrix1=alldistmat(:,:,7);
    myall5=mean(simmatrix1,2);   
    
    [~,alldistmat] = simmat_20161114_partial(newmatchedpatterninfoRR1,matchedpatterninfo_refRR1(76:100,1), oz);  % compared with afib
   
     %% Calculate SPR features 
    simmatrix1=alldistmat(:,:,6);
    myall6=mean(simmatrix1,2);

    simmatrix1=alldistmat(:,:,7);
    myall7=mean(simmatrix1,2);
    
    feature=[myall myall1 myall2 myall3 myall4 myall5 myall6 myall7 ];
 return