Outline : From User's Perspective

Data

1. NIRSdata : maybe a formal data for package

Preprocessing

1. data_select
2. data_summarize
3. downsample

Exploratory Data Analysis

1.edaplot
2.ciplot

Data

head(dta[,1:6],5)
  Subject   Channel Condition       Time1       Time2        Time3
1    Sub1 Channel_1         L 9.41547e-07 5.66481e-07 -2.69333e-07
2    Sub1 Channel_2         L 4.76202e-07 1.33424e-07 -4.35254e-07
3    Sub1 Channel_3         L 6.23525e-07 4.88530e-07  1.41329e-07
4    Sub1 Channel_4         L 8.10356e-07 5.98575e-07  2.28668e-07
5    Sub1 Channel_5         L 7.50515e-07 5.26700e-07  2.60588e-07
tail(dta[,1:6],5)
    Subject    Channel Condition        Time1        Time2        Time3
396   Sub20  Channel_6         H -1.04115e-06 -1.05311e-06 -8.54260e-07
397   Sub20  Channel_7         H -1.39371e-07 -6.96321e-07 -9.61779e-07
398   Sub20  Channel_8         H -1.60774e-07 -1.26477e-07  6.32308e-08
399   Sub20  Channel_9         H -6.81029e-08  1.82143e-07  3.34033e-07
400   Sub20 Channel_10         H  2.39154e-07  3.43515e-07  3.86194e-07

Data

str(dta[,1:9],digits.d=1)
'data.frame':   400 obs. of  9 variables:
 $ Subject  : Factor w/ 20 levels "Sub1","Sub2",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ Channel  : Factor w/ 10 levels "Channel_1","Channel_2",..: 1 2 3 4 5 6 7 8 9 10 ...
 $ Condition: Factor w/ 2 levels "L","H": 1 1 1 1 1 1 1 1 1 1 ...
 $ Time1    : num  9e-07 5e-07 6e-07 8e-07 8e-07 ...
 $ Time2    : num  6e-07 1e-07 5e-07 6e-07 5e-07 ...
 $ Time3    : num  -3e-07 -4e-07 1e-07 2e-07 3e-07 ...
 $ Time4    : num  -1e-06 -8e-07 -1e-07 5e-09 9e-08 ...
 $ Time5    : num  -1e-06 -6e-07 -3e-08 4e-09 7e-08 ...
 $ Time6    : num  -7e-07 -6e-08 2e-07 -3e-08 9e-08 ...

Look at Data : Overall

timepoint <- seq(-2,14.96,by=0.16)
Fig0 <- edaplot(data = dta,
                frames = timepoint ,
                datacol=4:110,
                subjcol=1,
                chancol=2,
                othvarcol=3)+
         geom_line(aes(col=Condition))+
        facet_grid(Channel~Subject)

Look at Data : Overall

Look at Data : Detail

timepoint <- seq(-2,14.96,by=0.16)
Fig1 <- edaplot(data = dta,
                frames = timepoint ,
                datacol=4:110,
                subjcol=1,
                chancol=2,
                othvarcol=3,
                select_subj = c("Sub7","Sub10","Sub12"))+
         geom_line(aes(col=Condition))+
        facet_grid(Subject~Channel)+
        theme_bw()

Look at Data : Detail

Look at Data : Detail

timepoint <- seq(-2,14.96,by=0.16)
Fig2 <- edaplot(data = dta,frames = timepoint ,
                datacol=4:110,subjcol=1,chancol=2,othvarcol=3,
                outlinesub = "Sub7",outcolor = "red")+
        facet_grid(.~Channel)+theme_bw()
Fig3 <- edaplot(data = dta,frames = timepoint,
                datacol=4:110,subjcol=1,chancol=2,othvarcol=3,
                outlinesub = "Sub10",outcolor = "green")+
        facet_grid(.~Channel)+theme_bw()
Fig4 <- edaplot(data = dta,frames = timepoint ,
                datacol=4:110,subjcol=1,chancol=2,othvarcol=3,
                outlinesub = "Sub12",outcolor = "blue")+
        facet_grid(.~Channel)+theme_bw()

Look at Data : Detail

Data Selection : Delete Subject 7,10,12

dta2 <- data_select(data = dta,frames = timepoint ,
                    datacol=4:110,subjcol=1,
                    chancol=2,othvarcol=3,
                    select_subj = c(paste("Sub",
                                          c(1:6,8:9,11,13:20),sep="")))
head(dta2[,1:6])
  Subject   Channel Condition       Time1       Time2        Time3
1    Sub1 Channel_1         L 9.41547e-07 5.66481e-07 -2.69333e-07
2    Sub1 Channel_2         L 4.76202e-07 1.33424e-07 -4.35254e-07
3    Sub1 Channel_3         L 6.23525e-07 4.88530e-07  1.41329e-07
4    Sub1 Channel_4         L 8.10356e-07 5.98575e-07  2.28668e-07
5    Sub1 Channel_5         L 7.50515e-07 5.26700e-07  2.60588e-07
6    Sub1 Channel_6         L 5.26136e-07 8.06925e-08 -2.61174e-07
dim(dta2)
[1] 340 110

Downsample : smoothing data

dta3 <- downsample(data = dta2,
                   datacol = 4:110,
                   binwidth = 10, 
                   movinginterval=5)
timepoint2 <- seq(-2,14.96,by = 0.6525)
Fig4 <- edaplot(data = dta3,
        frames = timepoint2 ,
        datacol= 4:29,
        subjcol=1,
        chancol=2,
        othvarcol=3)+
        geom_line(aes(col=Subject))+
        facet_wrap(~Channel)

Downsample:smoothing data

Data Exploration : Focus on "Condition"

Fig5 <- edaplot(data = dta3,
        frames = timepoint2 ,
        datacol= 4:29,
        subjcol=1,
        chancol=2,
        othvarcol=3)+
        geom_line(aes(col=Condition))+
        facet_wrap(~Channel)+
        stat_summary(aes(group=Condition,shape=Condition),
                     fun.y = "mean",col = "purple",
                     size = 1, geom = "point")+
        theme_bw()+
        theme(legend.position="bottom")+
        labs(list(x="Signal",y="Time Points"))

Data Exploration: Focus on "Condition"

Data Summarize : by "Condition"

dtasum <- data_summarize(data=dta3,
                          frames = timepoint2,
                          datacol = 4:29,
                          subjcol = 1,
                          chancol = 2,
                          othvarcol = 3,
                          summarycol= c(2,3),
                          fun=mean)
head(dtasum[,c(1:5)])
    Channel Condition       value.1       value.2      value.3
1 Channel_1         L -1.898317e-07  1.902874e-07 7.609002e-07
2 Channel_2         L -4.462120e-08 -3.553222e-09 3.033979e-07
3 Channel_3         L -9.023315e-09 -5.554516e-08 1.806674e-07
4 Channel_4         L -7.345304e-08 -1.542970e-08 3.596421e-07
5 Channel_5         L -3.494380e-08 -4.848521e-09 2.369591e-07
6 Channel_6         L  3.810523e-08 -7.817846e-08 1.162215e-07

Average Data Exploration : Focus on "aveRT", "Condition"

Fig7 <- edaplot(data = dtasum,
                frames = timepoint2 ,
                datacol= 3:28,
                #subjcol=NULL,
                chancol=1,
                othvarcol=2)+
        geom_line(aes(col=Condition))+
        facet_wrap(~Channel)+
        theme_bw()+
        #scale_size_discrete(name="Average RT",range=c(1,2))+
        theme(legend.position="bottom")+
        labs(list(title="Average HRF curve",
                  x="Time Points",y="Signal"))

Average Data Exploration

Average Data Exploration

Fig8 <- edaplot(data = dtasum,
                frames = timepoint2 ,
                datacol= 3:108,
                subjcol=NULL,
                chancol=1,
                othvarcol=2)+
        geom_line(aes(col=Condition))+
        scale_color_manual(values= c("blue","red"))+
        facet_wrap(~Channel)+
        theme_bw()+
        theme(legend.position="bottom")+
        labs(list(title="Average HRF curve",
                  x="Time Points",y="Signal"))

Average Data Exploration

Data Exploration : Bootstrap Confidence Interval

Fig9 <- ciplot(dta3,frames=timepoint2,
               datacol=4:29,subjcol=1,
               chancol=2,othvarcol=3,
               cpvarcol = 3 , 
               fun=samplemean <- function(x, d){return(mean(x[d]))}, # boot package
               bootnum=500, # bootsraping number 
               bootintval=c(.025,.975), # bootstrap confidence interval 
               bootalpha=0.5)

Data Exploration : Bootstrap Confidence Interval