def getDataExisting(path, requiredFeatures): name = getName(path) data = loadExistingData(name) existingFeatures = getExistingFeatures(name) # mFeatures = diff(requiredFeatures,existingFeatures) if isEmpty(diff(requiredFeatures, existingFeatures)): return data data = updateFeatures(data, path, requiredFeatures, existingFeatures) data = cleanData(data) storeData(data, name) storePickle(union(requiredFeatures, existingFeatures), name) return data
def getFeatures(path, name, nb, required, existing, existingVals): def getRawData(path, name, nb, hip): def getDir(path, subject, bodyPart, nb): return (path + subject + "\\" + bodyPart + "\\" + "DATA-00" + str(int(nb)) + ".csv") if hip: bodyPart = 'heup' else: bodyPart = 'enkel' datadir = getDir(path, name, bodyPart, nb) try: data = ac.readGCDCFormat(datadir) except: return None return ac.preprocessGCDC(data) def getRunningPart(data, hip): try: return pp.filterRun3(data, hip) except: return None def obtainFeatures(ankleData, hipData, features): try: return fa.extract(ankleData, hipData, features) except: return None def getDataForOneBodyPart(path, name, nb, hip): data = getRawData(path, name, nb, hip) data = getRunningPart(data, hip) return data ankleData = getDataForOneBodyPart(path, name, nb, False) hipData = getDataForOneBodyPart(path, name, nb, True) if existing is None: f = obtainFeatures(ankleData, hipData, required) if f is None: print('no features') return None return str(f) missingFeatures = diff(required, existing) # obtain features for existing cols and new features newFeaturesForOldCols = colsFirstFeaturesSecond(existing, missingFeatures) f1 = obtainFeatures(ankleData, hipData, newFeaturesForOldCols) # obtain features for new cols and all features featuresForNewCols = colsFirstFeaturesSecond(missingFeatures, union(missingFeatures, existing)) f2 = obtainFeatures(ankleData, hipData, featuresForNewCols) if f1 is not None: f = f1 if f2 is not None: f.update(f2) elif f2 is not None: f = f2 else: print('no features') return None if existingVals is not None: existingVals = literal_eval(existingVals) existingVals.update(f) f = existingVals return str(f)