GithubHelp home page GithubHelp logo

openslide / openslide-python Goto Github PK

View Code? Open in Web Editor NEW
355.0 355.0 182.0 1.39 MB

Python bindings to OpenSlide

Home Page: https://openslide.org/

License: GNU Lesser General Public License v2.1

Python 95.01% C 4.99%

openslide-python's Introduction

OpenSlide

OpenSlide is a C library for reading whole slide image files (also known as virtual slides). It provides a consistent and simple API for reading files from multiple vendors.

Features

OpenSlide can read brightfield whole slide images in several formats:

OpenSlide can also provide access to ICC profiles, textual metadata, and associated images such as a slide label and thumbnail.

Documentation

The API reference is available on the web, and is also included as doc/html/openslide_8h.html in the source tarball. Additional documentation is available on the OpenSlide website.

License

OpenSlide is released under the terms of the GNU Lesser General Public License, version 2.1.

OpenSlide is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

Compiling

To build OpenSlide, you will need:

  • Meson
  • cairo ≥ 1.2
  • GDK-PixBuf
  • glib ≥ 2.56
  • libdicom ≥ 1.0 (automatically built if missing)
  • libjpeg
  • libpng
  • libtiff ≥ 4.0
  • libxml2
  • OpenJPEG ≥ 2.1
  • SQLite ≥ 3.14
  • zlib
  • Zstandard

Then:

meson setup builddir
meson compile -C builddir
meson install -C builddir

Acknowledgements

OpenSlide has been developed by Carnegie Mellon University and other contributors.

OpenSlide has been supported by the National Institutes of Health and the Clinical and Translational Science Institute at the University of Pittsburgh.

Development of DICOM and ICC functionality was supported by NCI Imaging Data Commons and has been funded in whole or in part with Federal funds from the National Cancer Institute, National Institutes of Health, under Task Order No. HHSN26110071 under Contract No. HHSN261201500003l.

openslide-python's People

Contributors

agoode avatar bgilbert avatar hugovk avatar jaharkes avatar kaczmarj avatar userkkw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openslide-python's Issues

Performance bottleneck with Openslide and Openseadragon

Context

Issue type (bug report or feature request): performance issue
Operating system (e.g. Fedora 24, Mac OS 10.11, Windows 10): Ubuntu 16.04
Platform (e.g. 64-bit x86, 32-bit ARM): 64bit x86. i7 7700k, 16gb ddr4 RAM
OpenSlide Python version (openslide.__version__): 1.1.1
OpenSlide version (openslide.__library_version__): 3.4.1
Slide format (e.g. SVS, NDPI, MRXS): svs

Details

Hello,

I built a viewer based on the deepzoom example with openseadragon. I have several mounted folders using cifs, contains a lot of svs format images. I am currently testing it and the performance is terrible. it takes almost several minutes to load the image and when zooming it also takes a while to load. When I set the deepzoom server with local testing images it seems fine.

I wonder what could be the bottleneck? the way openslide convert svs to dzi on the go? or it's simply bandwidth problem ( although highly unlikely as the file system is across the street and the bandwidth is never a issue with much heavier projects)?

Any suggestion on improving the loading performance is greatly appreciated!

Cannot install (v 1.1.0) on Python 3.6 (x64) + Windows 10 x64

Context

LOG:
(py36) C:\Users\Usama Baig>pip install openslide-python==1.1.0
Collecting openslide-python==1.1.0
Using cached https://files.pythonhosted.org/packages/ae/c3/a691d533287435823f73b6812734ca930cf2ae48a56ebee0197de74e328d/openslide-python-1.1.0.tar.gz
Requirement already satisfied: Pillow in c:\users\usama baig\appdata\local\conda\conda\envs\py36\lib\site-packages (from openslide-python==1.1.0) (5.2.0)
Building wheels for collected packages: openslide-python
Running setup.py bdist_wheel for openslide-python ... error
Complete output from command "c:\users\usama baig\appdata\local\conda\conda\envs\py36\python.exe" -u -c "import setuptools, tokenize;file='C:\Users\USAMAB1\AppData\Local\Temp\pip-install-0lve6p9d\openslide-python\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d C:\Users\USAMAB1\AppData\Local\Temp\pip-wheel-mw1pxlfl --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\openslide
copying openslide\deepzoom.py -> build\lib.win-amd64-3.6\openslide
copying openslide\lowlevel.py -> build\lib.win-amd64-3.6\openslide
copying openslide_version.py -> build\lib.win-amd64-3.6\openslide
copying openslide_init_.py -> build\lib.win-amd64-3.6\openslide
running build_ext
building 'openslide._convert' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools


Failed building wheel for openslide-python
Running setup.py clean for openslide-python
Failed to build openslide-python
Installing collected packages: openslide-python
Running setup.py install for openslide-python ... error
Complete output from command "c:\users\usama baig\appdata\local\conda\conda\envs\py36\python.exe" -u -c "import setuptools, tokenize;file='C:\Users\USAMAB1\AppData\Local\Temp\pip-install-0lve6p9d\openslide-python\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\USAMAB1\AppData\Local\Temp\pip-record-4u5sv0i_\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\openslide
copying openslide\deepzoom.py -> build\lib.win-amd64-3.6\openslide
copying openslide\lowlevel.py -> build\lib.win-amd64-3.6\openslide
copying openslide_version.py -> build\lib.win-amd64-3.6\openslide
copying openslide_init_.py -> build\lib.win-amd64-3.6\openslide
running build_ext
building 'openslide._convert' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

