1 Legend

The German short version of the Five Facet Mindfulness Questionnaire (FFMQ; Baer et al., 2006; Michalak et al., 2016) was used for the main analysis. Therefore, the different variables and their meaning are listed below.

FFMQ = Five Facet Mindfulness Questionnaire (includes 39 items)

FFMQ_all = Gesamtwert des FFMQ

FFMQ_AOB = “Nicht-Urteilen” des ganzen FFMQ

FFMQ_sf_BEO = “Beobachten” des ganzen FFMQ

FFMQ_sf_BES = “Beschreiben” des ganzen FFMQ

FFMQ_sf_MAH = “Achtsames Handeln” des ganzen FFMQ

FFMQ_sf_NIR = “Nicht-Reagieren” des ganzen FFMQ

The master thesis refers to the „deutsche Kurzversion des FFMQ“, which means “German short version of the FFMQ.” This is abbreviated to “FFMQ-SF-D” in the thesis. It corresponds to the variable FFMQ_sf_all used here.

FFMQ_sf = Kurzversion des FFMQ = FFMQ short form = FFMQ-SF (includes 24 items)

FFMQ_sf_all = Gesamtwert des FFMQ-SF = Gesamtwert FFMQ-SF-D

FFMQ_sf_AOB = “Nicht-Urteilen” des FFMQ-SF

FFMQ_sf_BEO = “Beobachten” des FFMQ-SF

FFMQ_sf_BES = “Beschreiben” des FFMQ-SF

FFMQ_sf_MAH = “Achtsames Handeln” des FFMQ-SF

FFMQ_sf_NIR = “Nicht-Reagieren” des FFMQ-SF

2 Getting Started

2.1 Load Packages

knitr::opts_chunk$set(echo = TRUE, cache = TRUE, fig.align = "center", warning=FALSE, message=FALSE)

library(car)
library(cli)
library(dplyr)
library(ggbeeswarm)
library(ggcorrplot)
library(ggpubr)
library(ggrepel)
library(gld)
library(grid)
library(jmv)
library(kableExtra)
library(knitr)
library(lm.beta)
library(matlabr)
library(openxlsx)
library(PairedData)
library(ppcor)
library(psych)
library(purrr)
library(readxl)
library(reshape2)
library(R.matlab)
library(rstatix)
library(sjPlot)
library(tidyverse)
library(unglue)
library(wesanderson)

2.2 Define Functions

Behavior Data is read in from the DataOverview and desired variables were stored as .csv for further processsing and analysis.

# --------------------------------------------------
# Prepare to change electrode names from MATLAB 
# --------------------------------------------------

# read in csv with electrode names
electrodeNames <- 
  read.table(
    params$pathFileElectrodeNames,
    sep = ',',
    header = FALSE
  ) %>%
  as.character()

# generate vector with electrode-names 

elnames <- 
  electrodeNames # |>
  # .[which(electrodeNames %in% "WN_Fp1"):which(electrodeNames %in% "WN_AFz")]

elnames <- 
  substring(elnames,3)

rm(electrodeNames)

#### END ####

# ------------------------------------------------------------------
# Function FunReadDataxlsxAfterMatlab; to read in Power and behavior data after processing in MATLAB 
# ------------------------------------------------------------------

FunReadDataxlsxAfterMatlab <- function(
  dataPathxlsx,
  dataFilename
) {
  
  # --------------------------------------------------
  # INFO - SECTION
  # --------------------------------------------------
  # PURPOSE:reading file generated by MATLAB-Script ("A_MergeBehaviorandEEGdata"), renames power-Data with electrode-names
  # INPUT:
  # - dataPathxlsx: String containing path to folder of xlsx-files generated from MATLAB-Script (e.g. params$pathDatatable)
  # - dataFilename: String with name of excel file created by matlab script (can be defined in params (e.g. params$xlsxNameallData))
  # OUTPUT: allDataAfterMatlab -> Data frame of excel file that war read in. In chunk loadAllData, the output will be assigned to a new variable
  
  # load excel file created by MATLAB-Script
  allDataAfterMatlab <-
    read_excel(
      path = file.path(dataPathxlsx,dataFilename),
      sheet = 1)
  
  # append proper electrode-names 
   colStartRename <- grep("npower", colnames(allDataAfterMatlab))[1]
   if (is.na(colStartRename)){
     colStartRename <- grep("nPower", colnames(allDataAfterMatlab))[1]
   }
   if (is.na(colStartRename)){
     colStartRename <- grep("ipower", colnames(allDataAfterMatlab))[1]
   }
   if (is.na(colStartRename)){
     colStartRename <- grep("iPower", colnames(allDataAfterMatlab))[1]
   }
   
   colEndRename <- grep("nPower", colnames(allDataAfterMatlab))[length(grep("nPower", colnames(allDataAfterMatlab)))]
  
   if (is_empty(colEndRename)) {
        colEndRename <- grep("iPower", colnames(allDataAfterMatlab))[length(grep("iPower", colnames(allDataAfterMatlab)))]
   }
   restOldColname <- gsub('.{3}$',"",colnames(allDataAfterMatlab[colStartRename:colEndRename]))
   newNames <- paste(restOldColname, elnames, sep = "")
   
   colnames(allDataAfterMatlab)[colStartRename:colEndRename] <- newNames
   

  return(allDataAfterMatlab)
}

#### END ####
  

# ------------------------------------------------------------------
# #### FUNCTION FunCreateModBoxPlots ####
# ------------------------------------------------------------------

  # -----------------------------------------------
  # INFO - SECTION
  # -----------------------------------------------
  # PURPOSE: This function creates boxplots for a variable named  "myBoxplotData" 
   #   
   # INPUT: - y 
   #        - boxplotData: name of DataFrame that includes myY  variable(s) 
   # OUTPUT: .pdf withBoxplots for Overview


# function for computing mean, DS, max and min values
min.mean.sd.max <- function(x) {
  r <- c(mean(x) - 3*sd(x), mean(x) - 2*sd(x), mean(x), mean(x) + 2*sd(x), mean(x) + 3*sd(x))
  names(r) <- c("ymin", "lower", "middle", "upper", "ymax")
  r
}

# function for computing (modified) boxplot
FunCreateModBoxPlots <- function(myY){
  
   myBoxplotData %>%  
   ggplot(mapping = aes(x='', y = .data[[myY]]), na.rm=TRUE) +
    geom_boxplot(outlier.shape = NA, width= 0.5)+
    stat_boxplot(geom='errorbar', width = 0.2)+
    theme_bw() +
    geom_quasirandom(varwidth = TRUE, width= 0.3) +
    stat_summary(fun.y=mean, geom="point", shape=23, size=2.5, color="red", fill="red") +
    theme (
      axis.text.x = element_text(size=12),
      axis.text.y = element_text(size=12),
      axis.title.x = element_blank(),
      axis.title.y = element_text(size=12)) +
    geom_text_repel(aes(label = ifelse(.data[[myY]] > mean(.data[[myY]], na.rm=TRUE) + 2*sd(.data[[myY]], na.rm=TRUE)| .data[[myY]] < mean(.data[[myY]], na.rm=TRUE) - 2*sd(.data[[myY]], na.rm=TRUE),
                                 yes  = paste(Subject_ID),
                                 no   = '')),
              size=3,
              max.overlaps = Inf,   
              position= position_jitter(width = 0.2, seed = 2))
  
}

#### END #### 


# ------------------------------------------------------------------
# #### FUNCTION scatter_fun_spearman ####
# ------------------------------------------------------------------

  # -----------------------------------------------
  # INFO - SECTION
  # -----------------------------------------------
  # PURPOSE: This function creates Scatterplotts for x and y indices" 
  #   
  # INPUT: -x, y 
  #        - 
  # OUTPUT: .pdf with Scatterplots for Overview

# first create a funtion for scatterplots
scatter_fun_spearman = function(x, y) {

  ggplot(allData, aes(x = .data[[x]], y = .data[[y]]) ) +
    geom_point(shape=16, size=2) +
    theme_bw() +
    geom_smooth(method = lm, colour="red", se = TRUE, alpha=0.2) +
    labs(x = x, y = y) +
    theme (
      axis.title.x = element_text(size=9.8),
      axis.text.x = element_text(size=9.8),
      axis.title.y = element_text(size=9.8),
      axis.text.y = element_text(size=9.8)) +
    stat_cor(method = "spearman")+
    geom_text_repel(aes(label = ifelse(.data[[x]] > mean(.data[[x]], na.rm=TRUE) + 2*sd(.data[[x]], na.rm=TRUE)| .data[[x]] < mean(.data[[x]], na.rm=TRUE) - 2*sd(.data[[x]], na.rm=TRUE),
                                       yes  = paste(Subject_ID),
                                       no   = '')),
                    max.overlaps = Inf,
                    size = 3)
}

scatter_fun_pearson = function(x, y) {

  ggplot(allData, aes(x = .data[[x]], y = .data[[y]]) ) +
    geom_point(shape=16, size=2) +
    theme_bw() +
    geom_smooth(method = lm, colour="red", se = TRUE, alpha=0.2) +
    labs(x = x, y = y) +
    theme (
      axis.title.x = element_text(size=9.8),
      axis.text.x = element_text(size=9.8),
      axis.title.y = element_text(size=9.8),
      axis.text.y = element_text(size=9.8)) +
    stat_cor(method = "pearson")+
    geom_text_repel(aes(label = ifelse(.data[[x]] > mean(.data[[x]], na.rm=TRUE) + 2*sd(.data[[x]], na.rm=TRUE)| .data[[x]] < mean(.data[[x]], na.rm=TRUE) - 2*sd(.data[[x]], na.rm=TRUE),
                                       yes  = paste(Subject_ID),
                                       no   = '')),
                    max.overlaps = Inf,
                    size = 3)
}

scatter_fun_spearman_log = function(x, y) {

  ggplot(allData, aes(x = log(.data[[x]]), y = .data[[y]]) ) +
    geom_point(shape=16, size=2) +
    theme_bw() +
    geom_smooth(method = lm, colour="red", se = TRUE, alpha=0.2) +
    labs(x = x, y = y) +
    theme (
      axis.title.x = element_text(size=9.8),
      axis.text.x = element_text(size=9.8),
      axis.title.y = element_text(size=9.8),
      axis.text.y = element_text(size=9.8)) +
    stat_cor(method = "spearman")+
    geom_text_repel(aes(label = ifelse(.data[[x]] > mean(.data[[x]], na.rm=TRUE) + 2*sd(.data[[x]], na.rm=TRUE)| .data[[x]] < mean(.data[[x]], na.rm=TRUE) - 2*sd(.data[[x]], na.rm=TRUE),
                                       yes  = paste(Subject_ID),
                                       no   = '')),
                    max.overlaps = Inf,
                    size = 3)
}

scatter_fun_pearson_log = function(x, y) {

  ggplot(allData, aes(x = log(.data[[x]]), y = .data[[y]]) ) +
    geom_point(shape=16, size=2) +
    theme_bw() +
    geom_smooth(method = lm, colour="red", se = TRUE, alpha=0.2) +
    labs(x = x, y = y) +
    theme (
      axis.title.x = element_text(size=9.8),
      axis.text.x = element_text(size=9.8),
      axis.title.y = element_text(size=9.8),
      axis.text.y = element_text(size=9.8)) +
    stat_cor(method = "pearson")+
    geom_text_repel(aes(label = ifelse(.data[[x]] > mean(.data[[x]], na.rm=TRUE) + 2*sd(.data[[x]], na.rm=TRUE)| .data[[x]] < mean(.data[[x]], na.rm=TRUE) - 2*sd(.data[[x]], na.rm=TRUE),
                                       yes  = paste(Subject_ID),
                                       no   = '')),
                    max.overlaps = Inf,
                    size = 3)
}


# ------------------------------------------------------------------
# #### FUNCTION exclude Outliers ####
# ------------------------------------------------------------------

excludeOutliers <- function(dataVariable, stdThreshold) {
  dimdataVariable <- dim(dataVariable)
  
  if (length(dimdataVariable) == 2) {
    for (channel in 1:dim(dataVariable)[2]) {
      chanStd <- sd(dataVariable[, channel]) # Calculate Std per channel/column
      chanMean <- mean(dataVariable[, channel], na.rm = TRUE) # Calculate Mean per channel/column
      
      for (s in 1:dim(dataVariable)[1]) {
        if (!is.na(dataVariable[s, channel]) && abs(dataVariable[s, channel] - chanMean) > stdTreshold * chanStd) {
            dataVariable[s, channel] <- NA
        }
      }
    }
  } else {
    for (i in 1:dimdataVariable[3]) { # Loop along third dimension of dataVariable-Matrix
      for (channel in 1:dim(dataVariable)[2]) {
        chanStd <- sd(dataVariable[, channel, i]) # Calculate Std per channel/column
        chanMean <- mean(dataVariable[, channel, i],na.rm = TRUE) # Calculate Mean per channel/column
        
        for (s in 1:dim(dataVariable)[1]) {
          if (!is.na(dataVariable[s, channel,i]) && abs(dataVariable[s, channel,i] - chanMean) > stdTreshold * chanStd){
            dataVariable[s, channel, i] <- NA
          }
        }
      }
    }
  }
  
  return(dataVariable)
}

2.3 Load Data

Defining the Data set.

allData <- FunReadDataxlsxAfterMatlab(
  dataPathxlsx=file.path(params$pathDatatable), 
  dataFilename=params$xlsxNameallData)


otherDetails <-    
  read_excel(
      path = file.path(params$pathDatatable,
                       params$xlsxNameallData),
      sheet = 2
    )


###################################
#### Read Data Behaviors&Sleep ####
###################################

# This Dataset also includes RestingEEG-Data

#--------------------------------------------------
# read and prepare the data
#--------------------------------------------------
data <- read.csv(file.path(params$pathDatatable, params$fileBehaviorSleep), header = TRUE, sep = ";")
data$Subject_ID <- as.factor(data$Subject_ID)


# Exclude subjects with no or bad EEG and non-compliance with study-protocol
data <- data |>
  filter(General_inclusion != 0) 

data <- data |>
  filter(EEG_inclusion != 0) 


# Code Sex in binary format
data$sex_bin <- data$sex 


# Create Matrix with VP that have na in SleepParameters
data2 <- data |> 
  filter(EEG_sleepParameters ==1)

2.4 Define Subjects

2.4.1 Exclusion of participants

In total 62 subjects were collected; the following participants were excluded:

  • 2 Participants were excluded because of non-compliance to the study protocol
  • 6 Participants were excluded because of bad EEG-Quality
  • 6 Participants were excluded because they reported to regularly meditate*
  • 2 Participants were excluded because they had missing data in the FFMQ

= This results in 46 participants included for further analysis.

*We excluded the meditators form the sample, because previous literature has shown that people who meditate have an altered EEG pattern compared to people who do not meditate (Dentico et al., 2016; 2018; Ferrarelli et al., 2013; Pattanashetty et al., 2010).

##########################################
#### Analysis of the excluded Subjects ####
##########################################
exclude_subjects <- c(36, 40)

allDataMeditation <- allData |> 
  filter(Meditation1 == "Ja" & !(Subject_ID %in% exclude_subjects))

dataMeditation <- data |> 
  filter(Meditation1 == "Ja" & !(Subject_ID %in% exclude_subjects))

data2Meditation <- data2 |> 
  filter(Meditation1 == "Ja" & !(Subject_ID %in% exclude_subjects))

## Age of excluded Subjects 

# agerange
 range(allDataMeditation$age)

# mean age
 mean(allDataMeditation$age)

# standard deviation age
sd(allDataMeditation$age) / sqrt(length(allDataMeditation$age))


##########################
#### Exclude Subjects ####
##########################

allData <- allData |> 
  filter(Meditation1 == "Nein" & !(Subject_ID %in% exclude_subjects))

data <- data |> 
  filter(Meditation1 == "Nein" & !(Subject_ID %in% exclude_subjects))

data2 <- data2 |> 
  filter(Meditation1 == "Nein" & !(Subject_ID %in% exclude_subjects))

2.4.2 Descriptive statistics for the 46 participants included

2.4.2.1 age range

 range(allData$age)
## [1] 19 29

2.4.2.2 age mean

 mean(allData$age)
## [1] 21.56522

2.4.2.3 age standard deviation

 sd(allData$age) / sqrt(length(allData$age))
## [1] 0.3087331

2.4.2.4 gender of participants

table(allData$sex)
## 
## female   male 
##     24     22

3 First Overview

3.1 Looking at the complete Dataset

After reading in Data and excluding participants and merging with sleep Data we had collected behavior and sleep EEG Data from 46 participants.

The boxplots below provide a descriptive overview of gender, age and all questionnaire Data. In addition to displaying the median, the 25th and 75th percentiles, and the whiskers, the outliers are also displayed and the mean is shown in red.

4 Behavior - Overview

4.1 Behavioral variables of final dataset

As already mentioned, the short version of the FFMQ was used for the evaluation. Below is a behavioral overview with boxplots for the total score and the individual facets with the FFMQ_sf… variable used.

# Boxplots FFMQ
# - Totalscore
FFMQ_sf_totalmean <- 
  ggplot(allData, aes(x='', y=FFMQ_sf_all)) +
  geom_point(aes(), alpha=0.9, position='jitter', size=2) +
  geom_boxplot (outlier.color='red', outlier.size=4, alpha=0.3, width = 0.5) +  
  theme_bw () +
  ylab("Gesamtwert FFMQ-SF-D") +
  theme (
    axis.title.x = element_blank(),
    axis.text.x = element_blank(),
    axis.title.y = element_text(size=11),
    axis.text.y = element_text(size=11))+ 
  annotate("text", x=1, y=5.2, label=paste("Range:", as.character(round(min(allData$FFMQ_sf_all), digits = 2)), "-", as.character(round(max(allData$FFMQ_sf_all), digits =2)), sep=" "))
print(FFMQ_sf_totalmean) 

# - Subscales
# Non-judging
FFMQ_sf_AOB <- 
  ggplot(allData, aes(x='', y=FFMQ_sf_AOB)) +
  geom_point(aes(), alpha=0.9, position='jitter', size=2) +
  geom_boxplot (outlier.color='red', outlier.size=4, alpha=0.3, width = 0.5) +  
  theme_bw () +
  ylab("Nicht-Urteilen") +
  theme (
    axis.title.x = element_blank(),
    axis.text.x = element_blank(),
    axis.title.y = element_text(size=11),
    axis.text.y = element_text(size=11))+ 
  annotate("text", x=1, y=5.2, label=paste("Range:", as.character(round(min(allData$FFMQ_sf_AOB), digits = 2)), "-", as.character(round(max(allData$FFMQ_sf_AOB), digits =2)), sep=" "))
print(FFMQ_sf_AOB) 

# Observing
FFMQ_sf_BEO <- 
  ggplot(allData, aes(x='', y=FFMQ_sf_BEO)) +
  geom_point(aes(), alpha=0.9, position='jitter', size=2) +
  geom_boxplot (outlier.color='red', outlier.size=4, alpha=0.3, width = 0.5) +  
  theme_bw () +
  ylab("Beobachten") +
  theme (
    axis.title.x = element_blank(),
    axis.text.x = element_blank(),
    axis.title.y = element_text(size=11),
    axis.text.y = element_text(size=11))+ 
  annotate("text", x=1, y=5.2, label=paste("Range:", as.character(round(min(allData$FFMQ_sf_BEO), digits = 2)), "-", as.character(round(max(allData$FFMQ_sf_BEO), digits =2)), sep=" "))
print(FFMQ_sf_BEO) 

# Describing
FFMQ_sf_BES <- 
  ggplot(allData, aes(x='', y=FFMQ_sf_BES)) +
  geom_point(aes(), alpha=0.9, position='jitter', size=2) +
  geom_boxplot (outlier.color='red', outlier.size=4, alpha=0.3, width = 0.5) +  
  theme_bw () +
  ylab("Beschreiben") +
  theme (
    axis.title.x = element_blank(),
    axis.text.x = element_blank(),
    axis.title.y = element_text(size=11),
    axis.text.y = element_text(size=11))+ 
  annotate("text", x=1, y=5.2, label=paste("Range:", as.character(round(min(allData$FFMQ_sf_BES), digits = 2)), "-", as.character(round(max(allData$FFMQ_sf_BES), digits =2)), sep=" "))
print(FFMQ_sf_BES) 

