biomechzoo 0.3.0__tar.gz → 0.4.0__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.0}/PKG-INFO +1 -1
  2. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/pyproject.toml +1 -1
  3. biomechzoo-0.4.0/src/biomechzoo/conversion/mvnx2zoo_data.py +102 -0
  4. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/mvn/load_mvnx.py +2 -2
  5. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/mvn/main_mvnx.py +1 -1
  6. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/mvn/mvnx_file_accessor.py +3 -2
  7. {biomechzoo-0.3.0 → biomechzoo-0.4.0/src/biomechzoo.egg-info}/PKG-INFO +1 -1
  8. biomechzoo-0.3.0/src/biomechzoo/conversion/mvnx2zoo_data.py +0 -71
  9. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/LICENSE +0 -0
  10. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/README.md +0 -0
  11. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/setup.cfg +0 -0
  12. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/__init__.py +0 -0
  13. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/__main__.py +0 -0
  14. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/biomech_ops/__init__.py +0 -0
  15. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/biomech_ops/continuous_relative_phase_data.py +0 -0
  16. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/biomech_ops/continuous_relative_phase_line.py +0 -0
  17. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/biomech_ops/filter_data.py +0 -0
  18. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/biomech_ops/filter_line.py +0 -0
  19. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/biomech_ops/normalize_data.py +0 -0
  20. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/biomech_ops/normalize_line.py +0 -0
  21. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/biomech_ops/phase_angle_data.py +0 -0
  22. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/biomech_ops/phase_angle_line.py +0 -0
  23. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/biomechzoo.py +0 -0
  24. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/conversion/__init__.py +0 -0
  25. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/conversion/c3d2zoo_data.py +0 -0
  26. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/conversion/csv2zoo_data.py +0 -0
  27. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/conversion/opencap2zoo_data.py +0 -0
  28. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/mvn/__init__.py +0 -0
  29. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/mvn/mvn.py +0 -0
  30. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/processing/__init__.py +0 -0
  31. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/processing/add_channel_data.py +0 -0
  32. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/processing/addchannel_data.py +0 -0
  33. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/processing/addevent_data.py +0 -0
  34. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/processing/explodechannel_data.py +0 -0
  35. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/processing/partition_data.py +0 -0
  36. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/processing/removechannel_data.py +0 -0
  37. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/processing/renamechannel_data.py +0 -0
  38. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/processing/renameevent_data.py +0 -0
  39. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/processing/split_trial_by_gait_cycle.py +0 -0
  40. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/utils/__init__.py +0 -0
  41. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/utils/batchdisp.py +0 -0
  42. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/utils/compute_sampling_rate_from_time.py +0 -0
  43. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/utils/engine.py +0 -0
  44. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/utils/findfield.py +0 -0
  45. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/utils/get_split_events.py +0 -0
  46. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/utils/split_trial.py +0 -0
  47. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/utils/zload.py +0 -0
  48. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/utils/zplot.py +0 -0
  49. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo/utils/zsave.py +0 -0
  50. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo.egg-info/SOURCES.txt +0 -0
  51. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo.egg-info/dependency_links.txt +0 -0
  52. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo.egg-info/entry_points.txt +0 -0
  53. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/src/biomechzoo.egg-info/requires.txt +0 -0
  54. {biomechzoo-0.3.0 → biomechzoo-0.4.0}/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.0
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.0"
4
4
  description = "Python implementation of the biomechZoo toolbox"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -0,0 +1,102 @@
