Coder Social home page Coder Social logo

neuropsychology / neurokit.py Goto Github PK

View Code? Open in Web Editor NEW
359.0 34.0 102.0 229.06 MB

A Python Toolbox for Statistics and Neurophysiological Signal Processing (EEG, EDA, ECG, EMG...).

Home Page: http://neurokit.rtfd.io

License: MIT License

Python 100.00%
biosignals python eeg eda neuroscience microstates hrv rsa heart-rate ecg

neurokit.py's Introduction

⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️ ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

NeuroKit 1 is dead, long live NeuroKit 2

This package has been replaced by its successor: NeuroKit2.

⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️ ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️

neurokit python eeg biosignals meg electrophysiology logo

Neuroscience made easy!

NeuroKit.py

pypi Codacy Badge pypi travis codecov Dependency Status License Build status Code Health HitCount

A Python Toolbox for Statistics and Neurophysiological Signal Processing (EEG, EDA, ECG, EMG...).

Name NeuroKit
Documentation Documentation Status
Discussion Join the chat at https://gitter.im/NeuroKit-py/Lobby
Questions
Authors

Installation

You should install NeuroKit2, see here.

Contribute

Maintainability

You should contribute to NeuroKit2, see here.

Documentation

You should check the documentation of NeuroKit2, see here.

Citation

You should cite NeuroKit2, see here.

neurokit.py's People

Contributors

dominiquemakowski avatar fegalf avatar gattia avatar renatosc avatar rubinovitz avatar ucohen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

neurokit.py's Issues

missing recent releases (> 0.2.0)

Recent versions are not being published on PyPI anymore (see https://pypi.org/project/neurokit/#history, most recent there is 0.2.0 which was added Sept 5th 2017), and new versions are not tagged here on GitHub either (see https://github.com/neuropsychology/NeuroKit.py/releases).

Based on current master, it seems like the latest version is 0.2.7 which corresponds to commit bba8ed9 (since that's where the version bump was done). But that doesn't include the bug fix from 8f166ad which was done shortly after...

Can you please i) tag releases on GitHub, ii) push releases to PyPI?

Letting people install straight from master without proper versioning results in a lot of confusion, which is easy to avoid by tagging releases.

Peak-valley RSA?

Hi! Thanks for providing this toolkit.

