Update Mimic4Dataset.py
Browse files- Mimic4Dataset.py +8 -17
Mimic4Dataset.py
CHANGED
@@ -93,7 +93,7 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
|
|
93 |
|
94 |
DEFAULT_CONFIG_NAME = "Mortality"
|
95 |
|
96 |
-
def
|
97 |
if self.config_path==None:
|
98 |
if self.config.name == 'Phenotype' : self.config_path = _CONFIG_URLS['phenotype']
|
99 |
if self.config.name == 'Readmission' : self.config_path = _CONFIG_URLS['readmission']
|
@@ -147,17 +147,17 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
|
|
147 |
shutil.move(file_path,'./config')
|
148 |
with open(self.conf) as f:
|
149 |
config = yaml.safe_load(f)
|
|
|
|
|
150 |
timeW = config['timeWindow']
|
151 |
self.timeW=int(timeW.split()[1])
|
152 |
self.bucket = config['timebucket']
|
153 |
self.data_icu = config['icu_no_icu']=='ICU'
|
|
|
154 |
if self.data_icu:
|
155 |
self.feat_cond, self.feat_chart, self.feat_proc, self.feat_meds, self.feat_out, self.lab = config['diagnosis'], config['chart'], config['proc'], config['meds'], config['output'], False
|
156 |
-
self.feat_lab = False
|
157 |
else:
|
158 |
self.feat_cond, self.feat_lab, self.feat_proc, self.feat_meds, self.feat_chart, self.out = config['diagnosis'], config['lab'], config['proc'], config['meds'], False, False
|
159 |
-
self.feat_out = False
|
160 |
-
self.feat_chart = False
|
161 |
|
162 |
|
163 |
#####################downloads modules from hub
|
@@ -499,20 +499,14 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
|
|
499 |
'PROC': proc,
|
500 |
'CHART/LAB': lab,
|
501 |
'OUT': out,
|
502 |
-
}
|
503 |
-
else:
|
504 |
-
continue
|
505 |
-
|
506 |
|
507 |
#############################################################################################################################
|
508 |
def _info(self):
|
509 |
-
self.path = self.
|
510 |
self.size_cond, self.size_proc, self.size_meds, self.size_out, self.size_chart, self.size_lab, eth_vocab,gender_vocab,age_vocab,ins_vocab=vocab(self.config.name.replace(" ","_"),self.feat_cond,self.feat_proc,self.feat_out,self.feat_chart,self.feat_meds,self.feat_lab)
|
511 |
|
512 |
-
if self.encoding == 'concat' :
|
513 |
-
return self._info_encoded()
|
514 |
-
|
515 |
-
elif self.encoding == 'aggreg' :
|
516 |
return self._info_encoded()
|
517 |
|
518 |
elif self.encoding == 'tensor' :
|
@@ -538,10 +532,7 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
|
|
538 |
|
539 |
def _generate_examples(self, filepath):
|
540 |
|
541 |
-
if self.encoding == 'concat' :
|
542 |
-
yield from self._generate_examples_encoded(filepath)
|
543 |
-
|
544 |
-
elif self.encoding == 'aggreg' :
|
545 |
yield from self._generate_examples_encoded(filepath)
|
546 |
|
547 |
elif self.encoding == 'tensor' :
|
|
|
93 |
|
94 |
DEFAULT_CONFIG_NAME = "Mortality"
|
95 |
|
96 |
+
def init_cohort(self):
|
97 |
if self.config_path==None:
|
98 |
if self.config.name == 'Phenotype' : self.config_path = _CONFIG_URLS['phenotype']
|
99 |
if self.config.name == 'Readmission' : self.config_path = _CONFIG_URLS['readmission']
|
|
|
147 |
shutil.move(file_path,'./config')
|
148 |
with open(self.conf) as f:
|
149 |
config = yaml.safe_load(f)
|
150 |
+
|
151 |
+
|
152 |
timeW = config['timeWindow']
|
153 |
self.timeW=int(timeW.split()[1])
|
154 |
self.bucket = config['timebucket']
|
155 |
self.data_icu = config['icu_no_icu']=='ICU'
|
156 |
+
|
157 |
if self.data_icu:
|
158 |
self.feat_cond, self.feat_chart, self.feat_proc, self.feat_meds, self.feat_out, self.lab = config['diagnosis'], config['chart'], config['proc'], config['meds'], config['output'], False
|
|
|
159 |
else:
|
160 |
self.feat_cond, self.feat_lab, self.feat_proc, self.feat_meds, self.feat_chart, self.out = config['diagnosis'], config['lab'], config['proc'], config['meds'], False, False
|
|
|
|
|
161 |
|
162 |
|
163 |
#####################downloads modules from hub
|
|
|
499 |
'PROC': proc,
|
500 |
'CHART/LAB': lab,
|
501 |
'OUT': out,
|
502 |
+
}
|
|
|
|
|
|
|
503 |
|
504 |
#############################################################################################################################
|
505 |
def _info(self):
|
506 |
+
self.path = self.init_cohort()
|
507 |
self.size_cond, self.size_proc, self.size_meds, self.size_out, self.size_chart, self.size_lab, eth_vocab,gender_vocab,age_vocab,ins_vocab=vocab(self.config.name.replace(" ","_"),self.feat_cond,self.feat_proc,self.feat_out,self.feat_chart,self.feat_meds,self.feat_lab)
|
508 |
|
509 |
+
if (self.encoding == 'concat' or self.encoding =='aggreg'):
|
|
|
|
|
|
|
510 |
return self._info_encoded()
|
511 |
|
512 |
elif self.encoding == 'tensor' :
|
|
|
532 |
|
533 |
def _generate_examples(self, filepath):
|
534 |
|
535 |
+
if (self.encoding == 'concat' or self.encoding == 'aggreg'):
|
|
|
|
|
|
|
536 |
yield from self._generate_examples_encoded(filepath)
|
537 |
|
538 |
elif self.encoding == 'tensor' :
|