Loading

Install the necessary packages if not available:

# install.packages("R.matlab")
library(R.matlab)

Load the nirs file

data <- readMat("Simple_Probe.nirs")

Nirs format description is available here

Exploring

Get the available variable names

names(data)
## [1] "SD"       "t"        "d"        "s"        "aux"      "userdata"

Find the dimensions of data: samples and channels

dim(data$d)
## [1] 1200    8
# number of channels
ncol(data$d)
## [1] 8

Plotting

Create a custom plotting function

myPlot <- function(y){
  plot(data$t, y,
       type = "l",
       xlab = "Time", ylab = "Intensity",
       ylim = c(range(data$d)),
       main = paste("Channel ", toString(y)))
  # add the lines when triggers occur
  lines(data$t, data$s*1500, # multiply the trigger value to make it visible
        type = "l", xlab = "Time", col = "red")
}

Apply the plotting function to all channels

apply(data$d[, 1:ncol(data$d)], 2, myPlot)

## NULL

Session info:

sessionInfo()
## R version 3.3.2 (2016-10-31)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 7 x64 (build 7601) Service Pack 1
## 
## locale:
## [1] LC_COLLATE=English_United Kingdom.1252 
## [2] LC_CTYPE=English_United Kingdom.1252   
## [3] LC_MONETARY=English_United Kingdom.1252
## [4] LC_NUMERIC=C                           
## [5] LC_TIME=English_United Kingdom.1252    
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] R.matlab_3.6.1
## 
## loaded via a namespace (and not attached):
##  [1] backports_1.0.4   magrittr_1.5      rprojroot_1.1    
##  [4] tools_3.3.2       htmltools_0.3.5   yaml_2.1.14      
##  [7] Rcpp_0.12.8       R.methodsS3_1.7.1 stringi_1.1.2    
## [10] rmarkdown_1.2     knitr_1.15.1      stringr_1.1.0    
## [13] digest_0.6.10     R.utils_2.5.0     R.oo_1.21.0      
## [16] evaluate_0.10