Skip to content

Commit af92bad

Browse files
author
Nicolas Marc Simon Legrand
committed
Add Heart rate discrimination task
1 parent dda65ca commit af92bad

File tree

203 files changed

+2731
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

203 files changed

+2731
-2
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
# cardioception
2-
Cardioception Python Package - Behavioral battery to measure interoceptive individual performance
1+
# Cardioception
2+
Cardioception Python Package - Measuring interoceptive performance with Psychopy
3+
4+
# Tasks
5+
6+
# Analyses

cardioception/HeartRateDiscrimination/Analyses.ipynb

Lines changed: 1439 additions & 0 deletions
Large diffs are not rendered by default.
Loading
Loading
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
,Condition,Estimation,EstimationRT,Confidence,ConfidenceRT,Alpha,HR,Accuracy,nTrials
2+
0,Less,down,3.5959447999921395,,,-30,159,1,1
3+
1,More,up,2.1836129000002984,,,20,148,1,2
4+
2,More,down,3.6447859999898355,,,10,117,0,3
5+
3,Less,down,3.016804700004286,,,-15,138,1,4
6+
4,More,up,2.730346600001212,,,14,128,1,5
7+
5,Less,up,3.155651900000521,,,-13,127,0,6
8+
6,Less,down,4.047970400002669,,,-13,119,1,7
9+
7,More,down,3.8456051999964984,,,12,112,0,8
10+
8,Less,down,3.210338699995191,,,-12,110,1,9
11+
9,Less,down,4.608484900003532,,,-11,114,1,10
12+
10,Less,down,3.429933399995207,,,-10,111,1,11
13+
11,Less,down,3.9858021999971243,,,-9,109,1,12
14+
12,Less,down,3.600019000004977,,,-8,106,1,13
15+
13,Less,down,3.480336199994781,,,-7,105,1,14
16+
14,Less,up,3.3353012000006856,,,-6,111,0,15
17+
15,More,up,3.086833800000022,,,6,105,1,16
18+
16,Less,up,3.4640815000020666,,,-5,104,0,17
19+
17,More,up,3.280511100005242,,,5,103,1,18
20+
18,More,up,3.0359601999953156,,,4,107,1,19
21+
19,More,up,3.1955114000011235,,,3,105,1,20
22+
20,Less,up,3.2500035999983083,,,-2,103,0,21
23+
21,More,up,3.2739302000118187,,,2,102,1,22
24+
22,Less,up,3.353206100000534,,,-1,100,0,23
25+
23,More,down,3.5233325000008335,,,1,99,0,24
26+
24,Less,down,3.4503172999975504,,,-2,99,1,25
27+
25,More,up,3.9849517999973614,,,1,105,1,26
28+
26,More,down,3.082807099999627,,,1,102,0,27
29+
27,More,up,3.9992371999978786,,,1,102,1,28
30+
28,More,down,3.621647699997993,,,1,98,0,29
31+
29,More,down,3.6857683999987785,,,1,96,0,30
32+
30,More,down,3.318129199993564,,,2,98,0,31
33+
31,Less,up,3.732014799999888,,,-2,100,0,32
34+
32,Less,up,4.132532000003266,,,-3,101,0,33
35+
33,Less,down,3.715942199996789,,,-3,100,1,34
36+
34,Less,up,3.4214611999923363,,,-2,101,0,35
37+
35,Less,up,3.3630372999905376,,,-2,105,0,36
38+
36,More,up,4.077684499992756,,,3,101,1,37
39+
37,More,up,2.5979426999983843,,,2,115,1,38
40+
38,More,up,3.330186400009552,,,1,99,1,39
41+
39,Less,down,3.314331800007494,,,-1,97,1,40
42+
40,More,up,4.048904700001003,,,1,100,1,41
43+
41,Less,down,3.4913971000059973,,,-1,100,1,42
44+
42,Less,down,4.090169500006596,,,-1,100,1,43
45+
43,Less,down,3.2505117999971844,,,-1,101,1,44
46+
44,Less,up,3.453578300002846,,,-1,104,0,45
47+
45,More,up,3.689128099998925,,,1,101,1,46
48+
46,Less,up,3.0590823000093224,,,-1,99,0,47
49+
47,Less,down,3.346567899992806,,,-1,98,1,48
50+
48,More,down,3.9950571000081254,,,1,99,0,49
51+
49,More,up,3.7892972999979975,,,1,101,1,50
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[.ShellClassInfo]
2+
InfoTip=This folder is shared online.
3+
IconFile=C:\Program Files\Google\Drive\googledrivesync.exe
4+
IconIndex=16
5+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
,Condition,Estimation,EstimationRT,Confidence,ConfidenceRT,Alpha,HR,Accuracy,nTrials
2+
0,More,up,1.7114151999994647,,,30,78,1,1
3+
1,More,up,1.8081491999910213,,,20,68,1,2
4+
2,Less,up,3.539960499998415,,,-10,75,0,3
5+
3,More,up,1.874391100005596,,,15,68,1,4
6+
4,More,up,2.19410350000544,,,15,68,1,5
7+
5,More,up,2.850148600002285,,,14,68,1,6
8+
6,More,up,2.146785100005218,,,14,65,1,7
9+
7,More,up,2.582747600012226,,,13,69,1,8
10+
8,Less,up,4.877265000002808,,,-13,67,0,9
11+
9,More,up,1.5489697000011802,,,14,79,1,10
12+
10,Less,down,5.288358000005246,,,-14,66,1,11
13+
11,More,up,1.8755052000051364,,,13,67,1,12
14+
12,More,up,1.9999970999924699,,,13,71,1,13
15+
13,More,up,1.798217499992461,,,12,68,1,14
16+
14,More,up,3.4538143999961903,,,12,67,1,15
17+
15,Less,up,4.8844231999974,,,-11,67,0,16
18+
16,More,up,3.217056399997091,,,12,68,1,17
19+
17,More,up,1.8643901000032201,,,12,68,1,18
20+
18,More,up,4.283299499991699,,,11,72,1,19
21+
19,Less,down,6.282484600000316,,,-11,72,1,20
22+
20,More,up,2.199039700004505,,,10,69,1,21
23+
21,More,up,2.6189392000087537,,,10,80,1,22
24+
22,Less,up,5.9050358000095,,,-9,73,0,23
25+
23,More,up,1.9348903999925824,,,10,70,1,24
26+
24,More,up,1.9091025000088848,,,10,66,1,25
27+
25,Less,down,3.6022142000001622,,,-9,69,1,26
28+
26,Less,down,3.919948900002055,,,-9,68,1,27
29+
27,More,up,3.19549480000569,,,8,68,1,28
30+
28,More,up,3.295343199992203,,,8,68,1,29
31+
29,Less,up,5.493644100002712,,,-7,66,0,30
32+
30,Less,down,4.643800999998348,,,-8,66,1,31
33+
31,Less,up,2.226581499999156,,,-8,74,0,32
34+
32,More,up,2.0335067999985768,,,9,64,1,33
35+
33,Less,down,5.614680600003339,,,-9,64,1,34
36+
34,Less,up,3.558217700003297,,,-8,69,0,35
37+
35,Less,down,5.913405200000852,,,-9,74,1,36
38+
36,More,up,1.9813461000012467,,,9,71,1,37
39+
37,More,up,1.8935601999983191,,,8,68,1,38
40+
38,More,up,2.8582323000009637,,,8,68,1,39
41+
39,Less,down,2.0403537999955006,,,-7,68,1,40
42+
40,Less,down,3.8591592000011588,,,-7,70,1,41
43+
41,Less,down,2.410488699999405,,,-6,71,1,42
44+
42,Less,down,3.627759099996183,,,-6,70,1,43
45+
43,More,up,2.243277300003683,,,5,74,1,44
46+
44,More,up,2.5089002000022447,,,5,76,1,45
47+
45,Less,down,2.7039969000034034,,,-4,71,1,46
48+
46,Less,down,3.280268200003775,,,-4,70,1,47
49+
47,Less,up,3.2521186000085436,,,-3,69,0,48
50+
48,More,up,2.0251513000112027,,,4,73,1,49
51+
49,Less,up,4.222423699990031,,,-4,71,0,50
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
,Condition,Estimation,EstimationRT,Confidence,ConfidenceRT,Alpha,HR,Accuracy,nTrials
2+
0,Less,down,1.510346999988542,,,-30,75,1,1
3+
1,Less,down,1.507550900001661,,,-20,53,1,2
4+
2,Less,down,3.0094727000105195,,,-10,55,1,3
5+
3,Less,down,3.1377387999964412,,,-1,49,1,4
6+
4,Less,down,3.853005099997972,,,-1,52,1,5
7+
5,More,up,4.118184699997073,,,1,54,1,6
8+
6,More,down,2.7887380000029225,,,1,49,0,7
9+
7,More,up,3.1805986000108533,,,6,50,1,8
10+
8,Less,down,2.2743476999894483,,,-5,50,1,9
11+
9,Less,down,4.437297700002091,,,-4,55,1,10
12+
10,Less,up,3.9986504999978933,,,-3,58,0,11
13+
11,Less,down,2.743711000002804,,,-3,55,1,12
14+
12,Less,up,2.5991987000015797,,,-2,63,0,13
15+
13,Less,down,1.6778956000052858,,,-2,50,1,14
16+
14,Less,down,4.048448300003656,,,-1,49,1,15
17+
15,More,up,2.76331829999981,,,1,66,1,16
18+
16,More,down,5.073765500012087,,,1,50,0,17
19+
17,Less,down,3.9299887999950442,,,-1,52,1,18
20+
18,Less,up,3.755412599988631,,,-1,55,0,19
21+
19,More,up,2.949109999986831,,,1,67,1,20
22+
20,Less,up,1.8955512999964412,,,-1,69,0,21
23+
21,Less,down,2.1670729000034044,,,-1,56,1,22
24+
22,More,down,3.5391518999967957,,,1,50,0,23
25+
23,More,up,2.930058400001144,,,1,58,1,24
26+
24,Less,up,4.13950420000765,,,-1,55,0,25
27+
25,More,down,3.201377599994885,,,1,52,0,26
28+
26,Less,up,2.818684400001075,,,-2,56,0,27
29+
27,Less,up,3.555358099998557,,,-2,58,0,28
30+
28,Less,up,1.7636731999955373,,,-3,62,0,29
31+
29,More,up,2.4357507999957306,,,3,57,1,30
32+
30,Less,up,3.1263631000038004,,,-2,65,0,31
33+
31,More,up,2.5269900999992387,,,2,57,1,32
34+
32,More,down,5.422566499997629,,,1,47,0,33
35+
33,More,down,1.8967797000077553,,,1,51,0,34
36+
34,More,down,4.151314899994759,,,2,50,0,35
37+
35,More,up,2.8914598999981536,,,2,54,1,36
38+
36,More,up,4.135323199996492,,,1,61,1,37
39+
37,More,up,3.853812300003483,,,1,57,1,38
40+
38,More,down,4.76447460000054,,,1,55,0,39
41+
39,More,up,4.706588200002443,,,1,58,1,40
42+
40,Less,up,5.6506989000045,,,-1,55,0,41
43+
41,More,up,4.060947099991608,,,1,54,1,42
44+
42,Less,down,5.2732460999977775,,,-1,52,1,43
45+
43,More,up,1.7201631999923848,,,1,70,1,44
46+
44,Less,down,2.691788900003303,,,-1,54,1,45
47+
45,More,down,4.955210200001602,,,1,54,0,46
48+
46,More,down,3.476337900006911,,,1,52,0,47
49+
47,More,down,2.4699725000100443,,,2,55,0,48
50+
48,More,down,3.218724200007273,,,2,57,0,49
51+
49,More,up,3.1852923999977065,,,3,59,1,50
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
,Condition,Estimation,EstimationRT,Confidence,ConfidenceRT,Alpha,HR,Accuracy,nTrials
2+
0,More,up,2.3073464000044623,,,30,69,1,1
3+
1,Less,down,1.5777393000025768,,,-20,65,1,2
4+
2,Less,down,1.357326199999079,,,-10,64,1,3
5+
3,Less,down,1.4416472000011709,,,-1,65,1,4
6+
4,More,down,1.3300755999953253,,,1,65,0,5
7+
5,More,down,1.211751099996036,,,6,64,0,6
8+
6,Less,down,1.4654580999922473,,,-6,65,1,7
9+
7,Less,down,1.3901324999897042,,,-5,64,1,8
10+
8,More,up,1.9045867999957409,,,4,61,1,9
11+
9,Less,up,1.9080711999995401,,,-3,62,0,10
12+
10,Less,down,1.2479013999982271,,,-3,62,1,11
13+
11,More,down,1.2154370000062045,,,2,63,0,12
14+
12,Less,down,1.3195408999890788,,,-2,62,1,13
15+
13,More,down,1.2629259999957867,,,1,65,0,14
16+
14,Less,up,2.001203899999382,,,-1,63,0,15
17+
15,Less,down,1.1763977999944473,,,-2,64,1,16
18+
16,Less,down,1.312648099992657,,,-1,64,1,17
19+
17,More,down,1.5112512999912724,,,1,61,0,18
20+
18,More,up,1.5859256999974605,,,1,62,1,19
21+
19,Less,up,2.399382000003243,,,-1,63,0,20
22+
20,Less,up,1.5934769000014057,,,-1,63,0,21
23+
21,Less,down,1.265954900009092,,,-2,65,1,22
24+
22,More,down,1.5329855000018142,,,1,66,0,23
25+
23,More,up,1.4456377000024077,,,1,69,1,24
26+
24,More,up,1.6744979999930365,,,1,69,1,25
27+
25,More,down,1.3824246000003768,,,1,67,0,26
28+
26,More,down,1.3830794999958016,,,1,68,0,27
29+
27,Less,up,2.0032840999920154,,,-2,65,0,28
30+
28,More,down,1.536412499990547,,,2,67,0,29
31+
29,Less,up,1.8234842999954708,,,-3,72,0,30
32+
30,More,up,1.87523799999326,,,3,70,1,31
33+
31,More,up,1.2678101999918,,,2,71,1,32
34+
32,Less,up,1.54614489999949,,,-1,74,0,33
35+
33,More,down,1.165429700005916,,,1,71,0,34
36+
34,Less,down,2.313169100001687,,,-2,67,1,35
37+
35,More,up,2.190420200000517,,,1,66,1,36
38+
36,More,down,2.2157367000036174,,,1,65,0,37
39+
37,More,down,2.1285926999989897,,,1,65,0,38
40+
38,More,up,2.2092834999930346,,,2,63,1,39
41+
39,More,up,1.4419980999955442,,,1,65,1,40
42+
40,More,down,2.1680186000012327,,,1,66,0,41
43+
41,More,up,1.8241525999910664,,,1,68,1,42
44+
42,Less,up,1.7195599999977276,,,-1,64,0,43
45+
43,Less,up,2.135978599995724,,,-1,65,0,44
46+
44,More,up,2.101626000003307,,,2,67,1,45
47+
45,More,up,2.031946400005836,,,1,71,1,46
48+
46,More,up,2.389237099996535,,,1,68,1,47
49+
47,Less,up,1.7554002000106266,,,-1,67,0,48
50+
48,More,up,1.7155362000048626,,,1,76,1,49
51+
49,Less,down,1.5992597000004025,,,-1,68,1,50
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
,Condition,Estimation,EstimationRT,Confidence,ConfidenceRT,Alpha,HR,Accuracy,nTrials
2+
0,Less,down,1.9540208999969764,,,-30,71,1,1
3+
1,Less,down,2.737739500007592,,,-20,75,1,2
4+
2,Less,down,1.9350427000026684,,,-10,67,1,3
5+
3,Less,up,2.2324857999919914,,,-1,66,0,4
6+
4,Less,down,2.631938899998204,,,-11,66,1,5
7+
5,Less,up,2.6031068000011146,,,-11,66,0,6
8+
6,Less,down,2.0454002999904333,,,-21,68,1,7
9+
7,More,up,1.6798627999960445,,,21,68,1,8
10+
8,Less,up,2.2298893999977736,,,-11,65,0,9
11+
9,Less,down,1.8460632000060286,,,-16,72,1,10
12+
10,Less,down,1.6901515999925323,,,-16,64,1,11
13+
11,More,up,1.5675130000017816,,,11,63,1,12
14+
12,Less,up,4.09641849999025,,,-11,66,0,13
15+
13,Less,up,2.680778800000553,,,-12,70,0,14
16+
14,Less,down,1.6362243999901693,,,-13,65,1,15
17+
15,Less,down,1.8308112000086112,,,-13,64,1,16
18+
16,More,up,1.5287725999951363,,,12,64,1,17
19+
17,More,up,1.531244500001776,,,12,66,1,18
20+
18,More,up,1.5957804000063334,,,11,66,1,19
21+
19,Less,down,1.4900885000097333,,,-11,66,1,20
22+
20,More,up,1.3231350999994902,,,10,76,1,21
23+
21,More,up,1.9267897000099765,,,10,72,1,22
24+
22,Less,down,1.5183329999999842,,,-9,72,1,23
25+
23,More,up,1.4963253999885637,,,9,69,1,24
26+
24,Less,down,1.3723137999913888,,,-8,72,1,25
27+
25,More,up,1.4333847000089008,,,8,75,1,26
28+
26,More,up,1.4196150000061607,,,7,74,1,27
29+
27,Less,down,2.511074499998358,,,-7,74,1,28
30+
28,More,up,1.6536526999989292,,,6,76,1,29
31+
29,More,up,1.389690399999381,,,6,76,1,30
32+
30,Less,down,1.259961600007955,,,-5,76,1,31
33+
31,Less,down,1.3511346000013873,,,-5,78,1,32
34+
32,Less,up,2.9172315999894636,,,-4,78,0,33
35+
33,Less,up,1.6548336999985622,,,-5,74,0,34
36+
34,Less,down,3.11833789999946,,,-6,74,1,35
37+
35,Less,down,1.382446000003256,,,-6,74,1,36
38+
36,More,up,1.4804157000035048,,,5,74,1,37
39+
37,Less,up,2.880299299999024,,,-5,81,0,38
40+
38,Less,down,2.423955299993395,,,-6,72,1,39
41+
39,More,up,1.6218020999949658,,,6,72,1,40
42+
40,Less,up,3.141885499993805,,,-5,74,0,41
43+
41,More,up,1.6966356000048108,,,6,67,1,42
44+
42,More,down,2.3099643000023207,,,6,71,0,43
45+
43,Less,down,2.605455900004017,,,-7,74,1,44
46+
44,More,up,4.177192300005117,,,7,66,1,45
47+
45,More,up,2.321949900011532,,,6,69,1,46
48+
46,More,up,1.790507700003218,,,6,72,1,47
49+
47,Less,up,2.586329799989471,,,-5,76,0,48
50+
48,More,up,1.3814283999963664,,,6,75,1,49
51+
49,Less,up,3.5934295000042766,,,-6,76,0,50
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Author: Nicolas Legrand <nicolas.legrand@cfin.au.dk>
2+
3+
import os
4+
import serial
5+
import numpy as np
6+
from psychopy import data, visual
7+
8+
9+
def getParameters(subject):
10+
"""Create task parameters.
11+
12+
Parameters
13+
----------
14+
subject : str
15+
Subject ID.
16+
17+
Attributes
18+
----------
19+
confScale : list
20+
The range of the confidence rating scale.
21+
labelsRating : list
22+
The labels of the confidence rating scale.
23+
screenNb : int
24+
The screen number. Default set to 0.
25+
26+
Condition : 1d-array
27+
Array of 0s and 1s encoding the conditions (1 : Higher, 0 : Lower). The
28+
length of the array is defined by `parameters['nTrials']`. If
29+
`parameters['nTrials']` is odd, will use `parameters['nTrials']` - 1
30+
to enseure an equal nuber of Higher and Lower conditions.
31+
32+
"""
33+
parameters = {'confScale': [1, 7],
34+
'labelsRating': ['Guess', 'Certain'],
35+
'screenNb': 2,
36+
'nFeedback': 10,
37+
'nConfidence': 5,
38+
'minRatingTime': 1,
39+
'maxRatingTime': 3,
40+
'startKey': 'space',
41+
'respMax': 8,
42+
'monitor': 'testMonitor',
43+
'winSize': [800, 600],
44+
'allowedKeys': ['up', 'down'],
45+
'nTrials': 50,
46+
'nBeatsLim': 5}
47+
48+
# Create randomized condition vector
49+
parameters['Conditions'] = np.hstack(
50+
[np.array(['More'] * round(parameters['nTrials']/2)),
51+
np.array(['Less'] * round(parameters['nTrials']/2))])
52+
np.random.shuffle(parameters['Conditions']) # Shuffle vector
53+
54+
parameters['stairCase'] = data.StairHandler(
55+
startVal=30, nTrials=parameters['nTrials'], nUp=1,
56+
nDown=2, stepSizes=[20, 12, 7, 4, 3, 2, 1],
57+
stepType='lin', minVal=1, maxVal=100)
58+
59+
# Open seral port for Oximeter
60+
parameters['serial'] = serial.Serial('COM7',
61+
baudrate=9600,
62+
timeout=1/75,
63+
stopbits=1,
64+
parity=serial.PARITY_NONE)
65+
66+
# Set default path /Results/ 'Subject ID' /
67+
parameters['subject'] = subject
68+
parameters['path'] = os.getcwd() + '/Results/'
69+
# Create Results directory of not already exists
70+
if not os.path.exists(parameters['path'] + subject):
71+
os.makedirs(parameters['path'] + subject)
72+
parameters['path'] += subject # Set Subject Result path
73+
74+
# Texts
75+
parameters['texts'] = {
76+
'Estimation': """Do you think the flash frequency
77+
was higher or lower than your heart rate?""",
78+
'Confidence': 'How confident are you about your estimation?'}
79+
80+
parameters['Tutorial1'] = """During this experiment, we are going to record your heart rate and generate sounds reflecting your cardiac activity."""
81+
82+
parameters['Tutorial2'] = """When this heart icon is presented, you will have to focus on your cardiac activity while it is recorded for 5 seconds."""
83+
84+
parameters['Tutorial3'] = """After this procedure, you will be presented with the listening and response icons. You will then have to focus on the beats frequency and decide if it is faster than your heart rate as is was previously recorded (UP key) or slower (DOWN key). This beating frequency will ALWAYS be slower or faster than your heart rate as previously recorded."""
85+
86+
parameters['Tutorial4'] = """Once you have provided your estimation, you will also be asked to provide your level of confidence. A large number here means that you are confident with your estimation, a small number means that you are not confident. You should use the RIGHT and LEFT key to select your response and the DOWN key to confirm."""
87+
88+
parameters['Tutorial5'] = """This sequence will be repeated during the task. As you will improve your ability to discriminate between "FASTER" and "SLOWER" conditions, the difficulty will also adaptively improve, meaning that the difference between your True heart rate and the beats you hear will get smaller and smaller."""
89+
90+
# Open window
91+
parameters['win'] = visual.Window(
92+
monitor=parameters['monitor'],
93+
screen=parameters['screenNb'],
94+
fullscr=True, units='height')
95+
96+
# Get frame rate
97+
parameters['fRate'] = round(parameters['win'].getMsPerFrame()[2], 1)
98+
99+
# Image loading
100+
parameters['listenLogo'] = visual.ImageStim(win=parameters['win'],
101+
image='/Images/listenResponse.png',
102+
pos=(0.0, -0.2))
103+
parameters['listenLogo'].size *= 0.15
104+
parameters['heartLogo'] = visual.ImageStim(win=parameters['win'],
105+
image='/Images/heartbeat.png',
106+
pos=(0.0, -0.2))
107+
parameters['heartLogo'].size *= 0.15
108+
109+
return parameters

0 commit comments

Comments
 (0)