Neurokit2 Release 0.0.35
Total Page:16
File Type:pdf, Size:1020Kb
NeuroKit2 Release 0.0.35 Official Documentation Jun 06, 2020 CONTENTS 1 Introduction 3 1.1 Quick Example..............................................3 1.2 Installation................................................4 1.3 Contribution...............................................4 1.4 Documentation..............................................4 1.5 Citation..................................................5 1.6 Physiological Data Preprocessing....................................6 1.7 Physiological Data Analysis....................................... 11 1.8 Miscellaneous.............................................. 13 1.9 Popularity................................................ 16 1.10 Notes................................................... 17 2 Authors 19 2.1 Core team................................................. 19 2.2 Contributors............................................... 19 3 Installation 21 3.1 1. Python................................................. 21 3.2 2. NeuroKit................................................ 22 4 Tutorials 23 4.1 Recording good quality signals..................................... 23 4.2 What software for physiological signal processing........................... 24 4.3 Get familiar with Python in 10 minutes................................. 26 4.4 Understanding NeuroKit......................................... 34 4.5 How to use GitHub to contribute..................................... 37 4.6 Ideas for first contributions........................................ 40 4.7 Complexity Analysis of Physiological Signals............................. 42 4.8 Additional Resources........................................... 47 5 Examples 49 5.1 Simulate Artificial Physiological Signals................................ 49 5.2 Customize your Processing Pipeline................................... 54 5.3 Event-related Analysis.......................................... 59 5.4 Interval-related Analysis......................................... 66 5.5 Analyze Electrodermal Activity (EDA)................................. 70 5.6 Analyze Respiratory Rate Variability (RRV).............................. 72 5.7 ECG-Derived Respiration (EDR) Analysis............................... 77 5.8 Extract and Visualize Individual Heartbeats............................... 79 5.9 Locate P, Q, S and T waves in ECG................................... 82 i 5.10 How to create epochs........................................... 92 5.11 Cloud-based interactive examples.................................... 96 6 Datasets 97 6.1 ECG (1000 hz) .............................................. 97 6.2 ECG - pandas (3000 hz) ......................................... 97 6.3 Event-related (4 events) ......................................... 97 6.4 Resting state (5 min) ........................................... 98 6.5 Resting state (8 min) ........................................... 98 7 Functions 101 7.1 ECG................................................... 101 7.2 Heart Rate Variability.......................................... 117 7.3 RSP.................................................... 121 7.4 EDA................................................... 132 7.5 EMG................................................... 142 7.6 Automated Processing and Analysis................................... 148 7.7 EEG................................................... 150 7.8 PPG.................................................... 152 7.9 General Signal Processing........................................ 155 7.10 Events.................................................. 174 7.11 Read data................................................. 177 7.12 Epoch data................................................ 178 7.13 Statistics................................................. 180 7.14 Complexity................................................ 187 7.15 Miscellaneous.............................................. 218 Python Module Index 221 Index 223 ii NeuroKit2, Release 0.0.35 Welcome to NeuroKit’s documentation. Here you can find information and learn about Python, NeuroKit, Physiolog- ical Signals and more. You can navigate to the different sections using the left panel. We would recommend checking out the tutorials and examples, where you can find guides and hands-on walkthroughs. CONTENTS 1 NeuroKit2, Release 0.0.35 2 CONTENTS CHAPTER ONE INTRODUCTION The Python Toolbox for Neurophysiological Signal Processing This package is the continuation of NeuroKit 1. It’s a user-friendly package providing easy access to advanced biosig- nal processing routines. Researchers and clinicians without extensive knowledge of programming or biomedical signal processing can analyze physiological data with only two lines of code. 1.1 Quick Example import neurokit2 as nk # Download example data data= nk.data("bio_eventrelated_100hz") # Preprocess the data (filter, find peaks, etc.) processed_data, info= nk.bio_process(ecg=data["ECG"], rsp=data["RSP"], eda=data["EDA ,!"], sampling_rate=100) # Compute relevant features results= nk.bio_analyze(processed_data, sampling_rate=100) And boom your analysis is done 3 NeuroKit2, Release 0.0.35 1.2 Installation To install NeuroKit2, run this command in your terminal: pip install https://github.com/neuropsychology/neurokit/zipball/master If you’re not sure how/what to do, be sure to read our installation guide. 1.3 Contribution NeuroKit2 is a collaborative project with a community of contributors with all levels of development expertise. Thus, if you have some ideas for improvement, new features, or just want to learn Python and do something useful at the same time, do not hesitate and check out the following guides: • Contribution guide • How to use GitHub to contribute • Ideas for first contributions 1.4 Documentation Click on the links above and check out our tutorials: 1.4.1 General • Recording good quality signals • What software for physiological signal processing • Install Python and NeuroKit • Get familiar with Python in 10 minutes • Understanding NeuroKit • Included datasets • Additional Resources 4 Chapter 1. Introduction NeuroKit2, Release 0.0.35 1.4.2 Examples • Simulate Artificial Physiological Signals • Customize your Processing Pipeline • Event-related Analysis • Interval-related Analysis • Analyze Electrodermal Activity (EDA) • Analyze Respiratory Rate Variability (RRV) • Extract and Visualize Individual Heartbeats • Locate P, Q, S and T waves in ECG • Complexity Analysis of Physiological Signals You can try out these examples directly in your browser. Don’t know which tutorial is suited for your case? Follow this flowchart: 1.5 Citation nk.cite() You can cite NeuroKit2 as follows: - Makowski, D., Pham, T., Lau, Z. J., Brammer, J. C., Lesspinasse, F., Pham, H., (continues on next page) 1.5. Citation 5 NeuroKit2, Release 0.0.35 (continued from previous page) Schölzel, C.,& S H Chen, A. (2020). NeuroKit2: A Python Toolbox for ,!Neurophysiological Signal Processing. Retrieved March 28, 2020, from https://github.com/ ,!neuropsychology/NeuroKit Full bibtex reference: @misc{neurokit2, doi ={10.5281/ZENODO.3597887}, url ={https://github.com/neuropsychology/NeuroKit}, author ={Makowski, Dominique and Pham, Tam and Lau, Zen J. and Brammer, Jan C. and ,!Lespinasse, Fran\c{c}ois and Pham, Hung and Schölzel, Christopher and S H Chen, ,!Annabel}, title ={NeuroKit2: A Python Toolbox for Neurophysiological Signal Processing}, publisher ={Zenodo}, year ={2020}, } 1.6 Physiological Data Preprocessing 1.6.1 Simulate physiological signals import numpy as np import pandas as pd import neurokit2 as nk # Generate synthetic signals ecg= nk.ecg_simulate(duration=10, heart_rate=70) ppg= nk.ppg_simulate(duration=10, heart_rate=70) rsp= nk.rsp_simulate(duration=10, respiratory_rate=15) eda= nk.eda_simulate(duration=10, scr_number=3) emg= nk.emg_simulate(duration=10, burst_number=2) # Visualise biosignals data= pd.DataFrame({"ECG": ecg, "PPG": ppg, "RSP": rsp, "EDA": eda, "EMG": emg}) nk.signal_plot(data, subplots=True) 6 Chapter 1. Introduction NeuroKit2, Release 0.0.35 1.6.2 Electrodermal Activity (EDA/GSR) # Generate 10 seconds of EDA signal (recorded at 250 samples / second) with 2 SCR ,!peaks eda= nk.eda_simulate(duration=10, sampling_rate=250, scr_number=2, drift=0.01) # Process it signals, info= nk.eda_process(eda, sampling_rate=250) # Visualise the processing nk.eda_plot(signals, sampling_rate=250) 1.6. Physiological Data Preprocessing 7 NeuroKit2, Release 0.0.35 1.6.3 Cardiac activity (ECG) # Generate 15 seconds of ECG signal (recorded at 250 samples / second) ecg= nk.ecg_simulate(duration=15, sampling_rate=250, heart_rate=70) # Process it signals, info= nk.ecg_process(ecg, sampling_rate=250) # Visualise the processing nk.ecg_plot(signals, sampling_rate=250) 8 Chapter 1. Introduction NeuroKit2, Release 0.0.35 1.6.4 Respiration (RSP) # Generate one minute of respiratory (RSP) signal (recorded at 250 samples / second) rsp= nk.rsp_simulate(duration=60, sampling_rate=250, respiratory_rate=15) # Process it signals, info= nk.rsp_process(rsp, sampling_rate=250) # Visualise the processing nk.rsp_plot(signals, sampling_rate=250) 1.6. Physiological Data Preprocessing 9 NeuroKit2, Release 0.0.35 1.6.5 Electromyography (EMG) # Generate 10 seconds of EMG signal (recorded at 250 samples / second) emg= nk.emg_simulate(duration=10, sampling_rate=250, burst_number=3) # Process it signal, info= nk.emg_process(emg, sampling_rate=250) # Visualise the processing nk.emg_plot(signals, sampling_rate=250) 10 Chapter 1. Introduction NeuroKit2, Release 0.0.35 1.6.6 Photoplethysmography