def motion_regressors(motion_params, order=0, derivatives=1):
 import numpy as np
 out_files = []
 for (idx, filename) in enumerate(filename_to_list(motion_params)):
  params = np.genfromtxt(filename)
  out_params = params
  for d in range(1, (derivatives + 1)):
   cparams = np.vstack((np.repeat(params[0, :][None, :], d, axis=0), params))
   out_params = np.hstack((out_params, np.diff(cparams, d, axis=0)))
  out_params2 = out_params
  for i in range(2, (order + 1)):
   out_params2 = np.hstack((out_params2, np.power(out_params, i)))
  filename = os.path.join(os.getcwd(), (u'motion_regressor%02d.txt' % idx))
  np.savetxt(filename, out_params2, fmt='%.10f')
  out_files.append(filename)
 return out_files

def motion_regressors ( motion_params , order = 0 , derivatives = 1 ) : import numpy as np out_files = [ ] for ( idx , filename ) in enumerate ( filename_to_list ( motion_params ) ) : params = np . genfromtxt ( filename ) out_params = params for d in range ( 1 , ( derivatives + 1 ) ) : cparams = np . vstack ( ( np . repeat ( params [ 0 , : ] [ None , : ] , d , axis = 0 ) , params ) ) out_params = np . hstack ( ( out_params , np . diff ( cparams , d , axis = 0 ) ) ) out_params2 = out_params for i in range ( 2 , ( order + 1 ) ) : out_params2 = np . hstack ( ( out_params2 , np . power ( out_params , i ) ) ) filename = os . path . join ( os . getcwd ( ) , ( u'motion_regressor%02d.txt' % idx ) ) np . savetxt ( filename , out_params2 , fmt = '%.10f' ) out_files . append ( filename ) return out_files
compute motion regressors upto given order and derivative motion + d/dt + d2/dt2 .