I used all of these commands to make sure I have everything that's needed for loading dpi pyramidal images on google collab with no luck so far.

!pip install large_image
!apt update && apt install -y openslide-tools
!pip install openslide-python
!pip install libtiff openslide_python pyvips gdal mapnik pyproj glymur -f https://girder.github.io/large_image_wheels

I get the following error:

---------------------------------------------------------------------------
TileSourceException                       Traceback (most recent call last)
<ipython-input-23-0584be72095d> in <module>()
     27 print(os.listdir(ndpi_dir))
     28 print(target_filename)
---> 29 ts = large_image.getTileSource(target_filename)
     30 
     31 # print(ts.getMetadata())

1 frames
/usr/local/lib/python3.6/dist-packages/large_image/tilesource/__init__.py in getTileSourceFromDict(availableSources, pathOrUri, *args, **kwargs)
     65         if availableSources[sourceName].canRead(sourceObj, *args, **kwargs):
     66             return availableSources[sourceName](sourceObj, *args, **kwargs)
---> 67     raise TileSourceException('No available tilesource for %s' % pathOrUri)
     68 
     69 

TileSourceException: No available c for ndpi_images/Li88TDCLAMP.ndpi

I made sure the the file is there, it's loading okay in other platforms using the same command, so it's not the file.

How can I resolve this issue?

Thanks

1

There are 1 answers

0
garlon4 On

It turns out that (at least today, maybe not when the original question was posted), that you can ask Google CoLab to proxy a port. With large_image >= 1.23.5, there are some convenience functions to help this. There is a sample notebook here: https://github.com/girder/large_image/blob/master/docs/large_image_examples.ipynb

The main method is, given a local file sample.npdi:

# The find-links pulls from some non-official pre-built wheels for openslide, etc.
!pip install large_image[all] --find-links https://girder.github.io/large_image_wheels
!pip install ipyleaflet

import large_image

ts = large_image.open('sample.ndpi')

import importlib.util

if importlib.util.find_spec('google.colab'):
    # colab intercepts localhost
    large_image.tilesource.jupyter.IPyLeafletMixin.JUPYTER_PROXY = 'https://localhost'
else:
    # JupyterLab proxies from its own host
    large_image.tilesource.jupyter.IPyLeafletMixin.JUPYTER_PROXY = True

# Look at our tile source; it will be shown as an ipyleaflet map
ts

Internally, there is a bunch of work to get a tile layer in pixel coordinates in iPyLeaflet (and, at least present, I've only figure out how to have the pixel coordinates bottom-up (y, x), not top-down (x,y) which is what you'd expect.