forrestbao / pyeeg

Python + EEG/MEG = PyEEG
GNU General Public License v3.0
241 stars 85 forks source link

NaN values #15

Closed luiscruz closed 8 years ago

luiscruz commented 8 years ago

Maybe this is a question out of pyeeg's scope... Approximate entropy is a new concept to me and I'm having several NaN values in my data.

audio_ap_entropy_7days  activity_ap_entropy_7days
1   NaN NaN
2   -0.085044   -0.085044
4   -0.096893   -0.096893
5   -0.088628   -0.088628
7   -0.110994   -0.110994
8   NaN NaN
9   -0.086203   -0.086203
10  -0.085044   -0.085044
12  -0.085044   -0.085044
14  NaN NaN
15  NaN NaN
16  -0.088628   -0.088628
17  NaN NaN
18  NaN NaN
19  NaN NaN
22  NaN NaN
24  -0.169545   -0.169545
25  NaN NaN
27  -0.085044   -0.085044
30  NaN NaN
32  NaN NaN
33  NaN NaN
41  NaN NaN
43  NaN NaN
46  NaN NaN
49  -0.085044   -0.085044
52  NaN NaN
54  NaN NaN
57  -0.085044   -0.085044
59  -0.085044   -0.085044

Is this a normal behavior in approximate entropy, or do you think there's something wrong?

Luis

Borzou commented 8 years ago

Hi Luis,

I am not sure if I understand this data, could you help me better understand it? Are these the results after running app_entropy on your data? What are the rows and the columns?

Thanks, Borzou

On Tuesday, January 5, 2016, Luis Cruz notifications@github.com wrote:

Maybe this is a question out of pyeeg's scope... Approximate entropy is a new concept to me and I'm having several NaN values in my data.

audio_ap_entropy_7days activity_ap_entropy_7days 1 NaN NaN 2 -0.085044 -0.085044 4 -0.096893 -0.096893 5 -0.088628 -0.088628 7 -0.110994 -0.110994 8 NaN NaN 9 -0.086203 -0.086203 10 -0.085044 -0.085044 12 -0.085044 -0.085044 14 NaN NaN 15 NaN NaN 16 -0.088628 -0.088628 17 NaN NaN 18 NaN NaN 19 NaN NaN 22 NaN NaN 24 -0.169545 -0.169545 25 NaN NaN 27 -0.085044 -0.085044 30 NaN NaN 32 NaN NaN 33 NaN NaN 41 NaN NaN 43 NaN NaN 46 NaN NaN 49 -0.085044 -0.085044 52 NaN NaN 54 NaN NaN 57 -0.085044 -0.085044 59 -0.085044 -0.085044

Is this a normal behavior in approximate entropy, or do you think there's something wrong?

Luis

— Reply to this email directly or view it on GitHub https://github.com/forrestbao/pyeeg/issues/15.

luiscruz commented 8 years ago

This table has the results of ap_entropy for each participant (row). The columns is repeated by mistake.

I think I've found the issue. I am calculating ap_entropy for the mean activity of a person in a day. I have data for approximately 90 days. I've just found that in that data I also have a few NaN in some participants. So I'm getting a ap_entropy of NaN in those participants.

Do you know what's the best way to deal with NaN days?

Borzou commented 8 years ago

Let me see if I understood your problem correctly. You have a data collected over 90 days on about 59 participants. For each participant, you are analyzing the data by taking the mean activity over a day, and calculating the approximate entropy of the resulting series.

If you have NaN for a patient of yours, it is possible that you may end up getting NaN for your ap result. If the NaN values start after a certain time point, one way to overcome your problem is to analyze the data only up to that point in time. The other way is to take the average of two days rather than one day, this will creat a bias towards having low entropy however. You can also replace the NaN values with random numbers having distance higher than your chosen threshold from your data points and from each other. If you simply ignore the NaN values, omit them from your dataset, and they are randomly distributed then you will get a bias towards having high entropy.

On Tuesday, January 5, 2016, Luis Cruz notifications@github.com wrote:

This table has the results of ap_entropy for each participant (row). The columns is repeated by mistake.

I think I've found the issue. I am calculating ap_entropy for the mean activity of a person in a day. I have data for approximately 90 days. I've just found that in that data I also have a few NaN in some participants. So I'm getting a ap_entropy of NaN in those participants.

Do you know what's the best way to deal with NaN days?

— Reply to this email directly or view it on GitHub https://github.com/forrestbao/pyeeg/issues/15#issuecomment-168984278.

luiscruz commented 8 years ago

This is great @Borzou ! I will try it and let you know. Thank you so much.