# NOT RUN {
require(forecast)
require(dcemriS4)
require(plotly)
## In the "fMRI" chapter, we have a 4-dimension dataset
## with x,y,z and time dimension (dataset "fMRIVolume").
## So we can settle x,y,and z to determine a vector of time series data.
# You could find the raw "fMRIVolume" dataset on the SOCR website
# }
# NOT RUN {
fMRIURL <- "http://socr.umich.edu/HTML5/BrainViewer/data/fMRI_FilteredData_4D.nii.gz"
# }
# NOT RUN {
fMRIFile <- file.path(tempdir(), "fMRI_FilteredData_4D.nii.gz")
# }
# NOT RUN {
download.file(fMRIURL, dest=fMRIFile, quiet=TRUE)
# }
# NOT RUN {
fMRIVolume <- readNIfTI(fMRIFile, reorient=FALSE)
# }
# NOT RUN {
# Load three time series data(with a wrong format)
# }
# NOT RUN {
xA_fMRI_1D_x20_y20_z11 <- fMRIVolume[20, 20, 11, ]
# }
# NOT RUN {
xB_fMRI_1D_x30_y30_z13 <- fMRIVolume[30, 30, 13, ]
# }
# NOT RUN {
xC_fMRI_1D_x40_y40_z12 <- fMRIVolume[40, 40, 12, ]
# }
# NOT RUN {
# Change this to time series data
TS1<-ts(xA_fMRI_1D_x20_y20_z11,start=0,frequency =1/3)
TS2<-ts(xB_fMRI_1D_x30_y30_z13,start=0,frequency =1/3)
TS3<-ts(xC_fMRI_1D_x40_y40_z12,start=0,frequency =1/3)
# Package them into a data frame
TSDF<-data.frame(TS1,TS2,TS3)
# Using this function to create plot
GTSplot(TSDF,Xlab="Time(second)",Unit="sec",ts_name=c("xA_fMRI_1D_x20_y20_z11",
"xB_fMRI_1D_x30_y30_z13","xC_fMRI_1D_x40_y40_z12"),
COLO=c("green","red","blue"))
# }
Run the code above in your browser using DataLab