-
Notifications
You must be signed in to change notification settings - Fork 0
/
interventionViz.py
117 lines (93 loc) · 4.08 KB
/
interventionViz.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import pylab
import warnings
import pandas
from src.settings import setup, QUALITY_LEVEL, DATA_TYPES
from src.data.mAvatar.Data import DAY_TYPE
from src.data.Dataset import Dataset
import src.day_step_compare as day_step_compare
from src.post_view_event_steps_bars import plot_minutes, PLOT_TYPES, plot_difference
import sample_intervention
import knowMe
# these are switches to help debugging, set true to run on each part
avatar = False
knowme = True
# some optional tests:
# from src.post_view_event_steps_bars import test_get_avg_list
# test_get_avg_list()
#knowMe.makePlots(type=PLOT_TYPES.bars, show=True, pre_win=10, post_win=40)
#knowMe.makePlots(type=PLOT_TYPES.bars, show=True)
if avatar:
### USF mAVATAR DATA LOADING ###
settings = setup(dataset='USF', data_loc='../subjects/', subject_n=0)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
data = Dataset(settings, min_quality=QUALITY_LEVEL.acceptable, trim=True, check=True,
used_data_types=[DATA_TYPES.fitbit, DATA_TYPES.avatar_views], avatar_view_freq=60)
UP_TO_DATE = True # true if software versions are good
if pandas.version.version < '0.12.0':
UP_TO_DATE = False
print '\n\nWARN: Some analysis cannot be completed due to outdated pandas version ' + pandas.version.version + '\n\n'
# comparison of events selected with/without overlap from mAvatar dataset
# to demonstrate difference (especially at high time intervals like no-overlap for 3hrs around event)
#plot_minutes(data, MINS=12*60, overlap_okay=True, shift=-6*60, edgecolor='none')
#pylab.show()
plot_minutes(data, MINS=60, overlap_okay=True, shift=-30, edgecolor='none')
pylab.show()
#plot_minutes(data, MINS=60, overlap_okay=False, shift=-30)
#pylab.show()
### START ACTUAL VISUALS ###
# plot_minutes(data, MINS=80, shift=-20, overlap_okay=True, selected_activity_type=DAY_TYPE.active)
# pylab.show()
#
# knowMe.makePlot(type=PLOT_TYPES.bars)
# pylab.show()
# plot all event responses together
# print 'big control stackPlot with colored bars'
# sample_intervention.makePlot(type=PLOT_TYPES.bars, pre_win=15*60, post_win=15*60, color_events=True)
# pylab.show()
# print 'control data all events...'
# sample_intervention.plot_all_events()
# pylab.figure('smoothed')
sample_intervention.plot_all_events(smooth=7)
pylab.show()
# knowMe
# TODO: (maybe... not expecting anything interesting)
# mAvatar
# TODO: (maybe... not expecting anything interesting)
# # plot participant averages & global average response (lines)
# # ctrl
# print 'control avg...'
# sample_intervention.makePlot(type=PLOT_TYPES.lines)
# pylab.show()
if knowme:
# # knowMe
print 'knowMe lines...'
TARGET_COLUMN_INDEX = 16 # 27=HeartRate 16=Accelerometry
TARGET_COLUMN_KEY = knowMe.columnHeader[TARGET_COLUMN_INDEX]
knowMe.makePlot(type=PLOT_TYPES.lines, selected_data=TARGET_COLUMN_KEY, smooth=7, pre_win=120, post_win=6*60)
pylab.show()
# mAvatar
# looking at sedentary, active, or all not very interesting
#
# # plot stackGraphs of event response
# # ctrl
# print 'control stackPlot...'
# sample_intervention.makePlot(type=PLOT_TYPES.bars, pre_win=20, post_win=60, color_events=False)
# pylab.show()
# # knowMe
print 'knowMe stackPlot...'
knowMe.makePlot(type=PLOT_TYPES.bars, selected_data=TARGET_COLUMN_KEY)
pylab.show()
# # mAvatar
# # looking at sedentary, active, or all not very interesting
if avatar:
# # plot differences
# # ctrl real vs random pt
# sample_intervention.makePlot(type=PLOT_TYPES.lines, comparison=True)
# # knowMe intervention vs other sms
# # TODO: knowMe control/experimental?
# # mAvatar sedentary vs active avatar
plot_difference(data, MINS=60, shift=-30, verbose=False, overlap_okay=True, smooth=7,
control_event=DAY_TYPE.sedentary, experimental_event=DAY_TYPE.active, type=PLOT_TYPES.lines)
pylab.show()
# TODO http://matplotlib.org/examples/pylab_examples/arrow_demo.html maybe?