scverse / squidpy_notebooks

Tutorials for Squidpy
https://squidpy.readthedocs.io/en/stable/
MIT License
28 stars 17 forks source link

squidpy.im.ImageContainer.show() not showing image when run in Terminal (MacOS) #92

Closed amcrab closed 2 years ago

amcrab commented 2 years ago

Great work on this awesome tool! I am eager to implement it in my WSI analysis workflow, but I've encountered a setback. The tutorial to show layers of the ImageContainer (examples/image/compute_show.py), won't show the image through the Terminal but does show the image when run in Jupyter Notebook.

Viewing data from loop starting on line 26 works perfectly. However, running any squidpy.im.ImageContainer.show() function (lines 45 and 49) does not run correctly through MacOS terminal. A window (normally displaying a python-generated image) appears and disappears immediately.

To reproduce the issue:

import squidpy as sq
adata = sq.datasets.mibitof()
img = sq.im.ImageContainer(adata.uns["spatial"]["point16"]["images"]["hires"], library_id="point16")
img.show("image") # should show a single image, but no image is forthcoming on Terminal

Any ideas would be much appreciated!

-Angela


My computer & conda env info MacOS: Big Sur v11.6.5 Processor 2.6 GHz 6-Core Intel Core i7 Python version: Python 3.9.12 SquidPy version: 1.2.2 MatPlotLib version: 3.5.2

amcrab commented 2 years ago

Wow, okay, I figured it out. (I'm such a noob, sorry!) It won't show on the Terminal without a plt.show() command thrown in. For some reason, I didn't expect it to work like pyplot in that respect.

import squidpy as sq
import matplotlib.pyplot as plt
adata = sq.datasets.mibitof()
img = sq.im.ImageContainer(adata.uns["spatial"]["point16"]["images"]["hires"], library_id="point16")
img.show("image") 
plt.show() # shows image on Terminal, yay!

-Angela