thbndi commited on
Commit
8dc0ce1
·
1 Parent(s): 5ef652e

Delete cohort.py

Browse files
Files changed (1) hide show
  1. cohort.py +0 -126
cohort.py DELETED
@@ -1,126 +0,0 @@
1
-
2
- import sys
3
- from pathlib import Path
4
- import os
5
- import importlib
6
- import shutil
7
- import time
8
- import yaml
9
- import os
10
-
11
- def task_cohort(task,mimic_path,path_benchmark, config_path):
12
- root_dir = os.path.dirname(os.path.abspath('UserInterface.ipynb'))
13
- config_path='./config/'+config_path
14
- with open(config_path) as f:
15
- config = yaml.safe_load(f)
16
- version_path = mimic_path+'/'
17
- version = mimic_path.split('/')[-1][0]
18
- start = time.time()
19
- #----------------------------------------------config----------------------------------------------------
20
- disease_label = config['disease_label']
21
- tim = config['time']
22
- label = config['label']
23
- timeW = config['timeW']
24
- include=int(timeW.split()[1])
25
- bucket = config['bucket']
26
- radimp = config['radimp']
27
- predW = config['predW']
28
- diag_flag = config['diagnosis']
29
- out_flag = config['output']
30
- chart_flag = config['chart']
31
- proc_flag= config['proc']
32
- med_flag = config['meds']
33
- disease_filter = config['disease_filter']
34
- icu_no_icu = config['icu_no_icu']
35
- groupingICD = config['groupingICD']
36
- # -------------------------------------------------------------------------------------------------------------
37
-
38
- data_icu=icu_no_icu=="ICU"
39
- data_mort=label=="Mortality"
40
- data_admn=label=='Readmission'
41
- data_los=label=='Length of Stay'
42
-
43
- if (disease_filter=="Heart Failure"):
44
- icd_code='I50'
45
- elif (disease_filter=="CKD"):
46
- icd_code='N18'
47
- elif (disease_filter=="COPD"):
48
- icd_code='J44'
49
- elif (disease_filter=="CAD"):
50
- icd_code='I25'
51
- else:
52
- icd_code='No Disease Filter'
53
-
54
- #-----------------------------------------------EXTRACT MIMIC-----------------------------------------------------
55
- if version == '2':
56
- print('in0')
57
- cohort_output = day_intervals_cohort_v22.extract_data(icu_no_icu,label,tim,icd_code, root_dir,version_path,disease_label)
58
- print('out0')
59
- elif version == '1':
60
- cohort_output = day_intervals_cohort.extract_data(icu_no_icu,label,tim,icd_code, root_dir,version_path,disease_label)
61
- #----------------------------------------------FEATURES-------------------------------------------------------
62
- print(data_icu)
63
- if data_icu :
64
- feature_selection_icu.feature_icu(cohort_output, version_path,diag_flag,out_flag,chart_flag,proc_flag,med_flag)
65
- #----------------------------------------------GROUPING-------------------------------------------------------
66
- group_diag=False
67
- group_med=False
68
- group_proc=False
69
- if data_icu:
70
- if diag_flag:
71
- group_diag=groupingICD
72
- feature_selection_icu.preprocess_features_icu(cohort_output, diag_flag, group_diag,False,False,False,0,0)
73
- #----------------------------------------------SUMMARY-------------------------------------------------------
74
- if data_icu:
75
- feature_selection_icu.generate_summary_icu(diag_flag,proc_flag,med_flag,out_flag,chart_flag)
76
- #----------------------------------------------FEATURE SELECTION---------------------------------------------
77
-
78
- select_diag= config['select_diag']
79
- select_med= config['select_med']
80
- select_proc= config['select_proc']
81
- #select_lab= config['select_lab']
82
- select_out= config['select_out']
83
- select_chart= config['select_chart']
84
-
85
- feature_selection_icu.features_selection_icu(cohort_output, diag_flag,proc_flag,med_flag,out_flag, chart_flag,select_diag,select_med,select_proc,select_out,select_chart)
86
- #---------------------------------------CLEANING OF FEATURES-----------------------------------------------
87
- thresh=0
88
- if data_icu:
89
- if chart_flag:
90
- outlier_removal=config['outlier_removal']
91
- clean_chart=outlier_removal!='No outlier detection'
92
- impute_outlier_chart=outlier_removal=='Impute Outlier (default:98)'
93
- thresh=config['outlier']
94
- left_thresh=config['left_outlier']
95
- feature_selection_icu.preprocess_features_icu(cohort_output, False, False,chart_flag,clean_chart,impute_outlier_chart,thresh,left_thresh)
96
- # ---------------------------------------tim-Series Representation--------------------------------------------
97
- if radimp == 'forward fill and mean' :
98
- impute='Mean'
99
- elif radimp =='forward fill and median':
100
- impute = 'Median'
101
- else :
102
- impute = False
103
-
104
- if data_icu:
105
- gen=data_generation_icu_modify.Generator(task,cohort_output,data_mort,data_admn,data_los,diag_flag,proc_flag,out_flag,chart_flag,med_flag,impute,include,bucket,predW)
106
- end = time.time()
107
- print("Time elapsed : ", round((end - start)/60,2),"mins")
108
- print("[============TASK COHORT SUCCESSFULLY CREATED============]")
109
-
110
- if __name__ == '__main__':
111
-
112
-
113
- task = sys.argv[1]
114
- mimic_path = sys.argv[2]
115
- path_benchmark = sys.argv[3]
116
- config = sys.argv[4]
117
- sys.path.append('./preprocessing/day_intervals_preproc')
118
- sys.path.append('./utils')
119
- sys.path.append('./preprocessing/hosp_module_preproc')
120
- sys.path.append('./model')
121
- import day_intervals_cohort_v22
122
- import day_intervals_cohort
123
- import feature_selection_icu
124
- import data_generation_icu_modify
125
-
126
- task_cohort(task, mimic_path, path_benchmark, config)