Commit 327b30bb authored by dhomm's avatar dhomm
Browse files

add preparation files to main branch

parent dbc4eab5
%% Cell type:code id:729808fa tags:
``` python
import matplotlib.pyplot as plt
import numpy as np
from numpy import mean, sqrt, square, var, corrcoef
```
%% Cell type:code id:1a94bc3d tags:
``` python
def lr_distinction(body_part, first_component, second_component):
"""
This function distinguishes if the sensor is placed on the left or right
body part
:args:
body_part: the body_part the sensor was assigned to
first_component, second_component: the components which will be compared
The components should be as following for differen bps
upper arm:
first = sternum orientation (theta_x), second = upper arm z-accelerometer
upper leg:
first = pelvis orientation (theta_x), second upper leg z-accelerometer
shoulder:
first = shoulder, second = upper arm : z-accelerometer
forearm:
first = forearm, second = upper arm : x-accelerometer
hands:
first = hands, second = forearms : y-accelerometer
lower legs:
first = lower legs, second = upper legs : x-accelerometer
feet:
first = feet, second = lower legs : x-accelerometer
:return:
left or right as string
"""
cc = corrcoef(first_component, second_component)
if body_part == "upper arm":
if cc <= 1:
return "left"
else:
return "right"
if body_part == "upper leg":
if cc <= 1:
return "left"
else:
return "right"
if body_part == "shoulder":
if cc <= xxx:
return "left"
else:
return "right"
if body_part == "forearm":
if cc <= xxx:
return "left"
else:
return "right"
if body_part == "hands":
if cc <= xxx:
return "left"
else:
return "right"
if body_part == "lower legs":
if cc <= xxx:
return "left"
else:
return "right"
if body_part == "feet":
if cc <= xxx:
return "left"
else:
return "right"
```
%% Cell type:code id:0c98dc2e tags:
``` python
from av.io import read
import matplotlib.pyplot as plt
import numpy as np
from math import sqrt
import csv
%run ../base_functions.ipynb
```
%% Cell type:code id:24228594 tags:
``` python
# 1600-1650
wisdm_p1 = "../../../PycharmProjects/BP/WSDM/WISDM-all-sensors-final/1600.mkv"
wisdm_p2 = "../../../PycharmProjects/BP/WSDM/WISDM-all-sensors-final/1601.mkv"
# 1-17
realdisp_p1 = "../../../../PycharmProjects/BP/REALDISP-Activity/REALDISP-all-Sensors-final/Proband1.mkv"
realdisp_p2 = "../../../../PycharmProjects/BP/REALDISP-Activity/REALDISP-all-Sensors-final/Proband2.mkv"
#subject 101-109
pamap_p1 = "../../../../PycharmProjects/BP/PAMAP2/PAMAP2-final/Subject101.mkv"
pamap_p2 = "../../../../PycharmProjects/BP/PAMAP2/PAMAP2-final/Subject102.mkv"
#subject 1-15
original_file = "../../../Bachelorprojekt/Sets/Uni-Mannheim/original/proband1/data/relevant_acc_walking_csv/acc_walking_forearm.csv"
uni_file_new = "../../../../PycharmProjects/BP/uni-mannheim/uni-mannheim-all-sensors-final/Proband1.mkv"
```
%% Cell type:code id:d214e93d tags:
``` python
audio = read("a:", file=realdisp_p2)
sub = read("s:", file=realdisp_p2)
print(sub[0])
#BODYPOSITION': 'Right lower arm
# Accelerometer
acc_r_forearm = audio[0]
gyro_r_forearm = audio[1]
```
%% Output
Could not find codec parameters for stream 27 (Audio: wavpack, 50 Hz, 4 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' (10000000) and 'probesize' (5000000) options
Could not find codec parameters for stream 28 (Audio: wavpack, 50 Hz, 3 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' (10000000) and 'probesize' (5000000) options
Could not find codec parameters for stream 29 (Audio: wavpack, 50 Hz, 3 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' (10000000) and 'probesize' (5000000) options
Could not find codec parameters for stream 30 (Audio: wavpack, 50 Hz, 3 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' (10000000) and 'probesize' (5000000) options
Could not find codec parameters for stream 31 (Audio: wavpack, 50 Hz, 4 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' (10000000) and 'probesize' (5000000) options
Could not find codec parameters for stream 32 (Audio: wavpack, 50 Hz, 3 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' (10000000) and 'probesize' (5000000) options
Could not find codec parameters for stream 33 (Audio: wavpack, 50 Hz, 3 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' (10000000) and 'probesize' (5000000) options
Could not find codec parameters for stream 34 (Audio: wavpack, 50 Hz, 3 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' (10000000) and 'probesize' (5000000) options
Could not find codec parameters for stream 35 (Audio: wavpack, 50 Hz, 4 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' (10000000) and 'probesize' (5000000) options
Could not find codec parameters for stream 27 (Audio: wavpack, 50 Hz, 4 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' (10000000) and 'probesize' (5000000) options
Could not find codec parameters for stream 28 (Audio: wavpack, 50 Hz, 3 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' (10000000) and 'probesize' (5000000) options
Could not find codec parameters for stream 29 (Audio: wavpack, 50 Hz, 3 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' (10000000) and 'probesize' (5000000) options
Could not find codec parameters for stream 30 (Audio: wavpack, 50 Hz, 3 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' (10000000) and 'probesize' (5000000) options
Could not find codec parameters for stream 31 (Audio: wavpack, 50 Hz, 4 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' (10000000) and 'probesize' (5000000) options
Could not find codec parameters for stream 32 (Audio: wavpack, 50 Hz, 3 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' (10000000) and 'probesize' (5000000) options
Could not find codec parameters for stream 33 (Audio: wavpack, 50 Hz, 3 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' (10000000) and 'probesize' (5000000) options
Could not find codec parameters for stream 34 (Audio: wavpack, 50 Hz, 3 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' (10000000) and 'probesize' (5000000) options
Could not find codec parameters for stream 35 (Audio: wavpack, 50 Hz, 4 channels): unspecified sample format
Consider increasing the value for the 'analyzeduration' (10000000) and 'probesize' (5000000) options
[(0, 178000, 'unlabeled'), (178000, 263000, 'walking'), (263000, 272000, 'unlabeled'), (272000, 371000, 'jogging'), (371000, 380000, 'unlabeled'), (380000, 442000, 'running'), (442000, 558000, 'unlabeled'), (558000, 568000, 'jump up'), (568000, 581000, 'unlabeled'), (581000, 598000, 'jump front & back'), (598000, 608000, 'unlabeled'), (608000, 626000, 'Jump leg/arms open/closed'), (626000, 645000, 'unlabeled'), (645000, 664000, 'jump sideways'), (664000, 681000, 'unlabeled'), (681000, 690000, 'jump rope'), (690000, 711000, 'unlabeled'), (711000, 753000, 'Trunk twist (arms outstretched)'), (753000, 767000, 'unlabeled'), (767000, 801000, 'Trunk twist (elbows bended)'), (801000, 810000, 'unlabeled'), (810000, 847000, 'waist bends forward'), (847000, 871000, 'unlabeled'), (871000, 912000, 'waist rotation'), (912000, 943000, 'unlabeled'), (943000, 976000, 'Waist bends (reach foot with opposite hand)'), (976000, 993000, 'unlabeled'), (993000, 1027000, 'Reach heels backwards'), (1027000, 1046000, 'unlabeled'), (1046000, 1062000, 'Lateral bend (10x to the left + 10x to the right)'), (1062000, 1079000, 'unlabeled'), (1079000, 1096000, 'Lateral bend (10x to the left + 10x to the right)'), (1096000, 1112000, 'unlabeled'), (1112000, 1129000, 'Lateral bend arm up (10x to the left + 10x to the right)'), (1129000, 1133000, 'unlabeled'), (1133000, 1148000, 'Lateral bend arm up (10x to the left + 10x to the right)'), (1148000, 1169000, 'unlabeled'), (1169000, 1182000, 'Repetitive forward stretching'), (1182000, 1206000, 'unlabeled'), (1206000, 1224000, 'Upper trunk and lower body opposite twist'), (1224000, 1233000, 'unlabeled'), (1233000, 1270000, 'Arms lateral elevation'), (1270000, 1319000, 'unlabeled'), (1319000, 1357000, 'Arms frontal elevation'), (1357000, 1377000, 'unlabeled'), (1377000, 1403000, 'Frontal hand claps'), (1403000, 1444000, 'unlabeled'), (1444000, 1471000, 'Arms frontal crossing'), (1471000, 1510000, 'unlabeled'), (1510000, 1536000, 'Shoulders high amplitude rotation'), (1536000, 1574000, 'unlabeled'), (1574000, 1591000, 'Shoulders low amplitude rotation'), (1591000, 1630000, 'unlabeled'), (1630000, 1654000, 'Arms inner rotation'), (1654000, 1668000, 'unlabeled'), (1668000, 1676000, 'Knees (alternatively) to the breast'), (1676000, 1732000, 'unlabeled'), (1732000, 1740000, 'Heels (alternatively) to the backside'), (1740000, 1796000, 'unlabeled'), (1796000, 1829000, 'Knees bending (crouching)'), (1829000, 1945000, 'unlabeled'), (1945000, 1980000, 'Knees (alternatively) bend forward'), (1980000, 1991000, 'unlabeled'), (1991000, 2009000, 'Rotation on the knees'), (2009000, 2088000, 'unlabeled'), (2088000, 2128000, 'Rowing'), (2128000, 2225000, 'unlabeled'), (2225000, 2290000, 'Cycling'), (2290000, 2480000, 'unlabeled'), (2480000, 2565000, 'Elliptic')]
%% Cell type:code id:58fb0da8 tags:
``` python
plt.plot(acc_r_forearm[0//20:10000//20])
plt.show()
print(acc_r_forearm[0//20:100//20])
print(str(acc_r_forearm.info)[:])
plt.plot(gyro_r_forearm[0//20:500//20])
plt.show()
```
%% Output
[[-8.9177 4.2361 0.33997]
[-8.9029 4.2887 0.38759]
[-8.8931 4.2836 0.40459]
[-8.8638 4.2568 0.42185]
[-8.854 4.2446 0.43412]]
<av.AudioStream #0 wavpack at 50Hz, 2.1, fltp at 0x7fa704069100>
This source diff could not be displayed because it is too large. You can view the blob instead.