biomechzoo 0.5.1__tar.gz → 0.5.2__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.

Files changed (61) hide show
  1. {biomechzoo-0.5.1/src/biomechzoo.egg-info → biomechzoo-0.5.2}/PKG-INFO +1 -1
  2. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/pyproject.toml +1 -1
  3. biomechzoo-0.5.2/src/biomechzoo/biomech_ops/movement_onset.py +51 -0
  4. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/biomechzoo.py +3 -1
  5. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/processing/addevent_data.py +19 -8
  6. {biomechzoo-0.5.1 → biomechzoo-0.5.2/src/biomechzoo.egg-info}/PKG-INFO +1 -1
  7. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo.egg-info/SOURCES.txt +1 -1
  8. biomechzoo-0.5.1/src/biomechzoo/biomech_ops/movement_onset.py +0 -2
  9. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/LICENSE +0 -0
  10. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/README.md +0 -0
  11. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/setup.cfg +0 -0
  12. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/__init__.py +0 -0
  13. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/__init__.py +0 -0
  14. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/__main__.py +0 -0
  15. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/biomech_ops/__init__.py +0 -0
  16. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/biomech_ops/continuous_relative_phase_data.py +0 -0
  17. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/biomech_ops/continuous_relative_phase_line.py +0 -0
  18. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/biomech_ops/filter_data.py +0 -0
  19. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/biomech_ops/filter_line.py +0 -0
  20. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/biomech_ops/normalize_data.py +0 -0
  21. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/biomech_ops/normalize_line.py +0 -0
  22. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/biomech_ops/phase_angle_data.py +0 -0
  23. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/biomech_ops/phase_angle_line.py +0 -0
  24. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/conversion/__init__.py +0 -0
  25. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/conversion/c3d2zoo_data.py +0 -0
  26. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/conversion/mvnx2zoo_data.py +0 -0
  27. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/conversion/opencap2zoo_data.py +0 -0
  28. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/conversion/table2zoo_data.py +0 -0
  29. /biomechzoo-0.5.1/src/biomechzoo/imu/tilt_algoirthm.py → /biomechzoo-0.5.2/src/biomechzoo/imu/tilt_algorithm.py +0 -0
  30. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/mvn/__init__.py +0 -0
  31. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/mvn/load_mvnx.py +0 -0
  32. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/mvn/main_mvnx.py +0 -0
  33. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/mvn/mvn.py +0 -0
  34. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/mvn/mvnx_file_accessor.py +0 -0
  35. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/processing/__init__.py +0 -0
  36. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/processing/add_channel_data.py +0 -0
  37. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/processing/addchannel_data.py +0 -0
  38. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/processing/explodechannel_data.py +0 -0
  39. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/processing/partition_data.py +0 -0
  40. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/processing/removechannel_data.py +0 -0
  41. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/processing/removeevent_data.py +0 -0
  42. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/processing/renamechannel_data.py +0 -0
  43. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/processing/renameevent_data.py +0 -0
  44. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/processing/split_trial_by_gait_cycle.py +0 -0
  45. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/utils/__init__.py +0 -0
  46. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/utils/batchdisp.py +0 -0
  47. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/utils/compute_sampling_rate_from_time.py +0 -0
  48. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/utils/engine.py +0 -0
  49. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/utils/findfield.py +0 -0
  50. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/utils/get_split_events.py +0 -0
  51. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/utils/peak_sign.py +0 -0
  52. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/utils/set_zoosystem.py +0 -0
  53. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/utils/split_trial.py +0 -0
  54. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/utils/version.py +0 -0
  55. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/utils/zload.py +0 -0
  56. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/utils/zplot.py +0 -0
  57. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo/utils/zsave.py +0 -0
  58. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo.egg-info/dependency_links.txt +0 -0
  59. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo.egg-info/entry_points.txt +0 -0
  60. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo.egg-info/requires.txt +0 -0
  61. {biomechzoo-0.5.1 → biomechzoo-0.5.2}/src/biomechzoo.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: biomechzoo
3
- Version: 0.5.1
3
+ Version: 0.5.2
4
4
  Summary: Python implementation of the biomechZoo toolbox
5
5
  License-Expression: MIT
6
6
  Project-URL: Homepage, https://github.com/mcgillmotionlab/biomechzoo
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "biomechzoo"
3
- version = "0.5.1"
3
+ version = "0.5.2"
4
4
  description = "Python implementation of the biomechZoo toolbox"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11,<3.12" # max version for opencap-process tools is 3.11