I have a question about the way NeuroKit can score RSA (and I'm very new to Python as well as psychophysiology, so I apologize if the answer to this question is overly obvious). Because of the short interval over which I'm recording ECG (30 seconds per epoch), I'd like to use the peak-valley method to score RSA (as per Eckberg, 1983: http://jap.physiology.org/content/jap/54/4/961.full.pdf). Is there a way to do this in NeuroKit?

Many thanks!

Ellie

[Bug] R_Peaks changed by ecg_hrv

Following lines in function ecg_hrv:
beats_times = rpeaks[1:]
beats_times -= beats_times[0]
change values in rpeaks, which is a direct reference to the result returned by ecg_process.

In short, the bug causes the ecg_process to return incorrect r_peak indices.
One quick fix is to copy the sliced array:
beats_times = rpeaks[1:].copy()

ECG_R_peaks

Hi Dominique!

First of all, thanks for answering my earlier question about P2T RSA - you have already been super helpful!!

I have another question now. I've been running my Acqknowledge file through Neurokit trying to extra ECG data, and it seems to be working really well except for the ECG_R_peaks column, which just outputted only nans. Everything else seems to be doing what it's supposed to do. Can you think of a thing I have left out?

Thank you so much!!

Ellie

TypeError when analysing EDA

Hello, I have a problem when trying to analyse EDA. Here is the stacktrace:
File "C:\Users\jaros1024\PycharmProjects\Project1\lib\new_gsr.py", line 13, in __init__ self.data = nk.eda_scr(y, sampling_rate=freq) File "C:\Users\jaros1024\PycharmProjects\Project1\venv3\lib\site-packages\neurokit\bio\bio_eda.py", line 399, in eda_scr peaks, _ = biosppy.tools.find_extrema(signal=signal, mode='max') File "C:\Users\jaros1024\PycharmProjects\Project1\venv3\lib\site-packages\biosppy\signals\tools.py", line 1108, in find_extrema values = signal[extrema] TypeError: only integer scalar arrays can be converted to a scalar index

I tried Python 3.6 and 3.7, both with numpy 1.14.6 and 1.15.2. Same effect for all. As far as I know, something was changed in recent numpy versions, so the syntax that you used is no longer supported.
Could you track it down and try to implement a workaround for this issue?

HRV has an algorithmic issue - ecg_hrv

There is an omission in the heart rate variability calculations in function ecg_hrv(...) that may potentially affect the results, especially for the spectral domain methods.

The calculation of HRV is based on the RR intervals (rri variable in the code). However, rri is indexed at every heartbeat, so it is not uniformly sampled. A common practice is to interpolate the original rri signal and then resample it uniformly. Every subsequent HRV computation should occur in the resampled interpolated rri signal, not the original one that was computed just by subtracting adjacent RRs. If this does not happen, and the HRV computations are based on the original rri, the spectrum will not be a function of frequency but instead it will be a function of cycles per heartbeat.

The following papers decribe this issue in detail:

https://www.researchgate.net/publication/225086966_Role_of_Editing_of_R-R_Intervals_in_the_Analysis_of_Heart_Rate_Variability

http://www.apsipa.org/proceedings_2014/Data/paper/1366.pdf

Inside the ecg_hrv function, which is included in bio_ecg.py, in lines 563-565, there is an attempt to resample the raw rri values. However, what is done is only a scaling of RR values to a sampling rate of 1000Hz. It is not an actual inerpolation and resampling.

So to summarize, I think that the following proceedure should be followed for the HRV measures:

  1. calcualtion of original rri (done already): rri=f(heartbeat)
  2. interpolation on the rri using 3rd order splines: rri_interp
  3. resample rri_interp (perhpas to 1KHz) in order to get rri2=f(t)
  4. all subsequent HRV calculations will be based on rri2

ecg_process(): Sequence too short to compute heart rate - optimising for short signal

Hello,

We are trying to work with some of the researchers from a hospital and there signal samples are at about 2.4 seconds, which is too short. I modified the "interpolate" function and changed k to 2 in signal.py It made the signal run, but still gives ecg_process(): Sequence too short to compute heart rate and therefore, setting heart_rate to np.nan

How could be modified for a short signal? Thank you!

Paper reference

Thanks a lot for the great work that was put into implementing this library. I have been reading the source code related to the respiration signal processing (the bio_rsp.py) but I could not fully understand how the algorithms were implemented. If possible, would you please provide a paper or any other reference this work was based on? Did you make any publication related to respiration signal?
Regards,
K

Electrode (+) (-) mixup - problem for neurokit?

Hello,

I've a little question about neuroKit. If someone mixed up the (+) and (-) placement of the electrodes in ECG measurement, which means, you have a negative peaked heart beats (see picture below) instead of a positive peaked.

Now the question is: Does this affect the data analysis and is the output of your gr8 tool still valid in such a case?

negative_peak_heart_beat

Best Regards and Thanks

NeuroKit outdated installation

Hello,I have some question,and need your help
I wanted to use Neuropython but it's still failed
I ran the code,and it made error

error
module 'biosppy.signals.ecg' has no attribute 'correct_rpeaks'

I checked the file 'biosppy.signals.ecg', there has function'correct_rpeaks',and already has attribute
Is file "bio_ecg_preprocessing" wrong or file "biosppy.signals.ecg"?

code

import neurokit as nk
import pandas as pd
import numpy as np
import seaborn as sns

df = pd.read_csv("C:/Users/User/Desktop/CH1.csv")
df.plot()

bio = nk.ecg_process(ecg=df["ECG1"], rsp=None, sampling_rate=250, filter_type='FIR', filter_band='bandpass', filter_frequency=[3, 45], segmenter='hamilton', quality_model='default', hrv_features=['time', 'frequency'], age=None, sex=None, position=None)

nk.z_score(bio["df"]).plot()

I tried to unistall neurokit ,and upgrade it
but it still wrong>> C:\Users\User\AppData\Local\Temp\pip-j3oj0gb4-build
What can i do?

How to find non-responders for EDA?

Hi there,

I have read that around 5% of the people are non-responders for EDA. How can they be identified (and removed from the experiment)? I'm thinking about looking at the number of peaks (a person who has almost no peaks after a stimulus might be a non-responder).

Question about SCR detection

I'm using your Neurokit toolbox for SCR detection. Would it be possible to have the pseudocode or a detailed description of the 'makowski' method that you use for SCR detection in nk.eda_scr? and which method is used when method='fast', as in Gamboa, Kim or Makowski?

AttributeError: module 'neurokit' has no attribute 'bio_process'

I just wanted to try the features of your neurokit.
I´m using Anaconda installed on Windows 10.
The pip install of neurokit was successful.
Then I copied your following sample code into a Spyder window:

Import packages

import neurokit as nk
import pandas as pd
import numpy as np
import seaborn as sns

Download data

df = pd.read_csv("https://raw.githubusercontent.com/neuropsychology/NeuroKit.py/master/examples/Bio/bio_100Hz.csv")

Plot it

df.plot()

Process the signals

bio = nk.bio_process(ecg=df["ECG"], rsp=df["RSP"], eda=df["EDA"], add=df["Photosensor"], sampling_rate=100)

Plot the processed dataframe, normalizing all variables for viewing purpose

nk.z_score(bio["df"]).plot()
pd.DataFrame(bio["ECG"]["Cardiac_Cycles"]).plot(legend=False)

The first part imcuding the first plot runs well until nk.bio_process where I get this error message:
bio = nk.bio_process(ecg=df["ECG"], rsp=df["RSP"], eda=df["EDA"], add=df["Photosensor"], sampling_rate=100)
AttributeError: module 'neurokit' has no attribute 'bio_process'

What went wrong ?

Data must be 1-dimensional

This is a follow-on from issue #9.

When following the steps in the tutorial, I'm still stuck on the ecg process line (bio = nk.bio_process(ecg=df["ECG"], rsp=df["RSP"], eda=df["EDA"])).

Full traceback:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sklearn/base.py:315: UserWarning: Trying to unpickle estimator LabelBinarizer from version 0.18.1 when using version 0.18.2. This might lead to breaking code or invalid results. Use at your own risk.
  UserWarning)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sklearn/base.py:315: UserWarning: Trying to unpickle estimator MLPClassifier from version 0.18.1 when using version 0.18.2. This might lead to breaking code or invalid results. Use at your own risk.
  UserWarning)
Traceback (most recent call last):

  File "<ipython-input-8-be922da6b29f>", line 1, in <module>
    bio = nk.bio_process(ecg=df["ECG"], rsp=df["RSP"], eda=df["EDA"])

  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/neurokit/bio/bio_meta.py", line 112, in bio_process
    ecg = ecg_process(ecg=ecg, rsp=rsp, sampling_rate=sampling_rate, resampling_method=resampling_method, quality_model=ecg_quality_model, hrv_segment_length=hrv_segment_length, age=age, sex=sex, position=position)

  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/neurokit/bio/bio_ecg.py", line 208, in ecg_process
    processed_ecg["ECG"]["HRV"] = ecg_hrv(rri, sampling_rate, segment_length=hrv_segment_length)

  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/neurokit/bio/bio_ecg.py", line 671, in ecg_hrv
    hrv["Lyapunov"] = np.max(nolds.lyap_e(rri, emb_dim=58, matrix_dim=4))

  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nolds/measures.py", line 514, in lyap_e
    mat_X -= data[i:i + emb_dim:m]

  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/core/ops.py", line 727, in wrapper
    dtype=dtype,

  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/core/ops.py", line 635, in _construct_result
    return left._constructor(result, index=index, name=name, dtype=dtype)

  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/core/series.py", line 248, in __init__
    raise_cast_failure=True)

  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/core/series.py", line 3027, in _sanitize_array
    raise Exception('Data must be 1-dimensional')

Exception: Data must be 1-dimensional

Frequency output

Hi! Sorry to keep asking questions - I think once I get more familiar with the NeuroKit/BioSPPy environment, I'll be able to start figuring them out on my own more. But for now...

I'm trying to get the power in different frequency bands of HRV. In the ECG output, I see columns labeled ECG_HRV_HF, ECG_HRV_LF, etc., with a value for each index. I assume these correspond to high frequency, low frequency, etc., but I'm not sure how to extract the power in that specific frequency band, because I'm not sure what those values represent. Do I need to get the area under the function that is described by those values?

