lamp-cortex

The Cortex data analysis pipeline for the LAMP Platform.

https://github.com/bidmcdigitalpsychiatry/lamp-cortex

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    3 of 10 committers (30.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.4%) to scientific vocabulary
Last synced: 7 months ago · JSON representation ·

Repository

The Cortex data analysis pipeline for the LAMP Platform.

Basic Info
  • Host: GitHub
  • Owner: BIDMCDigitalPsychiatry
  • License: bsd-3-clause
  • Language: Jupyter Notebook
  • Default Branch: master
  • Homepage: https://docs.lamp.digital/
  • Size: 6.04 MB
Statistics
  • Stars: 5
  • Watchers: 1
  • Forks: 5
  • Open Issues: 0
  • Releases: 14
Created over 5 years ago · Last pushed 11 months ago
Metadata Files
Readme License Citation

README.md

Cortex data analysis pipeline for the LAMP Platform.

Overview

This API client is used to process and featurize data collected in LAMP. Visit our documentation for more information about using cortex and the LAMP API.

Jump to:

Setting up Cortex

You will need Python 3.8+ and pip installed in order to use Cortex. - You may need root permissions, using sudo. - Alternatively, to install locally, use pip --user. - If pip is not recognized as a command, use python3 -m pip.

If you meet the prerequisites, install Cortex:

sh pip install git+https://github.com/BIDMCDigitalPsychiatry/LAMP-cortex.git@master

If you do not have your environment variables set up you will need to perform the initial server credentials configuraton below:

python import os os.environ['LAMP_ACCESS_KEY'] = 'YOUR_EMAIL_ADDRESS' os.environ['LAMP_SECRET_KEY'] = 'YOUR_PASSWORD' os.environ['LAMP_SERVER_ADDRESS'] = 'YOUR_SERVER_ADDRESS'

Example: Passive data features from Cortex

The primary function of Cortex is to provide a set of features derived from pasive data. Data can be pulled either by calling Cortex functions directly, or by using the cortex.run() function to parse multiple participants or features simultaneously. For example, one feature of interest is screen_duration or the time spent with the phone "on".

First, we can pull this data using the Cortex function. Let's say we want to compute the amount of time spent by participant: "U1234567890" from 11/15/21 (epoch time: 1636952400000) to 11/30/21 (epoch time: 1638248400000) each day (resolution = miliseconds in a day = 86400000):

python import cortex screen_dur = cortex.secondary.screen_duration.screen_duration("U1234567890", start=1636952400000, end=1638248400000, resolution=86400000)

The output would look something like this: {'timestamp': 1636952400000, 'duration': 1296000000, 'resolution': 86400000, 'data': [{'timestamp': 1636952400000, 'value': 0.0}, {'timestamp': 1637038800000, 'value': 0.0}, {'timestamp': 1637125200000, 'value': 0.0}, {'timestamp': 1637211600000, 'value': 0.0}, {'timestamp': 1637298000000, 'value': 0.0}, {'timestamp': 1637384400000, 'value': 0.0}, {'timestamp': 1637470800000, 'value': 8425464}, {'timestamp': 1637557200000, 'value': 54589034}, {'timestamp': 1637643600000, 'value': 50200716}, {'timestamp': 1637730000000, 'value': 38500923}, {'timestamp': 1637816400000, 'value': 38872835}, {'timestamp': 1637902800000, 'value': 46796405}, {'timestamp': 1637989200000, 'value': 42115755}, {'timestamp': 1638075600000, 'value': 44383154}]} The 'data' in the dictionary holds the start timestamps (of each day from 11/15/21 to 11/29/21) and the screen duration for each of these days.

Second, we could have pulled this same data using the cortex.run function. Note that resolution is automatically set to a day in cortex.run. To invoke cortex.run, you must provide a specific ID or a list of IDs (only Researcher, Study, or Participant IDs are supported). Then, you specify the behavioral features to generate and extract. Once Cortex finishes running, you will be provided a dict where each key is the behavioral feature name, and the value is a dataframe. You can use this dataframe to save your output to a CSV file, for example, or continue data processing and visualization. This function call would look like this:

