This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Written by Mohammadreza Rezaie [kernalnt@gmail.com] | |
import org.opensim.utils as utils | |
import os | |
folder = utils.FileUtils.getInstance().browseForFolder('Choose a dirctory where STO/MOT files are located',0) | |
if folder==None: | |
print('Nothing was selected') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib import pyplot as plt | |
import numpy as np | |
from sklearn.neighbors import KDTree | |
def LyE(vec, dim, lag, fs, scale=None, theiler='meanPeriod', ws=10, neighbors=1, plot=False): | |
'''max lyapunov exponent (local dynamic stability) according to Rosenstein (1993) algorithm. | |
https://github.com/SjoerdBruijn/LocalDynamicStability | |
vec: 1D vector | |
dim: embedding dimention | |
lag: time delay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from matplotlib import pyplot as plt | |
from sklearn.metrics import pairwise_distances | |
from scipy import stats | |
def RQA(vec1, dim, lag, cross=None, scale=None, norm='euclidean', rescale=None, threshold=['rec',0.05], theiler=None, minLine=2, epoch=None, shift=None, get=False, save=True, show=False, plot=False, output='RQAepoch.txt'): | |
'''https://en.wikipedia.org/wiki/Recurrence_quantification_analysis#RQA_measures | |
https://juliadynamics.github.io/DynamicalSystems.jl/latest/rqa/quantification/ | |
diagonal vertical |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def normalize(vec, typ=None): | |
''' | |
normalize or scale data | |
typ: description: | |
==== ============ | |
'None' do nothing | |
'range' ** [a,b] ranged between a and b (e.g. [-1,1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from matplotlib import pyplot as plt | |
from scipy import signal | |
def PSD(data, fs, first=None, last=None, plot=False, statistics=False): | |
'''Power Spectral Density | |
fs: frequency sampled | |
The period is the time duration of one cycle. | |
MNF is an average frequency which is calculated as the sum of product of the EMG power spectrum and the frequency divided by the total sum of the power spectrum. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def SSR(data, dim, lag, plot=False): | |
'''State Space Reconstruction | |
represents all possible states of a system | |
''' | |
assert isinstance(data, np.ndarray), 'file type is not ndarray' | |
if data.ndim == 1: | |
data = data.reshape(-1,1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def readExp(file, sep='\t'): | |
''' Read OpenSim STO and MOT files | |
or any other format that the headers are separated from labels and data by 'endheader' line. | |
can return data and labels, dataFrame, or dict''' | |
with open(file, mode='r') as f: | |
while True: | |
line = f.readline() | |
if 'endheader' in line: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% function struct = readExp(file) | |
function [data, label] = readExp(file) | |
%Read OpenSim STO and MOT files Or any other format that | |
%the headers are separated from labels and data by 'endheader' line. | |
%can also return struct''' | |
i = 0 | |
while true | |
try | |
data = dlmread(file, '\t', i, 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.neighbors import KDTree | |
import numpy as np | |
def sampEnt(vec1, cross=None, scale=None, dim=3, radius=0.25, lag=1, norm='chebyshev'): | |
''' | |
scale: normalize input vector | |
[None]: no normalization | |
['range', [0,1]] : amplitude normalization [0,1] | |
['range', [-1,1]] : amplitude normalization [-1,1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Calculate free moment from Kistler (type 3) force plate | |
% Input is a text file contains analog signals (8 channels for each force plate) | |
% REF: http://isbweb.org/software/movanal/vaughan/kistler.pdf | |
clear all; clc; close all | |
i = 0; | |
while true | |
try | |
data = dlmread('atena_zarei_GR1.txt', '\t', i, 1); | |
% 'atena_zarei_GR1.txt' |
NewerOlder