----------------------------------------

Command ""c:\users\usama baig\appdata\local\conda\conda\envs\py36\python.exe" -u -c "import setuptools, tokenize;file='C:\Users\USAMAB1\AppData\Local\Temp\pip-install-0lve6p9d\openslide-python\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\USAMAB1\AppData\Local\Temp\pip-record-4u5sv0i_\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\USAMAB~1\AppData\Local\Temp\pip-install-0lve6p9d\openslide-python\

Can you tell me a way to install version 1.1.0? Thanks

Unable to install openslide-python

When I do this: pip install openslide-python

It gives me an error during the install process:

"error: Unable to find vcvarsall.bat"

Suggestions?

`MemoryError: Integer overflow in ysize` reading ndpi image

Context

Issue type: bug report
Operating system: Ubuntu 17.10 (Artful Aardvark)
Platform: 64-bit x86
OpenSlide Python version (openslide.__version__): 1.1.1
OpenSlide version (openslide.__library_version__): 3.4.1
Slide format (e.g. SVS, NDPI, MRXS): NDPI

Details

When trying to read this NDPI image, size (51200, 38144) ~ 1.82 Gpixels,

http://openslide.cs.cmu.edu/download/openslide-testdata/Hamamatsu/CMU-1.ndpi

with OpenSlide, the code

import openslide
slide = openslide.OpenSlide("CMU-1.ndpi")
foo = slide.read_region(location=(0, 0), level=0, size=slide.dimensions)

gives the error

Traceback (most recent call last):
  File "<input>", line 4, in <module>
  File "/home/rcasero/.conda/envs/elastixity/lib/python3.6/site-packages/openslide/__init__.py", line 223, in read_region
    level, size[0], size[1])
  File "/home/rcasero/.conda/envs/elastixity/lib/python3.6/site-packages/openslide/lowlevel.py", line 260, in read_region
    return _load_image(buf, (w, h))
  File "/home/rcasero/.conda/envs/elastixity/lib/python3.6/site-packages/openslide/lowlevel.py", line 65, in _load_image
    return PIL.Image.frombuffer('RGBA', size, buf, 'raw', 'RGBA', 0, 1)
  File "/home/rcasero/.conda/envs/elastixity/lib/python3.6/site-packages/PIL/Image.py", line 2398, in frombuffer
    core.map_buffer(data, size, decoder_name, None, 0, args)
MemoryError: Integer overflow in ysize

Package versions:

python                    3.6.4                hc3d631a_1
openslide-python          1.1.1                     <pip>
Pillow                    5.1.0                     <pip>

Open .scn file - libtiff is unrecognized

I'm trying to open a .scn file on a CentOS7 machine. libtiff5 is already installed, and openslide itself was installed using yum.

When calling openslide.OpenSlide(filename) I receive the following error:

Traceback (most recent call last):
  File "/home/alisa/PycharmProjects/openslide/read_data.py", line 7, in <module>
    data = openslide.OpenSlide(filename)
  File "/opt/anaconda/anaconda2/envs/oslide/lib/python3.5/site-packages/openslide/__init__.py", line 154, in __init__
    self._osr = lowlevel.open(filename)
  File "/opt/anaconda/anaconda2/envs/oslide/lib/python3.5/site-packages/openslide/lowlevel.py", line 178, in _check_open
    raise OpenSlideError(err)
openslide.lowlevel.OpenSlideError: Couldn't locate TIFF directory for quickhash

This is the latest versions of both openslide and openslide-python.

Thanks.

deepzoom module is not importable

Context

Issue type (bug report or feature request): bug
Operating system (e.g. Fedora 24, Mac OS 10.11, Windows 10): MacOS 10.12.6
Platform (e.g. 64-bit x86, 32-bit ARM): 64-bit
OpenSlide Python version (openslide.__version__): '1.1.1'
OpenSlide version (openslide.__library_version__): 3.4.1
Slide format (e.g. SVS, NDPI, MRXS): NA

Details

Running following when installed from pip or from github raises Not Found error:

import openslide
openslide.deepzoom.DeepZoomGenerator
openslide.deepzoom

Fix:

Add from openslide import deepzoom after line 47 to openslide/__init__.py

Segfault accessing property map after OpenSlide object freed

_PropertyMap and _AssociatedImageMap objects can outlive their parent OpenSlide. Attempts to use them will access a lowlevel._OpenSlide handle which has already been closed.

Handle cleanup via __del__ should happen in the _OpenSlide object, not in OpenSlide. This doesn't solve the OpenSlide.close() case, so _OpenSlide objects should know when they have been closed and throw an exception if they are used again.

I have successfully done all the preliminary work, but failed when running the example py code

