I tried to follow the landmark alignment tutorial and created a “points” layer that highlights some landmark features of the image as shown in the tutorial.
How can I save the points layer back in the spatialdata object? The tutorial suggests Ctrl+E, but that doesn’t seem to do anything.
This happens irrespective of if I open a spatialdata zarr file in napari, or open it by using
on Linux installed via pip into a conda env
Thanks for reporting!
Please use this branch GitHub - scverse/napari-spatialdata at spatialdata for enabling the feature. Unfortunately there have been some delays in merging the PR.
I’ll update the docs accordingly if we don’t manage to merge it soon enough.
Thanks for the quick response! Now at least something is happening, but pressing Ctrl+E raises the following error:
Traceback (most recent call last):
File "<path redacted>lib/python3.10/site-packages/napari/_qt/widgets/qt_viewer_dock_widget.py", line 230, in keyPressEvent
File "<path redacted>lib/python3.10/site-packages/napari/_qt/qt_viewer.py", line 1250, in keyPressEvent
File "<path redacted>lib/python3.10/site-packages/vispy/app/backends/_qt.py", line 622, in _keyEvent
func(native=ev, key=key, text=str(ev.text()), modifiers=mod)
File "<path redacted>lib/python3.10/site-packages/vispy/util/event.py", line 453, in __call__
File "<path redacted>lib/python3.10/site-packages/vispy/util/event.py", line 471, in _invoke_callback
File "<path redacted>lib/python3.10/site-packages/vispy/util/event.py", line 469, in _invoke_callback
File "<path redacted>lib/python3.10/site-packages/napari/utils/key_bindings.py", line 545, in on_key_press
File "<path redacted>lib/python3.10/site-packages/napari/utils/key_bindings.py", line 470, in press_key
generator_or_callback = func()
File "<path redacted>lib/python3.10/site-packages/napari_spatialdata/_view.py", line 305, in export
assert len(set(row)) == 1
TypeError: 'numpy.int64' object is not iterable
Thanks for reporting back. I have just tried again the notebook and I don’t get the error, could you please try the following?
- run the first 2 cells of the notebook
- the 3rd cell (
Interactive(visium_sdata)) needs to be set as a code cell
- run the 3rd cell
- napari opens, now create a new points layer
- add a few points (n >= 1)
- press Shift-E. You will see a tooltip in the bottom right interface of napari saying that the data was saved. Note: if you are running napari in a Jupyter Notebook you may see no tooltip, we haven’t investigated yet why this happens.
- try to print the sdata object (
print(visium_sdata)), you should see the points.
In your case are you doing something substantially different from this?
Thanks for reporting.
I think I did exactly this, but on my own data. I’ll try again with the example data and keep you posted!
I double-checked: doing exactly what you described with the example data from the notebook results in the same error.
pip install git+https://github.com/scverse/napari-spatialdata.git@spatialdata
as you suggested.
Python: 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:40:32) [GCC 12.3.0]
- GL version: 4.6.0 NVIDIA 470.129.06
- MAX_TEXTURE_SIZE: 32768
- screen 1: resolution 1920x1080, scale 1.0
@grst we merge this PR to main (the shortcut is Shift+E, no need to do Shift+L before). Saving / exporting new elements back to SpatialData by melonora · Pull Request #168 · scverse/napari-spatialdata · GitHub Can you please try to see if it works for you now?