Skip to content

Commit

Permalink
Fixed bug #12 in clean_data()
Browse files Browse the repository at this point in the history
The clean_data() function now no longer produces NAs. This seems to have happened in cases where a point failed to be tracked for every frame towards the end of the video (i.e. when more than the value for the final frame was 0).
  • Loading branch information
trettenbrein committed Apr 11, 2022
1 parent 209d277 commit 41e0492
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: OpenPoseR
Type: Package
Title: Analyze Motion-Tracking Data Derived from Video Files Using OpenPose
Version: 1.0.4
Version: 1.0.5
Authors@R: c(
person("Patrick C.", "Trettenbrein", email = "trettenbrein@cbs.mpg.de", role = c("aut", "cre")),
person("Emiliano", "Zaccarella", email = "zaccarella@cbs.mpg.de", role = "aut"))
Expand Down
16 changes: 8 additions & 8 deletions R/clean_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,21 @@ clean_data <- function(data, model, cutoff = .1) {

# Get next non-zero value
next_non_zero <- 1
while(r+next_non_zero<=nrow(data_points) &&
while(r+next_non_zero<nrow(data_points) &&
data_points[r+next_non_zero,c]==0) {
# Try next row by increasing counter
next_non_zero <- next_non_zero+1
}

# If we're at the end of the dataframe, just use the previous value
# In effect, the row will then be set to the value of the row above
if(next_non_zero==nrow(data_points)) {
next_non_zero <- -1
}
# If we've reached the end of the data frame without any non-zero value
# set point to 0. If not, compute mean and save it
if(r+next_non_zero==nrow(data_points)) {
data_points[r,c] <- 0
} else {

# Compute mean and save it
data_points[r,c] <- (data_points[r+last_non_zero,c]+
data_points[r,c] <- (data_points[r+last_non_zero,c]+
data_points[r+next_non_zero,c])/2
}
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ For details on what OpenPoseR can (and can't) do, respectively, how you can use

## Installation

For now, OpenPoseR (current version: 1.0.4) can be installed using the following commands (you will need to have the ``devtools`` package installed):
For now, OpenPoseR (current version: 1.0.5) can be installed using the following commands (you will need to have the ``devtools`` package installed):

```r
# Install devtools from CRAN (if not already installed)
Expand Down

0 comments on commit 41e0492

Please sign in to comment.