Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ad723ed
Add task
ParadoxicalNerd Apr 4, 2026
a36625c
cleanup
ParadoxicalNerd Apr 4, 2026
c344e07
add uv config
ParadoxicalNerd Apr 4, 2026
18167ba
Add support for chartevents
ParadoxicalNerd Apr 11, 2026
636dfb6
tpc.py
pranash2 Apr 19, 2026
8ce3978
Add TPC model implementation with comprehensive tests and documentation
tarakjc2c Apr 20, 2026
11e9947
Add setup instructions for groupmates
tarakjc2c Apr 20, 2026
e45fc6b
Add Google Colab notebook for TPC ablation study
tarakjc2c Apr 20, 2026
82e4634
Add fixed Google Colab notebook for TPC ablation study
tarakjc2c Apr 20, 2026
0a03a7c
Add working Google Colab notebook for TPC ablation
tarakjc2c Apr 20, 2026
6f31442
Fix Colab notebook to handle Windows path conversion
tarakjc2c Apr 20, 2026
49ad5df
Fix Colab notebook JSON escaping issues
tarakjc2c Apr 20, 2026
f2099ab
Add data finder to Colab notebook
tarakjc2c Apr 20, 2026
0bc94f0
Download MIMIC-IV data directly in Colab from shared Drive link
tarakjc2c Apr 20, 2026
d559c9f
Fix gdown download path handling in Colab
tarakjc2c Apr 20, 2026
d55c965
Fix Colab notebook: prevent nested dirs, robust download verification
tarakjc2c Apr 20, 2026
bb41a82
Add option to upload local data to Drive, improve verification
tarakjc2c Apr 20, 2026
b249bdf
Update TPC model and add demo data for chartevents tests
tarakjc2c Apr 21, 2026
b1549e5
Add contributor names and NetIDs
tarakjc2c Apr 21, 2026
fecd9a1
Fix contributor name formatting in TPC tasks file
tarakjc2c Apr 21, 2026
6129670
Clean up: Remove development artifacts from PR
tarakjc2c Apr 21, 2026
ea0a3f4
Add full pipeline replication for extra credit
tarakjc2c Apr 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ API Reference
models/pyhealth.models.GRASP
models/pyhealth.models.MedLink
models/pyhealth.models.TCN
models/pyhealth.models.TPC
models/pyhealth.models.TFMTokenizer
models/pyhealth.models.GAN
models/pyhealth.models.VAE
Expand Down
44 changes: 44 additions & 0 deletions docs/api/models/pyhealth.models.tpc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
pyhealth.models.TPC
===================

Temporal Pointwise Convolution (TPC) model for ICU remaining length-of-stay prediction.

Overview
--------

The TPC model combines grouped temporal convolutions with pointwise (1x1) convolutions to
capture both feature-specific temporal patterns and cross-feature interactions at each timestep.
The architecture is specifically designed for irregularly sampled multivariate time series in
intensive care settings.

**Paper Reference:**
Rocheteau, E., Liò, P., & Hyland, S. (2021). Temporal Pointwise Convolutional Networks for
Length of Stay Prediction in the Intensive Care Unit. In Proceedings of the Conference on
Health, Inference, and Learning (CHIL).

**Key Features:**

- Grouped temporal convolutions (one group per clinical feature)
- Pointwise convolutions for cross-feature learning
- Skip connections with hierarchical feature aggregation
- Custom MSLE (Masked Mean Squared Logarithmic Error) loss
- Monte Carlo Dropout for uncertainty estimation (extension)

**Model Classes:**

.. autoclass:: pyhealth.models.TPC
:members:
:undoc-members:
:show-inheritance:

**Loss Functions:**

.. autoclass:: pyhealth.models.MSLELoss
:members:
:undoc-members:
:show-inheritance:

.. autoclass:: pyhealth.models.MaskedMSELoss
:members:
:undoc-members:
:show-inheritance:
1 change: 1 addition & 0 deletions docs/api/tasks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ Available Tasks
DKA Prediction (MIMIC-IV) <tasks/pyhealth.tasks.dka>
Drug Recommendation <tasks/pyhealth.tasks.drug_recommendation>
Length of Stay Prediction <tasks/pyhealth.tasks.length_of_stay_prediction>
Remaining LoS (TPC MIMIC-IV) <tasks/pyhealth.tasks.length_of_stay_tpc_mimic4>
Medical Transcriptions Classification <tasks/pyhealth.tasks.MedicalTranscriptionsClassification>
Mortality Prediction (Next Visit) <tasks/pyhealth.tasks.mortality_prediction>
Mortality Prediction (StageNet MIMIC-IV) <tasks/pyhealth.tasks.mortality_prediction_stagenet_mimic4>
Expand Down
67 changes: 67 additions & 0 deletions docs/api/tasks/pyhealth.tasks.length_of_stay_tpc_mimic4.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
pyhealth.tasks.length_of_stay_tpc_mimic4
===========================================

Remaining ICU length-of-stay prediction task for MIMIC-IV with TPC-compatible preprocessing.

Overview
--------

The RemainingLOSMIMIC4 task generates samples for predicting remaining ICU length of stay at
hourly intervals. Unlike traditional length-of-stay tasks that predict total stay duration at
admission, this task formulates the problem as a time-series regression where the model predicts
remaining hours at each timestep throughout the ICU stay.

**Input Features:**

- **Timeseries** ``(2F+2, T)``: Hourly clinical measurements with:

- Elapsed time channel (1)
- Feature values from chartevents and labevents (F channels)
- Decay indicators showing time since last measurement (F channels)
- Hour of day (1 channel)

- **Static** ``(2,)``: Patient demographics (age, sex)

- **Conditions**: ICD diagnosis codes from admission

**Output:**

- **Remaining LoS** ``(T,)``: Remaining hours in ICU at each timestep


**Default Configuration:**

- Prediction step size: 1 hour
- Minimum history: 5 hours before predictions start
- Minimum remaining stay: 1 hour
- Maximum history window: 366 hours (15.25 days)
- Clinical features: 17 chartevents + 17 labevents = 34 features

**Clinical Features:**

*Vital Signs (chartevents):*

- Heart rate, blood pressure (systolic/diastolic/mean)
- Respiratory rate, SpO2, temperature
- Glasgow Coma Scale components
- Urine output, weight

*Laboratory Values (labevents):*

- Hematology: WBC, platelets, hemoglobin, hematocrit
- Chemistry: sodium, potassium, chloride, bicarbonate
- Renal: BUN, creatinine
- Metabolic: glucose, lactate
- Liver: bilirubin, ALT
API Reference
-------------

.. autoclass:: pyhealth.tasks.length_of_stay_tpc_mimic4.RemainingLOSMIMIC4
:members:
:undoc-members:
:show-inheritance:

.. autoclass:: pyhealth.tasks.length_of_stay_tpc_mimic4.RemainingLOSConfig
:members:
:undoc-members:
:show-inheritance:
Loading