Skip to content

Commit

Permalink
added example notebooks w/o streaming
Browse files Browse the repository at this point in the history
  • Loading branch information
pauladkisson committed Dec 19, 2024
1 parent 10c444a commit 0ab5241
Show file tree
Hide file tree
Showing 5 changed files with 1,394 additions and 0 deletions.
8 changes: 8 additions & 0 deletions 001259/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Example Sessions for Dandiset 001259

This submission provides 2 notebooks showcasing example sessions for the Dandiset 001259.

Each notebook provides an example of how to access the critical data and metadata from the 2 types of experiments in the dataset:

- `ephys_example_notebook.ipynb` showcases one example session from the 001259 dataset containing operant behavior and concurrent OpenEphys recordings in primary auditory cortex (A1).
- `optogenetics_example_notebook.ipynb` showcases one example session from the 001259 dataset containing operant behavior and concurrent optogenetic stimulation.
11 changes: 11 additions & 0 deletions 001259/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# run: conda env create --file environment.yml
name: schneider_notebook_env
channels:
- conda-forge
dependencies:
- python==3.12
- ipywidgets
- pip
- pip:
- matplotlib
- lerner-lab-to-nwb @ git+https://github.com/catalystneuro/lerner-lab-to-nwb.git@main
781 changes: 781 additions & 0 deletions 001259/ephys_example_notebook.ipynb

Large diffs are not rendered by default.

558 changes: 558 additions & 0 deletions 001259/opto_example_notebook.ipynb

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions 001259/stream_nwbfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from pynwb import NWBHDF5IO
from fsspec import filesystem
from h5py import File
from dandi.dandiapi import DandiAPIClient

def stream_nwbfile(DANDISET_ID, file_path):
'''Stream NWB file from DANDI archive.
Parameters
----------
DANDISET_ID : str
Dandiset ID
file_path : str
Path to NWB file in DANDI archive
Returns
-------
nwbfile : NWBFile
NWB file
io : NWBHDF5IO
NWB IO object (for closing)
Notes
-----
The io object must be closed after use.
'''
with DandiAPIClient() as client:
client.dandi_authenticate()
asset = client.get_dandiset(DANDISET_ID, 'draft').get_asset_by_path(file_path)
s3_url = asset.get_content_url(follow_redirects=1, strip_query=True)
fs = filesystem("http")
file_system = fs.open(s3_url, "rb")
file = File(file_system, mode="r")
io = NWBHDF5IO(file=file, load_namespaces=True)
nwbfile = io.read()
return nwbfile, io

0 comments on commit 0ab5241

Please sign in to comment.