Skip to content

updates for datastructures #335

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

Merged
merged 3 commits into from
Jul 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
Binary file added _static/dataarray.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/dataset.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/datatree1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/datatree2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/variable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 64 additions & 1 deletion fundamentals/01_datatree_hierarchical_data.ipynb

Large diffs are not rendered by default.

120 changes: 120 additions & 0 deletions intermediate/BiologyDataset.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "0",
"metadata": {},
"source": [
"# Datasets in other fields\n",
"\n",
"\n",
"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."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1",
"metadata": {},
"outputs": [],
"source": [
"import xarray as xr"
]
},
{
"cell_type": "markdown",
"id": "2",
"metadata": {},
"source": [
"## Loading the Dataset\n",
"\n",
"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 "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3",
"metadata": {},
"outputs": [],
"source": [
"ds = xr.tutorial.load_dataset(\"cells3d\")\n",
"ds"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4",
"metadata": {},
"outputs": [],
"source": [
"ds['images'].max('z').sel(c='nuclei').plot()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5",
"metadata": {},
"outputs": [],
"source": [
"ds['images'].sel(z=9, method='nearest').sel(c='membrane').plot()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6",
"metadata": {},
"outputs": [],
"source": [
"ds['images'].max('z').sel(c='nuclei').plot()\n",
"ds['mask'].plot.contour(cmap='r')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7",
"metadata": {},
"outputs": [],
"source": [
"ds['mask'].plot()"
]
},
{
"cell_type": "markdown",
"id": "8",
"metadata": {},
"source": [
"## Allows high level computations.\n",
"\n",
"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."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading
Loading