Skip to content

Commit 7d8edea

Browse files
committed
fix: CSV data parsing fixes
- expand the lists of expected column headers for units and observations. - set non-numeric observations to 0.0.
1 parent 61f62c8 commit 7d8edea

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

frontend-v2/src/features/data/normaliseDataHeaders.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const normalisation = {
33
'Additional Doses': ['additional doses', 'additional dose', 'addl'],
44
'Administration ID': ['administration id', 'cmt', 'adm'],
55
'Amount': ['amount', 'amt' ],
6-
'Amount Unit': ['amount unit', 'amt_unit', 'amt_units', 'amtunit', 'amtunits'],
6+
'Amount Unit': ['amount unit', 'amt_unit', 'amt_units', 'amtunit', 'amtunits', 'units_amt'],
77
'Cat Covariate': ['cat covariate', 'cat', 'sex', 'gender', 'group', 'cohort', 'study', 'route', 'matrix'],
88
'Censoring': ['cens', 'blq', 'lloq'],
99
'Cont Covariate': ['cont covariate', 'weight', 'wt', 'bw', 'age', 'dose'],
@@ -15,12 +15,12 @@ const normalisation = {
1515
'Infusion Rate': ['infusion rate', 'rate'],
1616
'Interdose Interval': ['interdose interval', 'ii', 'tau', 'dosing interval'],
1717
'Observation': ['observation', 'dv', 'c', 'y', 'conc', 'cobs', 'obs'],
18-
'Observation Unit': ['observation unit', 'dv_units', 'c_units', 'y_units', 'yunit', 'cunit', 'obs_units', 'obs_unit', 'obsunit'],
18+
'Observation Unit': ['observation unit', 'dv_units', 'c_units', 'y_units', 'yunit', 'cunit', 'obs_units', 'obs_unit', 'obsunit', 'units_conc'],
1919
'Observation ID': ['observation id', 'ytype', 'dvid'],
2020
'Occasion': ['occasion', 'occ'],
2121
'Regressor': ['x', 'regressor'],
2222
'Time': ['time', 't', 'ivar'],
23-
'Time Unit': ['time_unit', 'time_units', 't_units', 'tunit'],
23+
'Time Unit': ['time_unit', 'time_units', 't_units', 'tunit', 'units_time'],
2424
'Unit': ['unit', 'units'],
2525
}
2626

pkpdapp/pkpdapp/models/dataset.py

+4
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ def replace_data(self, data: pd.DataFrame):
156156
subject = subjects[subject_id]
157157

158158
if observation != ".": # measurement observation
159+
try:
160+
observation = float(observation)
161+
except ValueError:
162+
observation = 0.0
159163
Biomarker.objects.create(
160164
time=time,
161165
subject=subject,

pkpdapp/pkpdapp/utils/data_parser.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,30 @@ class DataParser:
1919
"SUBJECT_ID"
2020
],
2121
"TIME": [
22-
"Time", "TIME", "TIMEPOINT", "t", "T", "time"
22+
"Time", "TIME", "TIMEPOINT", "t", "T", "time",
2323
],
2424
"TIME_UNIT": [
25-
"Time_unit", "Time_units", "TIMEUNIT", "TIME_UNIT"
25+
"Time_unit", "Time_units", "TIMEUNIT", "TIME_UNIT", "Units_Time"
2626
],
2727
"AMOUNT": [
2828
"Amt", "Amount", "AMT", "AMOUNT"
2929
],
3030
"AMOUNT_UNIT": [
31-
"Amt_unit", "Amt_units", "AMTUNIT", "UNIT", "AMOUNT_UNIT"
31+
"Amt_unit", "Amt_units", "AMTUNIT", "UNIT", "AMOUNT_UNIT", "Units_AMT"
3232
],
3333
"AMOUNT_VARIABLE": [
3434
"Amount Variable", "AMOUNT_VARIABLE"
3535
],
3636
"OBSERVATION": [
37-
"DV", "Observation", "Y", "YVAL", "OBSERVATION",
37+
"DV", "Observation", "Y", "YVAL", "OBSERVATION", "Conc",
3838
"OBSERVATION_VALUE", "OBSERVATIONVALUE"
3939
],
4040
"OBSERVATION_NAME": [
4141
"Observation_id", "YDESC", "YNAME", "YTYPE", "OBSERVATION_ID",
4242
"OBSERVATION_NAME", "OBSERVATIONID", "OBSERVATIONNAME"
4343
],
4444
"OBSERVATION_UNIT": [
45-
"DV_units", "Observation_unit", "YUNIT", "UNIT",
45+
"DV_units", "Observation_unit", "YUNIT", "UNIT", "Units_Conc",
4646
"OBSERVATION_UNIT",
4747
"OBSERVATIONUNIT"
4848
],

0 commit comments

Comments
 (0)