File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -111,20 +111,24 @@ def __call__(self, sliding_window: SlidingWindow):
111111            RMS of jerk (third derivative). 
112112            Returns None if insufficient data. 
113113
114-         Output 
115-         ------------ 
116-         Prints smoothness metrics to stdout. 
114+         Returns 
115+         ------- 
116+         tuple of (float, float) 
117+             (SPARC value, Jerk RMS value) or (NaN, NaN) if insufficient data. 
117118        """ 
118119        if  len (sliding_window ) <  5 :
119-             return  None ,  None 
120+             return  float ( "nan" ),  float ( "nan" ) 
120121
121122        signal , _  =  sliding_window .to_array ()
122123
124+         # If multi-channel, compute for first channel only 
125+         if  signal .ndim  >  1  and  signal .shape [1 ] >  1 :
126+             signal  =  signal [:, 0 ]
127+ 
123128        filtered  =  self ._filter_signal (signal .squeeze ())
124129        normalized  =  normalize_signal (filtered )
125130
126131        sparc  =  compute_sparc (normalized , self .rate_hz )
127132        jerk  =  compute_jerk_rms (filtered , self .rate_hz )
128133
129-         print (f"SPARC: { sparc :.3f} { jerk :.3f}  )
130134        return  sparc , jerk 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments