Skip to content

Commit

Permalink
Merge pull request #62 from WenjieDu/dev
Browse files Browse the repository at this point in the history
Return physionet_2019 as two subsets;
  • Loading branch information
WenjieDu committed May 28, 2024
2 parents 18264e8 + c5ba01c commit 39f8e66
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions tsdb/loading_funcs/physionet_2019.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,25 @@

def load_physionet2019(local_path):
time_series_measurements_dir = ["training", "training_setB"]
label_feature = "SepsisLabel" # feature SepsisLabel contains labels indicating whether patients get sepsis
time_feature = "ICULOS" # ICU length-of-stay (hours since ICU admit)
# label_feature = "SepsisLabel" # feature SepsisLabel contains labels indicating whether patients get sepsis
# time_feature = "ICULOS" # ICU length-of-stay (hours since ICU admit)

df_collector = []
set_collector = []
for m_ in time_series_measurements_dir:
df_collector = []
raw_data_dir = os.path.join(local_path, m_)
for filename in os.listdir(raw_data_dir):
recordID = filename.split(".psv")[0]
with open(os.path.join(raw_data_dir, filename), "r") as f:
df_temp = pd.read_csv(f, sep="|", header=0)
df_temp["RecordID"] = recordID
df_collector.append(df_temp)

df = pd.concat(df_collector, sort=True)
df = df.reset_index(drop=True)
y = df[["RecordID", time_feature, label_feature]]
X = df.drop(label_feature, axis=1)

data = {"X": X, "y": y, "static_features": ["Age", "Gender", "HospAdmTime"]}
df = pd.concat(df_collector, sort=True)
set_collector.append(df)

data = {
"training_setA": set_collector[0],
"training_setB": set_collector[1],
"static_features": ["Age", "Gender", "Unit1", "Unit2", "HospAdmTime"],
}
return data

0 comments on commit 39f8e66

Please sign in to comment.