I have successfully build the packages, but when I try to run deepzoom_tile.py ,I got the following error:
sudo python deepzoom_tile.py
[sudo] password for wangdu:
Traceback (most recent call last):
File "deepzoom_tile.py", line 26, in
import openslide
File "/usr/local/lib/python2.7/dist-packages/openslide/init.py", line 29, in
from openslide import lowlevel
File "/usr/local/lib/python2.7/dist-packages/openslide/lowlevel.py", line 55, in
_lib = cdll.LoadLibrary('libopenslide.so.0')
File "/usr/lib/python2.7/ctypes/init.py", line 443, in LoadLibrary
return self._dlltype(name)
File "/usr/lib/python2.7/ctypes/init.py", line 365, in init
self._handle = _dlopen(self._name, mode)
OSError: libopenslide.so.0: cannot open shared object file: No such file or directory

How can I solve this problem?

convert jpeg to svs or mrxs

Context

Issue type (bug report or feature request): feature request
Operating system (e.g. Fedora 24, Mac OS 10.11, Windows 10): CentOS
Platform (e.g. 64-bit x86, 32-bit ARM): 64-bit
OpenSlide Python version (openslide.__version__): 1.1.1
OpenSlide version (openslide.__library_version__): don't know
Slide format (e.g. SVS, NDPI, MRXS): MRXS

Details

Hi! Is there any python API for converting jpeg or png files to MRXS or SVS files? Saving as jpeg files occupied me too much memory, thanks!

openslide.lowlevel.OpenSlideError: OpenJPEG error: tcd_decode: incomplete bistream

Context

Issue type (bug report):
Operating system (CentOS):
Platform (Linux 64bit):
OpenSlide Python version (2.7):
OpenSlide version (1.1.1):
Slide format (e.g. SVS, NDPI, MRXS):

Details

Hi, when i run image=np.array(slide.read_region((20000,20000),0,(4000,4000))), i got error like title. and other region like slide.read_region((0,0),0,(4000,4000)) has no problem. So how can I fix this error.

Switching between associated images causes performance loss

If you switch between the Slide and other associated images in a statically tiled slide, you'll notice that performance worsens. This is because multiple seadragons are constructed but not destroyed. Timers seem to keep firing, which slows down performance.

This can be easily verified in the Timeline in a webkit browser.

Mosaiced image viewer without creating single large image. Is it possible?

Is there any way to stitch multiple images in a grid and deepzoom using deepzoom_server.py. I don't want to stitch images and save it to tiff or any other format, it will take huge RAM and time for 40000 images of resolution 1920X1200. I want to pass these images directly to openseadragon viewer. Any suggestion would be helpful.

I am using linux and python environemt for the development.

Windows Binaries 2017/11/22 64-bit giving error with openslide-python

Details:
Windows-10 64-bit
Python - 2.7.16

Using:
openslide-python 1.1.1 from pip
Windows Binaries from 2017-11-22

I get entry point not found error:
"The procedure entry point inflateValidate could not be located in the dynamic link library C:\openslide\bin\libintl-8.dll"
and
"The procedure entry point inflateValidate could not be located in the dynamic link library C:\openslide\bin\libxml2-2.dll"

[Question] Handle confocal image stack?

Context

Issue type (bug report or feature request):
Operating system ( Windows 10):
Platform (64-bit):
OpenSlide Python version (1.1.1):
OpenSlide version (3.4.1):
Slide format (NDPI):

Details

I have a confocal image stack NDPI file with 11 layers (focal positions). I have tried opening the NDPI file, but see only resolution pyramid related information. I do not see any confocal related information.

I am just wondering whether OpenSlide could handle this kind of confocal image stack NDPI files. If OpenSlide could not, do you have any suggestions to other Python libraries which can handle it? Many thanks.

[python api] openslide.read_region broke when svs too large

Context

Issue type (bug report or feature request): bug report
Operating system (e.g. Fedora 24, Mac OS 10.11, Windows 10): Windows 10
Platform (e.g. 64-bit x86, 32-bit ARM): 64-bit x86
OpenSlide version: 1.1.1
Slide format (e.g. SVS, NDPI, MRXS): svs

Details

call like this:
openslide.open_slide(svs_file)
level = 1
dimension=slide.level_dimensions[level]
// It broken many times.
// Among all broken dimensions of all svs files, min is (25895,21005) max is (89639,51222)
slide.read_region((0, 0), level, dimension)

stack_trace:
File "D:\projects\cancer_ml_project\tools\SVS2PNGConverter.py", line 31, in convert_for_file
imsave(out_folder + "/" + png_file, np.array(slide.read_region((0, 0), level, dimension)))
File "D:\projects\cancer_ml_project\venv\lib\site-packages\openslide_init_.py", line 223, in read_region
level, size[0], size[1])
File "D:\projects\cancer_ml_project\venv\lib\site-packages\openslide\lowlevel.py", line 258, in read_region
buf = (w * h * c_uint32)()
OverflowError: The 'length' attribute is too large

Memory release for circulate use slide tiling

Context

Issue type (bug report or feature request): feature request
Operating system (e.g. Fedora 24, Mac OS 10.11, Windows 10): Windows 10
Platform (e.g. 64-bit x86, 32-bit ARM): 64-bit x86
OpenSlide Python version (openslide.__version__): 1.1.1
OpenSlide version (openslide.__library_version__): 3.4.1
Slide format (e.g. SVS, NDPI, MRXS): MRXS

