This vignette will show how to load raw csv files produced by Hitachi ETG-4000 fNIRS. The rationale for writing this package was to allow conducting fNIRS data analysis in R.
In its current development stage this package can only read raw csv files produced by Hitachi ETG-4000. Other systems produce file with a different structure and so far I did not need to use them. Eventually, I might expand this package to work with other file types.
Install the package from GitHub:
devtools::install_github("erzk/fnirsr")
File Hitachi_ETG4000_24Ch_Total.csv , which is used in this vignette and is attached to this package, comes from NIRS-SPM.
Top level information about the recording is held in a header. It has an irregular form so it is a bit tricky to parse. This package version reads the section of the csv file before the data section and returns a vector with header info:
library(fnirsr)
file_path <- system.file("extdata", "Hitachi_ETG4000_24Ch_Total.csv", package = "fnirsr")
header <- load_ETG4000_header(file_path)
head(header)
## [1] "File Version,1.08" "Patient Information"
## [3] "ID,KikuchiWF" "Name,Kikuchi"
## [5] "Comment,IOWA fukawa-late,," "Age, 44y"
Loading the signal from csv files can be accomplished using the basic load_ETG4000_data() function. It reads the data section of a csv file, changes the Time column to reflect time period from the beginning of the recording (instead of actual hour), and returns a data frame.
df <- load_ETG4000_data(file_path)
str(df)
## 'data.frame': 3351 obs. of 30 variables:
## $ Probe1.Total.: int 1 2 3 4 5 6 7 8 9 10 ...
## $ CH1 : num -0.0284 -0.0264 -0.0251 -0.0244 -0.0241 ...
## $ CH2 : num 0.0174 0.0198 0.0221 0.0238 0.025 ...
## $ CH3 : num -0.0217 -0.0199 -0.0189 -0.0184 -0.0182 ...
## $ CH4 : num -0.008498 -0.005906 -0.003531 -0.001651 -0.000384 ...
## $ CH5 : num 0.00966 0.01212 0.01442 0.01579 0.01667 ...
## $ CH6 : num -0.0194 -0.0176 -0.0158 -0.0146 -0.0138 ...
## $ CH7 : num -0.0292 -0.0267 -0.0247 -0.0237 -0.0231 ...
## $ CH8 : num -0.0513 -0.0493 -0.0488 -0.05 -0.05 ...
## $ CH9 : num -0.0716 -0.0686 -0.066 -0.0635 -0.0636 ...
## $ CH10 : num 0.0131 0.0149 0.0155 0.0154 0.0148 ...
## $ CH11 : num -0.0708 -0.0695 -0.0675 -0.0662 -0.0681 ...
## $ CH12 : num -0.0458 -0.0469 -0.0472 -0.0493 -0.0485 ...
## $ CH13 : num 0.0151 0.0177 0.0178 0.0186 0.0196 ...
## $ CH14 : num 0.00488 0.00832 0.01059 0.01139 0.01237 ...
## $ CH15 : num -0.00092 -0.000109 0.001794 0.004157 0.005974 ...
## $ CH16 : num 0.0128 0.0147 0.0165 0.0177 0.0183 ...
## $ CH17 : num 0.0327 0.0352 0.0372 0.039 0.0403 ...
## $ CH18 : num -0.0378 -0.0358 -0.0348 -0.0335 -0.0326 ...
## $ CH19 : num 0.0289 0.0318 0.0345 0.0361 0.0375 ...
## $ CH20 : num -0.01041 -0.00884 -0.00789 -0.00707 -0.00677 ...
## $ CH21 : num -0.0736 -0.0714 -0.0697 -0.0687 -0.0682 ...
## $ CH22 : num 0.0229 0.0264 0.0291 0.0311 0.0322 ...
## $ CH23 : num -0.145 -0.144 -0.143 -0.142 -0.141 ...
## $ CH24 : num -0.0446 -0.0412 -0.038 -0.0359 -0.0353 ...
## $ Mark : int 0 0 0 0 0 0 0 0 0 0 ...
## $ Time : num 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 ...
## $ BodyMovement : int 0 0 0 0 0 0 0 0 0 0 ...
## $ RemovalMark : int 0 0 0 0 0 0 0 0 0 0 ...
## $ PreScan : int 0 0 0 0 0 0 0 0 0 0 ...
Once the csv file is loaded and a data frame is created, you can start plotting the signal.
Plotting function plot_ETG4000() comes with three arguments: * facets * overlap * channel
The default choice is facets which will show all channels in separate facets. This should enable spotting outliers.
plot_ETG4000(df)
Another option is plotting all channels overlapping each other:
plot_ETG4000(df, type = "overlap")
Alternatively, if you want to plot a single channel of interest then use the separate argument and a channel number. This option uses time column as an x-axis (as opposed to the previous plots using samples).
plot_ETG4000(df, type = "separate", channel = 1)
Next releases will include filtering, splitting, and averaging the continuous recordings.