diff --git a/README.md b/README.md index 045710e..6a69285 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,30 @@ To install watchlib simply run: pip install watchlib ``` +## Update to newest version +``` +pip install --upgrade watchlib +``` + +## Run watchlib demonstrator +First you will have to download the demonstrator Python file [here](https://github.com/marcjulianschwarz/watchlib/blob/main/demonstrator/watchlib_demonstrator.py). + +To run it, you will need to install streamlit: +``` +pip install streamlit +``` +and watchlib: +``` +pip install watchlib +``` + +After you have installed both modules, navigate to the `watchlib_demonstrator.py` file and run the following command: +``` +streamlit run watchlib_demonstrator.py +``` ## How to export Apple Watch health data -To use this Python package you first have to export the health data like this: 1. Open *Health* app 2. Open your profile in the upper right corner diff --git a/demonstrator/watchlib_demonstrator.py b/demonstrator/watchlib_demonstrator.py index 76e52f6..a9fd4e2 100644 --- a/demonstrator/watchlib_demonstrator.py +++ b/demonstrator/watchlib_demonstrator.py @@ -1,6 +1,3 @@ -import sys -sys.path.append("../") - import streamlit as st import streamlit.components.v1 as components from datetime import datetime as dt @@ -9,14 +6,15 @@ from watchlib.animation import WorkoutAnimation, constants, WorkoutAnimationConfig from watchlib.filtering import CountryFilter, DiagonalBBoxFilter, TimeFilter, FilterPipeline from watchlib.data_handler import DataLoader, CacheHandler -from watchlib.analysis import heart_rate_variability, bpm -from watchlib.plot import plot_ecg +from watchlib.analysis import heart_rate_variability, bpm, stats +from watchlib.plot import plot_ecg, distribution_for from watchlib.utils.structs import ECG, WorkoutRoute def header(): st.write("# Watchlib Demo") + def set_selected_route(): st.session_state.selected_route = [ route for route in st.session_state.all_routes if route.name == st.session_state.route_option][0] @@ -229,19 +227,32 @@ def start(): f"{len(list(data))} dataframes have been loaded.") if "data" in st.session_state: - st.sidebar.selectbox('Select a key', list( - st.session_state.data.keys()), key="data_option", on_change=set_selected_data) + st.sidebar.selectbox('Select a key', sorted(list( + st.session_state.data.keys())), key="data_option", on_change=set_selected_data) selected_data = st.session_state.data[st.session_state.data_option] st.session_state.selected_data = selected_data if "data" in st.session_state: st.write("## Health Data") + + # left_c, right_c = st.columns(2) + # with left_c: + st.write("### Distribution") + st.slider("Bins", min_value=0, max_value=400, value=35, step=1, key="bins") + st.write(distribution_for(st.session_state.selected_data, st.session_state.bins)) + # with right_c: + # _max, _min = stats(st.session_state.selected_data) + # st.write("### Stats") + # st.write(f"Max: {_max}") + # st.write(f"Min {_min}") + if st.button("Show dataframe"): if st.session_state.selected_data is None: st.error("Please specify a health path in the sidebar first.") else: st.write(f"## {st.session_state.data_option}") st.write(st.session_state.selected_data) + if __name__ == "__main__":