Add/task.mimic ckd#550
Conversation
… into add/task.mimic_ckd
There was a problem hiding this comment.
Pull Request Overview
This pull request adds comprehensive integration testing for the CKD survival analysis task on the MIMIC-IV demo dataset. The implementation includes a new task class for chronic kidney disease survival prediction with support for three different analysis modes and a robust test suite that handles various environment constraints.
- Added
MIMIC4CKDSurvAnalysistask class supporting time-invariant, time-variant, and heterogeneous survival analysis modes - Implemented comprehensive integration test that downloads MIMIC-IV demo data and validates the complete pipeline
- Added graceful handling for missing dependencies and network connectivity issues in the test environment
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/core/test_mimic4_ckd_surv.py | Integration test suite that downloads MIMIC-IV demo data and validates CKD survival analysis across all supported modes |
| pyhealth/tasks/ckd_surv.py | New task implementation for CKD survival analysis with eGFR calculation, patient filtering, and mode-specific processing |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| - Original implementation: pkgs.data.utils.calculate_eGFR() | ||
| - Formula source: pkgs.data.store.get_egfr_df() | ||
| - Reference: CKD-EPI 2021 formula | ||
| (https://pubmed.ncbi.nlm.nih.gov/34554658/) |
There was a problem hiding this comment.
The indentation in the docstring is inconsistent. Lines 17-20 should align with line 16 for proper formatting.
| - Original implementation: pkgs.data.utils.calculate_eGFR() | |
| - Formula source: pkgs.data.store.get_egfr_df() | |
| - Reference: CKD-EPI 2021 formula | |
| (https://pubmed.ncbi.nlm.nih.gov/34554658/) | |
| - Original implementation: pkgs.data.utils.calculate_eGFR() | |
| - Formula source: pkgs.data.store.get_egfr_df() | |
| - Reference: CKD-EPI 2021 formula | |
| (https://pubmed.ncbi.nlm.nih.gov/34554658/) |
| Implementation adapted from original MIMIC-IV analysis code: | ||
| - Source file: pkgs.data.utils.calculate_eGFR() | ||
| - Formula: CKD-EPI 2021 (https://pubmed.ncbi.nlm.nih.gov/34554658/) | ||
| - Original coefficient: 142 (updated from 141 in this implementation) |
There was a problem hiding this comment.
This comment is confusing - it states the coefficient was 'updated from 141' but the implementation uses 142. The comment should clarify whether this is maintaining the original value or if there was an actual change.
| - Original coefficient: 142 (updated from 141 in this implementation) | |
| - Base coefficient used in this implementation: 142 (original implementation used 141) |
| try: | ||
| subprocess.run(cmd, check=True, capture_output=True, text=True) | ||
| except subprocess.CalledProcessError as e: | ||
| raise unittest.SkipTest(f"Failed to download MIMIC-IV demo dataset: {e}") | ||
| except FileNotFoundError: | ||
| raise unittest.SkipTest( | ||
| "wget not available - skipping MIMIC-IV download test" | ||
| ) |
There was a problem hiding this comment.
The subprocess call executes wget with user-controlled URL without validation. Consider validating the download URL or using a more secure HTTP client library to prevent potential security issues.
This pull request adds a new integration test for the CKD survival analysis task on the MIMIC-IV demo dataset, ensuring that the pipeline works end-to-end with real data. The test is designed to be robust in various environments by gracefully skipping if dependencies or network access are unavailable.
Testing and integration improvements:
TestMIMIC4CKDSurvclass intests/core/test_mimic4_ckd_surv.pythat downloads the MIMIC-IV demo dataset usingwget, initializes aMIMIC4Datasetwith required EHR tables, and runs theMIMIC4CKDSurvAnalysistask in all supported modes (time_invariant,time_variant,heterogeneous). The test prints and validates sample outputs for each mode, and is tolerant to missing dependencies or lack of network access by skipping tests when necessary.