Skip to content

Commit 972768c

Browse files
author
LegrandNico
committed
Update README and add tutorial notebooks
1 parent 10606d0 commit 972768c

11 files changed

+10634
-20
lines changed

README.md

Lines changed: 66 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,86 @@
11
[![GitHub license](https://img.shields.io/github/license/embodied-computation-group/Cardioception)](https://github.com/embodied-computation-group/Cardioception/blob/master/LICENSE) [![GitHub release](https://img.shields.io/github/release/embodied-computation-group/Cardioception)](https://GitHub.com/embodied-computation-group/Cardioception/releases/) [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) [![pip](https://badge.fury.io/py/cardioception.svg)](https://badge.fury.io/py/cardioception) [![travis](https://travis-ci.com/embodied-computation-group/Cardioception.svg?token=nsE8eGgm9VmJ11Ep64Di&branch=master)](https://travis-ci.com/embodied-computation-group/Cardioception) [![codecov](https://codecov.io/gh/embodied-computation-group/Cardioception/branch/master/graph/badge.svg)](https://codecov.io/gh/embodied-computation-group/Cardioception) [![black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/) [![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
22

3+
***
34

45
# Cardioception
56

7+
<img src="/images/logo.png" align="left" alt="metadPy" height="250" HSPACE=30>
8+
69
The Cardioception Python Package - Measuring Interoception with Psychopy - implements two measures of cardiac interoception (cardioception):
710
1. The *Heartbeat counting task* developed by Rainer Schandry<sup>1,2</sup>
8-
2. a novel *Heart Rate Discrimination Task* implementing an adaptive psychophysical measure for measuring cardioception.
11+
2. a novel *Heart Rate Discrimination Task* <sup>5</sup> implementing an adaptive psychophysical measure for measuring cardioception.
12+
13+
# How to cite Cardioception?
14+
15+
If you are using cardioception in a publication we ask you to cite the following paper:
16+
17+
>Legrand, N., Nikolova, N., Correa, C., Brændholt, M., Stuckert, A., Kildahl, N., Vejlø, M., Fardo, F., & Allen, M. (2021). The heart rate discrimination task: a psychophysical method to estimate the accuracy and precision of interoceptive beliefs. bioRxiv 2021.02.18.431871. https://doi.org/10.1101/2021.02.18.431871
18+
19+
If you are using Systole to interact with your recording device (this is the default behavior in cardioception), you might also cite the following reference:
20+
21+
> Legrand, N., & Allen, M. (2020). Systole: V 0.1.2—September 2020 (0.1.2) [Computer software]. Zenodo. https://doi.org/10.5281/ZENODO.3607912
922
10-
Currently the toolbox natively supports the [Nonin 3012LP Xpod USB pulse oximeter](https://www.nonin.com/products/xpod/) together with [Nonin 8000SM 'soft-clip' fingertip sensors](https://www.nonin.com/products/8000s/) as well as Remote Data Access (RDA) via BrainVision Recorder together with Brain product ExG amplifier [](https://www.brainproducts.com/>).
1123

1224
# Installation
1325

14-
* Cardioception can be installed using pip:
15-
`pip install cardioception`.
26+
* Cardioception can be installed uing `pip install cardioception`.
1627

1728
## Dependencies
1829

19-
We recommend to use the last install of Anaconda for Python 3.8 or latest (see https://www.anaconda.com/products/individual#download-section).
30+
Cardioception has been tested with Python 3.7. We recommend to use the last install of Anaconda for Python 3.7 or latest (see https://www.anaconda.com/products/individual#download-section).
31+
32+
Make sure that you have the following packages installed and up to date before running cardioception:
33+
34+
* [psychopy](https://www.psychopy.org/) can be installed with `pip install psychopy`.
35+
36+
* [systole](https://systole-docs.github.io/) can be installed with `pip install systole`.
37+
38+
The other main dependencies are:
39+
40+
* [numpy](https://numpy.org/) (>=1.19.4)
41+
* [scipy](https://www.scipy.org/) (>=1.3.0)
42+
* [pandas](https://pandas.pydata.org/) (>=1.0.3)
43+
* [pyserial](https://pypi.org/project/pyserial/) (>=3.4)
2044

21-
The following packages should be installed:
45+
In addition, some function for HTML report functions will require:
2246

23-
* [Psychopy](https://www.psychopy.org/) can be installed using pip:
24-
`pip install psychopy`.
47+
* [papermill](https://papermill.readthedocs.io/en/latest/) (>=2.3.1)
48+
* [matplotlib](https://matplotlib.org/) (>=3.3.3)
49+
* [seaborn](https://seaborn.pydata.org/) (>=0.11.1)
50+
* [pingouin](https://pingouin-stats.org/) (>=0.3.10)
51+
* [metadPy](https://github.com/LegrandNico/metadPy) (>=0.01)
2552

26-
* [Systole](https://systole-docs.github.io/) can be installed using pip:
27-
`pip install systole`.
53+
**NOTE**
54+
The version provided here are the ones used when testing and runing cardioception locally, and are often the last ones. For several packages however, older version might also be compatibles.
2855

29-
Notes: Cardioception will automatically copy the images and sound files necessary to run the task correctly (~ 200 Mo). These files will be removed if you uninstall the package using `pip uninstall cardioception`.
56+
Cardioception will automatically copy the images and sound files necessary to run the task correctly (~ 200 Mo). These files will be removed if you uninstall the package using `pip uninstall cardioception`.
3057

31-
## Run tasks
58+
## Physiological recording
3259

33-
Each task contains a `parameters` and a `task` submodule describing the experimental parameters and the Psychopy script respectively. Once the package has been installed, you can run the task (e.g. here the Heart rate Discrimination task) using the following code snippet:
60+
Both the Heartbeat counting task (HBC) and the heart rate discrimination task (HRD) require access to physiological recording device during the task to estimate the heart rate or count the number of heartbeats in a given time window. Cardioception natively supports:
61+
* The [Nonin 3012LP Xpod USB pulse oximeter](https://www.nonin.com/products/xpod/) together with [Nonin 8000SM 'soft-clip' fingertip sensors](https://www.nonin.com/products/8000s/)
62+
* Remote Data Access (RDA) via BrainVision Recorder together with [Brain product ExG amplifier](https://www.brainproducts.com/>).
63+
64+
The package can easily be extended and integrate other recording devices by providing another recording class that will interface with your own devices (ECG, pulse oximeters, or any king of recording that will offer precise estimation of the cardiac frequency).
65+
66+
# Run the tasks
67+
68+
Each task contains a `parameters` and a `task` submodule describing the experimental parameters and the Psychopy script respectively. Several changes and adaptation can be parametrized just by passing arguments to the parameters functions. Please refer to the API documentation for details.
69+
70+
## From the command line
71+
72+
*(forthcoming)*
73+
## Using a script
74+
75+
Once the package has been installed, you can run the task (e.g. here the Heart rate Discrimination task) using the following code snippet:
3476

3577
```python
3678
from cardioception.HRD import parameters, task
3779

3880
# Set global task parameters
3981
parameters = parameters.getParameters(
4082
participant='Subject_01', session='Test', serialPort=None,
41-
setup='behavioral', nTrials=10, nTrialsUpDown=4, screenNb=0)
83+
setup='behavioral', nTrials=10, screenNb=0)
4284

4385
# Run task
4486
task.run(parameters, confidenceRating=True, runTutorial=True)
@@ -69,10 +111,6 @@ This module is an implementation of the classic "heartbeat counting task" (HCT)<
69111

70112
By default, this task implement the version used in recent publications <sup>3</sup> in which a training trial of 20s is proposed, after which the 6 experimental trials of different time-windows (25, 30, 35,40, 45 and 50s) occurred in a randomized order. The trial length, the condition ('Rest', 'Count', 'Training') and the randomization can be controlled in the parameters dictionary.
71113

72-
73-
## The Heartbeat Discrimination task
74-
75-
76114
## The Heart Rate Discrimination task
77115

78116
<img src= "images/HeartRateDiscrimination.png">
@@ -81,9 +119,14 @@ This task implements an adaptive psychophysical procedure for estimating partici
81119

82120
# Analyses
83121

84-
By default, the results will be saved in the `data` folder contained in each task folder.
122+
Some of the default analyses and the Python code can be found in the report notebook templates (`./cardioception/notebooks/`). These notebooks will automatically save preprocessed data in the result folder.
85123

86-
The `notebooks` folder includes Jupyter notebooks documenting the recommended analyses steps for each tasks that can be used to generate reports.
124+
More advanced subject and group-level Bayesian modeling approaches are described in the following notebooks.
125+
126+
| Notebook | Colab | nbViewer |
127+
| --- | ---| --- |
128+
| Fitting psychometric function with PyMC3 - Subject-level | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/embodied-computation-group/Cardioception/blob/main/code/psychophysics_subjectLevel.ipynb?flush_cache=true) | [![View the notebook](https://img.shields.io/badge/render-nbviewer-orange.svg)](https://nbviewer.jupyter.org/github/embodied-computation-group/Cardioception/blob/main/code/psychophysics_subjectLevel.ipynb?flush_cache=true)
129+
| Fitting psychometric function with PyMC3 - Group-level | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/embodied-computation-group/Cardioception/blob/main/code/psychophysics_groupLevel.ipynb?flush_cache=true) | [![View the notebook](https://img.shields.io/badge/render-nbviewer-orange.svg)](https://nbviewer.jupyter.org/github/embodied-computation-group/Cardioception/blob/main/code/psychophysics_groupLevel.ipynb?flush_cache=true)
87130

88131
# Generate reports
89132

@@ -109,6 +152,7 @@ for sub in subjects:
109152
subprocess.call(command)
110153
```
111154

155+
112156
# References
113157

114158
1. Dale, A., & Anderson, D. (1978). Information Variables in Voluntary Control and Classical Conditioning of Heart Rate: Field Dependence and Heart-Rate Perception. Perceptual and Motor Skills, 47(1), 79–85. https://doi.org/10.2466/pms.1978.47.1.79
@@ -118,6 +162,8 @@ for sub in subjects:
118162
3. Leganes-Fonteneau, M., Cheang, Y., Lam, Y., Garfinkel, S., & Duka, T. (2019). Interoceptive awareness is associated with acute alcohol-induced changes in subjective effects. Pharmacology Biochemistry and Behavior, 181, 69–76. https://doi.org/10.1016/j.pbb.2019.03.007
119163

120164
4. Hart, N., McGowan, J., Minati, L., & Critchley, H. D. (2013). Emotional Regulation and Bodily Sensation: Interoceptive Awareness Is Intact in Borderline Personality Disorder. Journal of Personality Disorders, 27(4), 506–518. https://doi.org/10.1521/pedi_2012_26_049
165+
166+
5. Legrand, N., Nikolova, N., Correa, C., Brændholt, M., Stuckert, A., Kildahl, N., Vejlø, M., Fardo, F., & Allen, M. (2021). The heart rate discrimination task: a psychophysical method to estimate the accuracy and precision of interoceptive beliefs. bioRxiv 2021.02.18.431871. https://doi.org/10.1101/2021.02.18.431871
121167

122168
# Development
123169
This package was created and is maintained by [Nicolas Legrand](https://legrandnico.github.io/) and [Micah Allen](https://micahallen.org/) from the [ECG group](https://the-ecg.org/).

images/HeartBeatCounting.png

-252 KB
Loading

0 commit comments

Comments
 (0)