-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.md~
More file actions
307 lines (223 loc) · 9.24 KB
/
Copy pathREADME.md~
File metadata and controls
307 lines (223 loc) · 9.24 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# DPLocate Modules
There are six DPLocate modules. They are run in tandem. Their dependencies are:
* MATLAB >= 2017a
* https://www.mathworks.com/products/mapping.html
* Python >= 3.6
* pandas
# Installation
* Make sure you have the stated MATLAB and Python
* Install the [Mapping Toolbox](https://www.mathworks.com/products/mapping.html)
The toolbox should automatically install when you install MATLAB.
Otherwise, [this](https://www.mathworks.com/matlabcentral/answers/1457044-install-a-toolbox-from-command-line?s_tid=mlc_ans_email_ques)
thread may be helpful to install it later. You can verify its existence by running
[this](https://www.mathworks.com/help/map/creating-maps-using-geoshow.html) quick example.
* Install Python packages:
pip install -r requirements.txt
* Finally, clone this repository:
git clone https://github.com/dptools/dplocate.git
Individual module scripts are `dplocate/dplocate*/*py`. Learn more about them below.
# DPLocate0-read
DPLocate Step 0: Extract the raw GPS data
## Table of contents
1. [Requirements](#requirements)
2. [Usage](#usage)
## Requirements
- The Raw data is saved as an unencrypted `.json` file that is saved in
the 'phone/gps/raw' directory
- The Data has the following format:
```text
{"sensor": "lamp.gps", "data": {"latitude": (deg), "longitude": (deg),
"accuracy": m, "altitude": (deg)}, "timestamp": (JAVA time)}
```
- The output directory can be edited. The default is `./processed/gps_dash2` and the
file is saved as `file_gps.mat` which contains five vector variables in MATLAB
with the following names and contents:
```text
t1: timestamp(JAVA time)
lat1: latitude(deg)
lon1: longitude(deg)
alt1: altitude(deg)
acc1: accuracy(m)
```
- This step is the longest part of the pipeline and it can take hours per
subject. Running that in parallel for different subjects of a study is
recommended to reduce the execution time.
- After this step run dplocate-preprocess pipeline
### Passphrase
(Encryption is not applied currently so you can skip all the *Passphrase* sections)
For files that are locked, please provide a passphrase by setting the
`BEIWE_STUDY_PASSCODE` environment variable.
For example:
```
export BEIWE_STUDY_PASSCODE='test passcode 1 2 3'
```
## Usage
The default is that the pipeline runs for the `new` files.
```bash
# To generate reports for subject A and subject C in STUDY_PILOT under their processed folders
# Define the PHOENIX, consent and MATLAB directories
parse_gps_mc.py --phoenix-dir [PHOENIX DIR] --consent-dir [CONSENT DIR] --matlab-dir [MATLAB DIR] --study STUDY_PILOT --data-type phone --include active --data-dir PROTECTED --subject A C
```
For more information, please run
```bash
parse_gps_mc.py -h
```
# DPLocate1-preprocess
DPLocate Step 1: Preprocess the GPS data with temporal filtering
## Table of contents
1. [Requirements](#requirements)
2. [Usage](#usage)
## Requirements
- The Input to this module is the Output of dplocate0-read. The input data is saved as an unencrypted
`file_gps.mat` file.
- The Data has the following format:
- Five vector variables in MATLAB with the following names and contents:
```text
t1: timestamp(JAVA time)
lat1: latitude(deg)
lon1: longitude(deg)
alt1: altitude(deg)
acc1: accuracy(m)
```
- The output directory can be edited. The default is `./processed/gps_dash2` and the
file is saved as `dash.mat`.
- This step applies temporal filtering by defining 'epochs'
and saves the summary of the epochs; as the following columns:

- After this step run dplocate2-process pipeline
### Passphrase
For files that are locked, please provide a passphrase by setting the
`BEIWE_STUDY_PASSCODE` environment variable.
For example:
```
export BEIWE_STUDY_PASSCODE='test passcode 1 2 3'
```
## Usage
The default is that the pipeline runs for the `new` files.
```bash
# To generate reports for subject A and subject C in STUDY_PILOT under their processed folders
# Define the PHOENIX, consent and MATLAB directories
preprocess_gps_mc.py --phoenix-dir [PHOENIX DIR] --consent-dir [CONSENT DIR] --matlab-dir [MATLAB DIR] --study STUDY_PILOT --data-type phone --include active --data-dir PROTECTED --subject A C
```
For more information, please run
```bash
preprocess_gps_mc.py -h
```
# DPLocate2-process
DPLocate Step 2: Process the GPS data with clustering (every 150 days for long studies)
## Table of contents
1. [Requirements](#requirements)
2. [Usage](#usage)
## Requirements
- The Input to this module is the Output of dplocate1-preprocess.
The input data is saved as an unencrypted `dash.mat` file.
- The Data has the following format:
- Epoch data from row 1 with the following columns:

- The output directory can be edited. The default is `./processed/gps_dash2` and the
file is saved as `daily_nr#.mat` where # is a natural number from 1 to inf.
- This step applies spatial clustering to the 'epochs' and saves the daily maps and the
coordinates of the Points of Interest (PoIs).
- After this step run dplocate3-aggregate pipeline
### Passphrase
For files that are locked, please provide a passphrase by setting the
`BEIWE_STUDY_PASSCODE` environment variable.
For example:
```
export BEIWE_STUDY_PASSCODE='test passcode 1 2 3'
```
## Usage
```bash
# To generate reports for subject A and subject C in STUDY_PILOT under their processed folders
# Define the PHOENIX, consent and MATLAB directories
process_gps_mc.py --phoenix-dir [PHOENIX DIR] --consent-dir [CONSENT DIR] --matlab-dir [MATLAB DIR] --study STUDY_PILOT --data-type phone --include active --data-dir PROTECTED --subject A C
```
For more information, please run
```bash
process_gps_mc.py -h
```
# DPLocate3-aggregate
DPLocate Step 3: Aggregate the processed daily maps of the study
## Table of contents
1. [Requirements](#requirements)
2. [Usage](#usage)
## Requirements
- The Input to this module is the Output of dplocate2-process.
The input data is saved as encrypted `daily_nr#.mat` files.
- The output directory can be edited. The default is `./processed/gps_dash2` and the
file is saved as `daily_all.mat`.
- This step aggregates the daily maps of the 150-day clusters.
- After this step run dplocate4-plot pipeline
### Passphrase
For files that are locked, please provide a passphrase by setting the
`BEIWE_STUDY_PASSCODE` environment variable.
For example:
```
export BEIWE_STUDY_PASSCODE='test passcode 1 2 3'
```
## Usage
```bash
# To generate reports for subject A and subject C in STUDY_PILOT under their processed folders
# Define the PHOENIX, consent and MATLAB directories
aggregate_gps_mc.py --phoenix-dir [PHOENIX DIR] --consent-dir [CONSENT DIR] --matlab-dir [MATLAB DIR] --study STUDY_PILOT --data-type phone --include active --data-dir PROTECTED --subject A C
```
For more information, please run
```bash
aggregate_gps_mc.py -h
```
# DPLocate4-plot
DPLocate Step 4: Plot color-coded GPS daily map
## Table of contents
1. [Requirements](#requirements)
2. [Usage](#usage)
## Requirements
- The Input to this module is the Output of dplocate3-aggregate.
The input data is saved as encrypted `daily_all.mat` files.
- The output directory can be edited. The default is GENERAL directory `/phone/processed/mtl_plt` and the
file is saved as `STUDY_SUBJECT-tmzn.png.`.
- This step plots the daily maps and transfers the processed data into the GENERAL folder.
### Passphrase
For files that are locked, please provide a passphrase by setting the
`BEIWE_STUDY_PASSCODE` environment variable.
For example:
```
export BEIWE_STUDY_PASSCODE='test passcode 1 2 3'
```
## Usage
```bash
# To generate reports for subject A and subject C in STUDY_PILOT under their processed folders
# Define the PHOENIX, consent and MATLAB directories
phone_gps_mc.py --phoenix-dir [PHOENIX DIR] --consent-dir [CONSENT DIR] --matlab-dir [MATLAB DIR] --study STUDY_PILOT --data-type phone --include active --data-dir PROTECTED --subject A C
```
For more information, please run
```bash
phone_gps_mc.py -h
```
# DPLocate5-markov
DPLocate Step 5: Plot color-coded GPS daily map
## Table of contents
1. [Requirements](#requirements)
2. [Usage](#usage)
## Requirements
- The Input to this module is the Output of dplocate3-aggregate.
The input data is saved as encrypted `daily_all.mat` files.
- The output directory can be edited. The default is GENERAL directory `/phone/processed/mtl_plt` and the
files are saved as `STUDY_SUBJECT-markov....png.`.
- This step plots the Time-Band maps and Markov diagrams of the processed data into the GENERAL folder.
### Passphrase
For files that are locked, please provide a passphrase by setting the
`BEIWE_STUDY_PASSCODE` environment variable.
For example:
```
export BEIWE_STUDY_PASSCODE='test passcode 1 2 3'
```
## Usage
```bash
# To generate reports for subject A and subject C in STUDY_PILOT under their processed folders
# Define the PHOENIX, consent and MATLAB directories
markov_gps_mc.py --phoenix-dir [PHOENIX DIR] --consent-dir [CONSENT DIR] --matlab-dir [MATLAB DIR] --study STUDY_PILOT --data-type phone --include active --data-dir PROTECTED --subject A C
```
For more information, please run
```bash
markov_gps_mc.py -h
```