|
| 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