# Acting with Awareness
FFMQ_sf_MAH <- 
  ggplot(allData, aes(x='', y=FFMQ_sf_MAH)) +
  geom_point(aes(), alpha=0.9, position='jitter', size=2) +
  geom_boxplot (outlier.color='red', outlier.size=4, alpha=0.3, width = 0.5) +  
  theme_bw () +
  ylab("Achtsames Handel") +
  theme (
    axis.title.x = element_blank(),
    axis.text.x = element_blank(),
    axis.title.y = element_text(size=11),
    axis.text.y = element_text(size=11))+ 
  annotate("text", x=1, y=5.2, label=paste("Range:", as.character(round(min(allData$FFMQ_sf_MAH), digits = 2)), "-", as.character(round(max(allData$FFMQ_sf_MAH), digits =2)), sep=" "))
print(FFMQ_sf_MAH) 

# Non-reactivity
FFMQ_sf_NIR <- 
  ggplot(allData, aes(x='', y=FFMQ_sf_NIR)) +
  geom_point(aes(), alpha=0.9, position='jitter', size=2) +
  geom_boxplot (outlier.color='red', outlier.size=4, alpha=0.3, width = 0.5) +  
  theme_bw () +
  ylab("Nicht-Reagieren") +
  theme (
    axis.title.x = element_blank(),
    axis.text.x = element_blank(),
    axis.title.y = element_text(size=11),
    axis.text.y = element_text(size=11))+ 
  annotate("text", x=1, y=5.2, label=paste("Range:", as.character(round(min(allData$FFMQ_sf_NIR), digits = 2)), "-", as.character(round(max(allData$FFMQ_sf_NIR), digits =2)), sep=" "))
print(FFMQ_sf_NIR) 

4.2 Histograms and Shapiro-Wilk of behavioral Data

Histograms and the Shapiro-Wilk test were prepared to check the normal distribution. In addition, the mean value and the standard deviation for the total score and the individual facets were calculated.

# Defining the range of the x-axis and y-axis so that the scaling is the same everywhere

x_range <- c(1, 5) # FFMQ-Scale is from 1 to 5
y_range <- c(0, 20)

# FFMQ_sf_all
hist(allData$FFMQ_sf_all, main="Histogramm Gesamtwert FFMQ-SF-D", xlab="Gesamtwert FFMQ-SF-D", xlim=x_range, ylim=y_range)

SW_all <- shapiro.test(allData$FFMQ_sf_all)
print(SW_all)
## 
##  Shapiro-Wilk normality test
## 
## data:  allData$FFMQ_sf_all
## W = 0.98633, p-value = 0.8591
print(paste("Mean Gesamtwert FFMQ-SF-D:", mean(allData$FFMQ_sf_all)))
## [1] "Mean Gesamtwert FFMQ-SF-D: 3.56702898550725"
print(paste ("SD Gesamtwert FFMQ-SF-D:", sd(allData$FFMQ_sf_all) / sqrt(length(allData$FFMQ_sf_all))))
## [1] "SD Gesamtwert FFMQ-SF-D: 0.0656254011166532"
# FFMQ_sf_AOB
hist(allData$FFMQ_sf_AOB, main="Histogramm Nicht-Urteilen", xlab="Nicht-Urteilen", xlim=x_range, ylim=y_range)

SW_AOB <- shapiro.test(allData$FFMQ_sf_AOB)
print(SW_AOB)
## 
##  Shapiro-Wilk normality test
## 
## data:  allData$FFMQ_sf_AOB
## W = 0.96967, p-value = 0.2692
print(paste("Mean Nicht-Urteilen:", mean(allData$FFMQ_sf_AOB)))
## [1] "Mean Nicht-Urteilen: 3.73478260869565"
print(paste ("SD Nicht-Urteilen:", sd(allData$FFMQ_sf_AOB) / sqrt(length(allData$FFMQ_sf_AOB))))
## [1] "SD Nicht-Urteilen: 0.109112245149607"
# FFMQ_sf_BEO
hist(allData$FFMQ_sf_BEO, main="Histogramm Beobachten", xlab="Beobachten", xlim=x_range, ylim=y_range)

SW_BEO <- shapiro.test(allData$FFMQ_sf_BEO)
print(SW_BEO)
## 
##  Shapiro-Wilk normality test
## 
## data:  allData$FFMQ_sf_BEO
## W = 0.96975, p-value = 0.2711
print(paste("Mean Beobachten:", mean(allData$FFMQ_sf_BEO)))
## [1] "Mean Beobachten: 3.70108695652174"
print(paste ("SD Beobachten:", sd(allData$FFMQ_sf_BEO) / sqrt(length(allData$FFMQ_sf_BEO))))
## [1] "SD Beobachten: 0.0947344257710521"
# FFMQ_sf_BES
hist(allData$FFMQ_sf_BES, main="Histogramm Beschreiben", xlab="Beschreiben", xlim=x_range, ylim=y_range)

SW_BES <- shapiro.test(allData$FFMQ_sf_BES)
print(SW_BES)
## 
##  Shapiro-Wilk normality test
## 
## data:  allData$FFMQ_sf_BES
## W = 0.98088, p-value = 0.6421
print(paste("Mean Beschreiben:", mean(allData$FFMQ_sf_BES)))
## [1] "Mean Beschreiben: 3.64347826086957"
print(paste ("SD Beschreiben:", sd(allData$FFMQ_sf_BES) / sqrt(length(allData$FFMQ_sf_BES))))
## [1] "SD Beschreiben: 0.0942630799961871"
# FFMQ_sf_MAH
hist(allData$FFMQ_sf_MAH, main="Histogramm Achtsames Handeln", xlab="Achtsames Handeln", xlim=x_range, ylim=y_range)

SW_MAH <- shapiro.test(allData$FFMQ_sf_MAH)
print(SW_MAH)
## 
##  Shapiro-Wilk normality test
## 
## data:  allData$FFMQ_sf_MAH
## W = 0.95909, p-value = 0.1057
print(paste("Mean Achtsames Handeln:", mean(allData$FFMQ_sf_MAH)))
## [1] "Mean Achtsames Handeln: 3.61739130434783"
print(paste ("SD Achtsames Handeln:", sd(allData$FFMQ_sf_MAH) / sqrt(length(allData$FFMQ_sf_MAH))))
## [1] "SD Achtsames Handeln: 0.0934215084435355"
# FFMQ_sf_NIR
hist(allData$FFMQ_sf_NIR, main="Histogramm Nicht-Reagieren", xlab="Nicht-Reagieren", xlim=x_range, ylim=y_range)

SW_NIR <- shapiro.test(allData$FFMQ_sf_NIR)
print(SW_NIR)
## 
##  Shapiro-Wilk normality test
## 
## data:  allData$FFMQ_sf_NIR
## W = 0.96402, p-value = 0.1642
print(paste("Mean Nicht-Reagieren:", mean(allData$FFMQ_sf_NIR)))
## [1] "Mean Nicht-Reagieren: 3.16521739130435"
print(paste ("SD Nicht-Reagieren:", sd(allData$FFMQ_sf_NIR) / sqrt(length(allData$FFMQ_sf_NIR))))
## [1] "SD Nicht-Reagieren: 0.100107063040394"

5 SWA & total score FFMQ-SF-D

5.1 Overview with Scatterplot

A Pearson correlation was carried out in the main analysis. To provide an overview, scatterplots were first created to show the correlation of the individual electrodes with the overall FFMQ-SF-D score (Gesmatwert FFMQ-SF-D). The normalized power (nPower) for the activity at the respective electrodes is displayed on the x-axis, while the total FFMQ-SF-D score is shown on the y-axis.

A total of 66 electrodes were recorded, seven of which were used exclusively for sleep stage classification; therefore, no correlation is visible for these in the scatterplots.

5.2 Topography Gesamtwert FFMQ-SF-D

Then, a topography of the “Gesamtwert FFMQ-SF-D” was generated using Matlab. The results show a significant parietal Cluster that remains after correcting for multiple comparisons. The thick black dots represent the electrodes with a significant correlation.

In the topography figures, the logarithmized SWA is shown on the left, while the correlation of this SWA with the “Gesamtwert FFMQ-SF-D” is shown on the right.

  • Significant electrodes: POz, Pz, CPz, Cp2, P2, PO4, P6

5.3 Scatterplot Gesamtwert FFMQ-SF-D vs. parietal Cluster

A scatterplot of the significant parietal Cluster for the “Gesamtwert FFMQ-SF-D” was then created.

#-------------------------------------------------------
# Significant for parietal Cluster
#-------------------------------------------------------
# Calculate mean SWA over parietal Cluster 
# Significant Electrodes: POz, Pz, CPz, CP2, P2, PO4, P6 

meanSWA <- cbind(log(data$nSWA_POz), log(data$nSWA_Pz), log(data$nSWA_CPz), log(data$nSWA_CP2), log(data$nSWA_P2), log(data$nSWA_PO4), log(data$nSWA_P6))
data$meanSWA <- rowMeans(meanSWA, na.rm = TRUE)

# Scatter over significant Electrodes 
meanSWA.scatter <- 
  ggplot(data, aes(x = meanSWA, y = FFMQ_sf_all)) +
  geom_point(shape=16, size=2) +
  theme_bw() +
  geom_smooth(method = lm, colour="red", se = TRUE, alpha=0.2) +
  theme (
    axis.title.x = element_text(size=15),
    axis.text.x = element_text(size=15),
    axis.title.y = element_text(size=15),
    axis.text.y = element_text(size=15),
    panel.grid.major = element_blank(),
    panel.grid.minor = element_blank()) +
  ylim(0, 6) + 
  ylab("FFMQ-SF-D Gesamtwert") +
  xlab("SWA über parietalem Cluster (log)") +
  stat_cor(aes(label = paste(..r.label.., ..p.label.., ..rr.label.., sep = "~`,`~")), method = "pearson", r.accuracy = 0.01,  p.accuracy = 0.00001, alternative = "two.sided", size = 5)+
  geom_text_repel(aes(label = ifelse(meanSWA > mean(meanSWA, na.rm=TRUE) + 3*sd(meanSWA, na.rm=TRUE) | meanSWA < mean(meanSWA, na.rm=TRUE) - 3*sd(meanSWA, na.rm=TRUE),
                                     yes = paste(Subject_ID),
                                     no = '')),
                  max.overlaps = Inf,
                  size = 3) # Outlier SWA

setwd(params$pathResults)
jpeg("meanSWA_Sign_parietalCluster_FFMQ_sf_all_46Vpn_FIGUREforMA.jpg", width=10, height=10, units="cm", res=300) # FILENAME entsprechend logisch anpassen 
print(meanSWA.scatter)
plot(meanSWA.scatter) 

5.4 Localization of the significant parietal Cluster

