# View xenium images in napari

**URL:** <https://discourse.scverse.org/t/view-xenium-images-in-napari/2119>\
**Category:** spatialdata\
**Created:** [February 24, 2024, 4:05pm UTC](https://discourse.scverse.org/t/view-xenium-images-in-napari/2119 "2024-02-24T16:05:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dylanmr](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/dylanmr/32/976_2.png) [@dylanmr](https://discourse.scverse.org/u/dylanmr)\
**Post date:** [February 24, 2024, 4:05pm UTC](https://discourse.scverse.org/t/view-xenium-images-in-napari/2119/1 "2024-02-24T16:05:32Z")

</div>

I used the spatialdata\_io xenium function to load in my xenium data, which appears to work exactly as described. However, when I try to view my xenium image using:  
`Interactive([adata])`  
The napari viewer is empty. I am able to render images when using the included visium H&E datasets, so I don’t think there is anything going on with my environment. Any suggestions would be very much appreciated!

Dylan

---

<div class="post-metadata">

**Author:** ![LucaMarconato](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/lucamarconato/32/661_2.png) [@LucaMarconato](https://discourse.scverse.org/u/LucaMarconato)\
**Post date:** [February 24, 2024, 6:32pm UTC](https://discourse.scverse.org/t/view-xenium-images-in-napari/2119/2 "2024-02-24T18:32:35Z")

</div>

Hi Dylan, thanks for reaching out.

Please use `Interactive(sdata)` (or `Interactive([sdata])`), as differently from `squidpy`, `napari-spatialdata` visualizes `SpatialData` objects, not `AnnData` objects.

---

<div class="post-metadata">

**Author:** ![dylanmr](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/dylanmr/32/976_2.png) [@dylanmr](https://discourse.scverse.org/u/dylanmr)\
**Post date:** [February 24, 2024, 6:46pm UTC](https://discourse.scverse.org/t/view-xenium-images-in-napari/2119/3 "2024-02-24T18:46:16Z")

</div>

Hi Luca,

To clarify here - I just saved the output from the xenium call as adata (so it is a spatial data object).

So I ran: adata=xenium(“pathtoobj”)

Sorry for the confusion. My first go with spatial data!

Dylan

---

<div class="post-metadata">

**Author:** ![LucaMarconato](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/lucamarconato/32/661_2.png) [@LucaMarconato](https://discourse.scverse.org/u/LucaMarconato)\
**Post date:** [February 24, 2024, 11:32pm UTC](https://discourse.scverse.org/t/view-xenium-images-in-napari/2119/4 "2024-02-24T23:32:59Z")

</div>

Thanks for the updated details.

Please save the SpatialData object to disk and read it again before using napari, because until you save and re-read you won’t be exploiting the performance of Zarr. It could be that you see black because the image takes long to load.

Otherwise I would suggest trying installing the latest mail (pip install git+https://) of spatialdata, spatialdata-io, napari-spatialdata and spatialdata-plot.

---

<div class="post-metadata">

**Author:** ![dylanmr](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/dylanmr/32/976_2.png) [@dylanmr](https://discourse.scverse.org/u/dylanmr)\
**Post date:** [February 25, 2024, 10:03am UTC](https://discourse.scverse.org/t/view-xenium-images-in-napari/2119/5 "2024-02-25T10:03:36Z")

</div>

Hi Luca,

Unfortunately after attempting both changing my workflow and installing the latest mail I am unable to view in napari.

To confirm I am doing it correctly, would this be your suggested workflow?

```auto
import napari_spatialdata as nps
import spatialdata as sp
from spatialdata_io import xenium
import spatialdata_plot

sdata = xenium("/Users/xenium_folder/")
sdata.write("/Users/test.zarr")
zarr_data = sp.read_zarr("/Users/test.zarr")
nps.Interactive([zarr_data])

```

---

<div class="post-metadata">

**Author:** ![LucaMarconato](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/lucamarconato/32/661_2.png) [@LucaMarconato](https://discourse.scverse.org/u/LucaMarconato)\
**Post date:** [February 25, 2024, 6:09pm UTC](https://discourse.scverse.org/t/view-xenium-images-in-napari/2119/6 "2024-02-25T18:09:30Z")

</div>

Yes, the code is correct. I would need more details, please do the following:

- Check the content of the `SpatialData` object with `print(zarr_data)`. It could turn out that the problem is not in `napari_spatialdata` but in `xenium()`
- Which version of Xenium Analyzer was your dataset made with? 10x very recently uploaded a dataset that uses Xenium Analyzer 2.0.0, if you are using this version please use the code from this PR: [Support for xenium analyzer 2.0.0 by LucaMarconato · Pull Request #111 · scverse/spatialdata-io · GitHub](https://github.com/scverse/spatialdata-io/pull/111)
- Is the dataset public? If so, please share a link and I will have a look.
