Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates code to work with latest dependencies. #140

Merged
merged 28 commits into from
Aug 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
19906db
Use Octave interp1 instead of deprecated interp1q.
moorepants Aug 30, 2018
4081d91
oct2py >= 4.0 requires an nout kwarg for multiple outputs.
moorepants Aug 30, 2018
bdebece
Accomodate Octave 3 and 4.
moorepants Aug 30, 2018
aafd3b0
Round the indice count so that the numpy array is not indexed by a fl…
moorepants Aug 30, 2018
6d2182b
Arrays seemingly copied, moved to simpler verbose code to avoid copies.
moorepants Aug 30, 2018
04c0802
Setup Travis CI to use Conda and old/new testing.
moorepants Aug 30, 2018
68ea688
Corrected travis build matrix.
moorepants Aug 30, 2018
d21aad3
Bumped up oldest supported versions.
moorepants Aug 30, 2018
bf00fb2
Backup dtk to 0.3.5.
moorepants Aug 30, 2018
099cd61
Added mock to the env.ymls.
moorepants Aug 30, 2018
d84c61b
Added numpydoc.
moorepants Aug 30, 2018
a2b5481
Raise oct2py min version to 3.5.
moorepants Aug 30, 2018
3408d2d
Added conda moorepant channel.
moorepants Aug 30, 2018
0ce0edb
Try pip installing oct2py and dtk.
moorepants Aug 30, 2018
ce29cd6
Fixed yml error.
moorepants Aug 30, 2018
613219d
Use correct pip version sign.
moorepants Aug 30, 2018
f9beb7d
Trying apt install python libs for oldest.
moorepants Aug 30, 2018
a73e3ec
Use tornado compatible with python < 2.7.9.
moorepants Aug 30, 2018
550535d
Added missing quotes.
moorepants Aug 30, 2018
767a5e9
Use apt for pandas and sphinx.
moorepants Aug 30, 2018
5f238aa
Install more packages with apt.
moorepants Aug 30, 2018
d40e078
Add no-deps to pip install.
moorepants Aug 30, 2018
fb5b2ed
Add sudo to pip.
moorepants Aug 30, 2018
492bfef
Use sudo in install for oldest.
moorepants Aug 30, 2018
fe2593a
Try to avoid tornado install again.
moorepants Aug 30, 2018
87a98b9
Bumped DTK to 0.4.0.
moorepants Aug 30, 2018
7b44af2
Fixed octave interp1q typo.
moorepants Aug 30, 2018
47df4ff
Get index values for type conversion.
moorepants Aug 30, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 40 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,43 @@
language: python
python:
- "2.7"
virtualenv:
system_site_packages: true
language: generic
os:
- linux
env:
matrix:
- DEP_VERSIONS="oldest"
- DEP_VERSIONS="latest"
before_install:
- pip uninstall -y numpy
- sudo apt-add-repository -y ppa:octave/stable
- if [[ $DEP_VERSIONS == "oldest" ]]; then
sudo apt-get install -y -qq python-pip python-setuptools python-numpy python-scipy python-matplotlib python-tables python-nose python-coverage python-pandas python-sphinx python-mock python-numpydoc python-yaml;
sudo pip install --no-deps oct2py==2.4.2 DynamicistToolKit==0.4.0;
elif [[ $DEP_VERSIONS == "latest" ]]; then
MINICONDA_URL="https://repo.continuum.io/miniconda";
MINICONDA_FILE="Miniconda3-latest-Linux-x86_64.sh";
curl -L -O "${MINICONDA_URL}/${MINICONDA_FILE}";
bash $MINICONDA_FILE -b;
source ~/miniconda3/bin/activate root;
conda config --set always_yes yes;
conda update -q conda;
conda env create -f env-dev-latest.yml;
source activate gaitanalysis-dev-latest;
sudo apt-add-repository -y ppa:octave/stable;
fi
- sudo apt-get update
- sudo apt-get install -y -qq python-setuptools python-numpy python-scipy python-matplotlib python-tables python-nose python-coverage octave
- pip install pandas==0.12.0 pyyaml oct2py==1.2.0 DynamicistToolKit==0.4.0
- pip freeze
- octave --version
- sudo apt-get install -y -qq octave
install:
- python setup.py install
script: nosetests -v --with-coverage --cover-package=gaitanalysis
after_success: coveralls
- if [[ $DEP_VERSIONS == "oldest" ]]; then
sudo pip install --no-deps -e .;
elif [[ $DEP_VERSIONS == "latest" ]]; then
python setup.py install;
fi
before_script:
- octave --version
- if [[ $DEP_VERSIONS == "oldest" ]]; then
pip freeze;
elif [[ $DEP_VERSIONS == "latest" ]]; then
conda info;
conda list;
fi
script:
- nosetests -v --with-coverage --cover-package=gaitanalysis
- cd docs
- make html
2 changes: 1 addition & 1 deletion RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
2. Bump the version in gaitanalysis/version.py, for example 0.1.0dev to 0.1.0.
3. Commit changes.
4. git tag -a vX.X.X -m "Version X.X.X"
5. python setup.py regsiter sdist upload
5. python setup.py register sdist upload
6. Make sure the latest version is available on readthedocs.org
7. Bump the version in the git repo to one with "dev" appended.
18 changes: 18 additions & 0 deletions env-dev-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: gaitanalysis-dev-latest
channels:
- conda-forge
dependencies:
- python =2.7.*
- numpy
- scipy
- matplotlib
- pytables
- pandas
- pyyaml
- dynamicisttoolkit
- oct2py
- nose
- sphinx
- coverage
- mock
- numpydoc
20 changes: 20 additions & 0 deletions env-dev-oldest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: gaitanalysis-dev-oldest
channels:
- defaults
- moorepants
dependencies:
- python =2.7.*
- numpy =1.9.1
- scipy =0.14.0
- matplotlib =1.4.2
- pytables =3.1.1
- pandas =0.15.1
- pyyaml =3.11
- nose
- sphinx
- coverage
- mock
- numpydoc
- pip:
- dynamicisttoolkit==0.3.5
- oct2py==2.4.2
15 changes: 11 additions & 4 deletions gaitanalysis/gait.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import os

# external libraries
from pkg_resources import parse_version
import numpy as np
from scipy.integrate import simps
import matplotlib.pyplot as plt
import pandas
from dtk import process
import oct2py
from oct2py import octave

# local
Expand Down Expand Up @@ -65,7 +67,7 @@ def find_constant_speed(time, speed, plot=False, filter_cutoff=1.0):

additional_samples = sample_rate * 0.65

new_indice = indice - additional_samples
new_indice = indice - int(round(additional_samples))

if plot is True:
fig, ax = plt.subplots(2, 1)
Expand Down Expand Up @@ -237,9 +239,14 @@ def inverse_dynamics_2d(self, left_leg_markers, right_leg_markers,
# oct2py doesn't allow multiple outputs to be stored in a tuple
# like python, so you have to output each variable
# independently
angles, velocities, moments, forces = \
octave.leg2d(time, marker_array, normalized_force_array,
options)
if parse_version(oct2py.__version__) >= parse_version('4.0'):
angles, velocities, moments, forces = \
octave.leg2d(time, marker_array, normalized_force_array,
options, nout=4)
else:
angles, velocities, moments, forces = \
octave.leg2d(time, marker_array, normalized_force_array,
options)

dynamics = angles, velocities, moments, forces

Expand Down
22 changes: 15 additions & 7 deletions gaitanalysis/motek.py
Original file line number Diff line number Diff line change
Expand Up @@ -1209,17 +1209,25 @@ def orient_accelerometer(orientation, x_prime, y_prime, z_prime):
y_inertial = np.zeros(np.shape(y_prime))
z_inertial = np.zeros(np.shape(z_prime))

for row, world in enumerate([x_inertial, y_inertial, z_inertial]):
for col, local in enumerate([x_prime, y_prime, z_prime]):
world += orientation[row,col] * local
for col, local in enumerate([x_prime, y_prime, z_prime]):
x_inertial += orientation[0, col] * local

for col, local in enumerate([x_prime, y_prime, z_prime]):
y_inertial += orientation[1, col] * local

for col, local in enumerate([x_prime, y_prime, z_prime]):
z_inertial += orientation[2, col] * local

return x_inertial, y_inertial, z_inertial

for sensor, rot_matrix in self.meta['trial']['sensor-orientation'].iteritems():
data_frame[sensor + '_AccX'], data_frame[sensor + '_AccY'], \
data_frame[sensor + '_AccZ'] = orient_accelerometer(
np.array(rot_matrix), data_frame[sensor + '_AccX'],
data_frame[sensor + '_AccY'], data_frame[sensor + '_AccZ'])
ax, ay, az = orient_accelerometer(np.array(rot_matrix),
data_frame[sensor + '_AccX'],
data_frame[sensor + '_AccY'],
data_frame[sensor + '_AccZ'])
data_frame[sensor + '_AccX'] = ax
data_frame[sensor + '_AccY'] = ay
data_frame[sensor + '_AccZ'] = az

return data_frame

Expand Down
15 changes: 12 additions & 3 deletions gaitanalysis/octave/2d_inverse_dynamics/leg2d.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
% - missing marker data is interpolated *after* low pass filtering
% - x and y coordinates of the same marker must be either both valid or both NaN (missing)

oct_ver = strsplit(OCTAVE_VERSION, '.');

% some constants
Nmarkers = 6;
Ncoords = 2*Nmarkers;
Expand Down Expand Up @@ -91,9 +93,16 @@
maxmissing = max(diff(validsamples))-1; % determine largest gap
fprintf('Marker %d: %d samples are missing, longest gap is %d samples.\n', i, missing, maxmissing);
[xf, xd, xdd] = myfiltfilt(validtimes, d(validsamples,:), options.freq);
mocap_f(:,columns) = interp1q(validtimes, xf, times); % resample filtered signal to original time stamps
mocap_d(:,columns) = interp1q(validtimes, xd, times); % resample first derivative to original time stamps
mocap_dd(:,columns) = interp1q(validtimes, xdd, times); % resample second derivative to original time stamps
% Octave removed interp1q in version 4.2.
if ((str2num(oct_ver{1}) >= 4) && (str2num(oct_ver{2}) >= 2))
mocap_f(:,columns) = interp1(validtimes, xf, times); % resample filtered signal to original time stamps
mocap_d(:,columns) = interp1(validtimes, xd, times); % resample first derivative to original time stamps
mocap_dd(:,columns) = interp1(validtimes, xdd, times); % resample second derivative to original time stamps
else
mocap_f(:,columns) = interp1q(validtimes, xf, times); % resample filtered signal to original time stamps
mocap_d(:,columns) = interp1q(validtimes, xd, times); % resample first derivative to original time stamps
mocap_dd(:,columns) = interp1q(validtimes, xdd, times); % resample second derivative to original time stamps
end
end

% do the low-pass filtering on the force plate data
Expand Down
4 changes: 2 additions & 2 deletions gaitanalysis/tests/test_gait.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ def test_grf_landmarks(self, plot=False):
min_idx = len(self.data_frame) / 3
max_idx = 2*len(self.data_frame) / 3

min_time = self.data_frame.index.astype(float)[min_idx]
max_time = self.data_frame.index.astype(float)[max_idx]
min_time = self.data_frame.index.values.astype(float)[min_idx]
max_time = self.data_frame.index.values.astype(float)[max_idx]

right_strikes, left_strikes, right_offs, left_offs = \
gait_data.grf_landmarks('Right Vertical GRF',
Expand Down