generated from StanfordSpezi/SpeziTemplateApplication
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Firebase Integration and Confidence Filtering (#35)
# *Firebase Integration and Confidence Filtering* ## ♻️ Current situation & Problem Currently, the CoughSync app can detect coughs using sound analysis, but these detections are not persisted to any backend service. This means that cough data is lost when the app is closed, preventing long-term tracking and analysis. Additionally, the current implementation accepts all detected coughs regardless of confidence level, leading to potential false positives. This PR implements the Firebase integration for cough data storage, fixes dependency injection issues in the CoughDetectionViewModel, and adds confidence filtering to ensure only high-quality cough detections are recorded. ## ⚙️ Release Notes Key features: - Cough detections are now automatically stored in Firebase via the CoughSyncStandard - Only moderate-confidence coughs (>50%) are recorded to reduce false positives - Cough model enhanced to include confidence score information - Fixed dependency injection issues in view models to properly access the - - CoughSyncStandard Example of Firebase integration and confidence filtering: if displayName == "Coughs" && confidence > 0.5 { // Only record if confidence > 50% let cough = Cough(timestamp: Date(), confidence: confidence) coughCollection.addCough(cough) // Store the cough in Firebase Task { await standard.add(cough: cough) } } ## 📚 Documentation This PR introduces Firebase integration for persistent storage of cough detection data. When a cough is detected with sufficient confidence (>50%), it is both stored locally in the CoughCollection and sent to Firebase through the CoughSyncStandard interface. The Cough model has been enhanced to include a confidence property that stores the machine learning model's confidence level for each detection. This value ranges from 0.0 to 1.0, with higher values indicating greater confidence. By filtering coughs at the 0.5 threshold, we significantly reduce false positives while maintaining detection sensitivity. The dependency injection architecture has been improved to properly access the CoughSyncStandard from the SwiftUI environment. This follows the Spezi framework's recommended patterns for dependency injection, initializing view models when their containing views appear to ensure environment values are available. All code changes are documented with inline comments explaining the purpose of each component and the rationale behind design decisions, in accordance with the Spezi Documentation Guide. ## ✅ Testing Testing verified Firebase storage, confidence filtering effectiveness, and dependency injection fixes. Manual testing was used due to audio input simulation challenges. ## 📝 Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/CS342/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/CS342/.github/blob/main/CONTRIBUTING.md): - [x] I agree to follow the [Code of Conduct](https://github.com/CS342/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/CS342/.github/blob/main/CONTRIBUTING.md).
- Loading branch information
Showing
6 changed files
with
105 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -352,6 +352,9 @@ | |
} | ||
} | ||
} | ||
}, | ||
"Loading..." : { | ||
|
||
}, | ||
"Next" : { | ||
"localizations" : { | ||
|