Skip to content

Commit

Permalink
adding docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
timshell committed Mar 29, 2017
1 parent 385c328 commit 8fe815f
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions spykes/datasets.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Functions that allow examples to fetch data from online resources
"""

import os
import urllib
import scipy.io
Expand All @@ -7,6 +11,25 @@

def load_reward_data(dpath='spykes_data/reward/'):

"""
Downloads and returns data for Neural Coding Reward Example as well as
PopVis Example. Dataset comes from Ramkumar et al's "Premotor and Motor
Cortices Encode Reward" paper located at
http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0160851
Parameters
----------
dpath: str
specifies path to which the data files should be downloaded
Returns
-------
sess_one_mat: .mat file
Monkey M, Session 1
sess_four_mat: .mat file
Monkey M, Session 4
"""

if not os.path.exists(dpath):
os.makedirs(dpath)

Expand All @@ -33,6 +56,22 @@ def load_reward_data(dpath='spykes_data/reward/'):

def load_neuropixels_data(dpath='spykes_data/neuropixels/'):

"""
Downloads and returns data for Neuropixels Example. Dataset comes from
UCL's Cortex Lab, which is located at
http://data.cortexlab.net/dualPhase3/data/
Parameters
----------
dpath: str
specifies path to which the data files should be downloaded
Returns
-------
data_dict
dictionary, where every key corresponds to a needed file
"""

if not os.path.exists(dpath):
os.makedirs(dpath)

Expand Down Expand Up @@ -82,6 +121,21 @@ def load_neuropixels_data(dpath='spykes_data/neuropixels/'):

def load_reaching_data(dpath='spykes_data/reaching/'):

"""
Downloads and returns data for Reaching Dataset Example. Dataset is
publicly available at
https://northwestern.app.box.com/s/xbe3xpnv6gpx0c1mrfhb1bal4cyei5n8
Parameters
----------
dpath: str
specifies path to which the data files should be downloaded
Returns
-------
deep dish loaded dataset
"""

if not os.path.exists(dpath):
os.makedirs(dpath)

Expand All @@ -97,6 +151,20 @@ def load_reaching_data(dpath='spykes_data/reaching/'):

def _load_file(fname):

"""
Helper function to check whether a file is a .mat or .npy file and then
load it
Parameters
----------
fname: str
specifies exact path of where data will be downloaded to
Returns
-------
mat or numpy loaded dataset
"""

if fname[-4:] == '.mat':
return scipy.io.loadmat(fname)

Expand Down

0 comments on commit 8fe815f

Please sign in to comment.