Details

I modified the deepzoom_tile.py script to work on multiple slides instead of one.

DeepZoomStaticTiler(slide_name) for slide_name in slide_names:
removed the _shutdown() function

However, I found it can not release memory. When read slides one after another, the memory usage is also increased. Is there anyway to solve the problem?

Thanks in advance.

/bin/env not found

$ examples/deepzoom/deepzoom-tile.py
bash: examples/deepzoom/deepzoom-tile.py: /bin/env: bad interpreter: No such file or directory

AFAIK, it is typically available as /usr/bin/env

openslide memory leak

Context

Issue type (bug report):
Operating system (CentOS 7.3.1611):
Platform (x86_64 GNU/Linux):
OpenSlide Python version (1.1.0):
Slide format (SVS):

Details

Dear openslide team,
Thank you for making this software available. It greatly facilitates my research. I am building large-scale pipelines for digital pathology that rely on extracting tiles from thousands of slides on the fly. To achieve this I create all openslide objects at the beginning and append them to a list. I fetch tiles by looping through a list of pixel coordinates and slide index. The loop somehow leaks memory. The memory used keeps increasing until out of memory. The script below reproduces this behavior. You only need to change the path to a slide to make it work.

import openslide
import random
import sys
import numpy as np

class library(object):
    def __init__(self, slides, idx, grid, size):
        sl = []
        for i,slide in enumerate(slides):
            sl.append(openslide.OpenSlide(slide))
            sys.stdout.write("{}/{} \r".format(i+1,len(slides)))
            sys.stdout.flush()
        tup = zip(grid,idx)
        self.size = size
        self.slides = slides
        self.tup = tup
        self.sl = sl

    def make_list_of_objs(self):
        sl = []
        for i,slide in enumerate(self.slides):
            sl.append(openslide.OpenSlide(slide))
            sys.stdout.write("{}/{} \r".format(i+1,len(self.slides)))
            sys.stdout.flush()
        self.sl = sl

    def __getitem__(self, index):
        tup = self.tup[index]
        img = self.sl[tup[1]].read_region(tup[0],0,(self.size,self.size)).convert('RGB')
        return img

    def __len__(self):
        return len(self.tup)

class batch_loader(object):
    def __init__(self,dset,n):
        batches = []
        for i in range(0,dset.__len__(),n):
            d = min(n,dset.__len__()-i)
            batches.append(range(i,i+d))
        self.batches = batches

#MAKE DATA
slides = ['/scratch/gabriele/prostate_dict/389973.svs']*2000 #CHANGE SLIDE NAME
idx = list(np.random.choice(len(slides),2000000,replace=True))
gridx = list(np.random.choice(10000,2000000,replace=True))
gridy = list(np.random.choice(10000,2000000,replace=True))
grid = zip(gridx,gridy)

#SET UP LOADER
dset = library(slides,idx,grid,224)
loader = batch_loader(dset,512)

#LEAKING LOOP
for ii,batch in enumerate(loader.batches):
    imgs = []
    for i,idx in enumerate(batch):
        img = np.array(dset.__getitem__(idx))
        imgs.append(img)
    sys.stdout.write("{}/{} \r".format(ii+1,len(loader.batches)))
    sys.stdout.flush()

To circumvent this one can delete the list of openslide objects and recreate it every few iterations. This stabilizes memory footprint but it is an unfortunate work-around that wastes a lot of time reopening openslide objects:

import openslide
import random
import sys
import numpy as np

class library(object):
    def __init__(self, slides, idx, grid, size):
        sl = []
        for i,slide in enumerate(slides):
            sl.append(openslide.OpenSlide(slide))
            sys.stdout.write("{}/{} \r".format(i+1,len(slides)))
            sys.stdout.flush()
        tup = zip(grid,idx)
        self.size = size
        self.slides = slides
        self.tup = tup
        self.sl = sl
        self.idx = 0

    def make_list_of_objs(self):
        sl = []
        for i,slide in enumerate(self.slides):
            sl.append(openslide.OpenSlide(slide))
            sys.stdout.write("{}/{} \r".format(i+1,len(self.slides)))
            sys.stdout.flush()
        self.sl = sl

    def __getitem__(self, index):
        if self.idx > 5120:
            self.idx = 0
            self.make_list_of_objs()
        self.idx += 1
        tup = self.tup[index]
        img = self.sl[tup[1]].read_region(tup[0],0,(self.size,self.size)).convert('RGB')
        return img

    def __len__(self):
        return len(self.tup)

class batch_loader(object):
    def __init__(self,dset,n):
        batches = []
        for i in range(0,dset.__len__(),n):
            d = min(n,dset.__len__()-i)
            batches.append(range(i,i+d))
        self.batches = batches

#MAKE DATA
slides = ['/scratch/gabriele/prostate_dict/389973.svs']*2000 #CHANGE SLIDE NAME
idx = list(np.random.choice(len(slides),2000000,replace=True))
gridx = list(np.random.choice(10000,2000000,replace=True))
gridy = list(np.random.choice(10000,2000000,replace=True))
grid = zip(gridx,gridy)