1
+ import numpy as np
2
+ from src.biomechzoo.mvn.load_mvnx import load_mvnx
3
+ from src.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': 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
+ data[val] = {
29
+ 'line': r,
30
+ 'event': {}
31
+ }
32
+ except KeyError:
33
+ print('segment {} does not exist, skipping'.format(val))
34
+
35
+ # get foot strike events
36
+ data = _get_foot_strike_events(mvnx_file, data)
37
+
38
+ # add meta information
39
+ data = _get_meta_info(mvnx_file, data)
40
+
41
+ return data
42
+
43
+
44
+ def _get_meta_info(mvnx_file, data):
45
+ # todo: add more, see mvnx_file object
46
+ data['zoosystem'] = {}
47
+ data['zoosystem']['Video'] = {}
48
+ data['zoosystem']['Video']['Freq'] = int(mvnx_file.frame_rate)
49
+ data['zoosystem']['Version'] = mvnx_file.version
50
+ data['zoosystem']['configuration'] = mvnx_file.configuration
51
+ data['zoosystem']['recording_date'] = mvnx_file.recording_date
52
+ data['zoosystem']['original_file_name'] = mvnx_file.original_file_name
53
+ data['zoosystem']['frame_count'] = mvnx_file.frame_count
54
+ data['zoosystem']['comments'] = mvnx_file.comments
55
+ return data
56
+
57
+
58
+ def _get_foot_strike_events(mvnx_file, data):
59
+ RHeel = np.zeros(mvnx_file.frame_count)
60
+ LHeel = np.zeros(mvnx_file.frame_count)
61
+
62
+ for n in range(mvnx_file.frame_count):
63
+ list_contact = mvnx_file.get_foot_contacts(n)
64
+ for contact in list_contact:
65
+ if contact['segment_index'] == 17:
66
+ RHeel[n] = True
67
+ elif contact['segment_index'] == 21:
68
+ LHeel[n] = True
69
+
70
+ hs_r = []
71
+ hs_l = []
72
+ for i in range(1, len(LHeel)): # Start from 1 to avoid i-1 out-of-range
73
+ if RHeel[i - 1] == 0 and RHeel[i] == 1:
74
+ hs_r.append(i)
75
+ if LHeel[i - 1] == 0 and LHeel[i] == 1:
76
+ hs_l.append(i)
77
+
78
+ # add to event branch of any channel
79
+ if 'jL5S1' in data:
80
+ ch = 'jL5S1'
81
+ else:
82
+ ch = next(iter(data))
83
+
84
+ if hs_r:
85
+ for i, rHS in enumerate(hs_r):
86
+ data[ch]['event']['R_FS' + str(i + 1)] = [rHS, 0, 0]
87
+ if hs_l:
88
+ for i, lHS in enumerate(hs_l):
89
+ data[ch]['event']['L_FS' + str(i + 1)] = [lHS, 0, 0]
90
+
91
+ return data
92
+
93
+
94
+ if __name__ == '__main__':
95
+ """ testing """
96
+ import os
97
+ from src.biomechzoo.utils.zplot import zplot
98
+ # -------TESTING--------
99
+ project_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
100
+ fl = os.path.join(project_root, 'data', 'other', 'Flat-001.mvnx')
101
+ data = mvnx2zoo_data(fl)
102
+ zplot(data, 'jRightKnee')
@@ -6,8 +6,8 @@ Script to load an mvnx
6
6
  import xml.etree.ElementTree as ET
7
7
  import collections
8
8
  import numpy as np
9
- from biomechzoo.mvn.mvnx_file_accessor import MvnxFileAccessor
10
- from biomechzoo.mvn import mvn
9
+ from src.biomechzoo.mvn.mvnx_file_accessor import MvnxFileAccessor
10
+ from src.biomechzoo.mvn import mvn
11
11
 
12
12
  # Xml namespace for mvnx files
13
13
  ns = {'mvn': 'http://www.xsens.com/mvn/mvnx'}
@@ -1,7 +1,7 @@
1
1
  import os
2
2
  import argparse
3
3
  import matplotlib.pyplot as plt
4
- from biomechzoo.mvn.load_mvnx import load_mvnx
4
+ from src.biomechzoo.mvn.load_mvnx import load_mvnx
5
5
 
6
6
 
7
7
  # Convert mvnx file to python data
@@ -1,4 +1,4 @@
1
- from biomechzoo.mvn import mvn
1
+ from src.biomechzoo.mvn import mvn
2
2
  import warnings
3
3
 
4
4
 
@@ -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.0
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