If you'd like to follow along with this tutorial but don't have a Python development environment set up, consider using Google Collab, a free service from Google Research.
First install the package.
Then, import the library and connect to the server.
Methods native to the LAMP API can now be called to pull data from the platform.
For example, we can find all of the participants belonging to a Researcher:
The code below will make CSV files of all the 'lamp.gps.contextual' sensor events for all participants under a given researcher id:
Query sensor data with "all_by_participant"
Specify a sensor with "origin". If no origin is passed, it will try to query all sensors
Note that due to device or user specification, some spensors may not have data
Accelerometer data points are SensorEvents with the origin "lamp.accelerometer".
See LAMP-py documentation at https://github.com/BIDMCDigitalPsychiatry/LAMP-py for further API details.
Query responses are limtied to 1000 entries. In the event that there are more than 1000 events for a given sensor, the most recent 1000 events are returned. To access more data—or to query during a specific time range—you must use the "_to" and "from" parameters
Surveys are ActivityEvents, with each survey type defined as an Activity
'duration' is the survey completion time, in ms
'activity' is the Activity id
'temporal_slices' contains responses for each survey question
Details of the 'activity can be be viewed the following method
Pandas dataframe-based functionality has been implemented on top of the protocol methods to allow users to more easily work with data. This functionality is in the form of "ParticipantExt" and "StudyExt" objects.
"ParticipantExt" objects are designed to represent individual LAMP participants. They are separet from the "Participant" object defined in the protocol. The objects have various properties and methods that will discussed here and can be viewed in more detail in the "participant_ext.py" file.
Subjects are be initialized with their LAMP id, as well as various other (optional) fields:
Integrated data can now be viewed in the Subject's df:
To create this dataframe, "ParticipantExt.create_df()" is automatically called upon ParticipantExt initialization. A dataframe with customizable properties can also be generated after intialization:
If you have many participants that would like to group together as a cohort, you can do so with the StudyExt object.
A StudyExt consists of one or many ParticipantExt objects. They are initialized with a list of valid LAMP ids, along with other (optional) parameters:
Many methods are shared between ParticipantExt and StudyExt objects. More details on StudyExt objects can be viewed in the "study_ext.py" file.