Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError when analysing EDA #78

Open
jaros1024 opened this issue Sep 25, 2018 · 8 comments
Open

TypeError when analysing EDA #78

jaros1024 opened this issue Sep 25, 2018 · 8 comments

Comments

@jaros1024
Copy link

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?

@DominiqueMakowski
Copy link
Member

@jaros1024 That's weird indeed, I'll look at it :)
Could you tell me what is your version of NeuroKit and Biosppy?

@jaros1024
Copy link
Author

jaros1024 commented Sep 25, 2018

I just noticed that I had NeuroKit version 0.2.0 installed, but just updated to 0.2.7 and the problem is still the same. Biosppy is 0.6.1 - so I haven't changed anything.

@DominiqueMakowski
Copy link
Member

Great, could you provide a sample of data and a reproducible code snippet so that I can reproduce it and dig into it? Thanks!

@jaros1024
Copy link
Author

jaros1024 commented Sep 26, 2018

Sure! See the attached file. It's just a pickle dump, so you can open it like:

import pickle

def open_file(in_file):
    with open(in_file, 'rb') as fp:
        itemlist = pickle.load(fp)
        return itemlist

sample.zip

@DominiqueMakowski
Copy link
Member

It works for me with this code:

import pickle
import neurokit as nk
import pandas as pd

def open_file(in_file):
    with open(in_file, 'rb') as fp:
        itemlist = pickle.load(fp)
        return itemlist


data = open_file("sample.dat")
data = pd.DataFrame({"EDA" : data})  # Convert to dataframe
data.plot()  # Check signal

figure_1

results = nk.eda_process(data["EDA"], sampling_rate=100)

# Plot standardized data (visually more clear) wiht SCR peaks markers
nk.plot_events_in_signal(nk.z_score(results["df"]), results["EDA"]["SCR_Peaks_Indexes"])

figure_1-1

However, make sure to adjust correctly your sampling_rate (I set to 100 for illustrative purposes)

@jaros1024
Copy link
Author

Thanks! Do you think the error might be caused by wrong sampling_rate? To be honest, my data is so poorly documented that I won't be surprised if the sampling rate in documentation is wrong :)

@jaros1024
Copy link
Author

jaros1024 commented Sep 29, 2018

Just copied and pasted your code. I got an another error:

NeuroKit Warning: eda_process(): Error in cvxEDA algorithm, couldn't extract phasic and tonic components. Using raw signal.
Traceback (most recent call last):
  File "C:/Users/Jarek/PycharmProjects/emotion-predictor/test.py", line 22, in <module>
    nk.plot_events_in_signal(nk.z_score(results["df"]), results["EDA"]["SCR_Peaks_Indexes"])
  File "C:\Users\Jarek\PycharmProjects\emotion-predictor\venv\lib\site-packages\neurokit\signal\events.py", line 271, in plot_events_in_signal
    len(events_onsets[0])
IndexError: index 0 is out of bounds for axis 0 with size 0

So it looks like something is wrong with my configuration. What cvxopt version do you use? Mine is 1.2.1.

// never mind, downgraded to Python 3.6 and looks like it works.

@DominiqueMakowski
Copy link
Member

@jaros1024 Ok it's good that it works, but I'll try to understand what was wrong with 3.7 and fix it :) thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants