thbndi commited on
Commit
65408f0
1 Parent(s): 60f8433

Update Mimic4Dataset.py

Browse files
Files changed (1) hide show
  1. Mimic4Dataset.py +20 -11
Mimic4Dataset.py CHANGED
@@ -20,6 +20,11 @@ _HOMEPAGE = "https://huggingface.co/datasets/thbndi/Mimic4Dataset"
20
  _CITATION = "https://proceedings.mlr.press/v193/gupta22a.html"
21
  _URL = "https://github.com/healthylaife/MIMIC-IV-Data-Pipeline"
22
  _DATA_GEN = 'https://huggingface.co/datasets/thbndi/Mimic4Dataset/blob/main/data_generation_icu_modify.py'
 
 
 
 
 
23
  class Mimic4DatasetConfig(datasets.BuilderConfig):
24
  """BuilderConfig for Mimic4Dataset."""
25
 
@@ -52,25 +57,25 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
52
  Mimic4DatasetConfig(
53
  name="Phenotype",
54
  version=VERSION,
55
- config_path = './config/phenotype.config',
56
  description="Dataset for mimic4 Phenotype task"
57
  ),
58
  Mimic4DatasetConfig(
59
  name="Readmission",
60
  version=VERSION,
61
- config_path = './config/readmission.config',
62
  description="Dataset for mimic4 Readmission task"
63
  ),
64
  Mimic4DatasetConfig(
65
  name="Length of Stay",
66
  version=VERSION,
67
- config_path = './config/los.config',
68
  description="Dataset for mimic4 Length of Stay task"
69
  ),
70
  Mimic4DatasetConfig(
71
  name="Mortality",
72
  version=VERSION,
73
- config_path = './config/mortality.config',
74
  description="Dataset for mimic4 Mortality task"
75
  ),
76
  ]
@@ -137,13 +142,13 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
137
 
138
  def _split_generators(self, dl_manager: datasets.DownloadManager()):
139
  if self.config_path is None and self.name == 'Phenotype':
140
- self.config_path = './config/phenotype.config'
141
  elif self.config_path is None and self.name == 'Readmission':
142
- self.config_path = './config/readmission.config'
143
  elif self.config_path is None and self.name == 'Length of Stay':
144
- self.config_path = './config/los.config'
145
  elif self.config_path is None and self.name == 'Mortality':
146
- self.config_path = './config/mortality.config'
147
 
148
  repo_url='https://github.com/healthylaife/MIMIC-IV-Data-Pipeline'
149
  if os.path.exists(os.path.dirname(os.path.abspath('MIMIC-IV-Data-Pipeline-main'))):
@@ -152,13 +157,17 @@ class Mimic4Dataset(datasets.GeneratorBasedBuilder):
152
  repodir = os.getcwd()
153
  path_bench = repodir+'/MIMIC-IV-Data-Pipeline-main'
154
  subprocess.run(["git", "clone", repo_url, path_bench])
155
-
 
 
 
 
 
156
  file_path, head = urlretrieve(_DATA_GEN, "data_generation_icu_modify.py")
157
  shutil.move(file_path, path_bench+'/model')
158
 
159
  data_dir = path_bench + "/data/dataDic"
160
- print(data_dir)
161
- #task_cohort(self.name,self.mimic_path, path_bench, self.config_path)
162
  return [
163
  datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": data_dir}),
164
  ]
 
20
  _CITATION = "https://proceedings.mlr.press/v193/gupta22a.html"
21
  _URL = "https://github.com/healthylaife/MIMIC-IV-Data-Pipeline"
22
  _DATA_GEN = 'https://huggingface.co/datasets/thbndi/Mimic4Dataset/blob/main/data_generation_icu_modify.py'
23
+ _CONFIG_URLS = {'los' : 'https://huggingface.co/datasets/thbndi/Mimic4Dataset/blob/main/config/los.config',
24
+ 'mortality' : 'https://huggingface.co/datasets/thbndi/Mimic4Dataset/blob/main/config/mortality.config',
25
+ 'phenotype' : 'https://huggingface.co/datasets/thbndi/Mimic4Dataset/blob/main/config/phenotype.config',
26
+ 'readmission' : 'https://huggingface.co/datasets/thbndi/Mimic4Dataset/blob/main/config/readmission.config'
27
+ }
28
  class Mimic4DatasetConfig(datasets.BuilderConfig):
29
  """BuilderConfig for Mimic4Dataset."""
30
 
 
57
  Mimic4DatasetConfig(
58
  name="Phenotype",
59
  version=VERSION,
60
+ config_path = _CONFIG_URLS['phenotype'],
61
  description="Dataset for mimic4 Phenotype task"
62
  ),
63
  Mimic4DatasetConfig(
64
  name="Readmission",
65
  version=VERSION,
66
+ config_path = _CONFIG_URLS['readmission'],
67
  description="Dataset for mimic4 Readmission task"
68
  ),
69
  Mimic4DatasetConfig(
70
  name="Length of Stay",
71
  version=VERSION,
72
+ config_path = _CONFIG_URLS['los'],
73
  description="Dataset for mimic4 Length of Stay task"
74
  ),
75
  Mimic4DatasetConfig(
76
  name="Mortality",
77
  version=VERSION,
78
+ config_path = _CONFIG_URLS['mortality'],
79
  description="Dataset for mimic4 Mortality task"
80
  ),
81
  ]
 
142
 
143
  def _split_generators(self, dl_manager: datasets.DownloadManager()):
144
  if self.config_path is None and self.name == 'Phenotype':
145
+ self.config_path = _CONFIG_URLS['phenotype']
146
  elif self.config_path is None and self.name == 'Readmission':
147
+ self.config_path = _CONFIG_URLS['readmission']
148
  elif self.config_path is None and self.name == 'Length of Stay':
149
+ self.config_path = _CONFIG_URLS['los']
150
  elif self.config_path is None and self.name == 'Mortality':
151
+ self.config_path = _CONFIG_URLS['mortality']
152
 
153
  repo_url='https://github.com/healthylaife/MIMIC-IV-Data-Pipeline'
154
  if os.path.exists(os.path.dirname(os.path.abspath('MIMIC-IV-Data-Pipeline-main'))):
 
157
  repodir = os.getcwd()
158
  path_bench = repodir+'/MIMIC-IV-Data-Pipeline-main'
159
  subprocess.run(["git", "clone", repo_url, path_bench])
160
+
161
+ if not os.path.exists(path_bench+'/config'):
162
+ os.makedirs(path_bench+'/config')
163
+ file_path, head = urlretrieve(self.config_path)
164
+ shutil.move(file_path, path_bench+'/config')
165
+
166
  file_path, head = urlretrieve(_DATA_GEN, "data_generation_icu_modify.py")
167
  shutil.move(file_path, path_bench+'/model')
168
 
169
  data_dir = path_bench + "/data/dataDic"
170
+ task_cohort(self.name,self.mimic_path, path_bench, self.config_path)
 
171
  return [
172
  datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": data_dir}),
173
  ]