#SET UP LOADER
dset = library(slides,idx,grid,224)
loader = batch_loader(dset,512)

#LEAKING LOOP
for ii,batch in enumerate(loader.batches):
    imgs = []
    for i,idx in enumerate(batch):
        img = np.array(dset.__getitem__(idx))
        imgs.append(img)
    sys.stdout.write("{}/{} \r".format(ii+1,len(loader.batches)))
    sys.stdout.flush()

Thanks for your patience.

Exporting DZI With tiles

I understand I can give .scn image to openslide and it will create in-memory dzi object. Can I export this object? so that I can use it with openseadragon to view.

Urgent: Facing issues with the Level-Dimensions in Leica .scn Images

hello @bgilbert , @jaharkes

Context

Issue type (bug report or feature request): Bug
Operating system ( Windows ): Windows 8.1 and also Tried on Linux Server Machine (ppc64le)
Platform (64-bit):
OpenSlide Python version - 1.1.1:
OpenSlide version - 3.4.1
Slide format - .scn (Leica SCN Images)

Details

I am facing issues regarding the Whole Slide Image for Leica .scn images. Whenever I use the slide.level_dimensions and slide.properties functions from the openslide python package to get information about the dimensions and the overall information about the slide properties, it gives incorrect information about the level dimensions. The information doesn't seem to match the information from the image.

My code details to reproduce to issue are:

import openslide
slide = openslide.OpenSlide('./nims-002.scn')
print("Level count: %d" % slide.level_count)
print("Level dimensions: " + str(slide.level_dimensions))
print("Properties: " + str(slide.properties))
print("Dimensions: " + str(slide.dimensions))

I am hereby attaching the details of 2 Whole Slide Image and their information from the slide.level_dimension and slide.properties function and those extracted from actual Whole Slide Images. The width and height at each and every level dont seem to match to the original scn image at all. As a result I get tiles with huge y-coordinates and few tiles that are completely black. For two different Whole Slide Images, slide.level_dimensions and slide.properties function gives same level values and same dimensions. How is it possible when both of them have different values of the levels and different dimensions all together?

Request you to kindly inspect the issue and let me know about it, as I am unable to proceed with my research.

a2
nims-002.txt

a4
nims-004.txt

Regards,
Hitesha

Openslide can't find my dylib files

Context

Issue type (bug report or feature request):
Operating system Mac OS 10.12
Platform 64-bit x86
OpenSlide Python version (openslide.__version__):
OpenSlide version (openslide.__library_version__):
Slide format (e.g. SVS, NDPI, MRXS):

Details

I am working on installing openslide on my Mac OS but can't get it to work.
I am facing this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../lib/python2.7/site-packages/openslide/__init__.py", line 29, in <module>
    from openslide import lowlevel
  File ".../lib/python2.7/site-packages/openslide/lowlevel.py", line 55, in <module>
    "Is OpenSlide installed?")
ImportError: Couldn't locate OpenSlide dylib.  Is OpenSlide installed?

openslide is already installed and I can view it under lib/python2.7/site-packages

Please advise.

Thanks

Windows cdll.LoadLibrary('libopenslide-0.dll') OSError: [WinError 127] The specified procedure could not be found

Context

Issue type (bug report or feature request): bug report
Operating system (e.g. Fedora 24, Mac OS 10.11, Windows 10): Windows 10
Platform (e.g. 64-bit x86, 32-bit ARM): x86_64
OpenSlide Python version (openslide.__version__): 1.1.1
OpenSlide version (openslide.__library_version__): 3.4.1
Slide format (e.g. SVS, NDPI, MRXS): SVS

Details

I get the following error even though OpenSlide windows binary /bin is in my PATH.

>>> import openslide
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\jxu\AppData\Roaming\Python\Python36\site-packages\openslide\__init__.py", line 29, in <module>
    from openslide import lowlevel
  File "C:\Users\jxu\AppData\Roaming\Python\Python36\site-packages\openslide\lowlevel.py", line 41, in <module>
    _lib = cdll.LoadLibrary('libopenslide-0.dll')
  File "C:\Program Files\Python36\lib\ctypes\__init__.py", line 426, in LoadLibrary
    return self._dlltype(name)
  File "C:\Program Files\Python36\lib\ctypes\__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 127] The specified procedure could not be found

Maybe I misunderstood what "system search path" is. From https://docs.python.org/3/library/ctypes.html#finding-shared-libraries

On Windows, find_library() searches along the system search path

The only thing that works is running python interpreter from /bin folder.
https://openslide-users.andrew.cmu.narkive.com/uwZnTDGx/winerror-127-the-specified-procedure-could-not-be-found

how to save a ordinary image file as a svs file

excuse me,i use openslide-python api to open a svs file successfully,and then i want to slice the file into several part but still save them as svs files ,but i don't find the related Python API in openslide-python...

Read file from web (FTP/HTTP)

Context

Issue type (bug report or feature request): Feature request
Operating system (e.g. Fedora 24, Mac OS 10.11, Windows 10): Windows 10/Ubuntu/Mac OS
Platform (e.g. 64-bit x86, 32-bit ARM): 64-bit
OpenSlide Python version (openslide.__version__): 1.1.1
OpenSlide version (openslide.__library_version__):
Slide format (e.g. SVS, NDPI, MRXS): TIF

