Skip to content

Commit

Permalink
Merge pull request #39 from skim0119/38_sample_data
Browse files Browse the repository at this point in the history
Update: Sample dataset and utilities to install

fix 38
  • Loading branch information
skim0119 authored Jun 13, 2022
2 parents 670654e + 7bb3486 commit c99df04
Show file tree
Hide file tree
Showing 7 changed files with 403 additions and 1 deletion.
20 changes: 20 additions & 0 deletions docs/examples/sample_datasets.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Sample Datasets
###############

.. automodule:: miv.datasets

.. warning::
The size of the datasets are typically very large. The download can take
a long time to complete.

Raw Recording Samples
+++++++++++++++++++++

.. automodule:: miv.datasets.optogenetic
:members:

MiV Dataset Samples
+++++++++++++++++++

.. automodule:: miv.datasets.criticality
:members:
3 changes: 2 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ If you are interested in contributing to this project, we prepared contribution
:maxdepth: 2
:caption: Example Scripts

examples/spike_detection
examples/sample_datasets
.. examples/spike_detection
.. toctree::
:maxdepth: 2
Expand Down
9 changes: 9 additions & 0 deletions miv/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
__doc__ = """
Sample datasets for debugging/testing.
Any downloaded datasets will be saved in **datasets** directory.
If the dataset already exists, download will be skipped.
To remove any cache files, you can delete the **datasets** directory.
"""

from miv.datasets.optogenetic import load_data
40 changes: 40 additions & 0 deletions miv/datasets/criticality.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
__doc__ = """Sample data for criticality analysis."""
__all__ = ["load_data"]

import gzip
import os

import numpy as np

from miv.datasets.utils import get_file


def load_data():
"""
Loads the sample for criticality analysis
Total size: 5.1 MB (compressed)
Returns
-------
datapath: str
Examples
--------
>>> from miv import datasets
>>> data = datasets.criticality.load_data()
"""

subdir = "criticality"
base_url = "https://uofi.box.com/shared/static/mxj6mfjj0fdexod4nqoqovdeg7t8dbbq.mat"
file = "asdf.mat"
file_hash = "c8ff82f4700eed2023d37cb7643d24b37350e521469148406042ef206c3aac34"

path = get_file(
file_url=base_url,
cache_subdir=subdir,
fname=file,
file_hash=file_hash,
archive_format=None,
)
return path
80 changes: 80 additions & 0 deletions miv/datasets/optogenetic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
__doc__ = """Sample signal readout from optogenetic neuron."""
__all__ = ["load_data"]

import gzip
import os

import numpy as np

from miv.datasets.utils import get_file
from miv.io import DataManager


def load_data():
"""
Loads the sample optogenetic experiment data.
Total size: 600.5 MB (compressed)
Notes
-----
All experiment are 1 minute long, 30k Hz recording of optogenetic
neuron cells over 64 channels MEA. Dataset includes 1 spontaneous
recording and 4 stimulated recording.
Spontaneous recording is the recording over 1 minute period without
external stimulation. The purpose was to measure the baseline mean-
firing rate.
Stimulation was done by LED light. Over 1 minute (60 seconds) period,
6 stimulation was done with 10 seconds of intervals. For each stimulation,
LED light was shined over 1 seconds, followed by remaining 9 seconds
of rest (without light).
Containing experiments:
* experiment0: spontaneous recording
* experiment1-4: stimulated recordings
Returns
-------
dataset: miv.io.DataManager
Examples
--------
>>> from miv import datasets
>>> experiments: miv.io.DataManager = datasets.opogenetic.load_data()
>>> experiments.tree()
2022-03-10_16-19-09
0: <miv.io.data.Data object at 0x7fbc30b9a9a0>
└── Record Node 104/experiment1/recording1
1: <miv.io.data.Data object at 0x7fbc2ae16700>
└── Record Node 104/experiment0/recording1
2: <miv.io.data.Data object at 0x7fbc2ac9e7c0>
└── Record Node 104/experiment2/recording2
3: <miv.io.data.Data object at 0x7fbc2ac9edc0>
└── Record Node 104/experiment3/recording1
4: <miv.io.data.Data object at 0x7fbc2ac9e160>
└── Record Node 104/experiment4/recording3
License
-------
...
"""

subdir = "optogenetic"
base_url = "https://uofi.box.com/shared/static/9llg11ods9iejdt2omjwjosbsxb5ui10.zip"
file = "2022-03-10_16-19-09.zip"
file_hash = "5deadc1b2a20501b5f6ee8828fa9c85df0b7890bd6ac4eaa8dca768d3b8b5f83"

path = get_file(
file_url=base_url,
cache_subdir=subdir,
fname=file,
file_hash=file_hash,
archive_format="zip",
)
experiment = DataManager(path)
experiment.tree()
return experiment
Empty file added miv/datasets/protocol.py
Empty file.
Loading

0 comments on commit c99df04

Please sign in to comment.