Skip to content

Commit d83fa24

Browse files
feat: handle additional doses from a data row (#374)
Map ADDL and II columns, in the CSV, to repeat doses in the model and simulations.
1 parent 7ff2ad8 commit d83fa24

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

pkpdapp/pkpdapp/models/dataset.py

+8
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ def replace_data(self, data: pd.DataFrame):
164164
observation_name = row["OBSERVATION_NAME"]
165165
route = row['ROUTE']
166166
infusion_time = row['INFUSION_TIME']
167+
try:
168+
repeats = int(row['ADDITIONAL_DOSES']) + 1
169+
repeat_interval = float(row['INTERDOSE_INTERVAL'])
170+
except ValueError:
171+
repeats = 1
172+
repeat_interval = 1.0
167173

168174
amount_unit = Unit.objects.get(symbol=amount_unit)
169175

@@ -201,6 +207,8 @@ def replace_data(self, data: pd.DataFrame):
201207
amount=amount,
202208
duration=infusion_time,
203209
protocol=protocol,
210+
repeats=repeats,
211+
repeat_interval=repeat_interval,
204212
)
205213

206214
# insert covariate columns as categorical for now

pkpdapp/pkpdapp/utils/data_parser.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ class DataParser:
6161
],
6262
"GROUP_ID": [
6363
"Group ID", "Group", "GROUP", "cohort", "Cohort", "COHORT"
64+
],
65+
"ADDITIONAL_DOSES": [
66+
"ADDL", "Addl", "addl", "ADDITIONAL_DOSES"
67+
],
68+
"INTERDOSE_INTERVAL": [
69+
"II", "INFUSION_INTERVAL"
6470
]
6571
}
6672

@@ -81,7 +87,9 @@ class DataParser:
8187
"COMPOUND",
8288
"ROUTE",
8389
"INFUSION_TIME",
84-
"GROUP_ID"
90+
"GROUP_ID",
91+
"ADDITIONAL_DOSES",
92+
"INTERDOSE_INTERVAL"
8593
]
8694

8795
alternate_unit_names = {
@@ -189,6 +197,12 @@ def map_unit_names(x):
189197
if "GROUP_ID" not in found_cols:
190198
data["GROUP_ID"] = 1
191199

200+
# put in default additional dosing columns if not present
201+
if "ADDITIONAL_DOSES" not in found_cols:
202+
data["ADDITIONAL_DOSES"] = ""
203+
if "INTERDOSE_INTERVAL" not in found_cols:
204+
data["INTERDOSE_INTERVAL"] = ""
205+
192206
# put in default units if not present, convert any percentage units
193207
# to dimensionless
194208
for unit_col in ["TIME_UNIT", "AMOUNT_UNIT", "OBSERVATION_UNIT"]:

0 commit comments

Comments
 (0)