This post is cross-posted on the napari blog
Making napari and Xarray work better together will benefit many users. This has been long desired by the community but due to various roadblocks never implemented. At the SciPy 2025 sprints we formed a plan to implement a stronger integration.
napari is a high-performance, GPU-backed multidimensional array viewer with support for physical coordinates, data annotation, 2 and 3D visualization, and a plugin infrastructure, allowing users to customize it to their needs.
However, there are still several key pain points around managing image metadata when using napari.
TZYX
and the masks with shape TYX
. napari right-aligns axes which means that the slider names can't match both images. The TYX
images will use the Z
slider for their time dimension! This means the masks will always go out of the sync with the images.Xarray is a powerful multidimensional array library with deep support for labelled axes and managing metadata. If napari could understand Xarray objects' metadata, then this integration would provide a solution to all of these pain points.
To get a sense of the benefits Xarray provides, read the Accelerating Biological Analysis with Xarray blog post and look at the rich repr of an Xarray.DataArray
for an image stack:
Having napari leverage the Xarray metadata will not only improve the experience of napari users but also provide Xarray users with a polished interactive visualization tool.
There is progress toward this already. Some of the most successful plugins for napari are napari-aicsimageio which is built on top of aicsimageio and its successor bioio, which use xarray to manage their data and metadata.
This potential for napari and Xarray to bring out the best in each other is not a new insight.
The second oldest open issue on napari #14
is titled "Pass xarray to napari-gui for autolabeling sliders." That issue's age is a testament to the difficulty of the problems involved in this integration.
But something being hard is not a reason not to try to do it. In that spirit both the napari and Xarray developers are committed to improving the integration of napari and Xarray. This blog post is the kickoff of that collaboration.
Thanks to support from the Chan Zuckerberg Institute the napari, Xarray, and CellProfiler team members were able to attend SciPy 2025. At the sprints members of these three teams—Ian Hunt-Isaak, Tim Monko, Nodar Gogoberidze, Beth Cimini, Peter Sobolewski and Carol Willing—collaborated to develop a plan for enhancing the integration of Xarray with napari. The rest of this blog post is the initial roadmap we came up with for better integration of Xarray and napari.
The napari, Xarray, and CellProfiler teams at the SciPy 2025 sprints, collaborating on the roadmap for enhanced integration.
This is a community effort, so your contributions and thoughts are very welcome! To get involved in shaping this vision of the future, please join the napari Zulip and introduce yourself on this introductions issue in the napari-xarray repository.
To fully realize the potential of an integration between Xarray and napari, some deep changes in napari may be required. Therefore, we have developed a phased plan that progresses from simple to more complex enhancements, culminating in solutions that require more fundamental changes to how napari handles data.
In addition to the roadmap below we are maintaining a meta-issue that tracks all relevant issues in napari. That issue is napari-xarray #11.
This first step is the easiest, as it requires no changes to napari's core and can be implemented in a simple script or plugin.
Goal: Ingest Xarray data into napari's layer metadata to provide immediate context to the user.
Key Functionality:
'Z'
, 'Time'
).name
attributeImplementation: Script or plugin level, no napari core changes required. This will be an opportunity
napari enhancement napari has laid the groundwork for success here with the ability to include axis_labels
and units
on layers in this pr. The remaining work is to close the gap by adding connections from the napari layer list to the napari dims model. This improvement will help all napari users, not just those using xarray.
The next step is to map array indices to Xarray coordinates. This is harder than the previous step as it involves napari's viewer dims model, which is more complex than the layer metadata.
Goal: Display physical values instead of array indices in napari sliders and use coordinate information for proper scaling.
Key Functionality:
20.5
microns) using Xarray CoordinatesImplementation: First at script/plugin level, with eventual integration into napari core.
Today, if you mix up the order of your axes in non-standard way (e.g. lat, time, lon
, or XCZSYT
) and pass it to napari it will display as is, from right to left. This is because napari treats all axes equally, and does not know about or distinguish spatial or temporal dimensions! With knowledge of metadata and the conventions of a field napari could magically re-order the array to display in the "correct" order, with spatial dimensions on the right. This is a significant jump in complexity due to the "magic" involved - the system will need to correctly guess user intent, which can be challenging.
Goal: Handle a few clear cases of problematic dimension ordering, not solve the general case of arbitrary reordering.
Key Functionality:
lat, time, lon
-> time, lat, lon
XTCZYS
-> STCZYX
Implementation: Plugin with access to napari internals, requires deep integration with viewer logic.
The "magic" reordering naturally leads to issues where different fields of science have different conventions for what the "right" thing to do is. napari can't possibly know every convention across different scientific domains. napari now supports a startup script which can serve as an initial hook for this functionality.
Goal: Enable domain-specific configuration through pluggable personas with well-defined schemas for converting Xarray data into how napari should interpret it.
Key Functionality:
Implementation: Plugin mechanism and API provided by napari for extensible persona definitions.
Taking the lessons and user feedback from the earlier steps into account, we work to update napari's internal data model to be name-aware in addition to its current index-aware state. This is a major architectural change that addresses long-standing issues.
Goal: Transform napari's core to natively understand and preserve named dimensions throughout all operations.
Key Functionality:
Implementation: Deep changes to napari core architecture - significant development effort required. This addresses years-old open issues and fundamental limitations.