This web page includes full color versions of the Hilbert and Fourier spectrogram figures as well as instructions on how to install and use the “hht” package in R. Data and code for all analyses performed in this paper are available for download here as well. Finally, we show how to generate a web page like this one using the “knitr” and “markdown” packages in R.
R is an open-source programming language designed for scientific and statistical computation. The base R installation includes many functions for data analysis and display. Furthermore, over 4800 quality controlled, user contributed packages extend R's capabilities to many diverse areas. Below are instructions for installing and using the “hht” package, a series of functions designed for time series analysis using the Hilbert-Huang transform.
Linux users: start R as root if you want to make the package available to all users on the machine
Start the R interpreter and type (or copy and paste) the following:
library(hht, quietly = TRUE) #Load hht package data(PortFosterEvent) #Use example data from hht package emd.result <- Sig2IMF(sig, tt) #Run EMD using default parameters time.span <- c(5, 10) #Time span to plot imf.list <- 1:3 #IMFs to plot os <- TRUE #Show original signal in plot res <- FALSE #Do not show residual in plot fit.line <- TRUE #Plot a red line showing sum of displayed IMFs on original signal PlotIMFs(emd.result, time.span = time.span, imf.list = imf.list, original.signal = os, residue = res, fit.line = fit.line)
The R code below will regenerate Figure 1.
library(hht, quietly = TRUE) #Load hht package dt <- 0.01 tt <- seq_len(200) * dt sig1 <- sin(2 * pi * tt) sig2 <- sin(2 * pi * tt) + 0.25 # Create analytic signals asig1 <- HilbertTransform(sig1) asig2 <- HilbertTransform(sig2) # Get instantaneous frequency fsig1 <- InstantaneousFrequency(asig1, tt) fsig2 <- InstantaneousFrequency(asig2, tt) plot(tt, fsig1, type = "l", ylim = c(0.5, 1.5), xlab = "Time (s)", ylab = "Instantaneous Frequency (Hz)", lwd = 3) lines(tt, fsig2, lty = 2, lwd = 3)
This example will generate individual gray scale and full color images for Figures 2 through 4.
This example will generate gray scale and full color images for Figures 5 and 6.
This example will generate gray scale and full color images files for Figures 7 through 10.
This web page was built using R also. You can generate a working copy of this web page by downloading the source file “SRL-D-13-00025-esupp.Rmd” here, downloading all links, saving the tar files in the same directory as “SRL-D-13-00025-esupp.Rmd” and the JPEG images in a directory called “color_figures”, and executing the following code:
install.packages("knitr") install.packages("markdown") library(hht) library(knitr) library(markdown) knit2html("SRL-D-13-00025-esupp.Rmd")
This will create a file called “SRL-D-13-00025-esupp.html” that can be opened with your web browser.
[ Back ]