-
Notifications
You must be signed in to change notification settings - Fork 2
/
Script_to_generate_heart_rate_for_meta_analysis.R
100 lines (69 loc) · 3.38 KB
/
Script_to_generate_heart_rate_for_meta_analysis.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Script to generate heart rate files for the meta-analysis by König et al
# Hands
setwd("~/Box Sync/Sleepy Brain/Datafiles")
# Import pulse gating data
PgDataHands <- read.csv("HR/PgDataHandsSessionInfo_86subjects.csv", sep=";")
#Generate a column for time between two pulse registrations
PgDataHands$DeltaTimePulse <- PgDataHands$V1
PgDataHands$DeltaTimePulse <- (c(PgDataHands$V1, 0)-c(0, PgDataHands$V1))[1:length(PgDataHands$Subject)]
# Check registrations
plot(PgDataHands$DeltaTimePulse)
# Clean up false values (<0) and check again
PgDataHands$DeltaTimePulse[PgDataHands$DeltaTimePulse<0] <- NA
plot(PgDataHands$DeltaTimePulse ~ PgDataHands$Subject)
# Generate a column for subjects' heart rate
PgDataHands$HR <- 6000/PgDataHands$DeltaTimePulse
PgDataHands <- subset(PgDataHands, DeprivationCondition == "NotSleepDeprived")
PgDataHands <- PgDataHands[ ,c(1, 3, 7:8)]
subjectlist <- read.csv("~/Box Sync/Sleepy Brain/Datafiles/Subjects_151215.csv", sep=";")
Data <- merge(PgDataHands, subjectlist[, c("Subject", "newid")])
Data <- subset(Data, select = -c(Subject))
names(Data)[2] <- "IBI"
names(Data)[4] <- "Subject"
Data <- Data[order(Data$Subject), ]
write.csv2(Data, "~/Desktop/Pulse_empathy.csv", row.names = F)
# Script to generate heart rate files for the meta-analysis by König et al
# FACES
setwd("~/Box Sync/Sleepy Brain/Datafiles")
# Import pulse gating data
PgDataFACES <- read.csv("HR/PgDataFACESSessionInfo.csv", sep=";")
#Generate a column for time between two pulse registrations
PgDataFACES$DeltaTimePulse <- PgDataFACES$V1
PgDataFACES$DeltaTimePulse <- (c(PgDataFACES$V1, 0)-c(0, PgDataFACES$V1))[1:length(PgDataFACES$Subject)]
# Check registrations
plot(PgDataFACES$DeltaTimePulse)
# Clean up false values (<0) and check again
PgDataFACES$DeltaTimePulse[PgDataFACES$DeltaTimePulse<0] <- NA
plot(PgDataFACES$DeltaTimePulse ~ PgDataFACES$Subject)
# Generate a column for subjects' heart rate
PgDataFACES$HR <- 6000/PgDataFACES$DeltaTimePulse
PgDataFACES <- subset(PgDataFACES, DeprivationCondition == "NotSleepDeprived")
PgDataFACES <- PgDataFACES[ ,c(1, 3, 7:8)]
Data <- merge(PgDataFACES, subjectlist[, c("Subject", "newid")])
Data <- subset(Data, select = -c(Subject))
names(Data)[2] <- "IBI"
names(Data)[4] <- "Subject"
Data <- Data[order(Data$Subject), ]
write.csv2(Data, "~/Desktop/Pulse_mimicry.csv", row.names = F)
# ARROWS
setwd("~/Box Sync/Sleepy Brain/Datafiles")
# Import pulse gating data
PgDataARROWS <- read.csv("HR/PgDataARROWSSessionInfo.csv", sep=";")
#Generate a column for time between two pulse registrations
PgDataARROWS$DeltaTimePulse <- PgDataARROWS$V1
PgDataARROWS$DeltaTimePulse <- (c(PgDataARROWS$V1, 0)-c(0, PgDataARROWS$V1))[1:length(PgDataARROWS$Subject)]
# Check registrations
plot(PgDataARROWS$DeltaTimePulse)
# Clean up false values (<0) and check again
PgDataARROWS$DeltaTimePulse[PgDataARROWS$DeltaTimePulse<0] <- NA
plot(PgDataARROWS$DeltaTimePulse ~ PgDataARROWS$Subject)
# Generate a column for subjects' heart rate
PgDataARROWS$HR <- 6000/PgDataARROWS$DeltaTimePulse
PgDataARROWS <- subset(PgDataARROWS, DeprivationCondition == "NotSleepDeprived")
PgDataARROWS <- PgDataARROWS[ ,c(1, 3, 7:8)]
Data <- merge(PgDataARROWS, subjectlist[, c("Subject", "newid")])
Data <- subset(Data, select = -c(Subject))
names(Data)[2] <- "IBI"
names(Data)[4] <- "Subject"
Data <- Data[order(Data$Subject), ]
write.csv2(Data, "~/Desktop/Pulse_reappraisal.csv", row.names = F)