Details

Hello!

First of all, thank you for creating and supporting openslide. I started using it couple days ago and find it great!

Thing is, I'm working with and enormous dataset of *.TIF slides that is located at public FTP server. Furthermore, my future research is going to require access slides which are located in Amazon S3 data warehouse. So, the question is: is there any way to access files via FTP/HTTP or is it possible to implement such functionality in the nearest future?

Thank you again.

openslide acting different in python 2.7.10 and 2.7.6

Context

Issue type (bug report or feature request):
Operating system (e.g. Fedora 24, Mac OS 10.11, Windows 10):
Platform (e.g. 64-bit x86, 32-bit ARM):
OpenSlide Python version (openslide.__version__):
OpenSlide version (openslide.__library_version__):
Slide format (e.g. SVS, NDPI, MRXS):

Details

So i have a tiff image and am opening this image into level 6 on openslide but the width and height are different in python 2.7.10 and 2.7.6

Here is the code

    tumor_file = openslide.OpenSlide(tumor_img) 
    region_x, region_y = tumor_file.level_dimensions[6]

on python 2.7.10 region_x , region_y = 1472 1120
on python 2.7.6 region_x, region _y = 1536, 1536

Integer division bug

Hello,

This snippet on line 85 of openslide.deepzoom.py
z_size = tuple(max(1, int(math.ceil(z / 2))) for z in z_size)

should almost definitely read
z_size = tuple(max(1, int(math.ceil(z / 2.0))) for z in z_size)

In the case of images where either dimension is not a power of 2 the first line causes rounding errors which result in the incorrect number of blocks.

Unintuitive read_region for levels

Context

Issue type (bug report or feature request): Feature request
Operating system (e.g. Fedora 24, Mac OS 10.11, Windows 10): RHEL 7.6
Platform (e.g. 64-bit x86, 32-bit ARM): x86_64
OpenSlide Python version (openslide.__version__): 1.1.1
OpenSlide version (openslide.__library_version__): 3.4.1
Slide format (e.g. SVS, NDPI, MRXS): SVS

Details

For read_region in non-0 level I've found out that location is relative to level 0 image (stated in docs) but size is relative to level image. The docs say

Unlike in the C interface, the image data is not premultiplied.

but this should be clarified.

Open file slow in a docker container

Context

Issue type (bug report or feature request):
report
Operating system (e.g. Fedora 24, Mac OS 10.11, Windows 10):
Mac OS 10.03
Platform (e.g. 64-bit x86, 32-bit ARM):
64-bit x86
OpenSlide Python version (openslide.__version__):
1.1.1
OpenSlide version (openslide.__library_version__):
3.4.1
Slide format (e.g. SVS, NDPI, MRXS):
TIFF

Details

from openslide import OpenSlide

slide = OpenSlide("/path/to/slide")
this line of code works fine and fast on my mac,
but when I try to let that code work in a docker container which based on Ubuntu 14.04
and the file comes from a docker volume, the OpenSlide operation becomes very slow.
I'm now trying to change the docker's storage driver, hope that can help.

-s 512 doesn't work

$ PYTHONPATH=$HOME/openslide-git/openslide-python/build/lib ~/openslide-git/openslide-python/examples/deepzoom/deepzoom-tile.py -s 512 ~/openslide-testdata/Mirax/CMU-2.mrxs 
Suspension not allowed here
Process TileWorker:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/multiprocessing/process.py", line 232, in _bootstrap
    self.run()
  File "/home/agoode/openslide-git/openslide-python/examples/deepzoom/deepzoom-tile.py", line 62, in run
    tile.save(outfile, optimize=True, quality=90)
  File "/usr/lib64/python2.7/site-packages/PIL/Image.py", line 1439, in save
    save_handler(self, fp, filename)
  File "/usr/lib64/python2.7/site-packages/PIL/JpegImagePlugin.py", line 471, in _save
    ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])
  File "/usr/lib64/python2.7/site-packages/PIL/ImageFile.py", line 501, in _save
    raise IOError("encoder error %d when writing image file" % s)
IOError: encoder error -2 when writing image file

converting svs to jpeg

Context

Issue type (bug report or feature request): feature request
Operating system (e.g. Fedora 24, Mac OS 10.11, Windows 10): Windows 7
Platform (e.g. 64-bit x86, 32-bit ARM):
OpenSlide Python version (openslide.__version__):
OpenSlide version (openslide.__library_version__):
Slide format (e.g. SVS, NDPI, MRXS): svs

Details

I would like to convert the large SVS files I have into smaller jpeg files.

I found the following guide on the problem: https://developer.ibm.com/articles/an-automatic-method-to-identify-tissues-from-big-whole-slide-images-pt1/

but the functions called in the guide appear to be deprecated.

I have figured out how to save an individual tile as a jpeg image but now how to save the whole slide image as a smaller jpeg.

Please advise!

OSError: libopenslide.so.0: cannot open shared object file: No such file or directory

Context

