Skip to content

Commit

Permalink
add n5_download_demo.ipynb similar to ImageJ download using tensorstore
Browse files Browse the repository at this point in the history
  • Loading branch information
jcschaff committed Jan 24, 2025
1 parent bedb651 commit f5c11f3
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 1 deletion.
102 changes: 102 additions & 0 deletions examples/n5_download_demo.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"cells": [
{
"cell_type": "markdown",
"source": [
"# reading an exported VCell dataset from a server-side N5 store\n",
"1. set up tensorstore to point to remote dataset\n",
"2. retrieve data as a datastore object which lazily loads data upon request."
],
"metadata": {
"collapsed": false
},
"id": "29a6cffd5df3cb63"
},
{
"cell_type": "code",
"source": "import tensorstore as ts",
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2025-01-24T00:55:40.251947Z",
"start_time": "2025-01-24T00:55:39.504432Z"
}
},
"id": "c94978b833082ef7",
"outputs": [],
"execution_count": 1
},
{
"cell_type": "markdown",
"source": "### this configuration can be simplified by wrapping in pyvcell library",
"metadata": {
"collapsed": false
},
"id": "4b69965b59dd9af5"
},
{
"cell_type": "code",
"source": [
"# Define the URL and dataset name\n",
"url = \"https://vcell.cam.uchc.edu/n5Data/ACowan/11a0e2db531a208.n5\"\n",
"dataset_name = \"5580791597\"\n",
"\n",
"# Open the N5 dataset\n",
"spec = {\n",
" \"driver\": \"n5\",\n",
" \"kvstore\": {\n",
" \"driver\": \"http\",\n",
" \"base_url\": url\n",
" },\n",
" \"path\": dataset_name\n",
"}\n",
"\n",
"# Read the specified dataset\n",
"dataset = ts.open(spec).result()\n",
"data = dataset.read().result()\n",
"\n",
"# Print the shape of the data\n",
"print(\"Data shape:\", data.shape)\n"
],
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2025-01-24T00:56:05.521770Z",
"start_time": "2025-01-24T00:55:49.489764Z"
}
},
"id": "e88a4bb558aba920",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Data shape: (51, 51, 2, 51, 103)\n"
]
}
],
"execution_count": 2
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
2 changes: 1 addition & 1 deletion scripts/run_notebook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ cd ${ROOT_DIR} || (echo "Failed to cd into ${ROOT_DIR}" && exit 1)

python -m venv .venv_jupyter
source .venv_jupyter/bin/activate
pip install jupyter ipython matplotlib
pip install jupyter ipython matplotlib tensorstore
poetry install
jupyter notebook

0 comments on commit f5c11f3

Please sign in to comment.