Skip to content

Commit

Permalink
Added loader for sample data
Browse files Browse the repository at this point in the history
  • Loading branch information
Oli4 committed Sep 15, 2020
1 parent 46ec78c commit 451586d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions eyepy/data/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import urllib.request
import zipfile
from pathlib import Path

import eyepy.io as epio

SAMPLE_DATA = {"drusen_patient":
('https://uni-bonn.sciebo.de/s/VD8CPAgDKp2EYlm/download',
epio.read_xml)}

EYEPY_DATA_DIR = Path("~/.eyepy/data").expanduser()
if not EYEPY_DATA_DIR.is_dir():
EYEPY_DATA_DIR.mkdir(parents=True)


def load(name):
data_dir = (EYEPY_DATA_DIR / name)
if not data_dir.is_dir():
download_path = EYEPY_DATA_DIR / (name + ".zip")
urllib.request.urlretrieve(SAMPLE_DATA[name][0], download_path)
with zipfile.ZipFile(download_path, 'r') as zip_ref:
zip_ref.extractall(EYEPY_DATA_DIR)
download_path.unlink()

return SAMPLE_DATA[name][1](EYEPY_DATA_DIR / name / "metaclean.xml")

0 comments on commit 451586d

Please sign in to comment.