Finally, the determination of the intracortical origin of the electrode activity was calculated using the sLORETA software.

red = voxel with significance p < 0.1

yellow = voxel with r > 0.4

6 SWA & FFMQ-Facet

6.1 “Nicht-Urteilen”

6.1.1 Overview with Scatterplot

A Pearson correlation was carried out in the main analysis. To provide an overview, scatterplots were first created to show the correlation of the individual electrodes with the facet “Nicht-Urteilen”. The normalized power (nPower) for the activity at the respective electrodes is displayed on the x-axis, while value of the facet “Nicht-Urteilen” is shown on the y-axis.

A total of 66 electrodes were recorded, seven of which were used exclusively for sleep stage classification; therefore, no correlation is visible for these in the scatterplots.

6.1.2 Topography “Nicht-Urteilen”

Then, a topography of the facet “Nicht-Urteilen” was generated using Matlab. The results show a significant frontal Cluster that remains after correcting for multiple comparisons. The thick black dots represent the electrodes with a significant correlation.

In the topography figures, the logarithmized SWA is shown on the left, while the correlation of this SWA with the facet “Nicht-Urteilen” is shown on the right.

  • Significant electrodes: Fp1, Fpz, Fp2, AFz, AF4, Fz, F2

6.1.3 Scatterplot “Nicht-Urteilen” vs. frontal Cluster

A scatterplot of the significant frontal Custer for the facet “Nicht-Urteilen” was then created.

#-------------------------------------------------------
# Significant for frontal Cluster
#-------------------------------------------------------
# Calculate mean SWA over frontal Cluster
# Significant Electrodes: Fp1, Fpz, Fp2, AFz, AF4, Fz, F2

meanSWA <- cbind(log(data$nSWA_Fp1), log(data$nSWA_Fpz), log(data$nSWA_Fp2), log(data$nSWA_AFz), log(data$nSWA_AF4), log(data$nSWA_Fz), log(data$nSWA_F2))
data$meanSWA <- rowMeans(meanSWA, na.rm=T)


# Scatter over significant Electrodes 
meanSWA.scatter <- 
  ggplot(data, aes(x = meanSWA, y = FFMQ_sf_AOB)) +
  geom_point(shape=16, size=2) +
  theme_bw() +
  geom_smooth(method = lm, colour="red", se = TRUE, alpha=0.2) +
  theme (
    axis.title.x = element_text(size=15),
    axis.text.x = element_text(size=15),
    axis.title.y = element_text(size=15),
    axis.text.y = element_text(size=15),
    panel.grid.major = element_blank(),
    panel.grid.minor = element_blank())+
  ylim(0,6)+ 
  ylab("Nicht-Urteilen")+
  xlab("SWA über frontalem Cluster (log)")+
  stat_cor(aes(label = paste(..r.label.., ..p.label.., ..rr.label.., sep = "~`,`~")), method = "pearson", r.accuracy = 0.01,  p.accuracy = 0.00001, alternative = "two.sided", size = 5)+
  geom_text_repel(aes(label = ifelse(meanSWA > mean(meanSWA, na.rm=TRUE) + 3*sd(meanSWA, na.rm=TRUE)| meanSWA < mean(meanSWA, na.rm=TRUE) - 3*sd(meanSWA, na.rm=TRUE),
                                     yes  = paste(Subject_ID),
                                     no   = '')),
                  max.overlaps = Inf,
                  size = 3) # Outlier SWA


setwd(params$pathResults)
jpeg("meanSWA_Sign_frontal_FFMQ_sf_AOB_46Vpn_FiguresforMA.jpg", width=10, height=10, units="cm", res=300) # FILENAME entsprechend logisch anpassen 
print(meanSWA.scatter)
print(meanSWA.scatter)

6.1.4 Localization of the significant frontal Cluster

Finally, the determination of the intracortical origin of the electrode activity was calculated using the sLORETA software.

blue = voxel with significance p < 0.1

yellow = voxel with r < −0.4

6.2 “Beobachten”

6.2.1 Overview with Scatterplot

A Pearson correlation was carried out in the main analysis. To provide an overview, scatterplots were first created to show the correlation of the individual electrodes with the facet “Beobachten”. The normalized power (nPower) for the activity at the respective electrodes is displayed on the x-axis, while value of the facet “Beobachten” is shown on the y-axis.

A total of 66 electrodes were recorded, seven of which were used exclusively for sleep stage classification; therefore, no correlation is visible for these in the scatterplots.

6.2.2 Topography “Beobachten”

Then, a topography of the facet “Beobachten” was generated using Matlab. The results show no significant Cluster that remains after correcting for multiple comparisons. In the topography figures, the logarithmized SWA is shown on the left, while the correlation of this SWA with the facet “Beobachten” is shown on the right.

No thick black dots are visible, as no electrodes show a significant correlation. Consequently, no further scatterplot was created, and no infracortical origin determination was performed using sLORETA.

6.3 “Beschreiben”

6.3.1 Overview with Scatterplot

A Pearson correlation was carried out in the main analysis. To provide an overview, scatterplots were first created to show the correlation of the individual electrodes with the facet “Beschreiben”. The normalized power (nPower) for the activity at the respective electrodes is displayed on the x-axis, while value of the facet “Beschreiben” is shown on the y-axis.