Issue type
OSError: libopenslide.so.0: cannot open shared object file: No such file or directory
Operating system:
Centos6 (without administrator rights)
Platform
x64
OpenSlide Python version
python3.5 openslide-python 1.1.1

Details

I tried to install from source and using pip ,but both occured this issue. I also exported the path when I installed from source(export LD_LIBRARY_PATH=~/openslide-python-1.1.1:$LD_LIBRARY_PATH ) , but it didn't work. If there is any solution for this issues, please tell me. Thanks!
here is the output of error:
`Python 3.5.0 |Continuum Analytics, Inc.| (default, Oct 19 2015, 21:57:25)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.

import openslide
Traceback (most recent call last):
File "", line 1, in
File "/DATA/249/gli1/software/openslide-python-1.1.1/openslide/init.py", line 29, in
from openslide import lowlevel
File "/DATA/249/gli1/software/openslide-python-1.1.1/openslide/lowlevel.py", line 58, in
_lib = cdll.LoadLibrary('libopenslide.so.0')
File "/DATA/249/gli1/software/Anaconda3/lib/python3.5/ctypes/init.py", line 425, in LoadLibrary
return self._dlltype(name)
File "/DATA/249/gli1/software/Anaconda3/lib/python3.5/ctypes/init.py", line 347, in init
self._handle = _dlopen(self._name, mode)
OSError: libopenslide.so.0: cannot open shared object file: No such file or directory
`

ImportError: Couldn't locate OpenSlide dylib. Is OpenSlide installed?

Context

Issue type : bug report
Operating system : Mac OS 10.14.5
Platform :
OpenSlide Python version : openslide-python 1.1.1
Slide format : any

Details

hi, I am trying to install openslide-python 1.1.1 on Mac OS 10.14.5 (in a virtualenv environment) with the command :

pip install openslide-python

I am facing this error when typing import openslide in a python shell :

Traceback (most recent call last):
  File ".../lib/python3.6/site-packages/openslide/lowlevel.py", line 44, in <module>
    _lib = cdll.LoadLibrary('libopenslide.0.dylib')
  File "/anaconda3/lib/python3.6/ctypes/__init__.py", line 426, in LoadLibrary
    return self._dlltype(name)
  File "/anaconda3/lib/python3.6/ctypes/__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(libopenslide.0.dylib, 6): image not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../lib/python3.6/site-packages/openslide/__init__.py", line 29, in <module>
    from openslide import lowlevel
  File ".../lib/python3.6/site-packages/openslide/lowlevel.py", line 55, in <module>
    "Is OpenSlide installed?")
ImportError: Couldn't locate OpenSlide dylib.  Is OpenSlide installed?

Please advise.

Thanks

Support Windows

openslide.lowlevel may not correctly load the C library on Windows. Check this.

OpenJPEG error

Context

Operating system: Ubuntu 16.06
Platform: 64-bit x86,
OpenSlide Python version: newest
OpenSlide version: newest
Slide format: SVS

Details

OpenSlideError: OpenJPEG error: Error decoding tile. Component 1 contains only 32768 blocks while component 0 has 65536 blocks

How to force openslide to open a file as specific format?

Context

Issue type: Question
Operating system: Arch Linux
Platform: 64-Bit x86
OpenSlide Python version: Latest
OpenSlide version: Latest

Details

I've image that behaves just like aperio format. How can I force openslide library to read it as aperio image instead of generic tiff?

Some cache or buffer issues on server side

Hi,

I built an app using Openslide/Deepzoom server and its behavior seems a little awkward. When two clients access the server at de same time in differents devices, tiles from both slides are served scrambled.

It seems some cache or buffer issue, but I'm not able to find this on code or configuration files.

Can someone help me?

Regards

[OverflowError] size doesn't fit in an int

I'm trying to open a Hamamatsu style image, which is about 500MB compressed so it is quite big but should fit in RAM (32 GB). I get Overflow error : size does not fit in an int when I try to open at levels 0, 1 or 2 but can open the slide images on all higher levels.
Any pointers on how to solve this or is it simply not possible with the python bindings?

WindowsError when importing openslide using 64-bit version

Context

Issue type (bug report perhaps?):
Operating system (Windows 10):
Platform (64-bit):
OpenSlide version (2016-7-17 64 bit release):
Slide format (NA):

Details

Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "C:\dev_res\python\python2_713\lib\site-packages\openslide\__init__.py", line 29, in <module>
        from openslide import lowlevel
    File "C:\dev_res\python\python2_713\lib\site-packages\openslide\lowlevel.py", line 41, in <module>
        _lib = cdll.LoadLibrary('libopenslide-0.dll')
    File "C:\dev_res\python\python2_713\lib\ctypes\__init__.py", line 440, in LoadLibrary
        return self._dlltype(name)
    File "C:\dev_res\python\python2_713\lib\ctypes\__init__.py", line 362, in __init__
        self._handle = _dlopen(self._name, mode)
WindowsError: [Error 127] The specified procedure could not be found'

I installed the OpenSlide binaries and added the bin folder to my system path. I then installed python-openslide using pip. I tried same workflow with Python 3.5.3 and encountered the same problem. Interestingly, when I tested this with the 32-bit version of Python(2.7)/OpenSlide I did not have this issue. However, I have a 64-bit machine and would prefer to use the 64-bit versions.

Not sure if this is a bug or is specific to my configuration. Any help would be greatly appreciated!

Cannot install on Python 2.7.9 (x64) + Windows 7 x64

Log:

C:\Users\Nash>pip install openslide-python                                      
Collecting openslide-python                                                     
  Using cached openslide-python-1.1.0.tar.gz                                    
Requirement already satisfied (use --upgrade to upgrade): Pillow in d:\winpython
\python-2.7.9.amd64\lib\site-packages (from openslide-python)                   
Installing collected packages: openslide-python                                 
  Running setup.py install for openslide-python                                 
    Complete output from command D:\WinPython\python-2.7.9.amd64\python.exe -c "
import setuptools, tokenize;__file__='c:\\users\\nash\\appdata\\local\\temp\\pip
-build-89mzyi\\openslide-python\\setup.py';exec(compile(getattr(tokenize, 'open'
, open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --re
cord c:\users\nash\appdata\local\temp\pip-i496c8-record\install-record.txt --sin
gle-version-externally-managed --compile:                                       
    running install                                                             
    running build                                                               
    running build_py                                                            
    creating build                                                              
    creating build\lib.win-amd64-2.7                                            
    creating build\lib.win-amd64-2.7\openslide                                  
    copying openslide\deepzoom.py -> build\lib.win-amd64-2.7\openslide          
    copying openslide\lowlevel.py -> build\lib.win-amd64-2.7\openslide          
    copying openslide\_version.py -> build\lib.win-amd64-2.7\openslide          
    copying openslide\__init__.py -> build\lib.win-amd64-2.7\openslide          
    running build_ext                                                           
    building 'openslide._convert' extension                                     
    creating build\temp.win-amd64-2.7                                           
    creating build\temp.win-amd64-2.7\Release                                   
    creating build\temp.win-amd64-2.7\Release\openslide                         
    D:\WinPython\scripts\..\python-2.7.9.amd64\..\tools\mingw32\bin\gcc.exe -mdl
l -O -DMS_WIN64 -Wall -ID:\WinPython\python-2.7.9.amd64\include -ID:\WinPython\p
ython-2.7.9.amd64\PC -c openslide/_convert.c -o build\temp.win-amd64-2.7\Release
\openslide\_convert.o                                                           
    writing build\temp.win-amd64-2.7\Release\openslide\_convert.def             
    D:\WinPython\scripts\..\python-2.7.9.amd64\..\tools\mingw32\bin\gcc.exe -sha
red -s build\temp.win-amd64-2.7\Release\openslide\_convert.o build\temp.win-amd6
4-2.7\Release\openslide\_convert.def -LD:\WinPython\python-2.7.9.amd64\libs -LD:
\WinPython\python-2.7.9.amd64\PCbuild\amd64 -lpython27 -lmsvcr90 -o build\lib.wi
n-amd64-2.7\openslide\_convert.pyd                                              
    D:/WinPython/tools/mingw32/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../
../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-mingw_helpers.o
):mingw_helpers.c:(.text+0x0): multiple definition of `_decode_pointer'         
    D:\WinPython\python-2.7.9.amd64\libs/libmsvcr90.a(dacws00231.o):(.text+0x0):
 first defined here                                                             
    D:/WinPython/tools/mingw32/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../
../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-mingw_helpers.o
):mingw_helpers.c:(.text+0x10): multiple definition of `_encode_pointer'        
    D:\WinPython\python-2.7.9.amd64\libs/libmsvcr90.a(dacws00241.o):(.text+0x0):
 first defined here                                                             
    D:\WinPython\python-2.7.9.amd64\libs/libmsvcr90.a(dacws00288.o):(.text+0x0):
 multiple definition of `_fpreset'                                              
    D:/WinPython/tools/mingw32/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../
../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-CRT_fp8.o):CRT_
fp8.c:(.text+0x0): first defined here                                           
    D:/WinPython/tools/mingw32/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../
../x86_64-w64-mingw32/bin/ld.exe: D:/WinPython/tools/mingw32/bin/../lib/gcc/x86_
64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib6
4_libmingw32_a-mingw_helpers.o): bad reloc address 0x0 in section `.pdata'      
    collect2.exe: error: ld returned 1 exit status                              
    error: command 'D:\\WinPython\\scripts\\..\\python-2.7.9.amd64\\..\\tools\\m
ingw32\\bin\\gcc.exe' failed with exit status 1                                 

    ----------------------------------------                                    
    Command "D:\WinPython\python-2.7.9.amd64\python.exe -c "import setuptools, t
okenize;__file__='c:\\users\\nash\\appdata\\local\\temp\\pip-build-89mzyi\\opens
lide-python\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).re
ad().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\nash\a
ppdata\local\temp\pip-i496c8-record\install-record.txt --single-version-external
ly-managed --compile" failed with error code 1 in c:\users\nash\appdata\local\te
mp\pip-build-89mzyi\openslide-python                                            

This cannot be correct since gcc is installed on this machine:

C:\Users\Nash>gcc --version
gcc (x86_64-win32-seh-rev1, Built by MinGW-W64 project) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Any ideas what is going on?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.