biomechzoo 0.5.0__tar.gz → 0.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of biomechzoo might be problematic. Click here for more details.
- {biomechzoo-0.5.0/src/biomechzoo.egg-info → biomechzoo-0.5.1}/PKG-INFO +1 -1
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/pyproject.toml +1 -1
- biomechzoo-0.5.1/src/biomechzoo/biomech_ops/movement_onset.py +2 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/biomechzoo.py +22 -0
- biomechzoo-0.5.1/src/biomechzoo/imu/tilt_algoirthm.py +112 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/processing/addevent_data.py +7 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1/src/biomechzoo.egg-info}/PKG-INFO +1 -1
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo.egg-info/SOURCES.txt +2 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/LICENSE +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/README.md +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/setup.cfg +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/__init__.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/__init__.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/__main__.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/biomech_ops/__init__.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/biomech_ops/continuous_relative_phase_data.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/biomech_ops/continuous_relative_phase_line.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/biomech_ops/filter_data.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/biomech_ops/filter_line.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/biomech_ops/normalize_data.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/biomech_ops/normalize_line.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/biomech_ops/phase_angle_data.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/biomech_ops/phase_angle_line.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/conversion/__init__.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/conversion/c3d2zoo_data.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/conversion/mvnx2zoo_data.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/conversion/opencap2zoo_data.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/conversion/table2zoo_data.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/mvn/__init__.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/mvn/load_mvnx.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/mvn/main_mvnx.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/mvn/mvn.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/mvn/mvnx_file_accessor.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/processing/__init__.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/processing/add_channel_data.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/processing/addchannel_data.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/processing/explodechannel_data.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/processing/partition_data.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/processing/removechannel_data.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/processing/removeevent_data.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/processing/renamechannel_data.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/processing/renameevent_data.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/processing/split_trial_by_gait_cycle.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/utils/__init__.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/utils/batchdisp.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/utils/compute_sampling_rate_from_time.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/utils/engine.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/utils/findfield.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/utils/get_split_events.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/utils/peak_sign.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/utils/set_zoosystem.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/utils/split_trial.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/utils/version.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/utils/zload.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/utils/zplot.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/utils/zsave.py +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo.egg-info/dependency_links.txt +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo.egg-info/entry_points.txt +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo.egg-info/requires.txt +0 -0
- {biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import inspect
|
|
3
3
|
import time
|
|
4
|
+
|
|
5
|
+
from biomechzoo.imu.tilt_algoirthm import tilt_algorithm_data
|
|
4
6
|
from biomechzoo.utils.engine import engine # assumes this returns .zoo files in folder
|
|
5
7
|
from biomechzoo.utils.zload import zload
|
|
6
8
|
from biomechzoo.utils.zsave import zsave
|
|
@@ -134,6 +136,26 @@ class BiomechZoo:
|
|
|
134
136
|
def parquet2zoo(self, out_folder=None, inplace=None):
|
|
135
137
|
raise NotImplementedError('Use table2zoo instead')
|
|
136
138
|
|
|
139
|
+
def tilt_algorithm(self, chname_avert, chname_medlat, chname_antpost, out_folder=None, inplace=False):
|
|
140
|
+
""" tilt correction for acceleration data """
|
|
141
|
+
start_time = time.time()
|
|
142
|
+
verbose = self.verbose
|
|
143
|
+
in_folder = self.in_folder
|
|
144
|
+
if inplace is None:
|
|
145
|
+
inplace = self.inplace
|
|
146
|
+
fl = engine(in_folder, name_contains=self.name_contains, subfolders=self.subfolders)
|
|
147
|
+
for f in fl:
|
|
148
|
+
batchdisp('tilt correction of acceleration channels for {}'.format(f), level=2, verbose=verbose)
|
|
149
|
+
data = zload(f)
|
|
150
|
+
data = tilt_algorithm_data(data, chname_avert, chname_medlat, chname_antpost)
|
|
151
|
+
zsave(f, data, inplace=inplace, out_folder=out_folder, root_folder=in_folder)
|
|
152
|
+
method_name = inspect.currentframe().f_code.co_name
|
|
153
|
+
batchdisp(
|
|
154
|
+
'{} process complete for {} file(s) in {:.2f} secs'.format(method_name, len(fl), time.time() - start_time),
|
|
155
|
+
level=1, verbose=verbose)
|
|
156
|
+
# Update self.folder after processing
|
|
157
|
+
self._update_folder(out_folder, inplace, in_folder)
|
|
158
|
+
|
|
137
159
|
def phase_angle(self, ch, out_folder=None, inplace=None):
|
|
138
160
|
""" computes phase angles"""
|
|
139
161
|
start_time = time.time()
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import math
|
|
3
|
+
import pandas as pd
|
|
4
|
+
from biomechzoo.processing.add_channel_data import add_channel_data
|
|
5
|
+
|
|
6
|
+
def tilt_algorithm_data(data,ch_vert, ch_medlat, ch_antpost, plot_or_not=None):
|
|
7
|
+
|
|
8
|
+
# extract channels from data
|
|
9
|
+
avert = data[ch_vert]['line']
|
|
10
|
+
amedlat = data[ch_medlat]['line']
|
|
11
|
+
aantpost = data[ch_antpost]['line']
|
|
12
|
+
|
|
13
|
+
_, avert_corr, amedlat_corr, aantpost_corr = tilt_algorithm_line(avert, amedlat, aantpost)
|
|
14
|
+
|
|
15
|
+
data = add_channel_data(data, ch_vert + '_tilt_corr', avert_corr)
|
|
16
|
+
data = add_channel_data(data, ch_medlat + '_tilt_corr', amedlat_corr)
|
|
17
|
+
data = add_channel_data(data, ch_antpost + '_tilt_corr', aantpost_corr)
|
|
18
|
+
|
|
19
|
+
return data
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def tilt_algorithm_line(avert, amedlat, aantpost, plot_or_not=None):
|
|
23
|
+
"""
|
|
24
|
+
TiltAlgorithm - to account for gravity and improper tilt alignment of a tri-axial trunk accelerometer.
|
|
25
|
+
Step 1: Extract raw measured (mean) accelerations
|
|
26
|
+
Step 2: Calculate tilt angles
|
|
27
|
+
Step 3: Calculate horizontal dynamic accelerations vectors
|
|
28
|
+
Step 4: Calculate estimated provisional vertical vector
|
|
29
|
+
Step 5: Calculate vertical dynamic vector
|
|
30
|
+
step 6.1: Calculate the contribution of static components
|
|
31
|
+
step 6.2 Transpose static component matrices
|
|
32
|
+
step 7: Remove the static components from the templates of pre and post
|
|
33
|
+
|
|
34
|
+
:param avert: signal predominantly in vertical direction
|
|
35
|
+
:param amedlat: signal predominantly in medio-lateral direction
|
|
36
|
+
:param aantpost: signal predominantly in anterior-posterior direction
|
|
37
|
+
:param plot_or_not: whether to plot the results
|
|
38
|
+
:return: dataframe of the tilt corrected and gravity subtracted vertical, medio-lateral and anterior-posterior
|
|
39
|
+
acceleration signals
|
|
40
|
+
"""
|
|
41
|
+
#
|
|
42
|
+
|
|
43
|
+
a_vt = avert.mean()
|
|
44
|
+
a_ml = amedlat.mean()
|
|
45
|
+
a_ap = aantpost.mean()
|
|
46
|
+
|
|
47
|
+
# if avert is negative than turn the sensor around.
|
|
48
|
+
if a_vt < 0.5:
|
|
49
|
+
avert *= -1
|
|
50
|
+
amedlat *= -1
|
|
51
|
+
a_vt = avert.mean()
|
|
52
|
+
a_ml = amedlat.mean()
|
|
53
|
+
|
|
54
|
+
# Anterior tilt
|
|
55
|
+
TiltAngle_ap_rad = np.arcsin(a_ap)
|
|
56
|
+
TiltAngle_ap_deg = math.degrees(TiltAngle_ap_rad)
|
|
57
|
+
|
|
58
|
+
# mediolateral tilt
|
|
59
|
+
TiltAngle_ml_rad = np.arcsin(a_ml)
|
|
60
|
+
TiltAngle_ml_deg = math.degrees(TiltAngle_ml_rad)
|
|
61
|
+
|
|
62
|
+
# Anterior posterior
|
|
63
|
+
a_AP = (a_ap * np.cos(TiltAngle_ap_rad)) - (a_vt * np.sin(TiltAngle_ap_rad))
|
|
64
|
+
# AMediolateral
|
|
65
|
+
a_ML = (a_ml * np.cos(TiltAngle_ml_rad)) - (a_vt * np.sin(TiltAngle_ml_rad))
|
|
66
|
+
|
|
67
|
+
# a_vt_prov = a_ap*Sin(theta_ap) + a_vt*Cos(theta_ap)
|
|
68
|
+
a_vt_prov = (a_ap * np.sin(TiltAngle_ap_rad)) + (a_vt * np.cos(TiltAngle_ap_rad))
|
|
69
|
+
|
|
70
|
+
# a_VT = a_ml*sin(theta_ml) + a_vt_prov*cos(theta_ml) - 1
|
|
71
|
+
a_VT = (a_ml * np.sin(TiltAngle_ml_rad)) + (a_vt_prov * np.cos(TiltAngle_ml_rad)) - 1
|
|
72
|
+
|
|
73
|
+
a_AP_static = a_ap - a_AP
|
|
74
|
+
a_ML_static = a_ml - a_ML
|
|
75
|
+
a_VT_static = a_vt - a_VT
|
|
76
|
+
|
|
77
|
+
a_AP_static = np.transpose(a_AP_static)
|
|
78
|
+
a_ML_static = np.transpose(a_ML_static)
|
|
79
|
+
a_VT_static = np.transpose(a_VT_static)
|
|
80
|
+
|
|
81
|
+
amedlat2 = amedlat - a_ML_static
|
|
82
|
+
avert2 = avert - a_VT_static
|
|
83
|
+
aantpost2 = aantpost - a_AP_static
|
|
84
|
+
|
|
85
|
+
data = {'avert': avert2,
|
|
86
|
+
'amedlat': amedlat2,
|
|
87
|
+
'aantpost': aantpost2}
|
|
88
|
+
df_corrected = pd.DataFrame(data)
|
|
89
|
+
|
|
90
|
+
# if plot_or_not:
|
|
91
|
+
# f, ax = plt.subplots(nrows=3, ncols=1, sharex=True, dpi=300)
|
|
92
|
+
# sns.despine(offset=10)
|
|
93
|
+
# f.tight_layout()
|
|
94
|
+
# offset = 0.1
|
|
95
|
+
# f.subplots_adjust(left=0.15, top=0.95)
|
|
96
|
+
#
|
|
97
|
+
# sns.lineplot(avert, ax=ax[0], label='Raw')
|
|
98
|
+
# sns.lineplot(avert2, ax=ax[0], label='tilt corrected')
|
|
99
|
+
# ax[0].set_ylabel('vert acc (g)')
|
|
100
|
+
# ax[0].set_title('Vertical acceleration corrected with {}'.format(np.round(a_VT_static, 2)))
|
|
101
|
+
#
|
|
102
|
+
# sns.lineplot(amedlat, ax=ax[1], label='Raw')
|
|
103
|
+
# sns.lineplot(amedlat2, ax=ax[1], label='Tilt corrected')
|
|
104
|
+
# ax[1].set_ylabel('ml acc (g)')
|
|
105
|
+
# ax[1].set_title('Medio-lateral tilt angle corrected with {} degrees'.format(np.round(TiltAngle_ml_deg, 2)))
|
|
106
|
+
#
|
|
107
|
+
# sns.lineplot(aantpost, ax=ax[2], label='Raw')
|
|
108
|
+
# sns.lineplot(aantpost2, ax=ax[2], label='Tilt corrected')
|
|
109
|
+
# ax[2].set_ylabel('ap acc (g)')
|
|
110
|
+
# ax[2].set_title('Anterior-posterior tilt angle corrected with {} degrees'.format(np.round(TiltAngle_ap_deg, 2)))
|
|
111
|
+
|
|
112
|
+
return df_corrected, avert2, amedlat2, aantpost2
|
|
@@ -2,6 +2,7 @@ import numpy as np
|
|
|
2
2
|
import copy
|
|
3
3
|
import warnings
|
|
4
4
|
from biomechzoo.utils.peak_sign import peak_sign
|
|
5
|
+
from biomechzoo.biomech_ops.movement_onset import movement_onset
|
|
5
6
|
|
|
6
7
|
def addevent_data(data, channels, ename, etype, constant=None):
|
|
7
8
|
|
|
@@ -46,6 +47,12 @@ def addevent_data(data, channels, ename, etype, constant=None):
|
|
|
46
47
|
exd = max_stance(yd)
|
|
47
48
|
eyd = float(yd[exd])
|
|
48
49
|
eyd = float(yd[exd])
|
|
50
|
+
elif etype == 'movement_onset':
|
|
51
|
+
exd = movement_onset(yd, constant)
|
|
52
|
+
eyd = yd[exd]
|
|
53
|
+
elif etype == 'movement_offset':
|
|
54
|
+
exd = movement_onset(yd,constant)
|
|
55
|
+
eyd = yd[exd]
|
|
49
56
|
elif etype in ['fs_fp', 'fo_fp']:
|
|
50
57
|
# --- Handle constant ---
|
|
51
58
|
if constant is None:
|
|
@@ -16,6 +16,7 @@ src/biomechzoo/biomech_ops/continuous_relative_phase_data.py
|
|
|
16
16
|
src/biomechzoo/biomech_ops/continuous_relative_phase_line.py
|
|
17
17
|
src/biomechzoo/biomech_ops/filter_data.py
|
|
18
18
|
src/biomechzoo/biomech_ops/filter_line.py
|
|
19
|
+
src/biomechzoo/biomech_ops/movement_onset.py
|
|
19
20
|
src/biomechzoo/biomech_ops/normalize_data.py
|
|
20
21
|
src/biomechzoo/biomech_ops/normalize_line.py
|
|
21
22
|
src/biomechzoo/biomech_ops/phase_angle_data.py
|
|
@@ -25,6 +26,7 @@ src/biomechzoo/conversion/c3d2zoo_data.py
|
|
|
25
26
|
src/biomechzoo/conversion/mvnx2zoo_data.py
|
|
26
27
|
src/biomechzoo/conversion/opencap2zoo_data.py
|
|
27
28
|
src/biomechzoo/conversion/table2zoo_data.py
|
|
29
|
+
src/biomechzoo/imu/tilt_algoirthm.py
|
|
28
30
|
src/biomechzoo/mvn/__init__.py
|
|
29
31
|
src/biomechzoo/mvn/load_mvnx.py
|
|
30
32
|
src/biomechzoo/mvn/main_mvnx.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/biomech_ops/continuous_relative_phase_data.py
RENAMED
|
File without changes
|
{biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/biomech_ops/continuous_relative_phase_line.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/processing/split_trial_by_gait_cycle.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{biomechzoo-0.5.0 → biomechzoo-0.5.1}/src/biomechzoo/utils/compute_sampling_rate_from_time.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|