python import cortex screen_dur = cortex.run("U1234567890", ['screen_duration'], start=1636952400000, end=1638248400000) And the output might look like: {'screen_duration': id timestamp value 0 U1234567890 2021-11-15 05:00:00 0.0 1 U1234567890 2021-11-16 05:00:00 0.0 2 U1234567890 2021-11-17 05:00:00 0.0 3 U1234567890 2021-11-18 05:00:00 0.0 4 U1234567890 2021-11-19 05:00:00 0.0 5 U1234567890 2021-11-20 05:00:00 0.0 6 U1234567890 2021-11-21 05:00:00 8425464.0 7 U1234567890 2021-11-22 05:00:00 54589034.0 8 U1234567890 2021-11-23 05:00:00 50200716.0 9 U1234567890 2021-11-24 05:00:00 38500923.0 10 U1234567890 2021-11-25 05:00:00 38872835.0 11 U1234567890 2021-11-26 05:00:00 46796405.0 12 U1234567890 2021-11-27 05:00:00 42115755.0 13 U1234567890 2021-11-28 05:00:00 44383154.0} The output is the same as above, except the 'data' has been transformed into a Pandas DataFrame. Additionally, the dictionary is indexed by feature -- this way you can add to the list of features processed at once. Finally, a column "id" has been added so that multiple participants can be processed simultaneously.

Find a bug?

Our forum has many answers to common questions. If you find a bug, need help with working with Cortex, or have a suggestion for how the code can be improved please make a post on the forum.

Adding features to Cortex

If you are interesting in developing new features for Cortex, please check out our docs here. Note that the unittests in this repository will fail for users outside of BIDMC since you do not have access to our data.

Advanced Configuration

Ensure your server_address is set correctly. If using the default server, it will be api.lamp.digital. Keep your access_key (sometimes an email address) and secret_key (sometimes a password) private and do not share them with others. While you are able to set these parameters as arguments to the cortex executable, it is preferred to set them as session-wide environment variables. You can also run the script from the command line:

bash LAMP_SERVER_ADDRESS=api.lamp.digital LAMP_ACCESS_KEY=XXX LAMP_SECRET_KEY=XXX python3 -m \ cortex significant_locations \ --id=U26468383 \ --start=1583532346000 \ --end=1583618746000 \ --k_max=9

Or another example using the CLI arguments instead of environment variables (and outputting to a file):

bash python3 -m \ cortex --format=csv --server-address=api.lamp.digital --access-key=XXX --secret-key=XXX \ survey --id=U26468383 --start=1583532346000 --end=1583618746000 \ 2>/dev/null 1>./my_cortex_output.csv

Owner

  • Name: BIDMC Division of Digital Psychiatry
  • Login: BIDMCDigitalPsychiatry
  • Kind: organization
  • Email: team@digitalpsych.org
  • Location: Longwood Medical Area, Boston, MA, US

Citation (CITATION.cff)

cff-version: 0.0.1
message: "If you use this software, please cite it as below."
authors:
  - family-names: Currey
    given-names: Danielle
  - family-names: Hays
    given-names: Ryan
  - family-names: D'Mello
    given-names: Ryan
  - family-names: Scheuer
    given-names: Luke
  - family-names: Vaidyam
    given-names: Aditya
  - family-names: Lavoie
    given-names: Joel
  - family-names: Langholm
    given-names: Carsten
  - family-names: Gray
    given-names: Lucy
title: "LAMP-Cortex"
version: 2022.10.11
date-released: 2022-10-11

GitHub Events

Total
  • Create event: 10
  • Issues event: 1
  • Release event: 1
  • Watch event: 1
  • Delete event: 5
  • Member event: 1
  • Push event: 32
  • Pull request review comment event: 2
  • Pull request review event: 13
  • Pull request event: 12
  • Fork event: 2
