forked from qcri/sleep_awake_benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsleep_processdataset.py
34 lines (24 loc) · 1.04 KB
/
sleep_processdataset.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
File to pre-process the raw actigraphy data into format that can be used by machine learning and formula based methods for
distinguishing sleep from awake
"""
import sys
from sleep_misc import load_dataset
if len(sys.argv) <= 1:
print("Usage: %s <TASK_ID>" % (sys.argv[0]))
sys.exit(0)
TASK = int(sys.argv[1])
print("Generating dataset for Task %d" % (TASK))
OUTPUTFILE="hdf_task%d" % (TASK)
if TASK in [1, 2]:
PATH_TO_FILES = "./datasets/task%d/" % (TASK)
else:
PATH_TO_FILES = "./data/mesa/actigraphy_test/"
method = "stage" if TASK != 3 else "interval"
print("...Loading dataset into memory...")
dftrain, dftest, featnames = load_dataset(PATH_TO_FILES, useCache=False, saveCache=True, cacheName=OUTPUTFILE, ground_truth=method)
print("...Done...")
dfoutname = "dftest_task%d.csv" % (TASK)
print("...Saving Task %d dataset to disk. Filename: %s ..." % (TASK, dfoutname))
dftest[["mesaid", "linetime", "marker", "interval", "binterval", "gt", "gt_sleep_block", "wake"]].to_csv(dfoutname, index=False)
print("...Done...")