Update Mimic4Dataset.py
Browse files- Mimic4Dataset.py +6 -31
Mimic4Dataset.py
CHANGED
@@ -17,7 +17,7 @@ import torch
|
|
17 |
|
18 |
_DESCRIPTION = """\
|
19 |
Dataset for mimic4 data, by default for the Mortality task.
|
20 |
-
Available tasks are: Mortality, Length of Stay, Readmission, Phenotype
|
21 |
The data is extracted from the mimic4 database using this pipeline: 'https://github.com/healthylaife/MIMIC-IV-Data-Pipeline/tree/main'
|
22 |
mimic path should have this form : "path/to/mimic4data/from/username/mimiciv/2.2"
|
23 |
If you choose a Custom task provide a configuration file for the Time series.
|
@@ -39,8 +39,6 @@ _CONFIG_URLS = {'los' : 'https://huggingface.co/datasets/thbndi/Mimic4Dataset/re
|
|
39 |
def check_config(task,config_file):
|
40 |
with open(config_file) as f:
|
41 |
config = yaml.safe_load(f)
|
42 |
-
if 'Custom' in task:
|
43 |
-
task = task.rsplit('_', 1)[0]
|
44 |
|
45 |
if task=='Phenotype':
|
46 |
disease_label = config['disease_label']
|
@@ -627,37 +625,16 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
|
|
627 |
version=VERSION,
|
628 |
description="Dataset for mimic4 Mortality task"
|
629 |
),
|
630 |
-
Mimic4DatasetConfig(
|
631 |
-
name="Phenotype Custom",
|
632 |
-
version=VERSION,
|
633 |
-
description="Dataset for mimic4 Custom Phenotype task"
|
634 |
-
),
|
635 |
-
Mimic4DatasetConfig(
|
636 |
-
name="Readmission Custom",
|
637 |
-
version=VERSION,
|
638 |
-
description="Dataset for mimic4 Custom Readmission task"
|
639 |
-
),
|
640 |
-
Mimic4DatasetConfig(
|
641 |
-
name="Length of Stay Custom",
|
642 |
-
version=VERSION,
|
643 |
-
description="Dataset for mimic4 Custom Length of Stay task"
|
644 |
-
),
|
645 |
-
Mimic4DatasetConfig(
|
646 |
-
name="Mortality Custom",
|
647 |
-
version=VERSION,
|
648 |
-
description="Dataset for mimic4 Custom Mortality task"
|
649 |
-
),
|
650 |
]
|
651 |
|
652 |
DEFAULT_CONFIG_NAME = "Mortality"
|
653 |
|
654 |
def create_cohort(self):
|
655 |
-
if self.config.name
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
raise ValueError('Please provide a config file')
|
661 |
|
662 |
version = self.mimic_path.split('/')[-1]
|
663 |
mimic_folder= self.mimic_path.split('/')[-2]
|
@@ -991,8 +968,6 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
|
|
991 |
with open(filepath, 'rb') as fp:
|
992 |
dico = pickle.load(fp)
|
993 |
task=self.config.name.replace(" ","_")
|
994 |
-
#if 'Custom' in task:
|
995 |
-
# task = task.rsplit('_', 1)[0]
|
996 |
for key, data in dico.items():
|
997 |
stat, demo, meds, chart, out, proc, lab, y = getXY_deep(data, task, self.feat_cond, self.feat_proc, self.feat_out, self.feat_chart, self.feat_meds)
|
998 |
yield int(key), {
|
|
|
17 |
|
18 |
_DESCRIPTION = """\
|
19 |
Dataset for mimic4 data, by default for the Mortality task.
|
20 |
+
Available tasks are: Mortality, Length of Stay, Readmission, Phenotype.
|
21 |
The data is extracted from the mimic4 database using this pipeline: 'https://github.com/healthylaife/MIMIC-IV-Data-Pipeline/tree/main'
|
22 |
mimic path should have this form : "path/to/mimic4data/from/username/mimiciv/2.2"
|
23 |
If you choose a Custom task provide a configuration file for the Time series.
|
|
|
39 |
def check_config(task,config_file):
|
40 |
with open(config_file) as f:
|
41 |
config = yaml.safe_load(f)
|
|
|
|
|
42 |
|
43 |
if task=='Phenotype':
|
44 |
disease_label = config['disease_label']
|
|
|
625 |
version=VERSION,
|
626 |
description="Dataset for mimic4 Mortality task"
|
627 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
628 |
]
|
629 |
|
630 |
DEFAULT_CONFIG_NAME = "Mortality"
|
631 |
|
632 |
def create_cohort(self):
|
633 |
+
if self.config.name==None:
|
634 |
+
if self.config.name == 'Phenotype' : self.config_path = _CONFIG_URLS['phenotype']
|
635 |
+
if self.config.name == 'Readmission' : self.config_path = _CONFIG_URLS['readmission']
|
636 |
+
if self.config.name == 'Length of Stay' : self.config_path = _CONFIG_URLS['los']
|
637 |
+
if self.config.name == 'Mortality' : self.config_path = _CONFIG_URLS['mortality']
|
|
|
638 |
|
639 |
version = self.mimic_path.split('/')[-1]
|
640 |
mimic_folder= self.mimic_path.split('/')[-2]
|
|
|
968 |
with open(filepath, 'rb') as fp:
|
969 |
dico = pickle.load(fp)
|
970 |
task=self.config.name.replace(" ","_")
|
|
|
|
|
971 |
for key, data in dico.items():
|
972 |
stat, demo, meds, chart, out, proc, lab, y = getXY_deep(data, task, self.feat_cond, self.feat_proc, self.feat_out, self.feat_chart, self.feat_meds)
|
973 |
yield int(key), {
|