Thanks for everything, you have been so helpful!

Cubic interpolation for frequency domain

Hello

In bio_ecg.ecg_hrv you interpolate the RR intervals to convert to continuous RR interval before extracting the frequency domain features. You are doing this using a third order (i.e. cubic) spline. I assume that the way you calculate the frequency features needs a continuous signal. Would it not also be possible to compute frequency features without interpolation?

However, why are you using this cubic interpolation instead of a linear interpolation? I think with a cubic interpolation the signal can be overestimated or underestimated, especially around the RR values.

Add multiscale entropy slope / fit computation (Costa 2005)

"Finally, to assist in clinical classification, we extracted two simple features of MSE curves, the slopes for small and large time scales, i.e., the slopes of the curves defined by SE values between scale factors 1 and 5, and scale factors 6 and 20, respectively. Results for the healthy and congestive heart failure groups corresponding to the sleeping period are presented in Fig. 8. There is a good separation between the two groups. Considering other features of the MSE curves, in addition to these slopes, may further improve the separation. Alternatively, methods derived from pattern recognition techniques, e.g., Fisher’s discriminant, may also be useful for clinical discrimination" Costa (2005)

Maybe extract the best polynomial fit and get its coefs?

How to correctly doing baseline correction?

Hi there

I have a quick question regarding baseline correction for HRV and EDA features. I'm extracting the following features (over a 10s window):

EDA: latency, rise time, number of peaks, mean and std of tonic and phasic
HRV: pnn20, rmssd, sdnn, sdss

I have also done a 5 minute baseline recording for each person at the beginning. I think there are several possibilities for baseline correction:

  1. Dividing (or subtracting?) from each feature the minimum or mean value over the whole recording time (not the baseline).

  2. Dividing (or subtracting?) from each feature the minimum or mean value over the whole baseline.

  3. Dividing (or subtracting?) from each feature the minimum or mean value over e.g. the last 2 minutes of the baseline.

  4. Dividing (or subtracting?) from each feature the minimum or mean value around a 30 seconds window where the heart rate or EDA was minimal in the baseline.

What would you propose, i.e. with which method did you have the best results?

Thanks a lot for the help!

Window size for EDA and HRV

Hi there,

I'm using EDA and HRV features. I'm extracting these features for each stimulus by positioning a window at the start of the stimulus (I think including data before the stimulus does not make sense).

What window size is recommended for EDA and HRV? I've heard that for EDA the response should appear within 5 seconds.

Linear Trend in EDA

Hey

Do you know if the cvxEDA algorithm already removes linear trends? I think linear trends should not be a problem for phasic components but for tonic components.

Or else should we detrend the raw EDA data before running cvxEDA?

IndexError: arrays used as indices must be of integer (or boolean) type

Hello there,

I try to analyze ECG and EDA data with your gr8 tool. Unfortunately I ran into a problem.
What I've done so far:

  1. Downloaded working winpython distrib. as outlined here (http://neurokit.readthedocs.io/en/latest/tutorials/Python.html)
  2. Run the following Code (see attached file for review input data
    Data.xlsx)
# Import packages
import neurokit as nk
import pandas as pd
import numpy as np
import biosppy as biosppy

# Plotting preferences
%matplotlib inline


import matplotlib
matplotlib.rcParams['figure.figsize'] = [14.0, 10.0]  # Bigger figures
import seaborn as sns
sns.set_style("whitegrid")  # White background
sns.set_palette(sns.color_palette("colorblind"))  # Better colours

df = pd.read_csv("C:/Users/.../Data.csv", sep=';')
df=df.rename(columns = {'Input2':'EDA'})
df=df.rename(columns = {'Input3':'ECG'})

bio = nk.bio_process(ecg=df["ECG"], eda=df["EDA"])

However, execution ends with an error

bio = nk.bio_process(ecg=df["ECG"], eda=df["EDA"])
Traceback (most recent call last):

  File "<ipython-input-40-84efa8150f06>", line 1, in <module>
    bio = nk.bio_process(ecg=df["ECG"], eda=df["EDA"])

  File "C:\Users\...\Desktop\neuropython\WinPython-64bit-3.5.3.1Zero\python-3.5.3.amd64\lib\site-packages\neurokit\bio\bio_meta.py", line 95, in bio_process
    eda = eda_process(eda=eda, sampling_rate=sampling_rate, use_cvxEDA=use_cvxEDA)

  File "C:\Users\...\Desktop\neuropython\WinPython-64bit-3.5.3.1Zero\python-3.5.3.amd64\lib\site-packages\neurokit\bio\bio_eda.py", line 94, in eda_process
    scr_onsets[biosppy_eda['onsets']] = 1

IndexError: arrays used as indices must be of integer (or boolean) type

...With all other input data, it worked fine. Only this data-set seems to make problems but I cannot figure out why. Would be nice if you could help me to resolve this.

Thanks in advance

Baseline correcting signal

Hello

I have a 7 minute nature video recording at the beginning of my experiment which I would like to use as baseline for my EDA and RR signal. Currently I'm just using the whole 7 minutes or the last 3 minutes which can be a bad choice because it is possible that a participant relaxes at the beginning but after some minutes starts getting annoyed of the video. I thought about searching the minimum EDA or RR/HR signal of the video baseline and then using for example a 10s window around this minimum as baseline.

Do you know other common possibilities? I did not find very much useful information about baseline correction for this special case.

Timings of RR-intervals with polar H10 chest strap

Hi,

Regarding HRV, I’m using the polar H10 chest strap which works in general very well but I have faced a weird behavior. For example, I have observed the following values:

Timestamp                   RR-interval
1508770156395               892
1508770157370               905
1508770157370               863
1508770158345               846

The first column is the timestamp in milliseconds (in UNIX time). The second column is the corresponding RR-interval

The polar device sends me one package around every second (with a RR-interval value). As you can see in one package there are two RR values. This happens from time to time. According to the bluetooth protocol this is valid, but it is a bit strange to me. I think the RR interval should approximate real time. 1508770158345– 1508770156395 = 1950ms = 1.950s but when I sum up the RR intervals I’m getting 892 + 905 + 863 + 846 = 3506ms = 3.506s.

I don’t know how to approach this. The ecg_hrv function from neurokit, that computes HRV features, needs R peaks location as input. The step, in theory, before RRi computation. So we have to somehow transform your RRi data back into R peaks location. We can do it by computing the cumulative sum. But this assumes that the rr intervals sums up to real time which seems not to be the case in the above example.

ECG: Localize Q and T waves

This would be useful for being able to characterize periods of systole (R-T interval) and diastole. More and more papers (example) suggest that the cardiac phase has an impact on the processing of a stimulus.

We could then add a column within the processed dataframe corresponding to an array of zeros and ones, called for example 'Systole' that would indicate the cardiac phase.

Found some matlab code for the localization of QRS waves that, maybe, could be adapted?

@rhenanbartels do you think that detecting the t wave is complicated?

HRV not defined

When trying to extract regular HRV indices, I am getting this error message:


NameError Traceback (most recent call last)
in ()
----> 1 print(hrv.keys()) #

NameError: name 'hrv' is not defined

Sampling rate for ecg_hrv

Hi,

I have a series of RR-intervals (which I have retrieved from Polar H10 chest strap)

The ecg_hrv function from neurokit, that computes HRV features, needs R peaks location as input. The step, in theory, before RRi computation. So we have to somehow transform the RRi data back into R peaks location. We can do it by computing the cumulative sum rpeaks = list(np.cumsum(rri)).

rri_results = nk.ecg_hrv(rpeaks, sampling_rate=1000, hrv_features=["time", "nonlinear"])

On this line you have used a sampling rate of 1000. What should I use here? Somehow the sampling rate depends on the heart rate (the higher the heart rate, the more RR intervals).

Very different orders of magnitude in ECG output

Hi Dominique!

So I ran NeuroKit on some ECG data that I've collected, and I have vastly different orders of magnitude across participants for the output relating to power in the different frequency bands. For most of my subjects, the numbers are in the tens of thousands; for others, it's in the hundreds. I have the same sampling rate for all my subjects. This doesn't affect the average heart rate (which looks biological - between 60 and 90 bpm) or the RSA.

Do you have any idea what I might be doing wrong?

Thank you so much for your help!

Ellie

NeuroKit Warning: ecg_hrv(): Correlation Dimension. Error: NeuroKit warning: complexity_entropy_multiscale(): Signal might be to short to compute SampEn for scale factors > 0. Setting max_scale_factor to 0.

I am giving the data in form of 1D numpy array which is basically i, ii, iii, v1, v2, v3, v4, v5, v6, avr, avl, avf features from PTB database. I call this function nk.bio_process(ecg=ecg_signal[:,i],ecg_quality_model=None). It operates good on several columns but gives error after 2 iterations. Moreover, I have checked data is fine enough in all columns. can anyone please resolve the issue

numpy has no attribute 'norm'

Trying to work through the BioSignals processing in Python tutorial, but didn't make it far because I hit the above error when trying to run:

bio = nk.bio_process(ecg=df["ECG"], rsp=df["RSP"], eda=df["EDA"])

The full Traceback from the IPython console is:

Traceback (most recent call last):

File "<ipython-input-280-be922da6b29f>", line 1, in <module>
bio = nk.bio_process(ecg=df["ECG"], rsp=df["RSP"], eda=df["EDA"])

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/neurokit/bio/bio_meta.py", line 112, in bio_process
ecg = ecg_process(ecg=ecg, rsp=rsp, sampling_rate=sampling_rate, resampling_method=resampling_method, quality_model=ecg_quality_model, hrv_segment_length=hrv_segment_length, age=age, sex=sex, position=position)

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/neurokit/bio/bio_ecg.py", line 208, in ecg_process
processed_ecg["ECG"]["HRV"] = ecg_hrv(rri, sampling_rate, segment_length=hrv_segment_length)

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/neurokit/bio/bio_ecg.py", line 665, in ecg_hrv
hrv["Entropy_Multiscale"] = entropy_multiscale(rri, emb_dim=2)

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/neurokit/signal/complexity.py", line 408, in entropy_multiscale
se = nolds.sampen(temp_ts, 1, tolerance, dist="euler", debug_plot=False, plot_file=None)

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nolds/measures.py", line 653, in sampen
dsts = np.norm(diff, axis=1)

AttributeError: module 'numpy' has no attribute 'norm'

Use non-standard filter for ECG

This may very well be a silly question because I haven't looked through your thoroughly enough (or because I'm missing something painfully obvious), so please bear with me.

