Skip to content

Commit

Permalink
Merge commit '695afd'
Browse files Browse the repository at this point in the history
  • Loading branch information
satra committed Oct 31, 2021
2 parents 61e0db8 + 695afd8 commit 28331d6
Show file tree
Hide file tree
Showing 2 changed files with 183 additions and 28 deletions.
153 changes: 129 additions & 24 deletions 000108/chunglab/demo/2021-09-27_dandi-demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7f97c1540c70>"
"<matplotlib.image.AxesImage at 0x7fa3d43e7df0>"
]
},
"execution_count": 5,
Expand Down Expand Up @@ -554,7 +554,8 @@
"# This is what our sidecar looks like - we're going to use\n",
"# the pixel size and pieces of the chunk transform matrix.\n",
"\n",
"get_json(get_asset_url(\"000108\", chunks_41[0][\"sidecar_asset_id\"]))"
"meta = get_json(get_asset_url(\"000108\", chunks_41[0][\"sidecar_asset_id\"]))\n",
"meta"
]
},
{
Expand Down Expand Up @@ -802,16 +803,49 @@
{
"cell_type": "code",
"execution_count": 10,
"id": "2313647b-8fac-47dd-8252-ec950f4c4dd0",
"id": "c0abccb2-174d-479b-9f08-1a6c03e56251",
"metadata": {},
"outputs": [],
"source": [
"level = 6\n",
"extents6 = find_extents(\"000108\", \"MITU01\", \"41\", \"YO\", level)\n",
"overview = read(\"000108\", \"MITU01\", \"41\", \"YO\", 0, extents6[\"x1\"], 0, extents6[\"y1\"], 0, extents6[\"z1\"], level)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "36a5fdfa-ab4d-4360-b0ae-d060d906e8a1",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(32, 261, 571)"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"overview.shape"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "3de35868-c2e9-4286-8205-7181e1d30222",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7f97c14766a0>"
"<matplotlib.image.AxesImage at 0x7fa3d4321e20>"
]
},
"execution_count": 10,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
},
Expand Down Expand Up @@ -841,17 +875,88 @@
}
],
"source": [
"extents6 = find_extents(\"000108\", \"MITU01\", \"41\", \"YO\", 6)\n",
"overview = read(\"000108\", \"MITU01\", \"41\", \"YO\", 0, extents6[\"x1\"], 0, extents6[\"y1\"], 16, 17, 6)[0]\n",
"pyplot.figure(figsize=(12, 12))\n",
"pyplot.imshow(overview, cmap='cubehelix')\n",
"pyplot.imshow(overview[16, :], cmap='cubehelix')\n",
"pyplot.figure(figsize=(12, 12))\n",
"pyplot.imshow(photo[::-1, ::-1])"
]
},
{
"cell_type": "markdown",
"id": "cfc4afdc-f01d-4bd5-a04b-9a8f692ebbf6",
"metadata": {},
"source": [
"### Use neuroglancer to display the stitched volume"
]
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 13,
"id": "e93d0508-ad0e-4fb1-b002-5e53d7fe3076",
"metadata": {},
"outputs": [],
"source": [
"import neuroglancer\n",
"import os"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "d3b6abed-2d8e-4b7c-80a6-c80a6e3a283d",
"metadata": {},
"outputs": [],
"source": [
"viewer = neuroglancer.Viewer()"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "7a556758-c6b0-4286-8cc7-51c6b724f762",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Neuroglancer URL: https://hub.dandiarchive.org/user/satra/proxy/41511/v/19ce6d52b2adb874bb139eb855f64eda1c6f735e/\n"
]
}
],
"source": [
"# This volume handle can be used to notify the viewer that the data has changed.\n",
"volume = neuroglancer.LocalVolume(\n",
" overview,\n",
" dimensions=neuroglancer.CoordinateSpace(\n",
" names=['x', 'y', 'z'],\n",
" units=['um', 'um', 'um'],\n",
" scales=[val*level for val in meta[\"PixelSize\"]],\n",
" ),\n",
" voxel_offset=[0,0,0]\n",
" )\n",
"with viewer.txn() as s:\n",
" s.layers['volume'] = neuroglancer.ImageLayer(\n",
" source=volume,\n",
" # Define a custom shader to display this mask array as red+alpha.\n",
" shader=\"\"\"\n",
"#uicontrol vec3 color color(default=\"green\")\n",
"#uicontrol float brightness slider(min=-1, max=1)\n",
"#uicontrol float contrast slider(min=-9, max=-5, step=0.1)\n",
"void main() {\n",
" emitRGB(color *\n",
" (toNormalized(getDataValue(0)) + brightness) *\n",
" exp(contrast));\n",
"}\n",
"\"\"\",\n",
" )\n",
" s.position = np.array(overview.shape)/2\n",
"print(\"Neuroglancer URL:\", viewer.get_viewer_url().replace(\"http://127.0.0.1:\", f\"https://hub.dandiarchive.org/user/{os.environ['GITHUB_USER']}/proxy/\"))"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "hydraulic-terrain",
"metadata": {
"tags": []
Expand All @@ -865,17 +970,17 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 17,
"id": "9566618d-3025-42f0-ab6a-ad9044fc3686",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7f97c1387970>"
"<matplotlib.image.AxesImage at 0x7fa3cf471250>"
]
},
"execution_count": 12,
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
},
Expand Down Expand Up @@ -910,17 +1015,17 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 18,
"id": "81670a03-690f-4ef2-84c9-7a5a83e0ee4d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7f97bcfad400>"
"<matplotlib.image.AxesImage at 0x7fa3cf3df0d0>"
]
},
"execution_count": 13,
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
},
Expand All @@ -945,7 +1050,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 19,
"id": "9a50a25c-7ffe-4a55-a15d-ea889e33117d",
"metadata": {},
"outputs": [],
Expand All @@ -956,7 +1061,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 20,
"id": "1444c4ec-3083-46ff-ad91-1af41b15e132",
"metadata": {},
"outputs": [],
Expand All @@ -966,7 +1071,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 21,
"id": "7cfc7a25-4f1c-424b-b54c-bedf4c0b092e",
"metadata": {},
"outputs": [],
Expand All @@ -989,17 +1094,17 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 22,
"id": "13b5c5cd-21d6-43a0-a276-47991e016053",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7f97a89c5d90>"
"<matplotlib.image.AxesImage at 0x7fa39ae33370>"
]
},
"execution_count": 17,
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
},
Expand All @@ -1023,17 +1128,17 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 23,
"id": "38e58a07-938a-4aaf-9032-992e6183c25a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.image.AxesImage at 0x7f97a898b910>"
"<matplotlib.image.AxesImage at 0x7fa39ade7e50>"
]
},
"execution_count": 18,
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
},
Expand Down
58 changes: 54 additions & 4 deletions 000108/chunglab/demo/2021-09-27_dandi-demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ chunks_41
# This is what our sidecar looks like - we're going to use
# the pixel size and pieces of the chunk transform matrix.