@@ -0,0 +1,51 @@
1
+ def movement_onset(yd, constant, etype=etype):
2
+ """
3
+ Extracts movement onset based on the average and standard deviation of a sliding window
4
+ Standard thresholds for running are mean_thresh=1.2, std_thresh=0.2. For walking mean_thresh=0.6, std_thresh=0.2.
5
+
6
+ yd: 1d array of the vector
7
+ constants: [sample_frequency, mean_thresh, std_thresh]
8
+ """
9
+ acc_mag = yd.copy()
10
+
11
+ # ----extract the constants----
12
+ fs = constant[0]
13
+ mean_thresh = constant[1]
14
+ std_thresh = constant[2]
15
+
16
+ # ----sliding window features----
17
+ features = []
18
+ timestamps = []
19
+ window_size = 2 * fs # windows van 2 seconds
20
+ step_size = 1 * fs # with an overlap of 1 seconds
21
+
22
+ for start in range(0, len(acc_mag) - window_size, step_size):
23
+ segment = acc_mag[start:start + window_size]
24
+ mean_val = segment.mean()
25
+ std_val = segment.std()
26
+ # entropy = -np.sum((segment / np.sum(segment)) * np.log2(segment / np.sum(segment) + 1e-12))
27
+ timestamps.append(start)
28
+ features.append((mean_val, std_val))
29
+
30
+ features = np.array(features)
31
+ timestamps = np.array(timestamps)
32
+
33
+ # ----Check already moving else find start----
34
+ initial_window = features[:5] # First few seconds
35
+ if np.all(initial_window[:, 0] > mean_thresh) and np.all(initial_window[:, 1] > std_thresh):
36
+ print("already moving")
37
+ if etype == 'movement_offset':
38
+ index = 0
39
+ else:
40
+ # features, timestamps = self.sliding_window_features(acc_mag)
41
+ movement_flags = (features[:, 0] > mean_thresh) & (features[:, 1] > std_thresh)
42
+ index = None
43
+ for i in range(len(movement_flags) - int(min_duration * self.fs / 50)):
44
+ if np.all(movement_flags[i:i + int(min_duration * self.fs / 50)]):
45
+ index = i
46
+ break
47
+
48
+ if etype == 'movement_offset':
49
+ index = len(yd) - end_time
50
+
51
+ return timestamps[index] if index is not None else timestamps[0]
@@ -2,7 +2,7 @@ import os
2
2
  import inspect
3
3
  import time
4
4
 
5
- from biomechzoo.imu.tilt_algoirthm import tilt_algorithm_data
5
+ from biomechzoo.imu.tilt_algorithm import tilt_algorithm_data
6
6
  from biomechzoo.utils.engine import engine # assumes this returns .zoo files in folder
7
7
  from biomechzoo.utils.zload import zload
8
8
  from biomechzoo.utils.zsave import zsave
@@ -136,6 +136,8 @@ class BiomechZoo:
136
136
  def parquet2zoo(self, out_folder=None, inplace=None):
137
137
  raise NotImplementedError('Use table2zoo instead')
138
138
 
139
+ def rectify(self):
140
+ raise NotImplementedError
139
141
  def tilt_algorithm(self, chname_avert, chname_medlat, chname_antpost, out_folder=None, inplace=False):
140
142
  """ tilt correction for acceleration data """
141
143
  start_time = time.time()
@@ -1,6 +1,7 @@
1
1
  import numpy as np
2
2
  import copy
3
3
  import warnings
4
+ from scipy.signal import find_peaks
4
5
  from biomechzoo.utils.peak_sign import peak_sign
5
6
  from biomechzoo.biomech_ops.movement_onset import movement_onset
6
7
 
@@ -42,16 +43,16 @@ def addevent_data(data, channels, ename, etype, constant=None):
42
43
  elif etype == 'rom':
43
44
  eyd = float(np.max(yd) - np.min(yd))
44
45
  exd = 0 # dummy index (like MATLAB version)
45
- elif etype == 'max_stance':
46
+ elif etype == 'first peak':
46
47
  # special event for gait and running
47
- exd = max_stance(yd)
48
- eyd = float(yd[exd])
48
+ exd = find_first_peak(yd, constant)
49
49
  eyd = float(yd[exd])
50
50
  elif etype == 'movement_onset':
51
- exd = movement_onset(yd, constant)
51
+ exd = movement_onset(yd, constant, etype=etype)
52
52
  eyd = yd[exd]
53
53
  elif etype == 'movement_offset':
54
- exd = movement_onset(yd,constant)
54
+ yd2 = yd[::-1].copy() # Reverse the time series.
55
+ exd = movement_onset(yd2, constant, etype=etype)
55
56
  eyd = yd[exd]
56
57
  elif etype in ['fs_fp', 'fo_fp']:
57
58
  # --- Handle constant ---
@@ -99,7 +100,17 @@ def addevent_data(data, channels, ename, etype, constant=None):
99
100
 
100
101
  return data_new
101
102
 
102
- def max_stance(yd):
103
- """ extracts max from first 40% of the gait cycle"""
104
- raise NotImplementedError
103
+ def find_first_peak(yd, constant):
104
+ """ extracts first peak from a series of 2 peaks """
105
+ # Find peaks above threshold
106
+ peaks, _ = find_peaks(yd, height=constant)
107
+
108
+ if len(peaks) == 0:
109
+ raise ValueError('No peaks found')
110
+ elif len(peaks) == 1:
111
+ raise ValueError('Only 1 peak found')
112
+ else:
113
+ # Take the first valid peak
114
+ exd = peaks[0]
115
+
105
116
  return exd
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: biomechzoo
3
- Version: 0.5.1
3
+ Version: 0.5.2
4
4
  Summary: Python implementation of the biomechZoo toolbox
5
5
  License-Expression: MIT
6
6
  Project-URL: Homepage, https://github.com/mcgillmotionlab/biomechzoo
@@ -26,7 +26,7 @@ src/biomechzoo/conversion/c3d2zoo_data.py
26
26
  src/biomechzoo/conversion/mvnx2zoo_data.py
27
27
  src/biomechzoo/conversion/opencap2zoo_data.py
28
28
  src/biomechzoo/conversion/table2zoo_data.py
29
- src/biomechzoo/imu/tilt_algoirthm.py
29
+ src/biomechzoo/imu/tilt_algorithm.py
30
30
  src/biomechzoo/mvn/__init__.py
31
31
  src/biomechzoo/mvn/load_mvnx.py
32
32
  src/biomechzoo/mvn/main_mvnx.py
@@ -1,2 +0,0 @@
1
- def movement_onset():
2
- raise NotImplementedError
File without changes
File without changes
File without changes
File without changes