Skip to content

Add/task.mimic ckd#550

Closed
jhnwu3 wants to merge 8 commits into
masterfrom
add/task.mimic_ckd
Closed

Add/task.mimic ckd#550
jhnwu3 wants to merge 8 commits into
masterfrom
add/task.mimic_ckd

Conversation

@jhnwu3

@jhnwu3 jhnwu3 commented Sep 19, 2025

Copy link
Copy Markdown
Collaborator

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:

  • Added TestMIMIC4CKDSurv class in tests/core/test_mimic4_ckd_surv.py that downloads the MIMIC-IV demo dataset using wget, initializes a MIMIC4Dataset with required EHR tables, and runs the MIMIC4CKDSurvAnalysis task 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.

@jhnwu3 jhnwu3 requested a review from Copilot September 19, 2025 20:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 MIMIC4CKDSurvAnalysis task 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.

Comment thread pyhealth/tasks/ckd_surv.py Outdated
Comment on lines +17 to +20
- 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/)

Copilot AI Sep 19, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation in the docstring is inconsistent. Lines 17-20 should align with line 16 for proper formatting.

Suggested change
- 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/)

Copilot uses AI. Check for mistakes.
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)

Copilot AI Sep 19, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
- Original coefficient: 142 (updated from 141 in this implementation)
- Base coefficient used in this implementation: 142 (original implementation used 141)

Copilot uses AI. Check for mistakes.
Comment on lines +44 to +51
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"
)

Copilot AI Sep 19, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@jhnwu3 jhnwu3 closed this Oct 8, 2025
@jhnwu3 jhnwu3 deleted the add/task.mimic_ckd branch October 8, 2025 18:15
@jhnwu3 jhnwu3 restored the add/task.mimic_ckd branch October 27, 2025 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants