CoziePy: Python Package for Cozie
We have created a Python package for Cozie to make data wrangling with Cozie data as convenient as possible. The package is called CoziePy and is available on pypi.org
The packages helps with download in Cozie data from the backend, parsing the log file from the Cozie app, and it as some plotting functionality.Please note the CoziePy is still in early development. Hence, frequent changes are to be expected.
There are several ways to load Cozie data. We have listed a few examples below.
Import CoziePy and create a
from coziepy import Cozie
cozie = Cozie()
Parse from Cozie app log file
log_file is the path to the file downloaded from within the Cozie app.
output_file is an optional input parameter to save the Cozie dataframe as zipped parquet file. Alternatively, .csv is also a valid file extension but results in approximately ten times larger files.
clean_up currently needs to set to 'False' when parsing offline log files.
df = cozie.load(log_file="/content/cozie_example_participant_01_example_experiment_logs.txt",
Download data using the web API
api_key is provided by us. Please contact us at email@example.com if you need one.
df = cozie.load(id_experiment = "example_experiment",
participant_list = ["example_participant_01", "example_participant_02"],
timezone = "Asia/Singapore",
Load data from previously processed data
df = cozie.load(input_file="example.parquet.gzip")
CoziePy has some plotting functionality which is mainly focused on experiment monitoring and debugging. In the examples below it is assumed that you have already generated a Pandas dataframe containing Cozie data using one of the examples above.
Plot time-series data for one participant
fig, ax = cp.ts_inspection(id_participant='example_participant_01', column_name='ts_heart_rate')