A total of 66 electrodes were recorded, seven of which were used exclusively for sleep stage classification; therefore, no correlation is visible for these in the scatterplots.

6.3.2 Topography “Beschreiben”

Then, a topography of the facet “Beschreiben” was generated using Matlab. The results show a significant parietal Cluster that remains after correcting for multiple comparisons. The thick black dots represent the electrodes with a significant correlation.

In the topography figures, the logarithmized SWA is shown on the left, while the correlation of this SWA with the facet “Beschreiben” is shown on the right.

  • significant electrodes: P3, P1, Pz, P2, CP1, CPz, CP2, C2

6.3.3 Scatterplot “Beschreiben” vs. parietal Cluster

A scatterplot of the significant parietal Cluster for the facet “Beschreiben” was then created.

#-------------------------------------------------------
# Significant for parietal Cluster
#-------------------------------------------------------
# Calculate mean SWA over parietal Cluster
# Significant Electrodes: P3, P1, Pz, P2, CP1, CPz, CP2, C2

meanSWA <- cbind(log(data$nSWA_P3), log(data$nSWA_P1), log(data$nSWA_Pz), 
                 log(data$nSWA_P2), log(data$nSWA_CP1), log(data$nSWA_CPz),
                 log(data$nSWA_CP2), log(data$nSWA_C2))
data$meanSWA <- rowMeans(meanSWA, na.rm=T)


# Scatter over significant Electrodes 
meanSWA.scatter <- 
  ggplot(data, aes(x = meanSWA, y = FFMQ_sf_BES)) +
  geom_point(shape=16, size=2) +
  theme_bw() +
  geom_smooth(method = lm, colour="red", se = TRUE, alpha=0.2) +
  theme (
    axis.title.x = element_text(size=15),
    axis.text.x = element_text(size=15),
    axis.title.y = element_text(size=15),
    axis.text.y = element_text(size=15),
    panel.grid.major = element_blank(),
    panel.grid.minor = element_blank())+
  ylim(0,6)+ 
  ylab("Beschreiben")+
  xlab("SWA über parietalem Cluster (log)")+
  stat_cor(aes(label = paste(..r.label.., ..p.label.., ..rr.label.., sep = "~`,`~")), method = "pearson", r.accuracy = 0.01,  p.accuracy = 0.00001, alternative = "two.sided", size = 5)+
  geom_text_repel(aes(label = ifelse(meanSWA > mean(meanSWA, na.rm=TRUE) + 3*sd(meanSWA, na.rm=TRUE)| meanSWA < mean(meanSWA, na.rm=TRUE) - 3*sd(meanSWA, na.rm=TRUE),
                                     yes  = paste(Subject_ID),
                                     no   = '')),
                  max.overlaps = Inf,
                  size = 3) # Outlier SWA

setwd(params$pathResults)
jpeg("meanSWA_Sign_parietalCluster_FFMQ_sf_BES_46Vpn_FiguresforMA.jpg", width=10, height=10, units="cm", res=300) # FILENAME entsprechend logisch anpassen 
print(meanSWA.scatter)
plot(meanSWA.scatter) 

6.3.4 Localization of the significant parietal Cluster

Finally, the determination of the intracortical origin of the electrode activity was calculated using the sLORETA software.

green = voxel with r > 0.4

6.4 “Achtsames Handeln”

6.4.1 Overview with Scatterplot

A Pearson correlation was carried out in the main analysis. To provide an overview, scatterplots were first created to show the correlation of the individual electrodes with the facet “Achtsames Handeln”. The normalized power (nPower) for the activity at the respective electrodes is displayed on the x-axis, while value of the facet “Achtsames Handeln” is shown on the y-axis.

A total of 66 electrodes were recorded, seven of which were used exclusively for sleep stage classification; therefore, no correlation is visible for these in the scatterplots.

6.4.2 Tophography “Achtsames Handeln”

Then, a topography of the facet “Achtsames Handeln” was generated using Matlab. The results show no significant cluster that remains after correcting for multiple comparisons. In the topography figures, the logarithmized SWA is shown on the left, while the correlation of this SWA with the facet “Achtsames Handeln” is shown on the right.

No thick black dots are visible, as no electrodes show a significant correlation. Consequently, no further scatterplot was created, and no infracortical origin determination was performed using sLORETA.

6.5 “Nicht-Reagieren”

6.5.1 Overview with Scatterplot

A Pearson correlation was carried out in the main analysis. To provide an overview, scatterplots were first created to show the correlation of the individual electrodes with the facet “Nicht-Reagieren”. The normalized power (nPower) for the activity at the respective electrodes is displayed on the x-axis, while value of the facet “Nicht-Reagieren” is shown on the y-axis.

A total of 66 electrodes were recorded, seven of which were used exclusively for sleep stage classification; therefore, no correlation is visible for these in the scatterplots.

6.5.2 Topography “Nicht-Reagieren”

Then, a topography of the facet “Nicht-Reagieren” was generated using Matlab. The results show no significant cluster that remains after correcting for multiple comparisons. In the topography figures, the logarithmized SWA is shown on the left, while the correlation of this SWA with the facet “Nicht-Reagieren” is shown on the right.

No thick black dots are visible, as no electrodes show a significant correlation. Consequently, no further scatterplot was created, and no infracortical origin determination was performed using sLORETA.