biomechzoo 0.3.0__tar.gz → 0.4.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.

Files changed (54) hide show
  1. {biomechzoo-0.3.0/src/biomechzoo.egg-info → biomechzoo-0.4.1}/PKG-INFO +1 -1
  2. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/pyproject.toml +1 -1
  3. biomechzoo-0.4.1/src/biomechzoo/conversion/mvnx2zoo_data.py +113 -0
  4. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/mvn/mvnx_file_accessor.py +2 -1
  5. {biomechzoo-0.3.0 → biomechzoo-0.4.1/src/biomechzoo.egg-info}/PKG-INFO +1 -1
  6. biomechzoo-0.3.0/src/biomechzoo/conversion/mvnx2zoo_data.py +0 -71
  7. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/LICENSE +0 -0
  8. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/README.md +0 -0
  9. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/setup.cfg +0 -0
  10. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/__init__.py +0 -0
  11. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/__main__.py +0 -0
  12. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/biomech_ops/__init__.py +0 -0
  13. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/biomech_ops/continuous_relative_phase_data.py +0 -0
  14. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/biomech_ops/continuous_relative_phase_line.py +0 -0
  15. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/biomech_ops/filter_data.py +0 -0
  16. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/biomech_ops/filter_line.py +0 -0
  17. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/biomech_ops/normalize_data.py +0 -0
  18. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/biomech_ops/normalize_line.py +0 -0
  19. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/biomech_ops/phase_angle_data.py +0 -0
  20. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/biomech_ops/phase_angle_line.py +0 -0
  21. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/biomechzoo.py +0 -0
  22. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/conversion/__init__.py +0 -0
  23. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/conversion/c3d2zoo_data.py +0 -0
  24. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/conversion/csv2zoo_data.py +0 -0
  25. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/conversion/opencap2zoo_data.py +0 -0
  26. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/mvn/__init__.py +0 -0
  27. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/mvn/load_mvnx.py +0 -0
  28. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/mvn/main_mvnx.py +0 -0
  29. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/mvn/mvn.py +0 -0
  30. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/processing/__init__.py +0 -0
  31. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/processing/add_channel_data.py +0 -0
  32. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/processing/addchannel_data.py +0 -0
  33. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/processing/addevent_data.py +0 -0
  34. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/processing/explodechannel_data.py +0 -0
  35. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/processing/partition_data.py +0 -0
  36. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/processing/removechannel_data.py +0 -0
  37. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/processing/renamechannel_data.py +0 -0
  38. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/processing/renameevent_data.py +0 -0
  39. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/processing/split_trial_by_gait_cycle.py +0 -0
  40. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/utils/__init__.py +0 -0
  41. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/utils/batchdisp.py +0 -0
  42. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/utils/compute_sampling_rate_from_time.py +0 -0
  43. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/utils/engine.py +0 -0
  44. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/utils/findfield.py +0 -0
  45. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/utils/get_split_events.py +0 -0
  46. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/utils/split_trial.py +0 -0
  47. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/utils/zload.py +0 -0
  48. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/utils/zplot.py +0 -0
  49. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo/utils/zsave.py +0 -0
  50. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo.egg-info/SOURCES.txt +0 -0
  51. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo.egg-info/dependency_links.txt +0 -0
  52. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo.egg-info/entry_points.txt +0 -0
  53. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/src/biomechzoo.egg-info/requires.txt +0 -0
  54. {biomechzoo-0.3.0 → biomechzoo-0.4.1}/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.3.0
3
+ Version: 0.4.1
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.3.0"
3
+ version = "0.4.1"
4
4
  description = "Python implementation of the biomechZoo toolbox"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -0,0 +1,113 @@
