Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#"" latitude longitude senseStartTimeMillis uid phq9 accuracy depressed period
interval = 14 #quids interval, change to 14 if phq9
# map uid to os
map_uid_os = dict()
for l in open('mapping.csv').readlines():
if len(l)>0:
ll = l.split(',')
if len(ll)>1:
uid = ll[0]
os_ = ll[2][:-1]
map_uid_os[uid]=os_
# map uid to phq9
map_uid_phq9 = dict()
for l in open('phq9_convert.csv').readlines():
if len(l)>0:
ll = l.split(',')
if len(ll)>3:
uid = ll[0]
ts = ll[1]
phq9 = ll[2]
depressed = ll[3][:-1]
if uid not in map_uid_phq9.keys():
map_uid_phq9[uid] = []
map_uid_phq9[uid].append([ts,phq9,depressed])
print(map_uid_phq9)
import os
if not os.path.exists("actiprocess"):
os.makedirs("actiprocess")
#split activity data based on uid
owfile = dict()
title = dict()
with open('activity.csv') as file:
for line in file:
ll = line.split(',')
if len(ll)>5:
uid = ll[1]
ts = ll[4] # sensing time
act = ll[10]
acc = ll[11] # accuracy
# we only care about fast moving activity
if act == 'running':
act = '3'
if act == 'cycling' or act == 'in-vehicle':
act = '4'
else:
act = '0'
if uid in map_uid_os.keys():
os = map_uid_os[uid]
if uid in map_uid_phq9.keys():
phq9list = map_uid_phq9[uid]
for qts,phq9,depressed in phq9list:
if int(qts)-int(ts)>0 and int(qts)-int(ts)<interval*86400*1000: #only care about the data can be matched to phq9
os = map_uid_os[uid]
fn = 'actiprocess\\'+uid+'_Location.csv'
if fn in owfile.keys():
ow = owfile[fn]
else:
ow = open(fn,'a+')
owfile[fn] = ow
ow.write(','.join(['',uid,ts,act,depressed,qts,acc]))
for k in owfile.keys():
owfile[k].close()