Look at the result¶
Your result is a folder ending in .zarr. This page shows what is inside it
and how to open it.
What is inside¶
| Part | What it holds |
|---|---|
| The spectra | One row per measured pixel and one column per m/z bin |
| Average spectrum | The mean spectrum of all measured pixels |
| TIC image | The total ion current of every pixel, as an image |
| Pixel outlines | The position and size of every measured pixel |
| Optical image | The photo of the slide, when the acquisition has one (Bruker) |
| Description | The instrument, the settings and the pixel size: see Describe and share your data |
There are no ion images in the result: they are made from the spectra, as shown below. Thyra stores only the values that are there, so the result stays small.
Advanced: the names of the parts
Every part is named after the dataset, msi_dataset unless you choose
another name with --dataset-id, and after the slice, _z0 for the
first one:
msi_dataset_z0: the table of spectramsi_dataset_z0_tic: the TIC imagemsi_dataset_z0_pixels: the pixel outlinesmsi_dataset_optical_...: the optical images, named after their image files
Some data adds more. Bruker timsTOF data with ion mobility carries a
mass-mobility heatmap in the table, and PASEF MS/MS data adds a table
ending in _msms. Ion mobility and MS/MS
shows how to use them. Output format lists every
part, including those for 3D data.
Keep the folder whole¶
The .zarr folder is one dataset. Copy it, move it or share it like any
other folder, but do not take files out of it or rename files inside it. It
opens on Windows, macOS and Linux alike.
See it without Python¶
Two commands show the result with no Python. Type them where you typed
thyra.
This writes brain_section_1_report.html beside the folder. Open it in your
web browser: it shows the TIC image, the mean spectrum and images of the
tallest peaks.
This writes brain_section_1_mz760.5130.png, an image of m/z 760.513:

Advanced: what the image adds up, and its colours
The image adds up every m/z bin within 10 ppm of the value. --ppm
changes that, and -o chooses the file name.
The colours run from zero to the 99th percentile of the pixels with signal, so a few very bright pixels do not darken the rest. A position that was never measured is grey.
Data with several slices gives one image per slice. Data converted with
--handle-3d gives one image, with the slices side by side. See
Command-line options.
Open it in napari¶
napari is a free image viewer. With the napari-spatialdata plugin, it opens Thyra results.
-
Install napari with the plugin. With uv (see Install):
-
Start napari:
-
Open your
.zarrfolder with File > Open Folder.... If napari asks which plugin should open it, choose napari-spatialdata. - A SpatialData panel appears on the left. Click global in its list of coordinate systems.
- The panel now lists the parts of the result. Double-click
msi_dataset_z0_ticto show the TIC image.
napari shows the TIC image, the optical image and the pixel outlines. For an
image of one m/z value, use thyra ion-image.
Advanced: an optical image that is not in the list
An optical image that Thyra could not line up with the data is not under global. Click the coordinate system named after it to see it.
Open it in Python¶
A few lines of Python give you the TIC image, or an image of any m/z value. The Tutorial runs them step by step on example data.
You need Thyra in the Python you work in, and matplotlib to draw the images (see Already use Python?):
Then:
import matplotlib.pyplot as plt
import numpy as np
import spatialdata as sd
sdata = sd.read_zarr("brain_section_1.zarr")
# The TIC image
tic = np.asarray(sdata.images["msi_dataset_z0_tic"])[0]
plt.imshow(tic)
plt.show()
# An image of m/z 760.6: add up the intensities within 0.25 of it
table = sdata.tables["msi_dataset_z0"]
mz = table.var["mz"].values
lo, hi = np.searchsorted(mz, [760.35, 760.85])
values = np.asarray(table.X[:, lo:hi].sum(axis=1)).ravel()
x = table.obs["x"].values.astype(int)
y = table.obs["y"].values.astype(int)
ion_image = np.zeros((y.max() + 1, x.max() + 1))
ion_image[y, x] = values
plt.imshow(ion_image)
plt.show()
Advanced: why a window, and not one bin
On the shared m/z axis, most bins are empty. The single bin nearest your m/z value is usually one of them, so an image of it would be blank. Add up the bins in a small window around the value instead, as above.
To view the result in napari from Python, install napari-spatialdata[all]
in the same environment and run:
Go deeper¶
- Explore the result in Python: optical overlays, single spectra, slices and metadata, as a notebook.
- Analyse the result with scanpy and squidpy: clusters and spatial patterns.
- Output format: every part of the result, in full detail.