Coder Social home page Coder Social logo

Comments (4)

archanabhardwaj avatar archanabhardwaj commented on July 24, 2024 1

Hi
I converted the converted the Path objects to strings and it worked.

Thanks!!

from pathml.

jacob-rosenthal avatar jacob-rosenthal commented on July 24, 2024

Can you please share the full error message?
Can you please also share the output of print(wsi_paths)?

from pathml.

archanabhardwaj avatar archanabhardwaj commented on July 24, 2024

Hello

I am sharing full error message and exact path :

from pathlib import Path
from pathml.core import HESlide, SlideDataset
data_dir = Path("/home/Desktop/AI_pathology/test_AB/")
wsi_paths = list(data_dir.glob("*.svs"))

print(wsi_paths)
[PosixPath('/home/Desktop/AI_pathology/test_AB/test1.svs'), PosixPath('/home/Desktop/AI_pathology/test_AB/test2.svs')]

Error message :
wsi_list = [HESlide(p) for p in wsi_paths]


ArgumentError Traceback (most recent call last)
in
----> 1 wsi_list = [HESlide(p) for p in wsi_paths]

in (.0)
----> 1 wsi_list = [HESlide(p) for p in wsi_paths]

~/Desktop/AI_pathology/new_path/pathml/pathml/core/slide_data.py in init(self, *args, **kwargs)
501 def init(self, *args, **kwargs):
502 kwargs["slide_type"] = pathml.core.types.HE
--> 503 super().init(*args, **kwargs)
504
505

~/Desktop/AI_pathology/new_path/pathml/pathml/core/slide_data.py in init(self, filepath, name, masks, tiles, labels, backend, slide_type, stain, platform, tma, rgb, volumetric, time_series, counts, dtype)
161
162 if backend.lower() == "openslide":
--> 163 backend_obj = pathml.core.OpenSlideBackend(filepath)
164 elif backend.lower() == "bioformats":
165 backend_obj = pathml.core.BioFormatsBackend(filepath, dtype)

~/Desktop/AI_pathology/new_path/pathml/pathml/core/slide_backends.py in init(self, filename)
63 logger.info(f"OpenSlideBackend loading file at: {filename}")
64 self.filename = filename
---> 65 self.slide = openslide.open_slide(filename=filename)
66 self.level_count = self.slide.level_count
67

~/.local/lib/python3.8/site-packages/openslide/init.py in open_slide(filename)
386 object for other types of images."""
387 try:
--> 388 return OpenSlide(filename)
389 except OpenSlideUnsupportedFormatError:
390 return ImageSlide(filename)

~/.local/lib/python3.8/site-packages/openslide/init.py in init(self, filename)
158 AbstractSlide.init(self)
159 self._filename = filename
--> 160 self._osr = lowlevel.open(filename)
161
162 def repr(self):

ArgumentError: argument 1: <class 'TypeError'>: Incorrect type

Thanks in advance

from pathml.

jacob-rosenthal avatar jacob-rosenthal commented on July 24, 2024

Great, posting the entire error message is very useful!

Looks like the problem is being caused because the paths in wsi_paths are Pathlib.Path objects, which openslide doesn't know how to open (openslide/openslide-python#112). They did update openslide to fix this in v1.2.0 (openslide/openslide-python#123, mentioned in release notes).

So, I think there are two ways you could fix this:

  1. convert the Path objects to strings first (wsi_list = [HESlide(str(p)) for p in wsi_paths])
  2. Update openslide to v1.2.0 or greater

We can also add a check in PathML to prevent this from happening in the future. Thanks!!

from pathml.

Related Issues (20)

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.