Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into dev
  • Loading branch information
WenjieDu committed May 25, 2024
2 parents fbad4e1 + a6e89dc commit 83a9aa5
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions tsdb/loading_funcs/physionet_2012.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,11 @@ def load_physionet2012(local_path):
) # ensure RecordID's type is int
outcome = outcome.set_index("RecordID")
outcome_collector.append(outcome)
y = pd.concat(outcome_collector)

df_collector = []

# iterate over all samples
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 = int(filename.split(".txt")[0])
Expand All @@ -80,11 +79,16 @@ def load_physionet2012(local_path):
df_temp["Age"] = df_temp.loc[0, "Age"]
df_temp["Height"] = df_temp.loc[0, "Height"]
df_collector.append(df_temp)

df = pd.concat(df_collector, sort=True)
X = df.reset_index(drop=True)
unique_ids = df["RecordID"].unique()
y = y.loc[unique_ids]

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

data = {
"set-a": set_collector[0],
"set-b": set_collector[1],
"set-c": set_collector[2],
"outcomes-a": outcome_collector[0],
"outcomes-b": outcome_collector[1],
"outcomes-c": outcome_collector[2],
"static_features": ["Age", "Gender", "ICUType", "Height"],
}
return data

0 comments on commit 83a9aa5

Please sign in to comment.