From what I have been able to figure out by quickly scanning your code, you're using biosppy's filtering routine to filter ECG data prior to HRV/etc extraction. The biosppy filter, in turn, is set to a default bandpass filter at [3, 45] Hz.

If I wanted to run NeuroKit's ECG routine (processed_ecg = nk.ecg_process(ecg_signal, resp_signal)), but specify a different filter (say, just a high pass filter?), is there an easy way to do this? I figured that if all else fails I can edit ecg.py within biosppy…

NaN value in SCR_Recovery_Index

Hi, I'm using the processed_eda function to extract feature from the raw eda in my research. However, I found that there were some NaNs in the "processed_eda['EDA']['SCR_Recovery_Indexes']". Why these NaNs appear? And how should I deal with these NaNs to get the final feature such as mean of recovery times in your suggestion?

Extract EDA - SCR features error

gsr_slice.p.zip
Hi,

I'm trying to extract Skin Conductance Responses from a EDA Signal, but I'm getting errors.

Here is some example code and the errors and I'm attaching the file.

import pickle
import neurokit as nk

gsr_slice = pickle.load(open("gsr_slice.p", "rb"))
nk.eda_scr(gsr_slice, 512, method="fast")

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-101-9f5b83c41189> in <module>()
----> 1 nk.eda_scr(gsr_slice, 512, method="fast")

~/anaconda/envs/kohaf/lib/python3.5/site-packages/neurokit/bio/bio_eda.py in eda_scr(signal, sampling_rate, treshold, method)
    408     # ====================
    409     # Compute rising times
--> 410     risingtimes = peaks-onsets
    411     risingtimes = risingtimes/sampling_rate*1000
    412 

ValueError: operands could not be broadcast together with shapes (1319,) (1309,) 



