Skip to content

Commit fcf23a0

Browse files
committed
Merge branch 'main' of github.com:AI2MS/pyAKI
2 parents 5b94e61 + 49be7db commit fcf23a0

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
Python package to detect AKI within time series data.
66

77
The goal of this package is to establish well tested, comprehensive functions for the detection of Acute Kidney Injury (AKI) in time series data, according to the Kidney Disease Improving Global Outcomes (KDIGO) Criteria, established in 2012 [^kdigo].
8+
![](img/kdigo_criteria.png)
89

910
## Installation
1011

@@ -30,6 +31,4 @@ process_stay(stay_id: int,
3031
PYTHONPATH=".:${PYTHONPATH}" python -m unittest discover
3132
```
3233

33-
![kdigo_criteria](img/kdigo_criteria.png)
34-
35-
[^kdigo]: Khwaja A. KDIGO clinical practice guidelines for acute kidney injury. Nephron Clin Pract. 2012;120(4):c179-84. doi: 10.1159/000339789. Epub 2012 Aug 7. PMID: 22890468.
34+
[^kdigo]: Improving Global Outcomes (KDIGO) Acute Kidney Injury Work Group. KDIGO Clinical Practice Guideline for Acute Kidney Injury. Kidney inter., Suppl. 2012; 2: 1–138.

pyAKI/kdigo.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import logging
2+
13
from typing import Optional
24

35
import pandas as pd
@@ -20,6 +22,8 @@
2022

2123
from pyAKI.utils import Dataset
2224

25+
logger = logging.getLogger(__name__)
26+
2327

2428
class Analyser:
2529
"""
@@ -89,9 +93,12 @@ def __init__(
8993
self.validate_data(data)
9094

9195
# apply preprocessors to the input data
96+
logger.info("Start preprocessing")
9297
for preprocessor in preprocessors:
9398
data = preprocessor.process(data)
9499

100+
logger.info("Finish preprocessing")
101+
95102
self._data: list[Dataset] = data
96103
self._probes: list[Probe] = probes
97104
self._stay_identifier: str = stay_identifier
@@ -111,6 +118,8 @@ def process_stays(self) -> pd.DataFrame:
111118
Returns:
112119
pd.DataFrame: The analysis results for all stays.
113120
"""
121+
logger.info("Start probing")
122+
114123
(_, df), *datasets = self._data
115124
stay_ids: pd.Index = df.index.get_level_values("stay_id").unique()
116125
for _, df in datasets:
@@ -119,7 +128,8 @@ def process_stays(self) -> pd.DataFrame:
119128
data: pd.DataFrame = self.process_stay(stay_ids.values[0])
120129
for stay_id in stay_ids.values[1:]:
121130
data = pd.concat([data, self.process_stay(stay_id)])
122-
# data = data.drop(columns=["stay_id"]) # remove additional stay_id column
131+
132+
logger.info("Finish probing")
123133
return data
124134

125135
def process_stay(self, stay_id: str) -> pd.DataFrame:
@@ -135,6 +145,7 @@ def process_stay(self, stay_id: str) -> pd.DataFrame:
135145
Returns:
136146
pd.DataFrame: The analysis results for the specific stay.
137147
"""
148+
logger.debug("Processing stay with id: %s", stay_id)
138149

139150
datasets: list[Dataset] = [
140151
Dataset(dtype, data.loc[stay_id]) for dtype, data in self._data # type: ignore

pyAKI/utils.py

+8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
import logging
2+
13
from typing import NamedTuple, cast
24
from enum import StrEnum, auto
35
from functools import wraps
46

57
import numpy as np
68
import pandas as pd
79

10+
logger = logging.getLogger(__name__)
11+
812

913
class DatasetType(StrEnum):
1014
"""Enumeration class representing different types of datasets."""
@@ -89,6 +93,10 @@ def wrapper(self, datasets: list[Dataset], *args, **kwargs) -> list[Dataset]:
8993
}
9094
# check if all datasets are mapped, otherwise return the original datasets
9195
if len(in_mapping) != len(_mapping):
96+
logger.warning(
97+
"Skip %s because one or more datasets are missing to probe",
98+
self.__class__.__name__,
99+
)
92100
return datasets
93101

94102
# call the wrapped function with the converted DataFrames

0 commit comments

Comments
 (0)