Delete check_config.py
Browse files- check_config.py +0 -120
check_config.py
DELETED
@@ -1,120 +0,0 @@
|
|
1 |
-
import yaml
|
2 |
-
import sys
|
3 |
-
|
4 |
-
def check_config_file(task,config_file):
|
5 |
-
with open(config_file) as f:
|
6 |
-
config = yaml.safe_load(f)
|
7 |
-
|
8 |
-
if task=='Phenotype':
|
9 |
-
disease_label = config['disease_label']
|
10 |
-
else :
|
11 |
-
disease_label = ""
|
12 |
-
time = config['timePrediction']
|
13 |
-
label = task
|
14 |
-
timeW = config['timeWindow']
|
15 |
-
include=int(timeW.split()[1])
|
16 |
-
bucket = config['timebucket']
|
17 |
-
radimp = config['radimp']
|
18 |
-
predW = config['predW']
|
19 |
-
disease_filter = config['disease_filter']
|
20 |
-
icu_no_icu = config['icu_no_icu']
|
21 |
-
groupingDiag = config['groupingDiag']
|
22 |
-
|
23 |
-
assert( icu_no_icu in ['ICU','Non-ICU' ], "Chossen data should be one of the following: ICU, Non-ICU")
|
24 |
-
data_icu = icu_no_icu=='ICU'
|
25 |
-
|
26 |
-
if data_icu:
|
27 |
-
chart_flag = config['chart']
|
28 |
-
output_flag = config['output']
|
29 |
-
select_chart = config['select_chart']
|
30 |
-
lab_flag = False
|
31 |
-
select_lab = False
|
32 |
-
else:
|
33 |
-
lab_flag =config['lab']
|
34 |
-
select_lab = config['select_lab']
|
35 |
-
groupingMed = config['groupingMed']
|
36 |
-
groupingProc = config['groupingProc']
|
37 |
-
chart_flag = False
|
38 |
-
output_flag = False
|
39 |
-
select_chart = False
|
40 |
-
|
41 |
-
|
42 |
-
diag_flag= config['diagnosis']
|
43 |
-
proc_flag = config['proc']
|
44 |
-
meds_flag = config['meds']
|
45 |
-
select_diag= config['select_diag']
|
46 |
-
select_med= config['select_med']
|
47 |
-
select_proc= config['select_proc']
|
48 |
-
select_out = config['select_out']
|
49 |
-
|
50 |
-
outlier_removal=config['outlier_removal']
|
51 |
-
thresh=config['outlier']
|
52 |
-
left_thresh=config['left_outlier']
|
53 |
-
|
54 |
-
if data_icu:
|
55 |
-
assert (isinstance(select_diag,bool) and isinstance(select_med,bool) and isinstance(select_proc,bool) and isinstance(select_out,bool) and isinstance(select_chart,bool), " select_diag, select_chart, select_med, select_proc, select_out should be boolean")
|
56 |
-
assert (isinstance(chart_flag,bool) and isinstance(output_flag,bool) and isinstance(diag_flag,bool) and isinstance(proc_flag,bool) and isinstance(meds_flag,bool), "chart_flag, output_flag, diag_flag, proc_flag, meds_flag should be boolean")
|
57 |
-
|
58 |
-
else:
|
59 |
-
assert (isinstance(select_diag,bool) and isinstance(select_med,bool) and isinstance(select_proc,bool) and isinstance(select_out,bool) and isinstance(select_lab,bool), " select_diag, select_lab, select_med, select_proc, select_out should be boolean")
|
60 |
-
assert (isinstance(lab_flag,bool) and isinstance(diag_flag,bool) and isinstance(proc_flag,bool) and isinstance(meds_flag,bool), "lab_flag, diag_flag, proc_flag, meds_flag should be boolean")
|
61 |
-
|
62 |
-
if task=='Phenotype':
|
63 |
-
if disease_label=='Heart Failure':
|
64 |
-
label='Readmission'
|
65 |
-
time=30
|
66 |
-
disease_label='I50'
|
67 |
-
elif disease_label=='CAD':
|
68 |
-
label='Readmission'
|
69 |
-
time=30
|
70 |
-
disease_label='I25'
|
71 |
-
elif disease_label=='CKD':
|
72 |
-
label='Readmission'
|
73 |
-
time=30
|
74 |
-
disease_label='N18'
|
75 |
-
elif disease_label=='COPD':
|
76 |
-
label='Readmission'
|
77 |
-
time=30
|
78 |
-
disease_label='J44'
|
79 |
-
else :
|
80 |
-
raise ValueError('Disease label not correct provide one in the list: Heart Failure, CAD, CKD, COPD')
|
81 |
-
predW=0
|
82 |
-
assert (timeW[0]=='Last' and include<=72 and include>=24, "Time window should be between Last 24 and Last 72")
|
83 |
-
|
84 |
-
elif task=='Mortality':
|
85 |
-
time=0
|
86 |
-
label= 'Mortality'
|
87 |
-
assert (predW<=8 and predW>=2, "Prediction window should be between 2 and 8")
|
88 |
-
assert (timeW[0]=='Fisrt' and include<=72 and include>=24, "Time window should be between First 24 and First 72")
|
89 |
-
|
90 |
-
elif task=='Length_of_Stay':
|
91 |
-
label= 'Length of Stay'
|
92 |
-
assert (timeW[0]=='Fisrt' and include<=72 and include>=24, "Time window should be between Fisrt 24 and Fisrt 72")
|
93 |
-
assert (time<=10 and time>=1, "Length of stay should be between 1 and 10")
|
94 |
-
predW=0
|
95 |
-
|
96 |
-
elif task=='Readmission':
|
97 |
-
label= 'Readmission'
|
98 |
-
assert (timeW[0]=='Last' and include<=72 and include>=24, "Time window should be between Last 24 and Last 72")
|
99 |
-
assert (time<=150 and time>=10 and time%10==0, "Readmission window should be between 10 and 150 with a step of 10")
|
100 |
-
predW=0
|
101 |
-
|
102 |
-
else:
|
103 |
-
raise ValueError('Task not correct')
|
104 |
-
|
105 |
-
assert( disease_filter in ['Heart Failure','COPD','CKD','CAD',""], "Disease filter should be one of the following: Heart Failure, COPD, CKD, CAD or empty")
|
106 |
-
assert( groupingDiag in ['Convert ICD-9 to ICD-10 and group ICD-10 codes','Keep both ICD-9 and ICD-10 codes','Convert ICD-9 to ICD-10 codes'], "Grouping ICD should be one of the following: Convert ICD-9 to ICD-10 and group ICD-10 codes, Keep both ICD-9 and ICD-10 codes, Convert ICD-9 to ICD-10 codes")
|
107 |
-
assert (bucket<=6 and bucket>=1 and isinstance(bucket, int), "Time bucket should be between 1 and 6 and an integer")
|
108 |
-
assert (radimp in ['No Imputation', 'forward fill and mean','forward fill and median'], "imputation should be one of the following: No Imputation, forward fill and mean, forward fill and median")
|
109 |
-
if chart_flag:
|
110 |
-
assert (left_thresh>=0 and left_thresh<=10 and isinstance(left_thresh, int), "Left outlier threshold should be between 0 and 10 and an integer")
|
111 |
-
assert (thresh>=90 and thresh<=99 and isinstance(thresh, int), "Outlier threshold should be between 90 and 99 and an integer")
|
112 |
-
assert (outlier_removal in ['No outlier detection','Impute Outlier (default:98)','Remove outliers (default:98)'], "Outlier removal should be one of the following: No outlier detection, Impute Outlier (default:98), Remove outliers (default:98)")
|
113 |
-
if lab_flag:
|
114 |
-
assert (left_thresh>=0 and left_thresh<=10 and isinstance(left_thresh, int), "Left outlier threshold should be between 0 and 10 and an integer")
|
115 |
-
assert (thresh>=90 and thresh<=99 and isinstance(thresh, int), "Outlier threshold should be between 90 and 99 and an integer")
|
116 |
-
assert (outlier_removal in ['No outlier detection','Impute Outlier (default:98)','Remove outliers (default:98)'], "Outlier removal should be one of the following: No outlier detection, Impute Outlier (default:98), Remove outliers (default:98)")
|
117 |
-
assert (groupingProc in ['ICD-9 and ICD-10','ICD-10'], "Grouping procedure should be one of the following: ICD-9 and ICD-10, ICD-10")
|
118 |
-
assert (groupingMed in ['Yes','No'], "Do you want to group Medication codes to use Non propietary names? : Grouping medication should be one of the following: Yes, No")
|
119 |
-
|
120 |
-
return label, time, disease_label, predW
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|