Skip to content

Commit

Permalink
lots of fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Kiggins committed Apr 24, 2018
1 parent ea62fe7 commit eb99f28
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions neuroglia/datasets/figshare.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import os
import numpy as np
import pandas as pd
from collections import namedtuple
from scipy.io import loadmat
from six.moves.urllib.request import urlretrieve
from sklearn.datasets.base import _pkl_filepath
from .utils import _md5
from sklearn.utils import Bunch
from .utils import _md5, get_neuroglia_data_home


FigshareFileMetadata = namedtuple(
'FigshareFileMetadata',
['url', 'filename', 'md5'],
)


def fetch_10k_neurons(data_home=None,download_if_missing=True):

data_home = get_neuroglia_data_home(data_home=data_home)
Expand All @@ -22,20 +26,19 @@ def fetch_10k_neurons(data_home=None,download_if_missing=True):
calcium_path = _pkl_filepath(data_home, 'tenk_neurons.pkl')
behavior_path = _pkl_filepath(data_home, 'tenk_behavior.pkl')


if (not os.path.exists(calcium_path)) or (not os.path.exists(behavior_path)):
if not download_if_missing:
raise IOError("Data not found and `download_if_missing` is False")

mat_path = os.path.join(data_home,'figshare_10k.mat')
mat_path = os.path.join(data_home, 'figshare_10k.mat')

figshare = FigshareFileMetadata(
url="https://ndownloader.figshare.com/files/11152646",
filename="spont_M161025_MP030_2016-11-20.mat",
md5="54ffdc817e82710952dbee2655d4d1d2",
)

local_filename = _fetch_figshare_datafile(
_fetch_figshare_datafile(
figshare=figshare,
local_filename=mat_path,
)
Expand Down Expand Up @@ -81,7 +84,7 @@ def load_10k(mat_path):
return calcium_events, behavior


def _fetch_figshare_datafile(figshare,local_filename=None,chunk_size=1024):
def _fetch_figshare_datafile(figshare, local_filename=None, chunk_size=1024):

if local_filename is None:
local_filename = figshare.filename
Expand All @@ -91,13 +94,6 @@ def _fetch_figshare_datafile(figshare,local_filename=None,chunk_size=1024):
if figshare.checksum == checksum:
return local_filename

request_payload = _create_payload(
username,
password,
figshare.path,
figshare.filename,
)

urlretrieve(figshare.url, local_filename)

checksum = _md5(local_filename)
Expand Down

0 comments on commit eb99f28

Please sign in to comment.