def produceFeatureFile(baseDirPath,trial,includeSampleWithProbability,outputDirPath): dirPath = os.path.join(baseDirPath,'T' + str(trial).zfill(3)) metaFilePath = os.path.join(dirPath,'meta-' + str(trial).zfill(3)+".yml") dataFilePath = os.path.join(dirPath,'mocap-' + str(trial).zfill(3)+".txt") outputFilePath = os.path.join(outputDirPath,'t' + str(trial).zfill(3) + ".csv") metaData = data_util.getMetaData(metaFilePath) with open(outputFilePath, 'wb') as outputCSVFile: csvWriter = csv.writer(outputCSVFile) counter = 0 with open(dataFilePath, 'rb') as f: reader = csv.reader(f, delimiter='\t') for row in reader: features = row[2:143] if counter == 0: features.append('Subject') csvWriter.writerow(features) else: if random.random() <= includeSampleWithProbability: features.append(metaData.subject.id) csvWriter.writerow(features) #print features counter += 1 return
def produceFeatureFile(baseDirPath, trial, includeSampleWithProbability, outputDirPath): dirPath = os.path.join(baseDirPath, 'T' + str(trial).zfill(3)) metaFilePath = os.path.join(dirPath, 'meta-' + str(trial).zfill(3) + ".yml") dataFilePath = os.path.join(dirPath, 'mocap-' + str(trial).zfill(3) + ".txt") outputFilePath = os.path.join(outputDirPath, 't' + str(trial).zfill(3) + ".csv") metaData = data_util.getMetaData(metaFilePath) with open(outputFilePath, 'wb') as outputCSVFile: csvWriter = csv.writer(outputCSVFile) counter = 0 with open(dataFilePath, 'rb') as f: reader = csv.reader(f, delimiter='\t') for row in reader: features = row[2:143] if counter == 0: features.append('Subject') csvWriter.writerow(features) else: if random.random() <= includeSampleWithProbability: features.append(metaData.subject.id) csvWriter.writerow(features) #print features counter += 1 return
def readData(baseDirPath,trial): dirPath = os.path.join(baseDirPath,'T' + str(trial).zfill(3)) metaFilePath = os.path.join(dirPath,'meta-' + str(trial).zfill(3)+".yml") dataFilePath = os.path.join(dirPath,'mocap-' + str(trial).zfill(3)+".txt") metaData = data_util.getMetaData(metaFilePath) rows = [] with open(dataFilePath, 'rb') as f: reader = csv.reader(f, delimiter='\t') reader.next() # Skin header for row in reader: rows.append(row) return rows,metaData.subject.id