Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tutorials for electrophysiology and fiber photometry #28

Merged
merged 9 commits into from
Dec 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
cleanup
weiglszonja committed Dec 5, 2024
commit f09a43a5532b96b7ff11e6b83d5a50b332804b5d
Original file line number Diff line number Diff line change
@@ -42,64 +42,6 @@
"nwbfile = io.read()"
]
},
{
"cell_type": "markdown",
"id": "44c16af5-b5bd-455a-b678-2e46776ec5ce",
"metadata": {},
"source": [
"# Streaming an NWB file\n",
"\n",
"This section demonstrates how to access the files on the [DANDI Archive](https://dandiarchive.org) without downloading them. Based on the [Streaming NWB files](https://pynwb.readthedocs.io/en/stable/tutorials/advanced_io/streaming.html) tutorial from [PyNWB](https://pynwb.readthedocs.io/en/stable/#).\n",
"\n",
"The `dandi.dandiapi.DandiAPIClient` can be used to get the S3 URL of the NWB file stored in the DANDI Archive.\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "66a8d2ca-6ed6-4816-83af-e7f687f1f82e",
"metadata": {},
"outputs": [],
"source": [
"# from dandi.dandiapi import DandiAPIClient\n",
"\n",
"# client = DandiAPIClient.for_dandi_instance(\"dandi\")\n",
"\n",
"# dandiset_id = \"001265\"\n",
"# file_path = \"sub-G026/sub-G026_ses-RWTautowait2-20210528-101504.nwb\"\n",
"\n",
"# with DandiAPIClient() as client:\n",
"# asset = client.get_dandiset(dandiset_id, 'draft').get_asset_by_path(file_path)\n",
"# s3_url = asset.get_content_url(follow_redirects=1, strip_query=True)\n"
]
},
{
"cell_type": "markdown",
"id": "0cbbef68-7cdf-441c-b911-d887d1d58642",
"metadata": {},
"source": [
"We will use `remfile` for streaming the file. You can read more about `remfile` at [this tutorial section](https://pynwb.readthedocs.io/en/stable/tutorials/advanced_io/streaming.html#method-3-remfile)."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "95ac6631-3cc4-4db0-9b2b-f9ec7d17290f",
"metadata": {},
"outputs": [],
"source": [
"# import h5py\n",
"# from pynwb import NWBHDF5IO\n",
"# import remfile\n",
"\n",
"# # We stream the file using remfile and open it with h5py and pynwb\n",
"# file = remfile.File(s3_url)\n",
"# h5_file = h5py.File(file, \"r\")\n",
"# io = NWBHDF5IO(file=h5_file, load_namespaces=True)\n",
"\n",
"# nwbfile = io.read()"
]
},
{
"cell_type": "markdown",
"id": "7ee4f8ff-42b9-463e-b4ee-cf79a5e5276a",
Original file line number Diff line number Diff line change
@@ -46,64 +46,6 @@
"nwbfile = io.read()\n"
]
},
{
"cell_type": "markdown",
"id": "4781be7e-7af0-492e-bfb0-a4af09ecf0c2",
"metadata": {},
"source": [
"# Streaming an NWB file\n",
"\n",
"This section demonstrates how to access the files on the [DANDI Archive](https://dandiarchive.org) without downloading them. Based on the [Streaming NWB files](https://pynwb.readthedocs.io/en/stable/tutorials/advanced_io/streaming.html) tutorial from [PyNWB](https://pynwb.readthedocs.io/en/stable/#).\n",
"\n",
"The `dandi.dandiapi.DandiAPIClient` can be used to get the S3 URL of the NWB file stored in the DANDI Archive.\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "f402c0a8-285a-4270-9c46-c3ff2d24b13a",
"metadata": {},
"outputs": [],
"source": [
"# from dandi.dandiapi import DandiAPIClient\n",
"\n",
"# client = DandiAPIClient.for_dandi_instance(\"dandi\")\n",
"\n",
"# dandiset_id = \"001264\"\n",
"# file_path = \"sub-J076/sub-J076_ses-RWTautowait2-20231212-145250_ecephys.nwb\"\n",
"\n",
"# with DandiAPIClient() as client:\n",
"# asset = client.get_dandiset(dandiset_id, 'draft').get_asset_by_path(file_path)\n",
"# s3_url = asset.get_content_url(follow_redirects=1, strip_query=True)\n"
]
},
{
"cell_type": "markdown",
"id": "5b5f586b-c337-4c13-8a69-a83c640d1ebf",
"metadata": {},
"source": [
"We will use `remfile` for streaming the file. You can read more about `remfile` at [this tutorial section](https://pynwb.readthedocs.io/en/stable/tutorials/advanced_io/streaming.html#method-3-remfile)."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "25469dcf-3453-4391-be40-a1b9b199d31e",
"metadata": {},
"outputs": [],
"source": [
"# import h5py\n",
"# from pynwb import NWBHDF5IO\n",
"# import remfile\n",
"\n",
"# # We stream the file using remfile and open it with h5py and pynwb\n",
"# file = remfile.File(s3_url)\n",
"# h5_file = h5py.File(file, \"r\")\n",
"# io = NWBHDF5IO(file=h5_file, load_namespaces=True)\n",
"\n",
"# nwbfile = io.read()"
]
},
{
"cell_type": "markdown",
"id": "25a5bb56-7dd1-4d4e-b56c-a65543811c89",
@@ -435,16 +377,18 @@
},
{
"cell_type": "code",
"execution_count": 1,
"id": "281be40d-1a73-4b97-ad78-cf6ddbb8e0e7",
"metadata": {
"ExecuteTime": {
"end_time": "2024-12-04T12:41:53.499609Z",
"start_time": "2024-12-04T12:41:53.497410Z"
}
},
"source": "nwbfile.processing[\"ecephys\"]",
"outputs": [],
"execution_count": 1
"source": [
"nwbfile.processing[\"ecephys\"]"
]
},
{
"cell_type": "code",