Skip to content

Commit

Permalink
Fix inconsistency in string values in the visualisation module (#71)
Browse files Browse the repository at this point in the history
# *Fix inconsistency in string values in the visualisation module*

## ⚙️ Release Notes 
- Updated the `visualization` module to include enumeration for
diagnosis-related string in order to ensure consistency and easier
maintainability.


### Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md).

---------

Co-authored-by: Paul Schmiedmayer <[email protected]>
  • Loading branch information
Vicbi and PSchmiedmayer authored Jul 30, 2024
1 parent eae1fce commit c146ce7
Show file tree
Hide file tree
Showing 15 changed files with 3,901 additions and 5,087 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ jobs:
uses: actions/setup-python@v5
- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: '22'
- name: Setup Java
uses: actions/setup-java@v3
with:
Expand Down Expand Up @@ -129,13 +131,16 @@ jobs:
- name: Install ECGReviewer Dependencies
run: |
pip install -r ./ecg_data_manager/requirements.txt
- name: Install Cloud Functions Dependencies
run: |
npm install --prefix functions
- name: Set Firestore Emulator Environment Variable
run: |
echo "FIRESTORE_EMULATOR_HOST=localhost:8080" >> $GITHUB_ENV
echo "GCLOUD_PROJECT=ecg_example_project" >> $GITHUB_ENV
- name: Run Firebase Emulator & Execute Notebook
run: |
firebase emulators:exec --import=./ecg_data_manager/sample_data "jupyter nbconvert --to pdf --execute ./ecg_data_manager/ECGReviewer_ColabBasic.ipynb"
firebase emulators:exec --import=./ecg_data_manager/sample_data "jupyter nbconvert --to pdf --execute './ecg_data_manager/ECG Reviewer.ipynb'"
env:
CI: true
- uses: actions/upload-artifact@v4
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,6 @@ __pycache__/

# Fastlane
.screenshots/

# Stanford Google Cloud Setup
ecg_data_manager/packages*
61 changes: 56 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ SPDX-License-Identifier: MIT


This repository contains the Pediatric Apple Watch Study Application application.
The Pediatric Apple Watch Study Application is using the [Spezi](https://github.com/StanfordSpezi/Spezi) ecosystem and builds on top of the [Stanford Spezi Template Application](https://github.com/StanfordSpezi/SpeziTemplateApplication).
The Pediatric Apple Watch Study Application uses the [Spezi](https://github.com/StanfordSpezi/Spezi) ecosystem and builds on top of the [Stanford Spezi Template Application](https://github.com/StanfordSpezi/SpeziTemplateApplication).


## Application Structure
Expand All @@ -33,6 +33,7 @@ The application uses the FHIR standard to provide a shared standard to encode da

You can build and run the application using [Xcode](https://developer.apple.com/xcode/) by opening up the **PAWS.xcodeproj**.


## Generate Invitation Codes

When signing in to the application for the first time, you will be required to enter a valid invitation code before a user account is created.
Expand All @@ -47,9 +48,11 @@ python -m scripts.upload_codes --outfile=<local_path> \
--service_account=<service_account_key_file> [--dry]
```


## Generate Screenshots

PAWS uses [Fastlane Snapshots](https://docs.fastlane.tools/getting-started/ios/screenshots/) to automatically screenshot specific screens in the app during UI tests.
To generate new screenshots, you will likewise need to set the proper environment variables for you shell session.
To generate new screenshots, you will likewise need to set the proper environment variables for your shell session.

```bash
export FIRESTORE_EMULATOR_HOST="localhost:8080"
Expand All @@ -73,7 +76,7 @@ for i in {1..360}; do python -m scripts.upload_codes; sleep 10; done

## ECG Data Manager

The ECG Data Manager provides capabilities for reviewing and exploring the recorded ECG data. It relies on the [spezi_data_pipeline](https://test.pypi.org/project/spezi-data-pipeline/0.1.0b1/) package which is a library engineered to improve workflows associated with data accessibility and analysis in healthcare environments. In addition, to the functions and classes of the spezi_data_pipeline, the two notebooks, namely `ECGReviewer.ipynb` and `ECGExplore.ipynb` offer an environment for interactive data visualization and analysis.
The ECG Data Manager provides capabilities for reviewing and exploring the recorded ECG data. It relies on the [spezi_data_pipeline](https://pypi.org/project/spezi-data-pipeline/0.1.0) package, which is a library engineered to improve workflows associated with data accessibility and analysis in healthcare environments. In addition to the functions and classes of the spezi_data_pipeline, the two notebooks, namely `ECGReviewer.ipynb` and `ECGExplore.ipynb`, offer an environment for interactive data visualization and analysis.

The ECG Data Manager includes:
- `utils.py`: Provides utility functions for data processing.
Expand All @@ -94,15 +97,15 @@ cd PediatricAppleWatchStudy/ecg_data_manager

To run the notebooks, add them to Colab Enterprise within the same Google Cloud project as your Firebase setup. For other Python notebook environments, use the Firebase credentials and upload the `serviceAccountKey_file.json` to the workspace directory to enable Firebase access. This file is essential for authentication and should be securely handled.

### Use the Interactive ECG Reviewing Tool
#### Use the Interactive ECG Reviewing Tool

To start reviewing ECG data, execute the cells in your notebook.

This interactive tool allows you to plot ECG data, add diagnoses, evaluate the trace quality, and add notes.

![ecg_data_interactive_reviewer.png](ecg_data_manager/Figures/ecg_data_interactive_reviewer.png)

### Use the Interactive ECG Exploring Tool
#### Use the Interactive ECG Exploring Tool

To start exploring ECG data, execute the cells in your notebook.

Expand All @@ -111,6 +114,54 @@ This interactive tool allows you to plot ECG data, filter ECG recordings, and se
![ecg_data_interactive_explorer.png](ecg_data_manager/Figures/ecg_data_interactive_explorer.png)


## Firebase & Google Cloud Setup

The Google Cloud Setup at Stanford to deploy the project requires the following setup for Google Cloud Firebase and to execute the ECG review and exploration tools.

### Firebase Setup

Each Firebase Project for `development`, `staging`, and `production` GitHub environments need the following configurations:
- Firestore Database
- Firebase Authentication with Identity Platform (Anonymous Authentication, Username + Password, and Sign In With Apple Enabled)
- Firebase Storage
- Cloud Functions (also enable Cloud Build API, Google Cloud Run, and Eventarc API)

The CI setup requires a `github-deployment@PROJECT_ID.iam.gserviceaccount.com` account that requires the following rules:
- Cloud Datastore Index Admin
- Cloud Functions Developer
- Firebase Admin
- Firebase Rules Admin
- Service Account User on [email protected]

Set up a `cloudfunctionsserviceaccount@PROJECT_ID.iam.gserviceaccount.com` to execute cloud functions. It needs the following rules:
- Cloud Datastore User

### Notebooks & Colab Enterprise

Created a storage bucket that is used to store the packaged dependencies & code for the Python notebooks in a versioned and isolated state. You need to enable Colab Enterprise.

To secure the data in the notebook, [the network access should be retricted to needed Google Services only](https://cloud.google.com/colab/docs/service-controls) and using runners that only use a private network.

Run the following commands in the `ECGReviewer` folder to package the dependencies and upload them, as well as the `modules` folder to the cloud storage bucket if no outside internet access is enabled.
```sh
mkdir packages
pip download -r requirements.txt -d packages
tar -czvf packages.tar.gz packages/
```

Copy the `ECGExporter` and `ECGReviewer` notebooks in Colab Enterprise, uncomment, and adapt the storage bucket paths if the restricted network access is configured.


## Continous Integration Setup

The project supports different GitHub environments (`development`, `staging`, and `production`).
- The Firebase proejct ID needs to be saved as a GitHub variable with the name `FIREBASE_PROJECT_ID` for the different deployment environments.
- The service account key needs to be added to the GitHub secrets as `GOOGLE_APPLICATION_CREDENTIALS_BASE64` in a base64 encoding to enable the beta deployment.
- To report code coverage, a CodeCov token should be added as a `CODECOV_TOKEN` environment secret.
- The Firebase Google plist needs to be stored as a base64 encoded secret named `GOOGLE_SERVICE_INFO_PLIST_BASE64`.
- Store all secrets for a beta deployment of the iOS application as documented for the [Stanford Spezi Template Application](https://github.com/StanfordSpezi/SpeziTemplateApplication).


## Contributing

Contributions to this project are welcome. Please make sure to read the [contribution guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md) and the [contributor covenant code of conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md) first.
Expand Down
Loading

0 comments on commit c146ce7

Please sign in to comment.