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

PyActigraphy_Error with GENEActive bin file KeyError: accImputed #156

Open
Tony-555 opened this issue Sep 2, 2024 · 4 comments
Open

PyActigraphy_Error with GENEActive bin file KeyError: accImputed #156

Tony-555 opened this issue Sep 2, 2024 · 4 comments

Comments

@Tony-555
Copy link

Tony-555 commented Sep 2, 2024

Hello everyone,

I am using pyActigraphy to process actigraphy data from GENEActiv devices. I need to obtain M10 and L5C, but I’ve encountered the following error and have been struggling to solve it for months.

Here’s a snippet of the command I am using:

accProcess "path/to/file" --timeZone "America/Montevideo" --startTime "2023-09-17T21:15" --sampleRate 10 --resampleMethod "linear" --psd True --fourierFrequency True --activityClassification True --m10l5 True --mgCpLPA 100 --mgCpMPA 120 --mgCpVPA 500 --verbose True --deleteIntermediateFiles False

When I attempt to run the analysis, I encounter a KeyError: 'accImputed', which indicates that the column 'accImputed' does not exist. I’ve checked the CSV file, and indeed, the column is missing.

Has anyone experienced a similar issue? What additional steps should I take to ensure that the 'accImputed' column is correctly generated in the intermediate file? Could this be a problem with the imputation settings, or is there something else I should be checking?

Thank you in advance for any guidance you can offer!

@Tony-555 Tony-555 changed the title Error with GENEActive bin file KeyError: accImputed PyActigraphy_Error with GENEActive bin file KeyError: accImputed Sep 2, 2024
@ghammad
Copy link
Owner

ghammad commented Sep 4, 2024

Hello @Tony-555

First of all, thanks for using pyActigraphy.

Could you let me know:

  1. the package version that you use?
  2. the full error message?
  3. how to reproduce the error by providing me with a test file?

Cheers,

Greg

@Tony-555
Copy link
Author

Tony-555 commented Sep 5, 2024

Hi @ghammad,

Thank you very much for your reply!

1)The package version I use:
(pyactigraphy_env) C:\Windows\System32>pip show pyActigraphy Name: pyActigraphy Version: 1.2.2 Summary: Analysis package for actigraphy data Home-page: https://github.com/ghammad/pyActigraphy Author: Grégory Hammad Author-email: gregory.hammad@hotmail.fr License: GNU GPL-3.0 Location: c:\programdata\anaconda3\envs\pyactigraphy_env\lib\site-packages Requires: accelerometer, joblib, lmfit, numba, numpy, pandas, plotly, pyexcel, pyexcel-ods3, pyexcel-xlsx, scipy, spm1d, statsmodels, stochastic Required-by:

2) The full error message:

2024-09-05 09:15:46 === Summarizing === 60053 rows with NaN or Inf values, out of 102105 Traceback (most recent call last): File "C:\ProgramData\anaconda3\envs\pyactigraphy_env\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\ProgramData\anaconda3\envs\pyactigraphy_env\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\ProgramData\anaconda3\envs\pyactigraphy_env\Scripts\accProcess.exe\__main__.py", line 7, in <module> File "C:\ProgramData\anaconda3\envs\pyactigraphy_env\lib\site-packages\accelerometer\accProcess.py", line 324, in main epochData, labels = accelerometer.summarisation.getActivitySummary( File "C:\ProgramData\anaconda3\envs\pyactigraphy_env\lib\site-packages\accelerometer\summarisation.py", line 121, in getActivitySummary circadian.calculatePSD(data, epochPeriod, fourierWithAcc, labels, summary) File "C:\ProgramData\anaconda3\envs\pyactigraphy_env\lib\site-packages\accelerometer\circadian.py", line 24, in calculatePSD y = e[cols].idxmax(axis=1) == 'sleepImputed' # is sleepImputed highest? File "C:\Users\aarri\AppData\Roaming\Python\Python310\site-packages\pandas\core\frame.py", line 3464, in __getitem__ indexer = self.loc._get_listlike_indexer(key, axis=1)[1] File "C:\Users\aarri\AppData\Roaming\Python\Python310\site-packages\pandas\core\indexing.py", line 1314, in _get_listlike_indexer self._validate_read_indexer(keyarr, indexer, axis) File "C:\Users\aarri\AppData\Roaming\Python\Python310\site-packages\pandas\core\indexing.py", line 1374, in _validate_read_indexer raise KeyError(f"None of [{key}] are in the [{axis_name}]") KeyError: "None of [Index(['lightImputed', 'moderate-vigorousImputed', 'sedentaryImputed',\n 'sleepImputed', 'CpSBImputed', 'CpLPAImputed', 'CpMPAImputed',\n 'CpVPAImputed', 'CpMVPAImputed'],\n dtype='object')] are in the [columns]"

**3) Link to a test file. Data from one participant during 14 days
https://drive.google.com/drive/folders/1OrYYs-UJB4kHjF2z6pY4q8_86WZYncAj?usp=sharing

@ghammad
Copy link
Owner

ghammad commented Sep 10, 2024

Hello @Tony-555

Thanks for the info and the file.

From your error message, do I understand correctly that the issue is not related to pyActigraphy? It seems that you have an issue with processing your GeneActiv file with the accelerometer package. Is that correct? If so, I would suggest to contact the developers of that package to get some support.

Nonetheless, I converted your .bin file using the accelerometer package (v6.2.2) with the default settings and, as you can see below, it was successful:

2024-09-10 17:11:06	=== Summarizing ===
60052 rows with NaN or Inf values, out of 102104

2024-09-10 17:11:31	=== Short summary ===
{
    "file-name": "P011ET_56416_2023-11-28 12-48-58.bin",
    "file-startTime": "2023-09-17 22:15:00.500000+0100 [Europe/London]",
    "file-endTime": "2023-10-23 09:06:30.500000+0100 [Europe/London]",
    "acc-overall-avg": 24.59826495031706,
    "wearTime-overall(days)": 14.60138888888889,
    "nonWearTime-overall(days)": 20.85138888888889,
    "quality-goodWearTime": 1
}
Full summary written to: /home/ghammad/Downloads/P011ET_56416_2023-11-28 12-48-58-summary.json

I then read the output file P011ET_56416_2023-11-28 12-48-58-timeSeries.csv.gz with pyActigraphy (v1.2.2) and it did work:
newplot-270

Hard to understand what went wrong in the pre-processing. I can only speculate that, during the processing with the accelerometer package, you turned on an option that triggered the computation of "circadian" variables, which failed. Excerpt of your error message:

File "C:\ProgramData\anaconda3\envs\pyactigraphy_env\lib\site-packages\accelerometer\circadian.py", line 24, in calculatePSD y = e[cols].idxmax(axis=1) == 'sleepImputed'  # is sleepImputed highest?

As mentioned earlier, the dev of the accelerometer package should be able to help you out.

Do not hesitate to keep me posted about the outcome of your discussion with the accelerometer people.

Best regards,

Greg

@ghammad
Copy link
Owner

ghammad commented Oct 14, 2024

Hello @Tony-555

I hope you managed to move forward with the data preprocessing. Do not hesitate to share your findings, questions or thoughts with us.

Cheers,

Greg

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