1
+ import numpy as np
2
+ from biomechzoo.mvn.load_mvnx import load_mvnx
3
+ from biomechzoo.mvn.mvn import JOINTS, SEGMENTS
4
+
5
+ def mvnx2zoo_data(fl):
6
+ """ loads mvnx file from xsens"""
7
+
8
+ mvnx_file = load_mvnx(fl)
9
+
10
+ # create zoo data dict
11
+ data = {}
12
+
13
+ # extract joint angle data (All JOINTS may not exist in a given dataset)
14
+ for key, val in JOINTS.items():
15
+ try:
16
+ r = mvnx_file.get_joint_angle(joint=key)
17
+ data[val] = {
18
+ 'line': np.array(r),
19
+ 'event': {}
20
+ }
21
+ except KeyError:
22
+ print('joint {} does not exist, skipping'.format(val))
23
+
24
+ # extract segment orientations (All SEGMENTS may not exist in a given dataset)
25
+ for key, val in SEGMENTS.items():
26
+ try:
27
+ r = mvnx_file.get_sensor_ori(segment=key)
28
+
29
+ data[val] = {
30
+ 'line': np.array(r),
31
+ 'event': {}
32
+ }
33
+ except KeyError:
34
+ print('segment {} does not exist, skipping'.format(val))
35
+
36
+ # get foot strike events
37
+ data = _get_foot_strike_events(mvnx_file, data)
38
+
39
+ # add meta information
40
+ data = _get_meta_info(mvnx_file, data)
41
+
42
+ return data
43
+
44
+ def is_valid_for_zoo(val):
45
+ """
46
+ Returns True if the value is valid for a MATLAB-compatible zoo structure.
47
+ """
48
+ if val is None:
49
+ return False
50
+ if isinstance(val, list) and len(val) == 0:
51
+ return False
52
+ if isinstance(val, np.ndarray) and val.size == 0:
53
+ return False
54
+ return True
55
+
56
+ def _get_meta_info(mvnx_file, data):
57
+ # todo: add more, see mvnx_file object
58
+ data['zoosystem'] = {}
59
+ data['zoosystem']['Video'] = {}
60
+ data['zoosystem']['Video']['Freq'] = int(mvnx_file.frame_rate)
61
+ data['zoosystem']['Version'] = mvnx_file.version
62
+ data['zoosystem']['configuration'] = mvnx_file.configuration
63
+ data['zoosystem']['recording_date'] = mvnx_file.recording_date
64
+ data['zoosystem']['original_file_name'] = mvnx_file.original_file_name
65
+ data['zoosystem']['frame_count'] = mvnx_file.frame_count
66
+ return data
67
+
68
+
69
+ def _get_foot_strike_events(mvnx_file, data):
70
+ RHeel = np.zeros(mvnx_file.frame_count)
71
+ LHeel = np.zeros(mvnx_file.frame_count)
72
+
73
+ for n in range(mvnx_file.frame_count):
74
+ list_contact = mvnx_file.get_foot_contacts(n)
75
+ for contact in list_contact:
76
+ if contact['segment_index'] == 17:
77
+ RHeel[n] = True
78
+ elif contact['segment_index'] == 21:
79
+ LHeel[n] = True
80
+
81
+ hs_r = []
82
+ hs_l = []
83
+ for i in range(1, len(LHeel)): # Start from 1 to avoid i-1 out-of-range
84
+ if RHeel[i - 1] == 0 and RHeel[i] == 1:
85
+ hs_r.append(i)
86
+ if LHeel[i - 1] == 0 and LHeel[i] == 1:
87
+ hs_l.append(i)
88
+
89
+ # add to event branch of any channel
90
+ if 'jL5S1' in data:
91
+ ch = 'jL5S1'
92
+ else:
93
+ ch = next(iter(data))
94
+
95
+ if hs_r:
96
+ for i, rHS in enumerate(hs_r):
97
+ data[ch]['event']['R_FS' + str(i + 1)] = [rHS, 0, 0]
98
+ if hs_l:
99
+ for i, lHS in enumerate(hs_l):
100
+ data[ch]['event']['L_FS' + str(i + 1)] = [lHS, 0, 0]
101
+
102
+ return data
103
+
104
+
105
+ if __name__ == '__main__':
106
+ """ testing """
107
+ import os
108
+ from src.biomechzoo.utils.zplot import zplot
109
+ # -------TESTING--------
110
+ project_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
111
+ fl = os.path.join(project_root, 'data', 'other', 'Flat001.mvnx')
112
+ data = mvnx2zoo_data(fl)
113
+ zplot(data, 'jRightKnee')
@@ -405,9 +405,10 @@ class MvnxFileAccessor:
405
405
  :return: The contacts
406
406
  """
407
407
  frame, is_single_frame = self.frame_to_mapped_slice(frame)
408
- return_values = self.file_data['frames']['footContacts'][frame]
408
+ return_values = self.file_data['frames']['contacts_data'][frame] #edited Phil Dixon
409
409
  return return_values[0] if is_single_frame else return_values
410
410
 
411
+
411
412
  def has_foot_contact(self, frame, foot_contact_flags=0):
412
413
  """
413
414
  Find out if the frame has a contact, optionally for a specific segment/point combo
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: biomechzoo
3
- Version: 0.3.0
3
+ Version: 0.4.1
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,71 +0,0 @@
1
- import numpy as np
2
- from biomechzoo.mvn.load_mvnx import load_mvnx
3
-
4
-
5
- def mvnx2zoo_data(fl):
6
- """ loads mvnx file from xsens"""
7
- #todo: needs to be updated for the new version of mvnx direcly loaded in biomechzoo
8
- mvnx_file = load_mvnx(fl)
9
-
10
- # create zoo data dict
11
- data = {}
12
-
13
- # Accessing joint data :
14
- joint_angle_data = mvnx_file.get_joint_angle()
15
- joint_names = mvnx_file.joints
16
- for i, joint in enumerate(joint_names):
17
- start = i * 3
18
- stop = start + 3
19
- angles = joint_angle_data[:, start:stop] # shape: (n_frames, 3)
20
-
21
- data[joint] = {
22
- 'line': angles,
23
- 'event': {}
24
- }
25
- # get foot strike events
26
- # Index 0: Left Heel contact (1 for contact, 0 for no contact)
27
- # Index 1: Left Toe contact (1 for contact, 0 for no contact)
28
- # Index 2: Right Heel contact (1 for contact, 0 for no contact)
29
- # Index 3: Right Toe contact (1 for contact, 0 for no contact)
30
- left_heel_contacts = np.array(mvnx_file.footContacts[:, 0])
31
- right_heel_contacts = np.array(mvnx_file.footContacts[:, 2])
32
-
33
- # Detect transitions from no contact (0) to contact (1)
34
- left_contact_start = (left_heel_contacts[:-1] == 0) & (left_heel_contacts[1:] == 1)
35
- right_contact_start = (right_heel_contacts[:-1] == 0) & (right_heel_contacts[1:] == 1)
36
-
37
- # Get indices where these transitions occur (add 1 because we're checking between frames)
38
- left_contact_frames = np.where(left_contact_start)[0] + 1
39
- right_contact_frames = np.where(right_contact_start)[0] + 1
40
-
41
- # add to zoo
42
- data['jL5S1']['event'] = {}
43
- for i, right_contact_frame in enumerate(right_contact_frames):
44
- data['jL5S1']['event']['R_FS'+str(i+1)] = [right_contact_frame, 0, 0]
45
- for i, left_contact_frame in enumerate(left_contact_frames):
46
- data['jL5S1']['event']['L_FS' + str(i + 1)] = [left_contact_frame, 0, 0]
47
-
48
- # add meta information
49
- # todo: add more, see mvnx_file object
50
- data['zoosystem'] = {}
51
- data['zoosystem']['Video'] = {}
52
- data['zoosystem']['Video']['Freq'] = int(mvnx_file.frame_rate)
53
- data['zoosystem']['Version'] = mvnx_file.version
54
- data['zoosystem']['configuration'] = mvnx_file.configuration
55
- data['zoosystem']['recording_date'] = mvnx_file.recording_date
56
- data['zoosystem']['original_file_name'] = mvnx_file.original_file_name
57
- data['zoosystem']['frame_count'] = mvnx_file.frame_count
58
- data['zoosystem']['comments'] = mvnx_file.comments
59
-
60
- return data
61
-
62
-
63
- if __name__ == '__main__':
64
- """ testing """
65
- import os
66
- from src.biomechzoo.utils.zplot import zplot
67
- # -------TESTING--------
68
- project_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
69
- fl = os.path.join(project_root, 'data', 'other', 'Flat-001.mvnx')
70
- data = mvnx2zoo_data(fl)
71
- zplot(data, 'jRightKnee')
File without changes
File without changes
File without changes