Created
June 26, 2023 23:42
-
-
Save danibene/595f281bc118541e49b7d4462633d8ad to your computer and use it in GitHub Desktop.
nk_issue_850.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"provenance": [], | |
"authorship_tag": "ABX9TyPE3i/aPHt9c9RHx3p6DGvd", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/danibene/595f281bc118541e49b7d4462633d8ad/nk_issue_850.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "qGJepFmcEXTz", | |
"outputId": "c01b7a95-389c-462e-f98c-6336d654ccb0" | |
}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n", | |
"Requirement already satisfied: neurokit2 in /usr/local/lib/python3.10/dist-packages (0.2.4)\n", | |
"Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from neurokit2) (1.22.4)\n", | |
"Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from neurokit2) (1.5.3)\n", | |
"Requirement already satisfied: scipy in /usr/local/lib/python3.10/dist-packages (from neurokit2) (1.10.1)\n", | |
"Requirement already satisfied: scikit-learn>=1.0.0 in /usr/local/lib/python3.10/dist-packages (from neurokit2) (1.2.2)\n", | |
"Requirement already satisfied: matplotlib in /usr/local/lib/python3.10/dist-packages (from neurokit2) (3.7.1)\n", | |
"Requirement already satisfied: joblib>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from scikit-learn>=1.0.0->neurokit2) (1.2.0)\n", | |
"Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn>=1.0.0->neurokit2) (3.1.0)\n", | |
"Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->neurokit2) (1.1.0)\n", | |
"Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib->neurokit2) (0.11.0)\n", | |
"Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib->neurokit2) (4.40.0)\n", | |
"Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->neurokit2) (1.4.4)\n", | |
"Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib->neurokit2) (23.1)\n", | |
"Requirement already satisfied: pillow>=6.2.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib->neurokit2) (8.4.0)\n", | |
"Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib->neurokit2) (3.1.0)\n", | |
"Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.10/dist-packages (from matplotlib->neurokit2) (2.8.2)\n", | |
"Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->neurokit2) (2022.7.1)\n", | |
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.7->matplotlib->neurokit2) (1.16.0)\n" | |
] | |
} | |
], | |
"source": [ | |
"!pip install neurokit2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"!pip install mne" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "R-7zMzdDFO5w", | |
"outputId": "0b4a9b53-d885-4ac9-e635-bd24c6ffe73c" | |
}, | |
"execution_count": 2, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n", | |
"Requirement already satisfied: mne in /usr/local/lib/python3.10/dist-packages (1.4.2)\n", | |
"Requirement already satisfied: numpy>=1.15.4 in /usr/local/lib/python3.10/dist-packages (from mne) (1.22.4)\n", | |
"Requirement already satisfied: scipy>=1.6.3 in /usr/local/lib/python3.10/dist-packages (from mne) (1.10.1)\n", | |
"Requirement already satisfied: matplotlib>=3.4.0 in /usr/local/lib/python3.10/dist-packages (from mne) (3.7.1)\n", | |
"Requirement already satisfied: tqdm in /usr/local/lib/python3.10/dist-packages (from mne) (4.65.0)\n", | |
"Requirement already satisfied: pooch>=1.5 in /usr/local/lib/python3.10/dist-packages (from mne) (1.6.0)\n", | |
"Requirement already satisfied: decorator in /usr/local/lib/python3.10/dist-packages (from mne) (4.4.2)\n", | |
"Requirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from mne) (23.1)\n", | |
"Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from mne) (3.1.2)\n", | |
"Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.4.0->mne) (1.1.0)\n", | |
"Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.4.0->mne) (0.11.0)\n", | |
"Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.4.0->mne) (4.40.0)\n", | |
"Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.4.0->mne) (1.4.4)\n", | |
"Requirement already satisfied: pillow>=6.2.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.4.0->mne) (8.4.0)\n", | |
"Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.4.0->mne) (3.1.0)\n", | |
"Requirement already satisfied: python-dateutil>=2.7 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=3.4.0->mne) (2.8.2)\n", | |
"Requirement already satisfied: appdirs>=1.3.0 in /usr/local/lib/python3.10/dist-packages (from pooch>=1.5->mne) (1.4.4)\n", | |
"Requirement already satisfied: requests>=2.19.0 in /usr/local/lib/python3.10/dist-packages (from pooch>=1.5->mne) (2.27.1)\n", | |
"Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->mne) (2.1.3)\n", | |
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.7->matplotlib>=3.4.0->mne) (1.16.0)\n", | |
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->pooch>=1.5->mne) (1.26.16)\n", | |
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->pooch>=1.5->mne) (2023.5.7)\n", | |
"Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->pooch>=1.5->mne) (2.0.12)\n", | |
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.19.0->pooch>=1.5->mne) (3.4)\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"import neurokit2 as nk" | |
], | |
"metadata": { | |
"id": "cp5tl94jEi5X" | |
}, | |
"execution_count": 3, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"# Resample sample data from 100 Hz to 1000 Hz to try to reproduce issue\n", | |
"eog = nk.data(\"eog_100hz\")\n", | |
"desired_sampling_rate = 1000\n", | |
"eog_signal = nk.signal_resample(signal=eog, sampling_rate=100, desired_sampling_rate=desired_sampling_rate)" | |
], | |
"metadata": { | |
"id": "OIezEHH2Ej2e" | |
}, | |
"execution_count": 4, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"eog_cleaned = nk.eog_clean(eog_signal, sampling_rate=1000, method=\"neurokit\")\n", | |
"peaks = nk.eog_findpeaks(eog_cleaned, sampling_rate=1000)\n", | |
"info = nk.eog_features(eog_cleaned, peaks,sampling_rate=1000)" | |
], | |
"metadata": { | |
"id": "lNUYKyJvEmfY" | |
}, | |
"execution_count": 5, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"info" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "lhQcUJ8GFLS-", | |
"outputId": "f03d7802-4ba3-4005-c20c-47ec0f99d17d" | |
}, | |
"execution_count": 6, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"text/plain": [ | |
"{'Blink_LeftZeros': [2556,\n", | |
" 4111,\n", | |
" 5535,\n", | |
" 6776,\n", | |
" 9401,\n", | |
" 13649,\n", | |
" 15095,\n", | |
" 17349,\n", | |
" 33042,\n", | |
" 37328,\n", | |
" 39167,\n", | |
" 40223,\n", | |
" 41214,\n", | |
" 43317,\n", | |
" 47100,\n", | |
" 48649,\n", | |
" 52013,\n", | |
" 53153,\n", | |
" 56560,\n", | |
" 58547,\n", | |
" 62970,\n", | |
" 64953,\n", | |
" 66984,\n", | |
" 72053,\n", | |
" 73717,\n", | |
" 75406,\n", | |
" 77953,\n", | |
" 80080,\n", | |
" 81417,\n", | |
" 82972,\n", | |
" 86182,\n", | |
" 86866,\n", | |
" 90911,\n", | |
" 94121,\n", | |
" 96962,\n", | |
" 99357,\n", | |
" 101337,\n", | |
" 102134,\n", | |
" 103596,\n", | |
" 106971,\n", | |
" 109471,\n", | |
" 112330,\n", | |
" 116726,\n", | |
" 117666],\n", | |
" 'Blink_RightZeros': [3186,\n", | |
" 4713,\n", | |
" 5828,\n", | |
" 7181,\n", | |
" 10022,\n", | |
" 14231,\n", | |
" 15523,\n", | |
" 18019,\n", | |
" 34035,\n", | |
" 38327,\n", | |
" 39523,\n", | |
" 40560,\n", | |
" 42171,\n", | |
" 44004,\n", | |
" 47633,\n", | |
" 49044,\n", | |
" 52547,\n", | |
" 53916,\n", | |
" 57346,\n", | |
" 59546,\n", | |
" 63616,\n", | |
" 65892,\n", | |
" 67571,\n", | |
" 72722,\n", | |
" 74205,\n", | |
" 75991,\n", | |
" 78597,\n", | |
" 80343,\n", | |
" 82050,\n", | |
" 83621,\n", | |
" 86486,\n", | |
" 87529,\n", | |
" 91804,\n", | |
" 94733,\n", | |
" 97920,\n", | |
" 99955,\n", | |
" 101648,\n", | |
" 102579,\n", | |
" 104109,\n", | |
" 107586,\n", | |
" 110154,\n", | |
" 112821,\n", | |
" 117052,\n", | |
" 118181],\n", | |
" 'Blink_pAVR': [0.0003136272101159051,\n", | |
" 0.0006368454272506067,\n", | |
" 0.001909414955550698,\n", | |
" 0.0016087356561209575,\n", | |
" 0.0012698326878651616,\n", | |
" 0.0008892992897627082,\n", | |
" 0.001316691735207756,\n", | |
" 0.0003787473250420706,\n", | |
" 7.591610029222306e-05,\n", | |
" 4.4640902164447124e-05,\n", | |
" 0.000666782964147402,\n", | |
" 0.0007930158911538838,\n", | |
" 5.55184196073679e-05,\n", | |
" 0.0009499295495186568,\n", | |
" 0.0007220279944462859,\n", | |
" 0.0006525769402878863,\n", | |
" 0.0008696751559798329,\n", | |
" 6.987174175541886e-05,\n", | |
" 4.9021706873223736e-05,\n", | |
" 4.193060515231523e-05,\n", | |
" 0.0004964977157971728,\n", | |
" 4.479304459153163e-05,\n", | |
" 0.0009693434917085314,\n", | |
" 0.0007528781858356824,\n", | |
" 0.0012250964590442216,\n", | |
" 0.0012376872570405528,\n", | |
" 0.00013658110659553965,\n", | |
" 0.0013986878396488078,\n", | |
" 0.001191003594342023,\n", | |
" 0.0006901402844059219,\n", | |
" 0.001626860710164415,\n", | |
" 0.0005922392329872416,\n", | |
" 5.867923531005748e-05,\n", | |
" 0.0006484812438097832,\n", | |
" 0.00011297823498021069,\n", | |
" 0.0011724707375752488,\n", | |
" 0.001617427517621056,\n", | |
" 0.0007736768271228389,\n", | |
" 0.0016595332835222256,\n", | |
" 0.0008228439558024887,\n", | |
" 0.000706915100648147,\n", | |
" 9.877989956597359e-05,\n", | |
" 0.001111605015496887,\n", | |
" 0.0017427468078217287],\n", | |
" 'Blink_nAVR': [6.4704698657713315e-06,\n", | |
" 7.907573017786393e-07,\n", | |
" 1.2387881922524594e-05,\n", | |
" 8.039267121295563e-06,\n", | |
" 8.145466949087818e-07,\n", | |
" 1.943051903886913e-06,\n", | |
" 2.3794447714433933e-06,\n", | |
" 7.818703954640681e-07,\n", | |
" 7.514213380459391e-08,\n", | |
" 4.471420814603989e-06,\n", | |
" 7.444779562724692e-07,\n", | |
" 3.215497928551966e-06,\n", | |
" 8.03834719336611e-08,\n", | |
" 4.424544784597506e-07,\n", | |
" 1.7662432577780655e-07,\n", | |
" 1.3212699819007336e-06,\n", | |
" 5.278379945817673e-07,\n", | |
" 2.409449778022917e-06,\n", | |
" 2.0602824607576087e-07,\n", | |
" 1.1773945146556676e-07,\n", | |
" 2.670017519331793e-08,\n", | |
" 6.699582613722008e-07,\n", | |
" 1.508904219398311e-07,\n", | |
" 1.567154711309733e-07,\n", | |
" 2.0975445266912883e-06,\n", | |
" 2.0444075020306454e-06,\n", | |
" 1.1082608315105851e-05,\n", | |
" 7.262742977710377e-07,\n", | |
" 2.2459275905622383e-06,\n", | |
" 8.377401986024503e-06,\n", | |
" 7.966108293090784e-06,\n", | |
" 3.2854658176115736e-07,\n", | |
" 4.3111905748983034e-07,\n", | |
" 4.269534708875881e-07,\n", | |
" 4.5295572307034995e-07,\n", | |
" 2.110040786267297e-06,\n", | |
" 5.836157552192393e-06,\n", | |
" 3.0601389186688457e-06,\n", | |
" 2.7949802263893787e-07,\n", | |
" 7.584504765973852e-06,\n", | |
" 1.4283898180763072e-06,\n", | |
" 1.2639876721983258e-06,\n", | |
" 4.660160175359506e-06,\n", | |
" 2.7516752951332104e-05],\n", | |
" 'Blink_BAR': [159.37425893845923,\n", | |
" 338.62213105850935,\n", | |
" 2376.1407745094875,\n", | |
" 426.7375631569892,\n", | |
" nan,\n", | |
" 2.1192523535461807,\n", | |
" 2.7855827344114554,\n", | |
" nan,\n", | |
" nan,\n", | |
" nan,\n", | |
" 731.6007043561677,\n", | |
" 549.9382166253063,\n", | |
" 1.1991541165485173,\n", | |
" nan,\n", | |
" 2.06960073409256,\n", | |
" 217.01888549827598,\n", | |
" 249.22745462628012,\n", | |
" 366.41998902388127,\n", | |
" 2.3660394245556646,\n", | |
" nan,\n", | |
" 1045.5767678235459,\n", | |
" 1.4560639195661296,\n", | |
" 1.4444192892797036,\n", | |
" 407.8301139679111,\n", | |
" 545.4143051749979,\n", | |
" 766.2949117829257,\n", | |
" 1.5038971418585882,\n", | |
" 234.46956979116052,\n", | |
" nan,\n", | |
" nan,\n", | |
" 276.7537210178425,\n", | |
" nan,\n", | |
" 572.1517139772097,\n", | |
" 807.485635517723,\n", | |
" nan,\n", | |
" 1411.5293293676166,\n", | |
" 246.71095444988183,\n", | |
" 1.3146712888601633,\n", | |
" 770.8028447926151,\n", | |
" nan,\n", | |
" nan,\n", | |
" 1.4572190474805478,\n", | |
" 292.674590770501,\n", | |
" 397.3824097147671],\n", | |
" 'Blink_Duration': [0.63,\n", | |
" 0.602,\n", | |
" 0.293,\n", | |
" 0.405,\n", | |
" 0.621,\n", | |
" 0.582,\n", | |
" 0.428,\n", | |
" 0.67,\n", | |
" 0.993,\n", | |
" 0.999,\n", | |
" 0.356,\n", | |
" 0.337,\n", | |
" 0.957,\n", | |
" 0.687,\n", | |
" 0.533,\n", | |
" 0.395,\n", | |
" 0.534,\n", | |
" 0.763,\n", | |
" 0.786,\n", | |
" 0.999,\n", | |
" 0.646,\n", | |
" 0.939,\n", | |
" 0.587,\n", | |
" 0.669,\n", | |
" 0.488,\n", | |
" 0.585,\n", | |
" 0.644,\n", | |
" 0.263,\n", | |
" 0.633,\n", | |
" 0.649,\n", | |
" 0.304,\n", | |
" 0.663,\n", | |
" 0.893,\n", | |
" 0.612,\n", | |
" 0.958,\n", | |
" 0.598,\n", | |
" 0.311,\n", | |
" 0.445,\n", | |
" 0.513,\n", | |
" 0.615,\n", | |
" 0.683,\n", | |
" 0.491,\n", | |
" 0.326,\n", | |
" 0.515]}" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 6 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [], | |
"metadata": { | |
"id": "TUlTpThIFfQF" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment