Skip to content

Instantly share code, notes, and snippets.

View alcantarar's full-sized avatar
🌮
Twitter: @Ryan_Alcantara_

Ryan Alcantara alcantarar

🌮
Twitter: @Ryan_Alcantara_
View GitHub Profile
@alcantarar
alcantarar / filter_split_normalize_mean_vGRF.m
Created April 1, 2022 05:40
reads in dryft sample grf data, filters it, splits steps, normalizes to stance phase, then plots mean/sd waveform.
% relies on data and functions from https://github.com/alcantarar/dryft.
% Please cite the paper if you use it.
%
% This script reads in vgrf data, filters it, identifies stance phase,
% separates each stance phase, normalizes to stance phase, then plots
% the mean +/- SD vgrf waveform.
%
% Ryan Alcantara | ryansalcantara@gmail.com
@alcantarar
alcantarar / GRF_Tibia_Load.R
Created April 10, 2021 20:36
Analysis of “Ground reaction force metrics are not strongly correlated with tibial bone load when running across speeds and slopes: Implications for science, sport and wearable tech”
library(ggplot2)
library(dplyr)
library(Metrics)
## Import discrete variables ----
data <- read.csv('data_from_matlab_gui.csv', header = TRUE) # csv compiled from GUI data
data$sub <- as.factor(data$sub)
## Plot Correlation across Slopes ----
ggplot(data = data,
@alcantarar
alcantarar / get_full_text_links.ipynb
Last active October 8, 2020 02:56
Get full-text links from pubmed
@alcantarar
alcantarar / plot_qrf_trees.R
Created August 31, 2020 22:08
How to plot distribution of individual tree predictions in Quantile Regression Forest trained in R with {caret}
library(tidyr)
library(caret)
library(quantregForest)
library(ggplot2)
library(ggridges)
head(mtcars)
qrf<- train(mpg ~ cyl + disp + hp + drat + wt, data = mtcars, method = 'qrf') # train QRF model
n_cars = 8
class(qrf$finalModel) <- 'randomForest'

Data Discontinuity

Kenzie, you've got a fun situation because in POE2_Data_Discontinuity.xls, it's not just the signal exceeding the +/- 180 range. It's a signal exceeding 2x, 3x... the +/-180 range! I wasn't able to fix it completely with the time I currently have, but I think a place to start is breaking the trial into slices based on the "jumps" occurring in the signal. After you break the trial into slices, you need to shift signals by a certain amount and in a particular direction. That amount will depend on two things:

  1. the first value in that slice
  2. the number of times the signal has consecutively exceeded the range in the same direction.

What I thought would work is puting some shifting code into a while loop that keeps checking and shifting the slices until

pre_race = c(-5,-4,-3,0,0,0,0,0,0,3,4,5)
post_race_0 = c(-5,2,2,2,2,2,2,3,5,10,20,30)
post_race_24 = c(-5,-2,-1,0,0,0,1,1,1,1,2,3)
y = c(pre_race, post_race_0, post_race_24)
time = rep(c('pre','0hr post', '24hr post'), each = 12)
x = rep(as.factor(1), length(y))
@alcantarar
alcantarar / search_biopython.py
Last active June 8, 2018 21:01 — forked from bonzanini/search_biopython.py
Searching PubMed with Biopython
# you need to install Biopython:
# pip install biopython
# Full discussion:
# https://marcobonzanini.wordpress.com/2015/01/12/searching-pubmed-with-python/
from Bio import Entrez
def search(query):
Entrez.email = 'your.email@example.com'