nk.eda_scr(gsr_slice, 512, method="slow")

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-103-cf6859b8848d> in <module>()
----> 1 nk.eda_scr(gsr_slice, 512, method="slow")

~/anaconda/envs/kohaf/lib/python3.5/site-packages/neurokit/bio/bio_eda.py in eda_scr(signal, sampling_rate, treshold, method)
    402 
    403     # Keep only pairs
--> 404     peaks = peaks[peaks > onsets[0]]
    405     onsets = onsets[onsets < peaks[-1]]
    406 

TypeError: only integer scalar arrays can be converted to a scalar index


Filtering for EDA

Hi

Before applying the cvxEDA algorithm you are filtering the signal. According to the cvxEDA paper this is not necessary: "As a result, the method does not require pre-processing of the observed SC signal (e.g., bandpass filtering) nor post-processing of the inferred phasic and tonic components (e.g., to deal with negative neural activations)."

reading data from .acq

Hi

I'm trying to read my data from Acqknowledge file but it doesn't look right at all. It seems like it displays values for only one channel, where there are in fact three. Is there something I can do to get it load properly? I just find nothing works on the Acqknowledge data - even the plots look wrong, displaying the signal for a few of the recorded minutes. I'm completely new to this so apologies if this is an obvious question - just completely lost on what to do with it.

Thanks a lot

DLL load failed: The specified module could not be found.

I used pip to install neurokit-0.2.7 followed by the installation guide on windows 10 x64 and python 3.7.0. The installation was successful but I encountered this error when importing the library as "import neurokit as nk".
I'm a newbie so I really appreciate every help to fix this.

Exception has occurred: ImportError
DLL load failed: The specified module could not be found.
File "C:\users\vinhd\desktop\py&lt;frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\users\vinhd\desktop\py&lt;frozen importlib._bootstrap_external>", line 728, in exec_module
File "C:\users\vinhd\desktop\py&lt;frozen importlib._bootstrap>", line 677, in _load_unlocked
File "C:\users\vinhd\desktop\py&lt;frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "C:\users\vinhd\desktop\py&lt;frozen importlib._bootstrap>", line 983, in _find_and_load
File "C:\users\vinhd\desktop\py&lt;frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\users\vinhd\desktop\py&lt;frozen importlib._bootstrap_external>", line 728, in exec_module
File "C:\users\vinhd\desktop\py&lt;frozen importlib._bootstrap>", line 677, in _load_unlocked
File "C:\users\vinhd\desktop\py&lt;frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "C:\users\vinhd\desktop\py&lt;frozen importlib._bootstrap>", line 983, in _find_and_load
File "C:\users\vinhd\desktop\py&lt;frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\users\vinhd\desktop\py&lt;frozen importlib._bootstrap_external>", line 728, in exec_module
File "C:\users\vinhd\desktop\py&lt;frozen importlib._bootstrap>", line 677, in _load_unlocked
File "C:\users\vinhd\desktop\py&lt;frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "C:\users\vinhd\desktop\py&lt;frozen importlib._bootstrap>", line 983, in _find_and_load
File "C:\users\vinhd\desktop\py&lt;frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\users\vinhd\desktop\py&lt;frozen importlib._bootstrap_external>", line 728, in exec_module
File "C:\users\vinhd\desktop\py&lt;frozen importlib._bootstrap>", line 677, in _load_unlocked
File "C:\users\vinhd\desktop\py&lt;frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "C:\users\vinhd\desktop\py&lt;frozen importlib._bootstrap>", line 983, in _find_and_load
File "C:\Users\vinhd\Desktop\py\hello.py", line 5, in
import neurokit as nk

Number of SCR peaks

Hi,

The EDA stuff works but unfortunately I’m getting only peaks for 50% of my stimulus (10s pictures), i.e. in 50% of these 10s windows (picture duration) there is no peak. I have to evaluate a bit more to see the reason behind it (it seems a bit strange to me). Do you have any idea why this happens?

suggestion for pandas version

It seems that in the code you refer to the method DataFrame.rolling() inserted since pandas version >=0.18.0. To avoid errors as :

AttributeError: 'DataFrame' object has no attribute 'rolling'

it would be good to insert the minimum pandas version in setup.py or requirements.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.