get_json(get_asset_url("000108", chunks_41[0]["sidecar_asset_id"]))
meta = get_json(get_asset_url("000108", chunks_41[0]["sidecar_asset_id"]))
meta
```

```python
Expand Down Expand Up @@ -447,14 +448,63 @@ def find_extents(dandiset, subject, sample, stain, level=0):
```

```python
extents6 = find_extents("000108", "MITU01", "41", "YO", 6)
overview = read("000108", "MITU01", "41", "YO", 0, extents6["x1"], 0, extents6["y1"], 16, 17, 6)[0]
level = 6
extents6 = find_extents("000108", "MITU01", "41", "YO", level)
overview = read("000108", "MITU01", "41", "YO", 0, extents6["x1"], 0, extents6["y1"], 0, extents6["z1"], level)
```

```python
overview.shape
```

```python
pyplot.figure(figsize=(12, 12))
pyplot.imshow(overview, cmap='cubehelix')
pyplot.imshow(overview[16, :], cmap='cubehelix')
pyplot.figure(figsize=(12, 12))
pyplot.imshow(photo[::-1, ::-1])
```

### Use neuroglancer to display the stitched volume

```python
import neuroglancer
import os
```

```python
viewer = neuroglancer.Viewer()
```

```python
# This volume handle can be used to notify the viewer that the data has changed.
volume = neuroglancer.LocalVolume(
overview,
dimensions=neuroglancer.CoordinateSpace(
names=['x', 'y', 'z'],
units=['um', 'um', 'um'],
scales=[val*level for val in meta["PixelSize"]],
),
voxel_offset=[0,0,0]
)
with viewer.txn() as s:
s.layers['volume'] = neuroglancer.ImageLayer(
source=volume,
# Define a custom shader to display this mask array as red+alpha.
shader="""
#uicontrol vec3 color color(default="green")
#uicontrol float brightness slider(min=-1, max=1)
#uicontrol float contrast slider(min=-9, max=-5, step=0.1)
void main() {
emitRGB(color *
(toNormalized(getDataValue(0)) + brightness) *
exp(contrast));
}
""",
)
s.position = np.array(overview.shape)/2
print("Neuroglancer URL:", viewer.get_viewer_url().replace("http://127.0.0.1:", f"https://hub.dandiarchive.org/user/{os.environ['GITHUB_USER']}/proxy/"))
```

```python tags=[]
# This is approximately at the stitching between chunks 1 and 2
x, y, z = 16080, 1957, 1024
Expand Down

0 comments on commit 28331d6

Please sign in to comment.