Skip to content

Commit 627434f

Browse files
updates for datastructures (#335)
* updates for datastructures * actual files * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent e8f1a78 commit 627434f

File tree

8 files changed

+854
-1
lines changed

8 files changed

+854
-1
lines changed

_static/dataarray.png

98.7 KB
Loading

_static/dataset.png

141 KB
Loading

_static/datatree1.png

305 KB
Loading

_static/datatree2.png

285 KB
Loading

_static/variable.png

86.9 KB
Loading

fundamentals/01_datatree_hierarchical_data.ipynb

Lines changed: 64 additions & 1 deletion
Large diffs are not rendered by default.

intermediate/BiologyDataset.ipynb

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "0",
6+
"metadata": {},
7+
"source": [
8+
"# Datasets in other fields\n",
9+
"\n",
10+
"\n",
11+
"While there are many Xarray examples from geosciences the Xarray data model is not constrained to that field. Our examples so far solve problems that are highly analogous to the problems faced in biology. In this notebook we will load a dataset based on the [cells3d](https://scikit-image.org/docs/0.25.x/api/skimage.data.html#skimage.data.cells3d) dataset from scikit-image."
12+
]
13+
},
14+
{
15+
"cell_type": "code",
16+
"execution_count": null,
17+
"id": "1",
18+
"metadata": {},
19+
"outputs": [],
20+
"source": [
21+
"import xarray as xr"
22+
]
23+
},
24+
{
25+
"cell_type": "markdown",
26+
"id": "2",
27+
"metadata": {},
28+
"source": [
29+
"## Loading the Dataset\n",
30+
"\n",
31+
"This dataset follows a classic pattern in microscopy where we have a stack of images, with two fluoresence channels. In addition to that we have a mask (or labels layer) that identifies individual cells "
32+
]
33+
},
34+
{
35+
"cell_type": "code",
36+
"execution_count": null,
37+
"id": "3",
38+
"metadata": {},
39+
"outputs": [],
40+
"source": [
41+
"ds = xr.tutorial.load_dataset(\"cells3d\")\n",
42+
"ds"
43+
]
44+
},
45+
{
46+
"cell_type": "code",
47+
"execution_count": null,
48+
"id": "4",
49+
"metadata": {},
50+
"outputs": [],
51+
"source": [
52+
"ds['images'].max('z').sel(c='nuclei').plot()"
53+
]
54+
},
55+
{
56+
"cell_type": "code",
57+
"execution_count": null,
58+
"id": "5",
59+
"metadata": {},
60+
"outputs": [],
61+
"source": [
62+
"ds['images'].sel(z=9, method='nearest').sel(c='membrane').plot()"
63+
]
64+
},
65+
{
66+
"cell_type": "code",
67+
"execution_count": null,
68+
"id": "6",
69+
"metadata": {},
70+
"outputs": [],
71+
"source": [
72+
"ds['images'].max('z').sel(c='nuclei').plot()\n",
73+
"ds['mask'].plot.contour(cmap='r')"
74+
]
75+
},
76+
{
77+
"cell_type": "code",
78+
"execution_count": null,
79+
"id": "7",
80+
"metadata": {},
81+
"outputs": [],
82+
"source": [
83+
"ds['mask'].plot()"
84+
]
85+
},
86+
{
87+
"cell_type": "markdown",
88+
"id": "8",
89+
"metadata": {},
90+
"source": [
91+
"## Allows high level computations.\n",
92+
"\n",
93+
"We won't get into here - but this structuring data allows you to leverage Xarray to do powerful operations such as computing per cell properties. See the [Computational Patterns Notebook](./01-high-level-computation-patterns.ipynb) for more."
94+
]
95+
},
96+
{
97+
"cell_type": "code",
98+
"execution_count": null,
99+
"id": "9",
100+
"metadata": {},
101+
"outputs": [],
102+
"source": []
103+
}
104+
],
105+
"metadata": {
106+
"language_info": {
107+
"codemirror_mode": {
108+
"name": "ipython",
109+
"version": 3
110+
},
111+
"file_extension": ".py",
112+
"mimetype": "text/x-python",
113+
"name": "python",
114+
"nbconvert_exporter": "python",
115+
"pygments_lexer": "ipython3"
116+
}
117+
},
118+
"nbformat": 4,
119+
"nbformat_minor": 5
120+
}

0 commit comments

Comments
 (0)