Skip to content

Commit

Permalink
stable version
Browse files Browse the repository at this point in the history
  • Loading branch information
tuliofalmeida committed Jul 1, 2021
1 parent 1c22563 commit dc0a4f2
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 23 deletions.
13 changes: 7 additions & 6 deletions build/lib/pyjamalib/DataHandler.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pyjamalib
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
Expand Down Expand Up @@ -483,14 +484,14 @@ def toDataframe(data,data_calib,low_pass=.1,freq=75):
https://github.com/tuliofalmeida/pyjama
https://github.com/tuliofalmeida/jama
"""
time,acc,gyr,mag= pjl.DataHandler.get_imu_data(data)
time_calib,acc_calib,gyr_calib,mag_calib = pjl.DataHandler.get_imu_data(data_calib)
time,acc,gyr,mag= DataHandler.get_imu_data(data)
time_calib,acc_calib,gyr_calib,mag_calib = DataHandler.get_imu_data(data_calib)
time = np.arange(0, len(time)/freq, 1/freq)

acc, gyr, mag = pjl.DataHandler.calibration_imu(acc,gyr,mag,mag_calib)
accf = pjl.DataProcessing.low_pass_filter(acc,low_pass)
gyrf = pjl.DataProcessing.low_pass_filter(gyr,low_pass)
magf = pjl.DataProcessing.low_pass_filter(mag,low_pass)
acc, gyr, mag = DataHandler.calibration_imu(acc,gyr,mag,mag_calib)
accf = pyjamalib.DataProcessing.low_pass_filter(acc,low_pass)
gyrf = pyjamalib.DataProcessing.low_pass_filter(gyr,low_pass)
magf = pyjamalib.DataProcessing.low_pass_filter(mag,low_pass)

df = pd.DataFrame({'Time':time[:] ,
'Acc_X':acc[:,0] ,'Acc_Y': acc[:,1] ,'Acc_Z': acc[:,2] ,
Expand Down
6 changes: 3 additions & 3 deletions pyjamalib.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Metadata-Version: 2.1
Name: pyjamalib
Version: 0.7.5
Version: 1.0.0
Summary: A library for analyze joint angles from IMU data
Home-page: https://github.com/tuliofalmeida/pyjama
Author: Túlio 1F. Almeida
Author: Túlio F. Almeida
Author-email: tuliofalmeida@hotmail.com
License: MIT
Description:
Expand Down Expand Up @@ -70,7 +70,7 @@ Description:
-----------

- Example of using the library using data extracted using JAMA. [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/tuliofalmeida/pyjama/blob/main/PyJama_JAMA_exemple.ipynb)
- Example of using the library using data extracted using Vicon and Xsens. [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/tuliofalmeida/pyjama/blob/main/Pyjama_Validation.ipynb)
- Example of using the library using data extracted using Vicon and Xsens. [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/tuliofalmeida/pyjama/blob/main/Pyjama_total_capture.ipynb)

# Contributing
--------------
Expand Down
13 changes: 7 additions & 6 deletions pyjamalib/DataHandler.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pyjamalib
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
Expand Down Expand Up @@ -483,14 +484,14 @@ def toDataframe(data,data_calib,low_pass=.1,freq=75):
https://github.com/tuliofalmeida/pyjama
https://github.com/tuliofalmeida/jama
"""
time,acc,gyr,mag= pjl.DataHandler.get_imu_data(data)
time_calib,acc_calib,gyr_calib,mag_calib = pjl.DataHandler.get_imu_data(data_calib)
time,acc,gyr,mag= DataHandler.get_imu_data(data)
time_calib,acc_calib,gyr_calib,mag_calib = DataHandler.get_imu_data(data_calib)
time = np.arange(0, len(time)/freq, 1/freq)

acc, gyr, mag = pjl.DataHandler.calibration_imu(acc,gyr,mag,mag_calib)
accf = pjl.DataProcessing.low_pass_filter(acc,low_pass)
gyrf = pjl.DataProcessing.low_pass_filter(gyr,low_pass)
magf = pjl.DataProcessing.low_pass_filter(mag,low_pass)
acc, gyr, mag = DataHandler.calibration_imu(acc,gyr,mag,mag_calib)
accf = pyjamalib.DataProcessing.low_pass_filter(acc,low_pass)
gyrf = pyjamalib.DataProcessing.low_pass_filter(gyr,low_pass)
magf = pyjamalib.DataProcessing.low_pass_filter(mag,low_pass)

df = pd.DataFrame({'Time':time[:] ,
'Acc_X':acc[:,0] ,'Acc_Y': acc[:,1] ,'Acc_Z': acc[:,2] ,
Expand Down
22 changes: 16 additions & 6 deletions pyjamalib/DataProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2473,8 +2473,8 @@ def varianceEstimation(data):
return mean,std

def pattern_extraction(jointAngle,time,threshold,cycle=2,df=True,plot=False,bias=0,
save=False, save_name='Data',fsize=30, title='Pattern Extraction',
yaxis='Angle (°)',xaxis='Cycle (%)'):
flip = False ,save=False, save_name='Data',fsize=30,
title='Pattern Extraction', yaxis='Angle (°)',xaxis='Cycle (%)'):
""" Find and extract patterns from the data.
Able to plot all overlapping pattern data
for easy understanding. This function was
Expand Down Expand Up @@ -2506,6 +2506,8 @@ def pattern_extraction(jointAngle,time,threshold,cycle=2,df=True,plot=False,bias
Determines if the function will return the plot.
bias: int optional
Value to compensate the cycle adjust.
flip: bool
Variable to compensate the cycle representation.
save: bool
If true save a fig as pdf
save_name: str
Expand Down Expand Up @@ -2539,7 +2541,7 @@ def pattern_extraction(jointAngle,time,threshold,cycle=2,df=True,plot=False,bias
if plot == True:
plt.figure(figsize=(12,9))

diff = DataProcessing.low_pass_filter((jointAngle[1:] - jointAngle[:-1]))
diff = pyjamalib.DataProcessing.low_pass_filter((jointAngle[1:] - jointAngle[:-1]))
zero_crossings = np.where(np.diff(np.signbit(jointAngle-threshold)))[0]
Time_Data_Array = []
mCicloqtd = cycle
Expand All @@ -2555,17 +2557,21 @@ def pattern_extraction(jointAngle,time,threshold,cycle=2,df=True,plot=False,bias
Time_Data_Array.append((tempo[ç],data[ç]));

if plot == True:
plt.plot(tempo, DataProcessing.low_pass_filter(jointAngle[zero_crossings[0+ciclo]:zero_crossings[mCicloqtd+ciclo]]));

if flip == True:
plt.plot(tempo,pyjamalib.DataProcessing.low_pass_filter(np.flip(data)))
else:
plt.plot(tempo,pyjamalib.DataProcessing.low_pass_filter(data))
if plot == True:
plt.title(title,fontsize = fsize);
plt.ylabel(yaxis,fontsize = fsize);
plt.xlabel(xaxis,fontsize = fsize);
plt.yticks(fontsize = fsize)
plt.xticks(fontsize = fsize)
plt.grid();
if save == True:
plt.savefig(save_name + '.pdf')
plt.show();

return np.asarray(Time_Data_Array),np.asarray(rom)

def patternCI(all_x, all_y,poly_degree = 1,CI = 1.96,df = True,plot=False,
Expand Down Expand Up @@ -2664,6 +2670,8 @@ def patternCI(all_x, all_y,poly_degree = 1,CI = 1.96,df = True,plot=False,
plt.title(title).set_size(fsize);
plt.xlabel(x_label).set_size(fsize);
plt.ylabel(y_label).set_size(fsize);
plt.yticks(fontsize = fsize)
plt.xticks(fontsize = fsize)
plt.legend([label1, label2, label3], loc='upper right',fontsize = lsize)
plt.grid();
if save == True:
Expand Down Expand Up @@ -2741,6 +2749,8 @@ def data_comparison(Time_Data_Array,statistics_1,statistics_2, plot=True,
plt.title(title,fontsize = fsize);
plt.ylabel(yaxis,fontsize = fsize);
plt.xlabel(xaxis,fontsize = fsize);
plt.yticks(fontsize = fsize);
plt.xticks(fontsize = fsize);
plt.grid();
if save:
plt.savefig(save_name + '.pdf')
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

name="pyjamalib",
packages = ['pyjamalib'],
version="0.7.5",
author="Túlio 1F. Almeida",
version="1.0.0",
author="Túlio F. Almeida",
author_email="tuliofalmeida@hotmail.com",
description="A library for analyze joint angles from IMU data",
long_description=long_description,
Expand Down

0 comments on commit dc0a4f2

Please sign in to comment.