Last Year
  • Create event: 10
  • Issues event: 1
  • Release event: 1
  • Watch event: 1
  • Delete event: 5
  • Member event: 1
  • Push event: 32
  • Pull request review comment event: 2
  • Pull request review event: 13
  • Pull request event: 12
  • Fork event: 2

Committers

Last synced: about 3 years ago

All Time
  • Total Commits: 371
  • Total Committers: 10
  • Avg Commits per committer: 37.1
  • Development Distribution Score (DDS): 0.604
Top Committers
Name Email Commits
dcurrey88 d****8@g****m 147
Ryan Hays r****8@g****m 79
rydmel r****o@g****m 51
lukeoftheshire l****s@g****m 25
jlavoie9 j****e@b****u 23
Aditya Vaidyam a****m@b****u 19
carlan1 c****1@g****m 14
Aditya Vaidyam a****m@u****m 5
lugray1 l****y@l****u 4
Ryan D'Mello 4****l@u****m 4
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: over 2 years ago

All Time
  • Total issues: 0
  • Total pull requests: 107
  • Average time to close issues: N/A
  • Average time to close pull requests: 5 days
  • Total issue authors: 0
  • Total pull request authors: 7
  • Average comments per issue: 0
  • Average comments per pull request: 0.28
  • Merged pull requests: 94
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 10
  • Average time to close issues: N/A
  • Average time to close pull requests: about 11 hours
  • Issue authors: 0
  • Pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 0.1
  • Merged pull requests: 9
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • e-rozenblit (1)
Pull Request Authors
  • dcurrey88 (68)
  • carlan1 (21)
  • lukeoftheshire (9)
  • MattMatt27 (6)
  • rydmel (5)
  • ryan-hays (5)
  • burnsjt23 (5)
  • lugray1 (2)
  • jinsoo2311 (1)
  • e-rozenblit (1)
Top Labels
Issue Labels
Pull Request Labels
bug (25) enhancement (21) feature (9) documentation (2) testing (1)

Dependencies

poetry.lock pypi
  • altair 4.1.0
  • attrs 21.2.0
  • certifi 2020.12.5
  • compress-pickle 2.0.1
  • datetime 4.3
  • entrypoints 0.3
  • fastdtw 0.3.4
  • geographiclib 1.50
  • geopy 2.1.0
  • jinja2 3.0.1
  • joblib 1.0.1
  • jsonschema 3.2.0
  • lamp-core 2021.5.18
  • markupsafe 2.0.1
  • nulltype 2.3.1
  • numpy 1.20.3
  • pandas 1.2.4
  • pyrsistent 0.17.3
  • python-dateutil 2.8.1
  • pytz 2021.1
  • scikit-learn 0.24.2
  • scipy 1.6.1
  • shapely 1.7.1
  • similaritymeasures 0.4.4
  • six 1.16.0
  • sklearn 0.0
  • threadpoolctl 2.1.0
  • toolz 0.11.1
  • tzwhere 3.0.3
  • urllib3 1.26.4
  • zope.interface 5.4.0
pyproject.toml pypi
  • DateTime ^4.3
  • LAMP-core ^2021.5.18
  • altair ^4.1.0
  • compress-pickle ^2.0.1
  • fastdtw ^0.3.4
  • geopy ^2.1.0
  • matplotlib ^3.4.1
  • numpy ^1.20.3
  • pandas ^1.2.4
  • pymongo ^4.1.1
  • python ^3.8
  • pytz ^2021.1
  • pyyaml ^5.4.1
  • scipy ^1.6.2
  • seaborn ^0.11.1
  • similaritymeasures ^0.4.4
  • sklearn ^0.0
  • statsmodels ^0.12.2
  • tzwhere ^3.0.3
.github/workflows/publish.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite