def mtFeatureExtraction(signal, Fs, mtWin, mtStep, stWin, stStep):
 mtWinRatio = int(round((mtWin / stStep)))
 mtStepRatio = int(round((mtStep / stStep)))
 mtFeatures = []
 stFeatures = stFeatureExtraction(signal, Fs, stWin, stStep)
 numOfFeatures = len(stFeatures)
 numOfStatistics = 2
 mtFeatures = []
 for i in range((numOfStatistics * numOfFeatures)):
  mtFeatures.append([])
 for i in range(numOfFeatures):
  curPos = 0
  N = len(stFeatures[i])
  while (curPos < N):
   N1 = curPos
   N2 = (curPos + mtWinRatio)
   if (N2 > N):
    N2 = N
   curStFeatures = stFeatures[i][N1:N2]
   mtFeatures[i].append(numpy.mean(curStFeatures))
   mtFeatures[(i + numOfFeatures)].append(numpy.std(curStFeatures))
   curPos += mtStepRatio
 return (numpy.array(mtFeatures), stFeatures)

def mtFeatureExtraction ( signal , Fs , mtWin , mtStep , stWin , stStep ) : mtWinRatio = int ( round ( ( mtWin / stStep ) ) ) mtStepRatio = int ( round ( ( mtStep / stStep ) ) ) mtFeatures = [ ] stFeatures = stFeatureExtraction ( signal , Fs , stWin , stStep ) numOfFeatures = len ( stFeatures ) numOfStatistics = 2 mtFeatures = [ ] for i in range ( ( numOfStatistics * numOfFeatures ) ) : mtFeatures . append ( [ ] ) for i in range ( numOfFeatures ) : curPos = 0 N = len ( stFeatures [ i ] ) while ( curPos < N ) : N1 = curPos N2 = ( curPos + mtWinRatio ) if ( N2 > N ) : N2 = N curStFeatures = stFeatures [ i ] [ N1 : N2 ] mtFeatures [ i ] . append ( numpy . mean ( curStFeatures ) ) mtFeatures [ ( i + numOfFeatures ) ] . append ( numpy . std ( curStFeatures ) ) curPos += mtStepRatio return ( numpy . array ( mtFeatures ) , stFeatures )
mid-term feature extraction .