Added some new functions to the readCortrium package. It now returns time info (start of recording) with the data frames, can determine time of heart beats from ECG data (via a primitive and unreliable method) and some other stuff.
Load the libraries required for reading the data and plotting and general parameters.
library(devtools)
install_github("crtahlin/readCortrium")
library(readCortrium)
library(ggplot2)
library(reshape2)
# select which directory to work on
dirname <- "/home/crtah/Dropbox/DataSets/Cortrium/Data/2014-10-20 12.42.47/"
The C3 records two kinds of temperature values. The sensor is infrared and measures the “device temperature” and the “object temperature”. They are labeled degreesAmbient and degreesTarget on the graph (hopefully correctly - I guess the curve nearer 36.7 Celsius should be body temperature, aka “target temperature”).
# read the data from dirname directory
temperature <- readDegrees(dirname)
# add a column to the data, containing timestamps
ggplotData <- addTimestamp(temperature, frequency=25)
# transform the data into ggplot appropriate format
ggplotData <- melt(ggplotData, measure.vars = c("degreesAmbient","degreesTarget"))
# set breaks on scale, plot
breaks=seq( from = min(ggplotData$value), to=max(ggplotData$value)+1, by=0.5)
plot <- ggplot(data=ggplotData) +
geom_point(aes(x=timestamp, y=value, colour=variable)) +
scale_x_datetime(name="time") +
scale_y_continuous(breaks=breaks) +
theme_bw()
plot
In a recent addition to the readCortrium package, I have added time info to the data frames returned. I have also written a very primitive function to determine time of heart beats. The plot below shows a couple of hours of heart beat data read from the device. The heart rate obviously has values that are not possible in real life. This is probably due to the very basic nature of the heart beat detection algorithm - a better one needs to be implemented.
# read ECG track (ECG1) and detect where "heart beats" occur
beatTimes <- beatsFromECG(dirname)
# plot, add a smoother to get an idea of the curve
plot <- ggplot(data=beatTimes) +
geom_point(aes(x=timestamp, y=momentaryHR)) +
scale_x_datetime(name="time") +
scale_y_continuous(limits=c(60, 220)) +
geom_smooth(aes(x=timestamp, y=momentaryHR)) +
theme_bw()
plot
More work needed on extracting heart rate from the ECG signal.