LAMP Consortium

GPS Analysis Formatting

Hi! I’m looking to analyze some GPS data from the LAMP app using Ian Barnett’s GPSmobility package in R (https://github.com/ianjamesbarnett/GPSimputation) and having some trouble. I am trying to match my LAMP GPS data to match the formatting in his tutorial. In my GPS data I have id, timestamp, long, lat, and accuracy. Here are some troubleshooting questions:
-It looks like all participants have an accuracy of -1, is this correct?
-Does the app record UTC time?
-Does the app record altitude?

Thanks!

Hi @tairmaek!

  1. The CSV field UTC time should be ignored, I believe, and you can use placeholder empty strings if you’re in an R data frame. This is a string representation of the timestamp field that we already provide.
  2. Altitude is not recorded in mindLAMP v1 data, only mindLAMP v2 (which I believe you’re not using at the moment). Instead, impute a value of 0.0 for this column.
  3. The accuracy field is currently set to either -1 or unknown because there was a bug in mindLAMP v1 where the app was not able to specify a desired accuracy and instead retrieved a street name-level GPS coordinate that was then reverse-geocoded to produce coordinate values. Data recorded prior to January 2019 are thus slightly less accurate, but data recorded after this point still do not record the accuracy value.

Hope this helps!

Aditya-thank you so much for this input!

I tried running the code as follows and am getting the following errors:

setwd("~/Desktop")
args <- commandArgs(trailingOnly = TRUE)
library(GPSmobility)
fildir=getwd()
filename=args[1]
mout=MobilityFeatures(filename,fildir)
Read in all GPS csv files…
Error in mat[1, 1]/1000 : non-numeric argument to binary operator
In addition: Warning messages:
1: In read.table(file = file, header = header, sep = sep, quote = quote, :
incomplete final line found by readTableHeader on ‘als_test.csv’
2: In mean.default(mat$accuracy) :
argument is not numeric or logical: returning NA

I think we’ll need to manually make some changes to Ian’s code. Let me take a look and see what I can do. I’ll post my changes here as a diff/set of instructions for you to follow!

1 Like

@tairmaek, could you post the first few lines of your CSV file so I can determine its format? I think this may be easily fixed if we write a small script to reformat the CSV’s contents.

image

timestamp.x	UTC time	long	lat	altitude	accuracy
1.56E+12		-71.62602234	41.36608124		
1.56E+12		-71.62602234	41.36608124		
1.56E+12		-71.62602234	41.36608124		
1.56E+12		-71.62602234	41.36608124		
1.56E+12		-71.62602234	41.36608124		
1.56E+12		-71.62602234	41.36608124		
1.56E+12		-71.62602234	41.36608124

Hmm, @tairmaek, could you try inserting NA for the UTC time and 0.0 for altitude and accuracy columns? I wonder if that’s all we need to “trick” the code into working.

didnt work :frowning:

Read in all GPS csv files…
Collapse data within 10 second intervals…
Error in avgmat[, 1:4] : incorrect number of dimensions

It looks like it wants a different format if it says there’s an incorrect number of dimensions. Did you have a working data set I could compare with? I wonder if it’s not happy about a 0.0 accuracy, perhaps 1.0 would work?

I’ll also download the code and take a look myself - could you email or DM me a sample CSV file without patient IDs?

I think I’m able to reproduce the error you’re seeing but just to confirm something: how are you installing the GPSimputation package, @tairmaek? I’ve cloned the git repository and am using that version.

Hi @avaidyam!

I downloaded the package by doing the following into R

install.packages(“C:/Users/tkangarl/Downloads/GPSmobility_1.5.tar.gz”, repos = NULL, type = “source”)

@tairmaek, this is kind of odd because it works perfectly fine for me with the sample data you sent me.

Read in all GPS csv files...
Collapse data within 10 second intervals...
Convert from Lat/Lon to X/Y...
Convert from X/Y to flights/pauses...
Inferring pauses...
No flights in mobmat. Removing individual from analysis.

What I did notice when I modified the data files to fit LAMP data was that the UTC time field needs to be empty, and the accuracy field needs to be set to 1.0 and altitude to 0.0. Then it appears to work fine.