andreped commited on
Commit
676970f
·
1 Parent(s): 139f14d

Fixed DATA_DIR

Browse files
Files changed (1) hide show
  1. AeroPath.py +7 -7
AeroPath.py CHANGED
@@ -82,10 +82,10 @@ class AeroPath(datasets.GeneratorBasedBuilder):
82
 
83
  DEFAULT_CONFIG_NAME = "zenodo" # It's not mandatory to have a default configuration. Just use one if it make sense.
84
 
85
- self.data_dir = None
86
 
87
  def get_data_paths(self):
88
- return
89
 
90
  def get_patient(self, patient_id):
91
  if (patient_id < 1) or (patiend_id > 27):
@@ -122,7 +122,7 @@ class AeroPath(datasets.GeneratorBasedBuilder):
122
  )
123
 
124
  def get_data_dir(self):
125
- return self.data_dir
126
 
127
  def _split_generators(self, dl_manager):
128
  # TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
@@ -132,9 +132,9 @@ class AeroPath(datasets.GeneratorBasedBuilder):
132
  # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
133
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
134
  urls = _URLS[self.config.name]
135
- self.data_dir = dl_manager.download_and_extract(urls)
136
 
137
- print("data_dir:", self.data_dir)
138
 
139
  return [
140
  datasets.SplitGenerator(
@@ -150,8 +150,8 @@ class AeroPath(datasets.GeneratorBasedBuilder):
150
  def _generate_examples(self, split):
151
  # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
152
  # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
153
- for patient_id in os.listdir(self.data_dir):
154
- curr_path = os.path.join(self.data_dir, patient_id)
155
  yield patient_id, {
156
  "ct": os.path.join(curr_path, patient_id, "_CT_HR.nii.gz"),
157
  "airways": os.path.join(curr_path, patient_id, "_CT_HR_label_airways.nii.gz"),
 
82
 
83
  DEFAULT_CONFIG_NAME = "zenodo" # It's not mandatory to have a default configuration. Just use one if it make sense.
84
 
85
+ DATA_DIR = None
86
 
87
  def get_data_paths(self):
88
+ return DATA_DIR
89
 
90
  def get_patient(self, patient_id):
91
  if (patient_id < 1) or (patiend_id > 27):
 
122
  )
123
 
124
  def get_data_dir(self):
125
+ return DATA_DIR
126
 
127
  def _split_generators(self, dl_manager):
128
  # TODO: This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
 
132
  # It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
133
  # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
134
  urls = _URLS[self.config.name]
135
+ DATA_DIR = dl_manager.download_and_extract(urls)
136
 
137
+ print("data is downloaded to:", DATA_DIR)
138
 
139
  return [
140
  datasets.SplitGenerator(
 
150
  def _generate_examples(self, split):
151
  # TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
152
  # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
153
+ for patient_id in os.listdir(DATA_DIR):
154
+ curr_path = os.path.join(DATA_DIR, patient_id)
155
  yield patient_id, {
156
  "ct": os.path.join(curr_path, patient_id, "_CT_HR.nii.gz"),
157
  "airways": os.path.join(curr_path, patient_id, "_CT_HR_label_airways.nii.gz"),